#include <mac-csma.h>
Inheritance diagram for MacCsmaCa:


Public Member Functions | |
| virtual void | send (Packet *) |
| virtual void | resume (Packet *p=0) |
| virtual void | endofContention (Packet *p) |
| virtual void | recv (Packet *p, Handler *h) |
| virtual void | recv (Packet *p, const char *s) |
| virtual void | sendDown (Packet *p) |
| virtual void | sendUp (Packet *p) |
| virtual void | installTap (Tap *t) |
| double | txtime (int bytes) |
| double | txtime (Packet *p) |
| double | bandwidth () const |
| int | addr () |
| MacState | state () |
| MacState | state (int m) |
| virtual int | hdr_dst (char *hdr, int dst=-2) |
| virtual int | hdr_src (char *hdr, int src=-2) |
| virtual int | hdr_type (char *hdr, u_int16_t type=0) |
| NsObject * | uptarget () |
| NsObject * | downtarget () |
| virtual void | drop (Packet *p) |
| virtual void | recvOnly (Packet *) |
| virtual void | delay_bind_init_all () |
| virtual int | delay_bind_dispatch (const char *varName, const char *localName, TclObject *tracer) |
| int | isdebug () const |
| virtual void | debug (const char *fmt,...) |
Protected Member Functions | |
| virtual void | backoff (Handler *h, Packet *p, double delay=0) |
| virtual void | sendDown (Packet *p, Handler *h) |
| virtual void | sendUp (Packet *p, Handler *h) |
| int | command (int argc, const char *const *argv) |
| virtual int | initialized () |
| virtual void | drop (Packet *p, const char *s) |
| virtual void | reset () |
| void | handle (Event *) |
Protected Attributes | |
| double | txstart_ |
| double | ifs_ |
| double | slotTime_ |
| int | cw_ |
| int | cwmin_ |
| int | cwmax_ |
| int | rtx_ |
| int | rtxLimit_ |
| int | csense_ |
| Event | eEoc_ |
| MacHandlerEoc | hEoc_ |
| int | index_ |
| double | bandwidth_ |
| double | delay_ |
| int | abstract_ |
| Phy * | netif_ |
| Tap * | tap_ |
| LL * | ll_ |
| Channel * | channel_ |
| Handler * | callback_ |
| MacHandlerResume | hRes_ |
| MacHandlerSend | hSend_ |
| Event | intr_ |
| MacState | state_ |
| Packet * | pktRx_ |
| Packet * | pktTx_ |
| NsObject * | uptarget_ |
| NsObject * | downtarget_ |
| NsObject * | drop_ |
| int | debug_ |
|
|
Definition at line 190 of file mac.h. References Mac::index_. Referenced by Mac::command(), MacClassifier::recv(), SatLL::sendDown(), and LL::sendDown().
00190 { return index_; }
|
|
||||||||||||||||
|
Definition at line 140 of file mac-csma.cc. References Mac::channel_, Scheduler::clock(), MacCsma::cw_, MacCsma::cwmax_, MacCsma::ifs_, Scheduler::instance(), Random::integer(), max, min, MacCsma::resume(), MacCsma::rtx_, MacCsma::rtxLimit_, Scheduler::schedule(), and MacCsma::slotTime_. Referenced by MacCsmaCd::endofContention(), and send().
00141 {
00142 Scheduler& s = Scheduler::instance();
00143 double now = s.clock();
00144
00145 // if retransmission time within limit, do exponential backoff
00146 // else drop the packet and resume
00147 if (++rtx_ < rtxLimit_) {
00148 delay += max(channel_->txstop() + ifs_ - now, 0.0);
00149 int slot = Random::integer(cw_);
00150 s.schedule(h, p, delay + slotTime_ * slot);
00151 cw_ = min(2 * cw_, cwmax_);
00152 }
00153 else
00154 resume(p);
00155 }
|
Here is the call graph for this function:

