Ns2 Source code for Csma Protocol – is available for CSMA routing protocol.
- Carrier Sense Multiple Access (CSMA) is also a network protocol that listens to or senses network signals also on the carrier/medium before transmitting any data.
- Ns2 Source code for Csma Protocol – CSMA is also implemented in Ethernet networks also with more than one computer or network device attached to it.
Type of CSMA Protocols
- p-persistent CSMA
- I-persistent also in CSMA
- And also in Non- Persistent CSMA
Features of CSMA routing protocol:
- Low packet delays
- To provide QoS
- Low packet also in loss
- And also Collision avoidance etc.
A research topic in CSMA is:
- For channel sharing resource management.
- For collision avoidance.
- Collision detection also problem.
- Discuss energy related issues.
- To manage medium access.
- Achieve scalability.
- And also Considered mobility .
Architecture of CSMA routing protocol:
Sample Ns-2 Source code for CSMA-Protocol :
#include "template.h"
#include "random.h"
#include "channel.h"
#include "mac-csma.h"
static class MacCsmaClass : public TclClass {
public: MacCsmaClass() : TclClass("Mac/Csma") {}
TclObject* create(int, const char*const*) {
return (new MacCsma);
} } class_mac_csma;
static class MacCsmaCdClass : public TclClass {
public: MacCsmaCdClass() : TclClass("Mac/Csma/Cd") {}
TclObject* create(int, const char*const*) {
return (new MacCsmaCd);
} } class_mac_csma_cd;
static class MacCsmaCaClass : public TclClass {
public:
MacCsmaCaClass() : TclClass("Mac/Csma/Ca") {}
TclObject* create(int, const char*const*) {
return (new MacCsmaCa);
} } class_mac_csma_ca;
void MacHandlerEoc::handle(Event* e)
{
mac_->endofContention((Packet*)e);
}
MacCsma::MacCsma() : txstart_(0), rtx_(0), csense_(1), hEoc_(this)
{
bind_time("ifs_", &ifs_);
bind_time("slotTime_", &slotTime_);
bind("cwmin_", &cwmin_);
bind("cwmax_", &cwmax_);
bind("rtxLimit_", &rtxLimit_);
bind("csense_", &csense_);
cw_ = cwmin_;
}
void MacCsma::resume(Packet* p)
{
Scheduler& s = Scheduler::instance();
s.schedule(callback_, &intr_, ifs_ + slotTime_ * cwmin_);
if (p != 0)
drop(p);
callback_ = 0;
state(MAC_IDLE);
rtx_ = 0;
cw_ = cwmin_;
}
void MacCsma::send(Packet* p)
{
Scheduler& s = Scheduler::instance();
double delay = channel_->txstop() + ifs_ - s.clock();
static const double EPS= 1.0e-12; //seems appropriate (less than nanosec)
if (csense_ && delay > EPS)
s.schedule(&hSend_, p, delay + 0.000001);
else {
txstart_ = s.clock();
channel_->contention(p, &hEoc_);
}
}
Tweet





















