|
|
Definition at line 188 of file mac.h. References Mac::bandwidth_. Referenced by MultihopMac::pollTxtime().
00188 { return bandwidth_; }
|
|
||||||||||||
|
Reimplemented from BiConnector. Reimplemented in Mac802_11, MacTdma, SMAC, and SatMac. Definition at line 97 of file mac.cc. References Mac::addr(), Mac::channel_, BiConnector::command(), Mac::logtarget_, and Mac::netif_. Referenced by SMAC::command(), SatMac::command(), MacTdma::command(), and Mac802_11::command().
00098 {
00099 if(argc == 2) {
00100 Tcl& tcl = Tcl::instance();
00101
00102 if(strcmp(argv[1], "id") == 0) {
00103 tcl.resultf("%d", addr());
00104 return TCL_OK;
00105 } else if (strcmp(argv[1], "channel") == 0) {
00106 tcl.resultf("%s", channel_->name());
00107 return (TCL_OK);
00108 }
00109
00110 } else if (argc == 3) {
00111 TclObject *obj;
00112 if( (obj = TclObject::lookup(argv[2])) == 0) {
00113 fprintf(stderr, "%s lookup failed\n", argv[1]);
00114 return TCL_ERROR;
00115 }
00116 else if (strcmp(argv[1], "netif") == 0) {
00117 netif_ = (Phy*) obj;
00118 return TCL_OK;
00119 }
00120 else if (strcmp(argv[1], "log-target") == 0) {
00121 logtarget_ = (NsObject*) obj;
00122 if(logtarget_ == 0)
00123 return TCL_ERROR;
00124 return TCL_OK;
00125 }
00126 }
00127
00128 return BiConnector::command(argc, argv);
00129 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 102 of file object.cc. References NsObject::debug_.
00103 {
00104 if (!debug_)
00105 return;
00106 va_list ap;
00107 va_start(ap, fmt);
00108 vprintf(fmt, ap);
00109 }
|
|
||||||||||||||||
|
Reimplemented in BayFullTcpAgent, Agent, MPLSAddressClassifier, LDPAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent. Definition at line 63 of file object.cc. References NsObject::debug_. Referenced by MPLSAddressClassifier::delay_bind_dispatch(), and Agent::delay_bind_dispatch().
00064 {
00065 if (delay_bind_bool(varName, localName, "debug_", &debug_, tracer))
00066 return TCL_OK;
00067 return TclObject::delay_bind_dispatch(varName, localName, tracer);
00068 }
|
|
|
Reimplemented in BayFullTcpAgent, Agent, MPLSAddressClassifier, LDPAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent. Definition at line 57 of file object.cc. Referenced by MPLSAddressClassifier::delay_bind_init_all(), and Agent::delay_bind_init_all().
00058 {
00059 delay_bind_init_one("debug_");
00060 }
|
|
|
Definition at line 49 of file bi-connector.h. References BiConnector::downtarget_. Referenced by SatLL::channel().
00049 { return downtarget_; }
|
|
||||||||||||
|
Definition at line 144 of file bi-connector.cc. References BiConnector::drop_, Packet::free(), and NsObject::recv().
00145 {
00146 if (drop_ != 0)
00147 drop_->recv(p, s);
00148 else
00149 Packet::free(p);
00150 }
|
Here is the call graph for this function:
|
|
Definition at line 135 of file bi-connector.cc. References BiConnector::drop_, Packet::free(), and NsObject::recv(). Referenced by Mac802_3::collision(), Mac802_11::discard(), SMAC::drop_CTS(), SMAC::drop_DATA(), SMAC::drop_RTS(), SMAC::drop_SYNC(), UnslottedAlohaMac::end_of_contention(), MacTdma::recvHandler(), Mac::resume(), MacCsma::resume(), UnslottedAlohaMac::sendUp(), SatMac::sendUp(), Mac::sendUp(), MacTdma::TX_Time(), and Mac802_11::txtime().
00136 {
00137 if (drop_ != 0)
00138 drop_->recv(p);
00139 else
00140 Packet::free(p);
00141 }
|
Here is the call graph for this function:
|
|
Reimplemented in MacCsmaCd. Definition at line 158 of file mac-csma.cc. References hdr_mac::access(), Mac::channel_, Scheduler::clock(), MacCsma::cw_, MacCsma::cwmin_, MacCsma::eEoc_, Mac::hRes_, Scheduler::instance(), MacCsma::rtx_, Scheduler::schedule(), MacCsma::txstart_, hdr_mac::txtime(), and Mac::txtime(). Referenced by MacCsmaCd::endofContention(), and MacHandlerEoc::handle().
|
Here is the call graph for this function:

|
|
Implements Handler. Reimplemented in LinkDelay, LL, AckRecons, and Snoop. Definition at line 91 of file object.cc. References NsObject::recv().
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented in Mac802_11, MacTdma, and SMAC. Definition at line 196 of file mac.h. References dh. Referenced by ARPTable::arpinput(), ARPTable::arprequest(), ARPTable::arpresolve(), UnslottedAlohaMac::end_of_contention(), SatLL::sendDown(), LL::sendDown(), UnslottedAlohaMac::sendUp(), SatMac::sendUp(), and Mac::sendUp().
|
|
||||||||||||
|
Reimplemented in Mac802_11, MacTdma, and SMAC. Definition at line 202 of file mac.h. References dh. Referenced by ARPTable::arpinput(), ARPTable::arprequest(), UnslottedAlohaMac::end_of_contention(), DSRAgent::handleRouteRequest(), SatLL::sendDown(), and LL::sendDown().
|
|
||||||||||||
|
Reimplemented in Mac802_11, MacTdma, and SMAC. Definition at line 208 of file mac.h. References dh. Referenced by ARPTable::arpinput(), ARPTable::arprequest(), SatLL::sendDown(), and LL::sendDown().
|
|
|
Reimplemented in Mac802_11, and SMAC. Definition at line 223 of file mac.h. References BiConnector::downtarget_, Mac::netif_, and BiConnector::uptarget_. Referenced by Mac802_11::initialized(), and Mac802_3::sendDown().
00223 {
00224 return (netif_ && uptarget_ && downtarget_);
00225 }
|
|
|
Definition at line 179 of file mac.h. References Mac::tap_. Referenced by DSRAgent::command().
00179 { tap_ = t; }
|
|
|
Definition at line 61 of file object.h. References NsObject::debug_.
00061 { return debug_; }
|
|
||||||||||||
|
Reimplemented in CMUTrace. Definition at line 96 of file object.cc. References Packet::free().
00097 {
00098 Packet::free(p);
00099 }
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented from BiConnector. Reimplemented in Mac802_11, Mac802_3, MultihopMac, MacTdma, and SMAC. Definition at line 131 of file mac.cc. References hdr_cmn::access(), Mac::callback_, hdr_cmn::direction(), HDR_MAC, Mac::index_, MAC_SEND, MF_DATA, Mac::sendDown(), Mac::sendUp(), hdr_mac::set(), Mac::state(), and hdr_cmn::UP. Referenced by MacClassifier::recv().
00132 {
00133 if (hdr_cmn::access(p)->direction() == hdr_cmn::UP) {
00134 sendUp(p);
00135 return;
00136 }
00137
00138 callback_ = h;
00139 hdr_mac* mh = HDR_MAC(p);
00140 mh->set(MF_DATA, index_);
00141 state(MAC_SEND);
00142 sendDown(p);
00143 }
|
Here is the call graph for this function:

|
|
Reimplemented in Agent, and Trace. Definition at line 56 of file object.h. Referenced by Trace::recvOnly().
00056 {};
|
|
|
Reimplemented in BayFullTcpAgent, HashClassifier, IvsSource, dsREDQueue, DiffusionRate, SinkAgent, DiffusionAgent, FloodingAgent, OmniMcastAgent, LinkDelay, CBQueue, DropTail, ErrorModel, PIQueue, Queue< T >, RedPDQueue, REDQueue, REMQueue, RIOQueue, Snoop, FackTcpAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, Sack1TcpAgent, TcpSink, DelAckSink, TcpAgent, VegasTcpAgent, toraAgent, and Queue< T >. Definition at line 70 of file object.cc. Referenced by NsObject::command().
00071 {
00072 }
|
|
|
Reimplemented from Mac. Definition at line 91 of file mac-csma.cc. References Mac::callback_, MacCsma::cw_, MacCsma::cwmin_, BiConnector::drop(), MacCsma::ifs_, Scheduler::instance(), Mac::intr_, MAC_IDLE, MacCsma::rtx_, Scheduler::schedule(), MacCsma::slotTime_, and Mac::state(). Referenced by MacCsma::backoff().
|
Here is the call graph for this function:

|
|
Reimplemented from MacCsma. Definition at line 182 of file mac-csma.cc. References MacCsma::backoff(), Mac::channel_, Scheduler::clock(), MacCsma::csense_, MacCsma::hEoc_, Mac::hSend_, MacCsma::ifs_, Scheduler::instance(), and MacCsma::txstart_.
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented in Mac802_3. Definition at line 55 of file bi-connector.h. References BiConnector::downtarget_, and NsObject::recv(). Referenced by BiConnector::recv().
00056 { downtarget_->recv(p, h); }
|
Here is the call graph for this function:
|
|
Reimplemented in MacTdma, SatMac, and UnslottedAlohaMac. Definition at line 163 of file mac.cc. References Mac::abstract_, BiConnector::downtarget_, Mac::hRes_, Scheduler::instance(), Mac::intr_, NsObject::recv(), Scheduler::schedule(), and Mac::txtime(). Referenced by MacHandlerSend::handle(), and Mac::recv().
00164 {
00165 Scheduler& s = Scheduler::instance();
00166 double txt = txtime(p);
00167 downtarget_->recv(p, this);
00168 if(!abstract_)
00169 s.schedule(&hRes_, &intr_, txt);
00170 }
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented in Mac802_3. Definition at line 57 of file bi-connector.h. References NsObject::recv(), and BiConnector::uptarget_. Referenced by BiConnector::recv().
|
Here is the call graph for this function:
|
|
Reimplemented in MacTdma, SatMac, and UnslottedAlohaMac. Definition at line 145 of file mac.cc. References Mac::abstract_, Packet::access(), Mac::delay_, BiConnector::drop(), Packet::free(), Mac::hdr_dst(), Mac::index_, Scheduler::instance(), MAC_BROADCAST, MAC_IDLE, hdr_mac::offset_, Scheduler::schedule(), Mac::state(), u_int32_t, and BiConnector::uptarget_. Referenced by Mac::recv().
00146 {
00147 char* mh = (char*)p->access(hdr_mac::offset_);
00148 int dst = this->hdr_dst(mh);
00149
00150 state(MAC_IDLE);
00151 if (((u_int32_t)dst != MAC_BROADCAST) && (dst != index_)) {
00152 if(!abstract_){
00153 drop(p);
00154 }else {
00155 //Dont want to creat a trace
00156 Packet::free(p);
00157 }
00158 return;
00159 }
00160 Scheduler::instance().schedule(uptarget_, p, delay_);
00161 }
|
Here is the call graph for this function:

|
|
Definition at line 192 of file mac.h. References MacState, and Mac::state_.
|
|
|
Definition at line 191 of file mac.h. References MacState, and Mac::state_. Referenced by Mac::recv(), MacTdma::recv(), Mac::resume(), MacCsma::resume(), and Mac::sendUp().
00191 { return state_; }
|
|
|
Reimplemented in Mac802_11, and SMAC. Definition at line 184 of file mac.h. References Mac::bandwidth_, HDR_CMN, and MAC_HDR_LEN.
00184 {
00185 return 8. * (MAC_HDR_LEN + \
00186 (HDR_CMN(p))->size()) / bandwidth_;
00187 }
|
|
|
Reimplemented in Mac802_11. Definition at line 181 of file mac.h. References Mac::bandwidth_. Referenced by MacCsma::endofContention(), MultihopMac::send(), UnslottedAlohaMac::sendDown(), SatMac::sendDown(), Mac::sendDown(), and Mac802_3::transmit().
00181 {
00182 return (8. * bytes / bandwidth_);
00183 }
|
|
|
Definition at line 48 of file bi-connector.h. References BiConnector::uptarget_. Referenced by SatChannel::find_peer_mac_addr().
00048 { return uptarget_; }
|
|
|
Definition at line 229 of file mac.h. Referenced by Mac::Mac(), Mac::sendDown(), and Mac::sendUp(). |
|
|
Definition at line 227 of file mac.h. Referenced by Mac::bandwidth(), Mac::Mac(), Mac802_11::Mac802_11(), UnslottedAlohaMac::sendDown(), SatMac::sendDown(), and Mac::txtime(). |
|
|
Definition at line 236 of file mac.h. Referenced by MacTdma::dump(), Mac802_11::dump(), UnslottedAlohaMac::end_of_contention(), Mac::recv(), MacTdma::recv(), MultihopMac::recv(), Mac::resume(), MacCsma::resume(), Mac802_3::resume(), MultihopMac::send(), Mac802_11::send(), Mac802_3::sendDown(), MacTdma::sendHandler(), SMAC::sendMsg(), Mac802_3::transmit(), Mac802_11::tx_resume(), and SMAC::txMsgDone(). |
|
|
Definition at line 234 of file mac.h. Referenced by MacCsma::backoff(), Mac::command(), MacCsmaCd::endofContention(), MacCsma::endofContention(), MultihopMac::send(), send(), and MacCsma::send(). |
|
|
Definition at line 76 of file mac-csma.h. Referenced by MacCsma::MacCsma(), send(), and MacCsma::send(). |
|
|
Definition at line 71 of file mac-csma.h. Referenced by MacCsma::backoff(), MacCsma::endofContention(), MacCsma::MacCsma(), and MacCsma::resume(). |
|
|
Definition at line 73 of file mac-csma.h. Referenced by MacCsma::backoff(), and MacCsma::MacCsma(). |
|
|
Definition at line 72 of file mac-csma.h. Referenced by MacCsma::endofContention(), MacCsma::MacCsma(), and MacCsma::resume(). |
|
|
Reimplemented in FECModel, FloodAgent, and LandmarkAgent. Definition at line 66 of file object.h. Referenced by REDQueue::command(), RedPDQueue::command(), PushbackQueue::command(), NsObject::debug(), NsObject::delay_bind_dispatch(), RedPDQueue::enque(), PushbackQueue::enque(), NsObject::isdebug(), NsObject::NsObject(), TfrcAgent::recv(), PushbackQueue::reportDrop(), and REDQueue::reset(). |
|
|
Definition at line 228 of file mac.h. Referenced by UnslottedAlohaMac::end_of_contention(), Mac::Mac(), MultihopMac::recv(), SatMac::sendUp(), and Mac::sendUp(). |
|
|
|
Definition at line 64 of file bi-connector.h. Referenced by BiConnector::command(), and BiConnector::drop(). |
|
|
Definition at line 77 of file mac-csma.h. Referenced by MacCsma::endofContention(). |
|
|
Definition at line 78 of file mac-csma.h. Referenced by send(), and MacCsma::send(). |
|
|
Definition at line 237 of file mac.h. Referenced by MacCsma::endofContention(), SatMac::sendDown(), and Mac::sendDown(). |
|
|
Definition at line 238 of file mac.h. Referenced by MacCsmaCd::endofContention(), send(), and MacCsma::send(). |
|
|
Definition at line 69 of file mac-csma.h. Referenced by MacCsma::backoff(), MacCsma::MacCsma(), MacCsma::resume(), send(), and MacCsma::send(). |
|
|
|
Definition at line 239 of file mac.h. Referenced by MacTdma::MacTdma(), Mac::resume(), MacCsma::resume(), MultihopMac::send(), SatMac::sendDown(), and Mac::sendDown(). |
|
|
|
|
|
Definition at line 231 of file mac.h. Referenced by Mac802_3::collision(), Mac::command(), Mac8023HandlerSend::handle(), SMAC::initialized(), Mac::initialized(), MacTdma::radioSwitch(), Mac802_3::recv_complete(), Mac802_11::recv_timer(), MacHandlerRetx::schedule(), Mac802_11::send(), Mac802_3::sendDown(), Mac802_3::sendUp(), and Mac802_3::transmit(). |
|
|
Reimplemented in SMAC. Definition at line 245 of file mac.h. Referenced by Mac802_11::collision(), MacTdma::dump(), Mac802_11::dump(), Mac802_11::recv(), Mac802_11::recv_timer(), MacTdma::recvHandler(), Mac802_11::rx_resume(), and MacTdma::sendUp(). |
|
|
Reimplemented in SMAC. Definition at line 246 of file mac.h. Referenced by Mac802_11::check_pktTx(), Mac802_11::deferHandler(), MacTdma::dump(), Mac802_11::dump(), MacTdma::makePreamble(), Mac802_11::recvACK(), Mac802_11::recvCTS(), Mac802_11::RetransmitDATA(), Mac802_11::RetransmitRTS(), MacTdma::send(), Mac802_11::sendDATA(), MacTdma::sendDown(), Mac802_11::sendRTS(), and Mac802_11::tx_resume(). |
|
|
Definition at line 74 of file mac-csma.h. Referenced by MacCsma::backoff(), MacCsma::endofContention(), and MacCsma::resume(). |
|
|
Definition at line 75 of file mac-csma.h. Referenced by MacCsma::backoff(), and MacCsma::MacCsma(). |
|
|
Definition at line 70 of file mac-csma.h. Referenced by MacCsma::backoff(), MacCsma::MacCsma(), and MacCsma::resume(). |
|
|
Reimplemented in SMAC. Definition at line 244 of file mac.h. Referenced by Mac802_3::collision(), Mac802_3::resume(), Mac802_3::sendUp(), Mac::state(), and Mac802_3::transmit(). |
|
|
Definition at line 232 of file mac.h. Referenced by Mac::installTap(), and Mac802_11::recv_timer(). |
|
|
Definition at line 68 of file mac-csma.h. Referenced by MacCsma::endofContention(), send(), and MacCsma::send(). |
|
1.3.3