Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

Mac802_11 Class Reference

#include <mac-802_11.h>

Inheritance diagram for Mac802_11:

Inheritance graph
[legend]
Collaboration diagram for Mac802_11:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Mac802_11 (PHY_MIB *p, MAC_MIB *m)
void recv (Packet *p, Handler *h)
int hdr_dst (char *hdr, int dst=-2)
int hdr_src (char *hdr, int src=-2)
int hdr_type (char *hdr, u_int16_t type=0)
virtual void recv (Packet *p, const char *s)
virtual void sendDown (Packet *p)
virtual void sendUp (Packet *p)
virtual void resume (Packet *p=0)
virtual void installTap (Tap *t)
double bandwidth () const
int addr ()
MacState state ()
MacState state (int m)
NsObjectuptarget ()
NsObjectdowntarget ()
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

void backoffHandler (void)
void deferHandler (void)
void navHandler (void)
void recvHandler (void)
void sendHandler (void)
void txHandler (void)
virtual void sendDown (Packet *p, Handler *h)
virtual void sendUp (Packet *p, Handler *h)
virtual void drop (Packet *p, const char *s)
virtual void reset ()
void handle (Event *)

Protected Attributes

PHY_MIBphymib_
MAC_MIBmacmib_
int index_
double bandwidth_
double delay_
int abstract_
Phynetif_
Taptap_
LLll_
Channelchannel_
Handlercallback_
MacHandlerResume hRes_
MacHandlerSend hSend_
Event intr_
MacState state_
PacketpktRx_
PacketpktTx_
NsObjectuptarget_
NsObjectdowntarget_
NsObjectdrop_
int debug_

Private Member Functions

int command (int argc, const char *const *argv)
void recv_timer (void)
void send_timer (void)
int check_pktCTRL ()
int check_pktRTS ()
int check_pktTx ()
void send (Packet *p, Handler *h)
void sendRTS (int dst)
void sendCTS (int dst, double duration)
void sendACK (int dst)
void sendDATA (Packet *p)
void RetransmitRTS ()
void RetransmitDATA ()
void recvRTS (Packet *p)
void recvCTS (Packet *p)
void recvACK (Packet *p)
void recvDATA (Packet *p)
void capture (Packet *p)
void collision (Packet *p)
void discard (Packet *p, const char *why)
void rx_resume (void)
void tx_resume (void)
int is_idle (void)
void trace_pkt (Packet *p)
void dump (char *fname)
int initialized ()
void mac_log (Packet *p)
double txtime (Packet *p)
double txtime (double psz, double drt)
double txtime (int bytes)
void inc_cw ()
void rst_cw ()
double sec (double t)
u_int16_t usec (double t)
void set_nav (u_int16_t us)

Private Attributes

double basicRate_
double dataRate_
IFTimer mhIF_
NavTimer mhNav_
RxTimer mhRecv_
TxTimer mhSend_
DeferTimer mhDefer_
BackoffTimer mhBackoff_
double nav_
MacState rx_state_
MacState tx_state_
int tx_active_
PacketpktRTS_
PacketpktCTRL_
u_int32_t cw_
u_int32_t ssrc_
u_int32_t slrc_
double sifs_
double pifs_
double difs_
double eifs_
double tx_sifs_
double tx_pifs_
double tx_difs_
int min_frame_len_
NsObjectlogtarget_
u_int16_t sta_seqno_
int cache_node_count_
Hostcache_

Friends

class DeferTimer
class BackoffTimer
class IFTimer
class NavTimer
class RxTimer
class TxTimer

Constructor & Destructor Documentation

Mac802_11::Mac802_11 PHY_MIB p,
MAC_MIB m
 

Definition at line 148 of file mac-802_11.cc.

References Mac::bandwidth_, basicRate_, cache_, cache_node_count_, cw_, PHY_MIB::CWMin, dataRate_, difs_, eifs_, ETHER_ACK_LEN, MAC_IDLE, macmib_, nav_, phymib_, pifs_, pktCTRL_, pktRTS_, PHY_MIB::PLCPDataRate, rx_state_, PHY_MIB::RxTxTurnaroundTime, sifs_, PHY_MIB::SIFSTime, PHY_MIB::SlotTime, slrc_, ssrc_, sta_seqno_, tx_active_, tx_difs_, tx_pifs_, tx_sifs_, and tx_state_.

00148                                            : Mac(), mhIF_(this), mhNav_(this), mhRecv_(this), mhSend_(this), mhDefer_(this, p->SlotTime), mhBackoff_(this, p->SlotTime)
00149 {
00150         macmib_ = m;
00151         phymib_ = p;
00152         
00153         nav_ = 0.0;
00154         
00155         tx_state_ = rx_state_ = MAC_IDLE;
00156         tx_active_ = 0;
00157         
00158         pktRTS_ = 0;
00159         pktCTRL_ = 0;
00160 
00161         cw_ = phymib_->CWMin;
00162         ssrc_ = slrc_ = 0;
00163         
00164         sifs_ = phymib_->SIFSTime;
00165         pifs_ = sifs_ + phymib_->SlotTime;
00166         difs_ = sifs_ + 2*phymib_->SlotTime;
00167         
00168         // see (802.11-1999, 9.2.10) 
00169         eifs_ = sifs_ + (8 * ETHER_ACK_LEN / phymib_->PLCPDataRate) + difs_;
00170         
00171         tx_sifs_ = sifs_ - phymib_->RxTxTurnaroundTime;
00172         tx_pifs_ = tx_sifs_ + phymib_->SlotTime;
00173         tx_difs_ = tx_sifs_ + 2 * phymib_->SlotTime;
00174         
00175         sta_seqno_ = 1;
00176         cache_ = 0;
00177         cache_node_count_ = 0;
00178         
00179         // chk if basic/data rates are set
00180         // otherwise use bandwidth_ as default;
00181         
00182         Tcl& tcl = Tcl::instance();
00183         tcl.evalf("Mac/802_11 set basicRate_");
00184         if (strcmp(tcl.result(), "0") != 0) 
00185                 bind_bw("basicRate_", &basicRate_);
00186         else
00187                 basicRate_ = bandwidth_;
00188 
00189         tcl.evalf("Mac/802_11 set dataRate_");
00190         if (strcmp(tcl.result(), "0") != 0) 
00191                 bind_bw("dataRate_", &dataRate_);
00192         else
00193                 dataRate_ = bandwidth_;
00194 }


Member Function Documentation

int Mac::addr  )  [inline, inherited]
 

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_; }

void Mac802_11::backoffHandler void   )  [protected]
 

Definition at line 479 of file mac-802_11.cc.

References MacTimer::busy(), check_pktRTS(), check_pktTx(), mhDefer_, mhSend_, and pktCTRL_.

Referenced by BackoffTimer::handle().

00480 {
00481         if(pktCTRL_) {
00482                 assert(mhSend_.busy() || mhDefer_.busy());
00483                 return;
00484         }
00485 
00486         if(check_pktRTS() == 0)
00487                 return;
00488 
00489         if(check_pktTx() == 0)
00490                 return;
00491 }

Here is the call graph for this function:

double Mac::bandwidth  )  const [inline, inherited]
 

Definition at line 188 of file mac.h.

References Mac::bandwidth_.

Referenced by MultihopMac::pollTxtime().

00188 { return bandwidth_; }

void Mac802_11::capture Packet p  )  [private]
 

Definition at line 387 of file mac-802_11.cc.

References eifs_, Packet::free(), set_nav(), txtime(), and usec().

Referenced by recv().

00388 {
00389         /*
00390          * Update the NAV so that this does not screw
00391          * up carrier sense.
00392          */
00393         set_nav(usec(eifs_ + txtime(p)));
00394         Packet::free(p);
00395 }

Here is the call graph for this function:

int Mac802_11::check_pktCTRL  )  [private]
 

Definition at line 587 of file mac-802_11.cc.

References basicRate_, discard(), DROP_MAC_BUSY, DSSS_MaxPropagationDelay, ETHER_ACK_LEN, ETHER_CTS_LEN, HDR_MAC802_11, is_idle(), MAC_ACK, MAC_CTS, MAC_Subtype_ACK, MAC_Subtype_CTS, pktCTRL_, sec(), SET_TX_STATE, sifs_, TRANSMIT, tx_state_, and txtime().

Referenced by deferHandler().

00588 {
00589         struct hdr_mac802_11 *mh;
00590         double timeout;
00591 
00592         if(pktCTRL_ == 0)
00593                 return -1;
00594         if(tx_state_ == MAC_CTS || tx_state_ == MAC_ACK)
00595                 return -1;
00596 
00597         mh = HDR_MAC802_11(pktCTRL_);
00598                                                           
00599         switch(mh->dh_fc.fc_subtype) {
00600         /*
00601          *  If the medium is not IDLE, don't send the CTS.
00602          */
00603         case MAC_Subtype_CTS:
00604                 if(!is_idle()) {
00605                         discard(pktCTRL_, DROP_MAC_BUSY); pktCTRL_ = 0;
00606                         return 0;
00607                 }
00608                 SET_TX_STATE(MAC_CTS);
00609                 
00610                 /*
00611                  * timeout:  cts + data tx time calculated by
00612                  *           adding cts tx time to the cts duration
00613                  *           minus ack tx time -- this timeout is
00614                  *           a guess since it is unspecified
00615                  *           (note: mh->dh_duration == cf->cf_duration)
00616                  */
00617                 timeout = txtime(ETHER_CTS_LEN, basicRate_)
00618                         + DSSS_MaxPropagationDelay                      // XXX
00619                         + sec(mh->dh_duration)
00620                         + DSSS_MaxPropagationDelay                      // XXX
00621                         - sifs_
00622                         - txtime(ETHER_ACK_LEN, basicRate_);
00623                 
00624                 break;
00625                 /*
00626                  * IEEE 802.11 specs, section 9.2.8
00627                  * Acknowledments are sent after an SIFS, without regard to
00628                  * the busy/idle state of the medium.
00629                  */
00630         case MAC_Subtype_ACK:
00631                 SET_TX_STATE(MAC_ACK);
00632 
00633                 timeout = txtime(ETHER_ACK_LEN, basicRate_);
00634                 
00635                 break;
00636         default:
00637                 fprintf(stderr, "check_pktCTRL:Invalid MAC Control subtype\n");
00638                 exit(1);
00639         }
00640         TRANSMIT(pktCTRL_, timeout);
00641         return 0;
00642 }

Here is the call graph for this function:

int Mac802_11::check_pktRTS  )  [private]
 

Definition at line 645 of file mac-802_11.cc.

References basicRate_, MacTimer::busy(), cw_, DSSS_MaxPropagationDelay, ETHER_CTS_LEN, ETHER_RTS_LEN, HDR_MAC802_11, inc_cw(), is_idle(), MAC_RTS, MAC_Subtype_RTS, mhBackoff_, pktRTS_, SET_TX_STATE, sifs_, BackoffTimer::start(), TRANSMIT, and txtime().

Referenced by backoffHandler(), and deferHandler().

00646 {
00647         struct hdr_mac802_11 *mh;
00648         double timeout;
00649 
00650         assert(mhBackoff_.busy() == 0);
00651 
00652         if(pktRTS_ == 0)
00653                 return -1;
00654         //struct hdr_cmn *ch = HDR_CMN(pktRTS_);
00655         mh = HDR_MAC802_11(pktRTS_);
00656 
00657         switch(mh->dh_fc.fc_subtype) {
00658         case MAC_Subtype_RTS:
00659                 if(! is_idle()) {
00660                         inc_cw();
00661                         mhBackoff_.start(cw_, is_idle());
00662                         return 0;
00663                 }
00664                 SET_TX_STATE(MAC_RTS);
00665                 timeout = txtime(ETHER_RTS_LEN, basicRate_)
00666                         + DSSS_MaxPropagationDelay                      // XXX
00667                         + sifs_
00668                         + txtime(ETHER_CTS_LEN, basicRate_)
00669                         + DSSS_MaxPropagationDelay;                     // XXX
00670                 break;
00671         default:
00672                 fprintf(stderr, "check_pktRTS:Invalid MAC Control subtype\n");
00673                 exit(1);
00674         }
00675         TRANSMIT(pktRTS_, timeout);
00676         return 0;
00677 }

Here is the call graph for this function:

int Mac802_11::check_pktTx  )  [private]
 

Definition at line 680 of file mac-802_11.cc.

References basicRate_, MacTimer::busy(), cw_, DSSS_MaxPropagationDelay, ETHER_ACK_LEN, ETHER_ADDR, HDR_MAC802_11, inc_cw(), is_idle(), MAC_BROADCAST, MAC_SEND, MAC_Subtype_Data, mhBackoff_, Mac::pktTx_, sendRTS(), SET_TX_STATE, sifs_, BackoffTimer::start(), TRANSMIT, txtime(), and u_int32_t.

Referenced by backoffHandler(), and deferHandler().

00681 {
00682         struct hdr_mac802_11 *mh;
00683         double timeout;
00684         
00685         assert(mhBackoff_.busy() == 0);
00686 
00687         if(pktTx_ == 0)
00688                 return -1;
00689 
00690         mh = HDR_MAC802_11(pktTx_);
00691         //int len = HDR_CMN(pktTx_)->size();
00692 
00693         switch(mh->dh_fc.fc_subtype) {
00694         case MAC_Subtype_Data:
00695                 if(! is_idle()) {
00696                         sendRTS(ETHER_ADDR(mh->dh_da));
00697                         inc_cw();
00698                         mhBackoff_.start(cw_, is_idle());
00699                         return 0;
00700                 }
00701                 SET_TX_STATE(MAC_SEND);
00702                 if((u_int32_t)ETHER_ADDR(mh->dh_da) != MAC_BROADCAST)
00703                         timeout = txtime(pktTx_)
00704                                 + DSSS_MaxPropagationDelay              // XXX
00705                                 + sifs_
00706                                 + txtime(ETHER_ACK_LEN, basicRate_)
00707                                 + DSSS_MaxPropagationDelay;             // XXX
00708                 else
00709                         timeout = txtime(pktTx_);
00710                 break;
00711         default:
00712                 fprintf(stderr, "check_pktTx:Invalid MAC Control subtype\n");
00713                 //printf("pktRTS:%x, pktCTS/ACK:%x, pktTx:%x\n",pktRTS_, pktCTRL_,pktTx_);
00714                 exit(1);
00715         }
00716         TRANSMIT(pktTx_, timeout);
00717         return 0;
00718 }

Here is the call graph for this function:

void Mac802_11::collision Packet p  )  [private]
 

Definition at line 398 of file mac-802_11.cc.

References MacTimer::busy(), discard(), DROP_MAC_COLLISION, MacTimer::expire(), MAC_COLL, MAC_RECV, mhRecv_, Mac::pktRx_, rx_state_, SET_RX_STATE, MacTimer::start(), MacTimer::stop(), and txtime().

Referenced by recv().

00399 {
00400         switch(rx_state_) {
00401         case MAC_RECV:
00402                 SET_RX_STATE(MAC_COLL);
00403                 /* fall through */
00404         case MAC_COLL:
00405                 assert(pktRx_);
00406                 assert(mhRecv_.busy());
00407                 /*
00408                  *  Since a collision has occurred, figure out
00409                  *  which packet that caused the collision will
00410                  *  "last" the longest.  Make this packet,
00411                  *  pktRx_ and reset the Recv Timer if necessary.
00412                  */
00413                 if(txtime(p) > mhRecv_.expire()) {
00414                         mhRecv_.stop();
00415                         discard(pktRx_, DROP_MAC_COLLISION);
00416                         pktRx_ = p;
00417                         mhRecv_.start(txtime(pktRx_));
00418                 }
00419                 else {
00420                         discard(p, DROP_MAC_COLLISION);
00421                 }
00422                 break;
00423         default:
00424                 assert(0);
00425         }
00426 }

Here is the call graph for this function:

int Mac802_11::command int  argc,
const char *const *  argv
[private, virtual]
 

Reimplemented from Mac.

Definition at line 198 of file mac-802_11.cc.

References cache_, cache_node_count_, Mac::command(), and logtarget_.

00199 {
00200         if (argc == 3) {
00201                 if (strcmp(argv[1], "log-target") == 0) {
00202                         logtarget_ = (NsObject*) TclObject::lookup(argv[2]);
00203                         if(logtarget_ == 0)
00204                                 return TCL_ERROR;
00205                         return TCL_OK;
00206                 } else if(strcmp(argv[1], "nodes") == 0) {
00207                         if(cache_) return TCL_ERROR;
00208                         cache_node_count_ = atoi(argv[2]);
00209                         cache_ = new Host[cache_node_count_ + 1];
00210                         assert(cache_);
00211                         bzero(cache_, sizeof(Host) * (cache_node_count_+1 ));
00212                         return TCL_OK;
00213                 }
00214         }
00215         return Mac::command(argc, argv);
00216 }

Here is the call graph for this function:

void NsObject::debug const char *  fmt,
... 
[virtual, inherited]
 

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 }

void Mac802_11::deferHandler void   )  [protected]
 

Definition at line 494 of file mac-802_11.cc.

References MacTimer::busy(), check_pktCTRL(), check_pktRTS(), check_pktTx(), mhBackoff_, pktCTRL_, pktRTS_, and Mac::pktTx_.

Referenced by DeferTimer::handle().

00495 {
00496         assert(pktCTRL_ || pktRTS_ || pktTx_);
00497 
00498         if(check_pktCTRL() == 0)
00499                 return;
00500 
00501         assert(mhBackoff_.busy() == 0);
00502         //if (mhBackoff_.busy() != 0)
00503         //{
00504         //      printf("deferHandler:mhBackoff_ busy!\n");
00505         //      return;
00506         //}
00507         if(check_pktRTS() == 0)
00508                 return;
00509 
00510         if(check_pktTx() == 0)
00511                 return;
00512 }

Here is the call graph for this function:

int NsObject::delay_bind_dispatch const char *  varName,
const char *  localName,
TclObject tracer
[virtual, inherited]
 

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 }

void NsObject::delay_bind_init_all  )  [virtual, inherited]
 

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 }

void Mac802_11::discard Packet p,
const char *  why
[private]
 

Definition at line 310 of file mac-802_11.cc.

References PacketStamp::ant, hdr_mac802_11::dh_da, hdr_mac802_11::dh_fc, hdr_mac802_11::dh_sa, BiConnector::drop(), hdr_cmn::error(), ETHER_ADDR, frame_control::fc_subtype, frame_control::fc_type, Packet::free(), HDR_CMN, HDR_MAC802_11, Mac::index_, MAC_BROADCAST, MAC_Subtype_ACK, MAC_Subtype_CTS, MAC_Subtype_Data, MAC_Subtype_RTS, MAC_Type_Control, MAC_Type_Data, MAC_Type_Management, PacketStamp::Pr, trace_pkt(), Packet::txinfo_, and u_int32_t.

Referenced by check_pktCTRL(), collision(), recv_timer(), recvACK(), recvCTS(), recvDATA(), recvRTS(), RetransmitDATA(), and RetransmitRTS().

00311 {
00312         hdr_mac802_11* mh = HDR_MAC802_11(p);
00313         hdr_cmn *ch = HDR_CMN(p);
00314 
00315 #if 0
00316         /* old logic 8/8/98 -dam */
00317         /*
00318          * If received below the RXThreshold, then just free.
00319          */
00320         if(p->txinfo_.Pr < p->txinfo_.ant.RXThresh) {
00321                 Packet::free(p);
00322                 //p = 0;
00323                 return;
00324         }
00325 #endif // 0
00326 
00327         /* if the rcvd pkt contains errors, a real MAC layer couldn't
00328            necessarily read any data from it, so we just toss it now */
00329         if(ch->error() != 0) {
00330                 Packet::free(p);
00331                 //p = 0;
00332                 return;
00333         }
00334 
00335         switch(mh->dh_fc.fc_type) {
00336         case MAC_Type_Management:
00337                 drop(p, why);
00338                 return;
00339         case MAC_Type_Control:
00340                 switch(mh->dh_fc.fc_subtype) {
00341                 case MAC_Subtype_RTS:
00342                         if((u_int32_t)ETHER_ADDR(mh->dh_sa) == \
00343                            (u_int32_t)index_) {
00344                                 drop(p, why);
00345                                 return;
00346                         }
00347                         /* fall through - if necessary */
00348                 case MAC_Subtype_CTS:
00349                 case MAC_Subtype_ACK:
00350                         if((u_int32_t)ETHER_ADDR(mh->dh_da) == \
00351                            (u_int32_t)index_) {
00352                                 drop(p, why);
00353                                 return;
00354                         }
00355                         break;
00356                 default:
00357                         fprintf(stderr, "invalid MAC Control subtype\n");
00358                         exit(1);
00359                 }
00360                 break;
00361         case MAC_Type_Data:
00362                 switch(mh->dh_fc.fc_subtype) {
00363                 case MAC_Subtype_Data:
00364                         if((u_int32_t)ETHER_ADDR(mh->dh_da) == \
00365                            (u_int32_t)index_ ||
00366                            (u_int32_t)ETHER_ADDR(mh->dh_sa) == \
00367                            (u_int32_t)index_ ||
00368                            (u_int32_t)ETHER_ADDR(mh->dh_da) == MAC_BROADCAST) {
00369                                 drop(p);
00370                                 return;
00371                         }
00372                         break;
00373                 default:
00374                         fprintf(stderr, "invalid MAC Data subtype\n");
00375                         exit(1);
00376                 }
00377                 break;
00378         default:
00379                 fprintf(stderr, "invalid MAC type (%x)\n", mh->dh_fc.fc_type);
00380                 trace_pkt(p);
00381                 exit(1);
00382         }
00383         Packet::free(p);
00384 }

Here is the call graph for this function:

NsObject* BiConnector::downtarget  )  [inline, inherited]
 

Definition at line 49 of file bi-connector.h.

References BiConnector::downtarget_.

Referenced by SatLL::channel().

00049 { return downtarget_; }

void BiConnector::drop Packet p,
const char *  s
[protected, virtual, inherited]
 

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:

void BiConnector::drop Packet p  )  [virtual, inherited]
 

Definition at line 135 of file bi-connector.cc.

References BiConnector::drop_, Packet::free(), and NsObject::recv().

Referenced by Mac802_3::collision(), 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 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:

void Mac802_11::dump char *  fname  )  [private]
 

Definition at line 234 of file mac-802_11.cc.

References MacTimer::busy(), Mac::callback_, MacTimer::expire(), Mac::index_, Scheduler::instance(), is_idle(), mhBackoff_, mhDefer_, mhNav_, mhRecv_, mhSend_, nav_, MacTimer::paused(), pktCTRL_, pktRTS_, Mac::pktRx_, Mac::pktTx_, rx_state_, and tx_state_.

00235 {
00236         fprintf(stderr,
00237                 "\n%s --- (INDEX: %d, time: %2.9f)\n",
00238                 fname, index_, Scheduler::instance().clock());
00239 
00240         fprintf(stderr,
00241                 "\ttx_state_: %x, rx_state_: %x, nav: %2.9f, idle: %d\n",
00242                 tx_state_, rx_state_, nav_, is_idle());
00243 
00244         fprintf(stderr,
00245                 "\tpktTx_: %x, pktRx_: %x, pktRTS_: %x, pktCTRL_: %x, callback: %x\n",
00246                 (int) pktTx_, (int) pktRx_, (int) pktRTS_,
00247                 (int) pktCTRL_, (int) callback_);
00248 
00249         fprintf(stderr,
00250                 "\tDefer: %d, Backoff: %d (%d), Recv: %d, Timer: %d Nav: %d\n",
00251                 mhDefer_.busy(), mhBackoff_.busy(), mhBackoff_.paused(),
00252                 mhRecv_.busy(), mhSend_.busy(), mhNav_.busy());
00253         fprintf(stderr,
00254                 "\tBackoff Expire: %f\n",
00255                 mhBackoff_.expire());
00256 }

Here is the call graph for this function:

void NsObject::handle Event  )  [protected, virtual, inherited]
 

Implements Handler.

Reimplemented in LinkDelay, LL, AckRecons, and Snoop.

Definition at line 91 of file object.cc.

References NsObject::recv().

00092 {
00093         recv((Packet*)e);
00094 }

Here is the call graph for this function:

int Mac802_11::hdr_dst char *  hdr,
int  dst = -2
[inline, virtual]
 

Reimplemented from Mac.

Definition at line 263 of file mac-802_11.cc.

References dh, ETHER_ADDR, and STORE4BYTE.

00264 {
00265         struct hdr_mac802_11 *dh = (struct hdr_mac802_11*) hdr;
00266         //dst = (u_int32_t)(dst);
00267 
00268         if(dst > -2)
00269                 STORE4BYTE(&dst, (dh->dh_da));
00270 
00271         return ETHER_ADDR(dh->dh_da);
00272 }

int Mac802_11::hdr_src char *  hdr,
int  src = -2
[inline, virtual]
 

Reimplemented from Mac.

Definition at line 275 of file mac-802_11.cc.

References dh, ETHER_ADDR, and STORE4BYTE.

00276 {
00277         struct hdr_mac802_11 *dh = (struct hdr_mac802_11*) hdr;
00278         if(src > -2)
00279                 STORE4BYTE(&src, (dh->dh_sa));
00280         return ETHER_ADDR(dh->dh_sa);
00281 }

int Mac802_11::hdr_type char *  hdr,
u_int16_t  type = 0
[inline, virtual]
 

Reimplemented from Mac.

Definition at line 284 of file mac-802_11.cc.

References dh, GET2BYTE, and STORE2BYTE.

00285 {
00286         struct hdr_mac802_11 *dh = (struct hdr_mac802_11*) hdr;
00287         if(type)
00288                 STORE2BYTE(&type,(dh->dh_body));
00289         return GET2BYTE(dh->dh_body);
00290 }

void Mac802_11::inc_cw  )  [inline, private]
 

Definition at line 306 of file mac-802_11.h.

References cw_, PHY_MIB::CWMax, and phymib_.

Referenced by check_pktRTS(), check_pktTx(), RetransmitDATA(), and RetransmitRTS().

00306                              {
00307                 cw_ = (cw_ << 1) + 1;
00308                 if(cw_ > phymib_->CWMax)
00309                         cw_ = phymib_->CWMax;
00310         }

int Mac802_11::initialized  )  [inline, private, virtual]
 

Reimplemented from Mac.

Definition at line 295 of file mac-802_11.h.

References cache_, Mac::initialized(), logtarget_, macmib_, and phymib_.

Referenced by recv().

00295                                  {
00296                 return (phymib_ && macmib_ && cache_ && logtarget_ && 
00297                         Mac::initialized());
00298         }

Here is the call graph for this function:

virtual void Mac::installTap Tap t  )  [inline, virtual, inherited]
 

Definition at line 179 of file mac.h.

References Mac::tap_.

Referenced by DSRAgent::command().

00179 { tap_ = t; }

int Mac802_11::is_idle void   )  [inline, private]
 

Definition at line 297 of file mac-802_11.cc.

References Scheduler::clock(), Scheduler::instance(), MAC_IDLE, nav_, rx_state_, and tx_state_.

Referenced by check_pktCTRL(), check_pktRTS(), check_pktTx(), dump(), navHandler(), recvACK(), RetransmitDATA(), RetransmitRTS(), and send().

00298 {
00299         if(rx_state_ != MAC_IDLE)
00300                 return 0;
00301         if(tx_state_ != MAC_IDLE)
00302                 return 0;
00303         if(nav_ > Scheduler::instance().clock())
00304                 return 0;
00305         
00306         return 1;
00307 }

Here is the call graph for this function:

int NsObject::isdebug  )  const [inline, inherited]
 

Definition at line 61 of file object.h.

References NsObject::debug_.

00061 { return debug_; }

void Mac802_11::mac_log Packet p  )  [inline, private]
 

Reimplemented from Mac.

Definition at line 299 of file mac-802_11.h.

References logtarget_, and NsObject::recv().

Referenced by recvACK(), recvCTS(), and recvRTS().

00299                                 {
00300                 logtarget_->recv(p, (Handler*) 0);
00301         }

Here is the call graph for this function:

void Mac802_11::navHandler void   )  [protected]
 

Definition at line 515 of file mac-802_11.cc.

References difs_, is_idle(), mhBackoff_, MacTimer::paused(), and BackoffTimer::resume().

Referenced by NavTimer::handle().

00516 {
00517         if(is_idle() && mhBackoff_.paused())
00518                 mhBackoff_.resume(difs_);
00519 }

Here is the call graph for this function:

void NsObject::recv Packet p,
const char *  s
[virtual, inherited]
 

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:

void Mac802_11::recv Packet p,
Handler h
[virtual]
 

Reimplemented from Mac.

Definition at line 1090 of file mac-802_11.cc.

References capture(), collision(), PacketStamp::CPThresh, hdr_cmn::DOWN, HDR_CMN, initialized(), MAC_IDLE, MAC_RECV, mhRecv_, Mac::pktRx_, rx_state_, PacketStamp::RxPr, send(), SET_RX_STATE, MacTimer::start(), tx_active_, Packet::txinfo_, and txtime().

01091 {
01092         struct hdr_cmn *hdr = HDR_CMN(p);
01093         /*
01094          * Sanity Check
01095          */
01096         assert(initialized());
01097 
01098         /*
01099          *  Handle outgoing packets.
01100          */
01101         if(hdr->direction() == hdr_cmn::DOWN) {
01102                 send(p, h);
01103                 return;
01104         }
01105         /*
01106          *  Handle incoming packets.
01107          *
01108          *  We just received the 1st bit of a packet on the network
01109          *  interface.
01110          *
01111          */
01112 
01113         /*
01114          *  If the interface is currently in transmit mode, then
01115          *  it probably won't even see this packet.  However, the
01116          *  "air" around me is BUSY so I need to let the packet
01117          *  proceed.  Just set the error flag in the common header
01118          *  to that the packet gets thrown away.
01119          */
01120         if(tx_active_ && hdr->error() == 0) {
01121                 hdr->error() = 1;
01122         }
01123 
01124         if(rx_state_ == MAC_IDLE) {
01125                 SET_RX_STATE(MAC_RECV);
01126                 pktRx_ = p;
01127 
01128                 /*
01129                  * Schedule the reception of this packet, in
01130                  * txtime seconds.
01131                  */
01132                 mhRecv_.start(txtime(p));
01133         } else {
01134                 /*
01135                  *  If the power of the incoming packet is smaller than the
01136                  *  power of the packet currently being received by at least
01137                  *  the capture threshold, then we ignore the new packet.
01138                  */
01139                 if(pktRx_->txinfo_.RxPr / p->txinfo_.RxPr >= p->txinfo_.CPThresh) {
01140                         capture(p);
01141                 } else {
01142                         collision(p);
01143                 }
01144         }
01145 }

Here is the call graph for this function:

void Mac802_11::recv_timer void   )  [private]
 

Definition at line 1148 of file mac-802_11.cc.

References EnergyModel::adaptivefidelity(), EnergyModel::add_neighbor(), hdr_mac802_11::dh_da, hdr_mac802_11::dh_duration, hdr_mac802_11::dh_fc, hdr_mac802_11::dh_sa, discard(), DROP_MAC_COLLISION, DROP_MAC_PACKET_ERROR, eifs_, Node::energy_model(), hdr_cmn::error(), ETHER_ADDR, frame_control::fc_subtype, frame_control::fc_type, Packet::free(), HDR_CMN, HDR_MAC802_11, Mac::index_, MAC_BROADCAST, MAC_COLL, MAC_RECV, MAC_Subtype_ACK, MAC_Subtype_CTS, MAC_Subtype_Data, MAC_Subtype_RTS, MAC_Type_Control, MAC_Type_Data, MAC_Type_Management, Mac::netif_, Phy::node(), Mac::pktRx_, recvACK(), recvCTS(), recvDATA(), recvRTS(), rx_resume(), rx_state_, set_nav(), Tap::tap(), Mac::tap_, tx_active_, u_int32_t, u_int8_t, and usec().

Referenced by recvHandler().

01149 {
01150         u_int32_t src; 
01151         hdr_cmn *ch = HDR_CMN(pktRx_);
01152         hdr_mac802_11 *mh = HDR_MAC802_11(pktRx_);
01153         u_int32_t dst = ETHER_ADDR(mh->dh_da);
01154         // XXX debug
01155         //struct cts_frame *cf = (struct cts_frame*)pktRx_->access(hdr_mac::offset_);
01156         //u_int32_t src = ETHER_ADDR(mh->dh_sa);
01157         
01158         u_int8_t  type = mh->dh_fc.fc_type;
01159         u_int8_t  subtype = mh->dh_fc.fc_subtype;
01160 
01161         assert(pktRx_);
01162         assert(rx_state_ == MAC_RECV || rx_state_ == MAC_COLL);
01163         
01164         /*
01165          *  If the interface is in TRANSMIT mode when this packet
01166          *  "arrives", then I would never have seen it and should
01167          *  do a silent discard without adjusting the NAV.
01168          */
01169         if(tx_active_) {
01170                 Packet::free(pktRx_);
01171                 goto done;
01172         }
01173 
01174         /*
01175          * Handle collisions.
01176          */
01177         if(rx_state_ == MAC_COLL) {
01178                 discard(pktRx_, DROP_MAC_COLLISION);
01179                 set_nav(usec(eifs_));
01180                 goto done;
01181         }
01182 
01183         /*
01184          * Check to see if this packet was received with enough
01185          * bit errors that the current level of FEC still could not
01186          * fix all of the problems - ie; after FEC, the checksum still
01187          * failed.
01188          */
01189         if( ch->error() ) {
01190                 Packet::free(pktRx_);
01191                 set_nav(usec(eifs_));
01192                 goto done;
01193         }
01194 
01195         /*
01196          * IEEE 802.11 specs, section 9.2.5.6
01197          *      - update the NAV (Network Allocation Vector)
01198          */
01199         if(dst != (u_int32_t)index_) {
01200                 set_nav(mh->dh_duration);
01201         }
01202 
01203         /* tap out - */
01204         if (tap_ && type == MAC_Type_Data &&
01205             MAC_Subtype_Data == subtype ) 
01206                 tap_->tap(pktRx_);
01207         /*
01208          * Adaptive Fidelity Algorithm Support - neighborhood infomation 
01209          * collection
01210          *
01211          * Hacking: Before filter the packet, log the neighbor node
01212          * I can hear the packet, the src is my neighbor
01213          */
01214         if (netif_->node()->energy_model() && 
01215             netif_->node()->energy_model()->adaptivefidelity()) {
01216                 src = ETHER_ADDR(mh->dh_sa);
01217                 netif_->node()->energy_model()->add_neighbor(src);
01218         }
01219         /*
01220          * Address Filtering
01221          */
01222         if(dst != (u_int32_t)index_ && dst != MAC_BROADCAST) {
01223                 /*
01224                  *  We don't want to log this event, so we just free
01225                  *  the packet instead of calling the drop routine.
01226                  */
01227                 discard(pktRx_, "---");
01228                 goto done;
01229         }
01230 
01231         switch(type) {
01232 
01233         case MAC_Type_Management:
01234                 discard(pktRx_, DROP_MAC_PACKET_ERROR);
01235                 goto done;
01236                 break;
01237 
01238         case MAC_Type_Control:
01239                 switch(subtype) {
01240                 case MAC_Subtype_RTS:
01241                         recvRTS(pktRx_);
01242                         break;
01243                 case MAC_Subtype_CTS:
01244                         recvCTS(pktRx_);
01245                         break;
01246                 case MAC_Subtype_ACK:
01247                         recvACK(pktRx_);
01248                         break;
01249                 default:
01250                         fprintf(stderr,"recvTimer1:Invalid MAC Control Subtype %x\n",
01251                                 subtype);
01252                         exit(1);
01253                 }
01254                 break;
01255         case MAC_Type_Data:
01256                 switch(subtype) {
01257                 case MAC_Subtype_Data:
01258                         recvDATA(pktRx_);
01259                         break;
01260                 default:
01261                         fprintf(stderr, "recv_timer2:Invalid MAC Data Subtype %x\n",
01262                                 subtype);
01263                         exit(1);
01264                 }
01265                 break;
01266         default:
01267                 fprintf(stderr, "recv_timer3:Invalid MAC Type %x\n", subtype);
01268                 exit(1);
01269         }
01270  done:
01271         pktRx_ = 0;
01272         rx_resume();
01273 }

Here is the call graph for this function:

void Mac802_11::recvACK Packet p  )  [private]
 

Definition at line 1470 of file mac-802_11.cc.

References MacTimer::busy(), cw_, discard(), DROP_MAC_INVALID_STATE, Packet::free(), HDR_CMN, is_idle(), mac_log(), MAC_SEND, macmib_, mhBackoff_, mhSend_, Mac::pktTx_, rst_cw(), MAC_MIB::RTSThreshold, slrc_, ssrc_, BackoffTimer::start(), MacTimer::stop(), tx_resume(), tx_state_, and u_int32_t.

Referenced by recv_timer().

01471 {
01472         
01473         struct hdr_cmn *ch = HDR_CMN(p);
01474 
01475         if(tx_state_ != MAC_SEND) {
01476         discard(p, DROP_MAC_INVALID_STATE);
01477         return;
01478         }
01479         //printf("(%d)...................recving ACK:%x\n",index_,p);
01480         assert(pktTx_);
01481         Packet::free(pktTx_); pktTx_ = 0;
01482 
01483         mhSend_.stop();
01484 
01485         /*
01486          * The successful reception of this ACK packet implies
01487          * that our DATA transmission was successful.  Hence,
01488          * we can reset the Short/Long Retry Count and the CW.
01489          */
01490         if((u_int32_t) ch->size() <= macmib_->RTSThreshold)
01491                 ssrc_ = 0;
01492         else
01493                 slrc_ = 0;
01494 
01495         /*
01496          * Backoff before sending again.
01497          */
01498         rst_cw();
01499         assert(mhBackoff_.busy() == 0);
01500         mhBackoff_.start(cw_, is_idle());
01501 
01502         tx_resume();
01503 
01504         mac_log(p);
01505 }

Here is the call graph for this function:

void Mac802_11::recvCTS Packet p  )  [private]
 

Definition at line 1340 of file mac-802_11.cc.

References discard(), DROP_MAC_INVALID_STATE, Packet::free(), mac_log(), MAC_RTS, mhSend_, pktRTS_, Mac::pktTx_, MacTimer::stop(), tx_resume(), and tx_state_.

Referenced by recv_timer().

01341 {
01342         if(tx_state_ != MAC_RTS) {
01343                 discard(p, DROP_MAC_INVALID_STATE);
01344                 return;
01345         }
01346 
01347         assert(pktRTS_);
01348         Packet::free(pktRTS_); pktRTS_ = 0;
01349 
01350         assert(pktTx_);
01351         // debug
01352         //struct hdr_mac802_11 *mh = HDR_MAC802_11(pktTx_);
01353         //printf("(%d):recvCTS:pktTx_-%x,mac-subtype-%d & pktCTS_:%x\n",index_,pktTx_,mh->dh_fc.fc_subtype,p);
01354         
01355         mhSend_.stop();
01356 
01357         /*
01358          * The successful reception of this CTS packet implies
01359          * that our RTS was successful.  Hence, we can reset
01360          * the Short Retry Count and the CW.
01361          */
01362         //ssrc_ = 0;
01363         //rst_cw();
01364 
01365         tx_resume();
01366 
01367         mac_log(p);
01368 }

Here is the call graph for this function:

void Mac802_11::recvDATA Packet p  )  [private]
 

Definition at line 1371 of file mac-802_11.cc.

References MacTimer::busy(), cache_, cache_node_count_, dh, discard(), DROP_MAC_BUSY, DROP_MAC_DUPLICATE, ETHER_ADDR, ETHER_HDR_LEN11, Packet::free(), HDR_CMN, HDR_MAC802_11, MAC_BROADCAST, MAC_CTS, macmib_, mhSend_, pktCTRL_, NsObject::recv(), MAC_MIB::RTSThreshold, sendACK(), Host::seqno, MacTimer::stop(), tx_resume(), tx_state_, u_int32_t, and BiConnector::uptarget_.

Referenced by recv_timer().

01372 {
01373         struct hdr_mac802_11 *dh = HDR_MAC802_11(p);
01374         u_int32_t dst, src, size;
01375 
01376         {       struct hdr_cmn *ch = HDR_CMN(p);
01377 
01378                 dst = ETHER_ADDR(dh->dh_da);
01379                 src = ETHER_ADDR(dh->dh_sa);
01380                 size = ch->size();
01381 
01382                 /*
01383                  * Adjust the MAC packet size - ie; strip
01384                  * off the mac header
01385                  */
01386                 ch->size() -= ETHER_HDR_LEN11;
01387                 ch->num_forwards() += 1;
01388         }
01389 
01390         /*
01391          *  If we sent a CTS, clean up...
01392          */
01393         if(dst != MAC_BROADCAST) {
01394                 if(size >= macmib_->RTSThreshold) {
01395                         if (tx_state_ == MAC_CTS) {
01396                                 assert(pktCTRL_);
01397                                 Packet::free(pktCTRL_); pktCTRL_ = 0;
01398                                 mhSend_.stop();
01399                                 /*
01400                                  * Our CTS got through.
01401                                  */
01402                                 //printf("(%d): RECVING DATA!\n",index_);
01403                                 //ssrc_ = 0;
01404                                 //rst_cw();
01405                         }
01406                         else {
01407                                 discard(p, DROP_MAC_BUSY);
01408                                 //printf("(%d)..discard DATA\n",index_);
01409                                 return;
01410                         }
01411                         sendACK(src);
01412                         tx_resume();
01413                 }
01414                 /*
01415                  *  We did not send a CTS and there's no
01416                  *  room to buffer an ACK.
01417                  */
01418                 else {
01419                         if(pktCTRL_) {
01420                                 discard(p, DROP_MAC_BUSY);
01421                                 return;
01422                         }
01423                         sendACK(src);
01424                         if(mhSend_.busy() == 0)
01425                                 tx_resume();
01426                 }
01427         }
01428 
01429         /* ============================================================
01430             Make/update an entry in our sequence number cache.
01431            ============================================================ */
01432 
01433         /* Changed by Debojyoti Dutta. This upper loop of if{}else was 
01434            suggested by Joerg Diederich <dieder@ibr.cs.tu-bs.de>. 
01435            Changed on 19th Oct'2000 */
01436 
01437         if(dst != MAC_BROADCAST) {
01438                 if (src < (u_int32_t) cache_node_count_) {
01439                         Host *h = &cache_[src];
01440 
01441                         if(h->seqno && h->seqno == dh->dh_scontrol) {
01442                                 discard(p, DROP_MAC_DUPLICATE);
01443                                 return;
01444                         }
01445                         h->seqno = dh->dh_scontrol;
01446                 } else {
01447                         static int count = 0;
01448                         if (++count <= 10) {
01449                                 printf ("MAC_802_11: accessing MAC cache_ array out of range (src %u, dst %u, size %d)!\n", src, dst, cache_node_count_);
01450                                 if (count == 10)
01451                                         printf ("[suppressing additional MAC cache_ warnings]\n");
01452                         };
01453                 };
01454         }
01455 
01456         /*
01457 
01458          *  Pass the packet up to the link-layer.
01459          *  XXX - we could schedule an event to account
01460          *  for this processing delay.
01461          */
01462         //p->incoming = 1;
01463         // XXXXX NOTE: use of incoming flag has been depracated; In order to track direction of pkt flow, direction_ in hdr_cmn is used instead. see packet.h for details. 
01464         
01465         uptarget_->recv(p, (Handler*) 0);
01466 }

Here is the call graph for this function:

void Mac802_11::recvHandler void   )  [protected]
 

Definition at line 522 of file mac-802_11.cc.

References recv_timer().

Referenced by RxTimer::handle().

00523 {
00524         recv_timer();
00525 }

Here is the call graph for this function:

virtual void NsObject::recvOnly Packet  )  [inline, virtual, inherited]
 

Reimplemented in Agent, and Trace.

Definition at line 56 of file object.h.

Referenced by Trace::recvOnly().

00056 {};

void Mac802_11::recvRTS Packet p  )  [private]
 

Definition at line 1277 of file mac-802_11.cc.

References Packet::access(), MacTimer::busy(), discard(), DROP_MAC_BUSY, ETHER_ADDR, MAC_IDLE, mac_log(), mhDefer_, hdr_mac::offset_, pktCTRL_, sendCTS(), MacTimer::stop(), tx_resume(), and tx_state_.

Referenced by recv_timer().

01278 {
01279         struct rts_frame *rf = (struct rts_frame*)p->access(hdr_mac::offset_);
01280 
01281         if(tx_state_ != MAC_IDLE) {
01282                 discard(p, DROP_MAC_BUSY);
01283                 return;
01284         }
01285 
01286         /*
01287          *  If I'm responding to someone else, discard this RTS.
01288          */
01289         if(pktCTRL_) {
01290                 discard(p, DROP_MAC_BUSY);
01291                 return;
01292         }
01293 
01294         sendCTS(ETHER_ADDR(rf->rf_ta), rf->rf_duration);
01295 
01296         /*
01297          *  Stop deferring - will be reset in tx_resume().
01298          */
01299         if(mhDefer_.busy()) mhDefer_.stop();
01300 
01301         tx_resume();
01302 
01303         mac_log(p);
01304 }

Here is the call graph for this function:

void NsObject::reset  )  [protected, virtual, inherited]
 

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 }

void Mac::resume Packet p = 0  )  [virtual, inherited]
 

Reimplemented in MacCsma.

Definition at line 173 of file mac.cc.

References Mac::callback_, BiConnector::drop(), Handler::handle(), Mac::intr_, MAC_IDLE, and Mac::state().

Referenced by UnslottedAlohaMac::backoff(), UnslottedAlohaMac::end_of_contention(), and MacHandlerResume::handle().

00174 {
00175         if (p != 0)
00176                 drop(p);
00177         state(MAC_IDLE);
00178         callback_->handle(&intr_);
00179 }

Here is the call graph for this function:

void Mac802_11::RetransmitDATA  )  [private]
 

Definition at line 963 of file mac-802_11.cc.

References MAC_MIB::ACKFailureCount, MacTimer::busy(), Packet::copy(), cw_, dh, discard(), DROP_MAC_RETRY_COUNT_EXCEEDED, ETHER_ADDR, ETHER_HDR_LEN11, MAC_MIB::FailedCount, Packet::free(), HDR_CMN, HDR_MAC802_11, inc_cw(), is_idle(), MAC_MIB::LongRetryLimit, MAC_BROADCAST, macmib_, mhBackoff_, pktRTS_, Mac::pktTx_, rst_cw(), MAC_MIB::RTSThreshold, sendRTS(), MAC_MIB::ShortRetryLimit, hdr_cmn::size(), slrc_, ssrc_, BackoffTimer::start(), u_int32_t, hdr_cmn::xmit_failure_, hdr_cmn::xmit_failure_data_, hdr_cmn::xmit_reason_, and XMIT_REASON_ACK.

Referenced by send_timer().

00964 {
00965         struct hdr_cmn *ch;
00966         struct hdr_mac802_11 *mh;
00967         u_int32_t *rcount, *thresh;
00968 
00969         assert(mhBackoff_.busy() == 0);
00970 
00971         assert(pktTx_);
00972         assert(pktRTS_ == 0);
00973 
00974         ch = HDR_CMN(pktTx_);
00975         mh = HDR_MAC802_11(pktTx_);
00976 
00977         /*
00978          *  Broadcast packets don't get ACKed and therefore
00979          *  are never retransmitted.
00980          */
00981         if((u_int32_t)ETHER_ADDR(mh->dh_da) == MAC_BROADCAST) {
00982                 Packet::free(pktTx_); pktTx_ = 0;
00983 
00984                 /*
00985                  * Backoff at end of TX.
00986                  */
00987                 rst_cw();
00988                 mhBackoff_.start(cw_, is_idle());
00989 
00990                 return;
00991         }
00992 
00993         macmib_->ACKFailureCount++;
00994 
00995         if((u_int32_t) ch->size() <= macmib_->RTSThreshold) {
00996                 rcount = &ssrc_;
00997                 thresh = &macmib_->ShortRetryLimit;
00998         }
00999         else {
01000                 rcount = &slrc_;
01001                 thresh = &macmib_->LongRetryLimit;
01002         }
01003 
01004         (*rcount)++;
01005 
01006         if(*rcount > *thresh) {
01007                 macmib_->FailedCount++;
01008                 /* tell the callback the send operation failed 
01009                    before discarding the packet */
01010                 hdr_cmn *ch = HDR_CMN(pktTx_);
01011                 if (ch->xmit_failure_) {
01012                         ch->size() -= ETHER_HDR_LEN11;
01013                         ch->xmit_reason_ = XMIT_REASON_ACK;
01014                         ch->xmit_failure_(pktTx_->copy(),
01015                                           ch->xmit_failure_data_);
01016                 }
01017 
01018                 discard(pktTx_, DROP_MAC_RETRY_COUNT_EXCEEDED); pktTx_ = 0;
01019                 //printf("(%d)DATA discarded: count exceeded\n",index_);
01020                 *rcount = 0;
01021                 rst_cw();
01022         }
01023         else {
01024                 struct hdr_mac802_11 *dh;
01025                 dh = HDR_MAC802_11(pktTx_);
01026                 dh->dh_fc.fc_retry = 1;
01027 
01028                 sendRTS(ETHER_ADDR(mh->dh_da));
01029                 //printf("(%d)retxing data:%x..sendRTS..\n",index_,pktTx_);
01030                 inc_cw();
01031                 mhBackoff_.start(cw_, is_idle());
01032         }
01033 }

Here is the call graph for this function:

void Mac802_11::RetransmitRTS  )  [private]
 

Definition at line 921 of file mac-802_11.cc.

References Packet::access(), MacTimer::busy(), Packet::copy(), cw_, discard(), DROP_MAC_RETRY_COUNT_EXCEEDED, ETHER_HDR_LEN11, HDR_CMN, inc_cw(), is_idle(), macmib_, mhBackoff_, hdr_mac::offset_, pktRTS_, Mac::pktTx_, rst_cw(), MAC_MIB::RTSFailureCount, MAC_MIB::ShortRetryLimit, hdr_cmn::size(), ssrc_, BackoffTimer::start(), hdr_cmn::xmit_failure_, hdr_cmn::xmit_failure_data_, hdr_cmn::xmit_reason_, and XMIT_REASON_RTS.

Referenced by send_timer().

00922 {
00923         assert(pktTx_);
00924         assert(pktRTS_);
00925         assert(mhBackoff_.busy() == 0);
00926 
00927         macmib_->RTSFailureCount++;
00928 
00929         ssrc_ += 1;                     // STA Short Retry Count
00930 
00931         if(ssrc_ >= macmib_->ShortRetryLimit) {
00932                 discard(pktRTS_, DROP_MAC_RETRY_COUNT_EXCEEDED); pktRTS_ = 0;
00933                 /* tell the callback the send operation failed 
00934                    before discarding the packet */
00935                 hdr_cmn *ch = HDR_CMN(pktTx_);
00936                 if (ch->xmit_failure_) {
00937                         /*
00938                          *  Need to remove the MAC header so that 
00939                          *  re-cycled packets don't keep getting
00940                          *  bigger.
00941                          */
00942                         ch->size() -= ETHER_HDR_LEN11;
00943                         ch->xmit_reason_ = XMIT_REASON_RTS;
00944                         ch->xmit_failure_(pktTx_->copy(),
00945                                           ch->xmit_failure_data_);
00946                 }
00947                 //printf("(%d)....discarding RTS:%x\n",index_,pktRTS_);
00948                 discard(pktTx_, DROP_MAC_RETRY_COUNT_EXCEEDED); pktTx_ = 0;
00949                 ssrc_ = 0;
00950                 rst_cw();
00951         } else {
00952                 //printf("(%d)...retxing RTS:%x\n",index_,pktRTS_);
00953                 struct rts_frame *rf;
00954                 rf = (struct rts_frame*)pktRTS_->access(hdr_mac::offset_);
00955                 rf->rf_fc.fc_retry = 1;
00956 
00957                 inc_cw();
00958                 mhBackoff_.start(cw_, is_idle());
00959         }
00960 }

Here is the call graph for this function:

void Mac802_11::rst_cw  )  [inline, private]
 

Definition at line 311 of file mac-802_11.h.

References cw_, PHY_MIB::CWMin, and phymib_.

Referenced by recvACK(), RetransmitDATA(), and RetransmitRTS().

00311 { cw_ = phymib_->CWMin; }

void Mac802_11::rx_resume void   )  [private]
 

Definition at line 467 of file mac-802_11.cc.

References MacTimer::busy(), MAC_IDLE, mhRecv_, Mac::pktRx_, and SET_RX_STATE.

Referenced by recv_timer().

00468 {
00469         assert(pktRx_ == 0);
00470         assert(mhRecv_.busy() == 0);
00471         SET_RX_STATE(MAC_IDLE);
00472 }

Here is the call graph for this function:

double Mac802_11::sec double  t  )  [inline, private]
 

Definition at line 312 of file mac-802_11.h.

Referenced by check_pktCTRL(), and sendCTS().

00312 { return(t *= 1.0e-6); }

void Mac802_11::send Packet p,
Handler h
[private]
 

Definition at line 1039 of file mac-802_11.cc.

References MacTimer::busy(), Mac::callback_, cw_, dh, difs_, Node::energy_model(), ETHER_ADDR, HDR_MAC802_11, EnergyModel::INROUTE, is_idle(), mhBackoff_, mhDefer_, Mac::netif_, Phy::node(), phymib_, Random::random(), sendDATA(), sendRTS(), EnergyModel::set_node_sleep(), EnergyModel::set_node_state(), EnergyModel::sleep(), PHY_MIB::SlotTime, sta_seqno_, BackoffTimer::start(), and DeferTimer::start().

Referenced by recv().

01040 {
01041         double rTime;
01042         struct hdr_mac802_11* dh = HDR_MAC802_11(p);
01043 
01044         /* 
01045          * drop the packet if the node is in sleep mode
01046          XXX sleep mode can't stop node from sending packets
01047          */
01048         EnergyModel *em = netif_->node()->energy_model();
01049         if (em && em->sleep()) {
01050                 em->set_node_sleep(0);
01051                 em->set_node_state(EnergyModel::INROUTE);
01052         }
01053         
01054         callback_ = h;
01055         sendDATA(p);
01056         sendRTS(ETHER_ADDR(dh->dh_da));
01057 
01058         /*
01059          * Assign the data packet a sequence number.
01060          */
01061         dh->dh_scontrol = sta_seqno_++;
01062 
01063         /*
01064          *  If the medium is IDLE, we must wait for a DIFS
01065          *  Space before transmitting.
01066          */
01067         if(mhBackoff_.busy() == 0) {
01068                 if(is_idle()) {
01069                         /*
01070                          * If we are already deferring, there is no
01071                          * need to reset the Defer timer.
01072                          */
01073                         if(mhDefer_.busy() == 0) {
01074                                 rTime = (Random::random() % cw_) * (phymib_->SlotTime);
01075                                 mhDefer_.start(difs_ + rTime);
01076                         }
01077                         
01078                 }
01079         /*
01080          * If the medium is NOT IDLE, then we start
01081          * the backoff timer.
01082          */
01083                 else {
01084                         mhBackoff_.start(cw_, is_idle());
01085                 }
01086         }
01087 }

Here is the call graph for this function:

void Mac802_11::send_timer void   )  [private]
 

Definition at line 545 of file mac-802_11.cc.

References Packet::free(), MAC_ACK, MAC_CTS, MAC_IDLE, MAC_RTS, MAC_SEND, pktCTRL_, RetransmitDATA(), RetransmitRTS(), tx_resume(), and tx_state_.

Referenced by sendHandler().

00546 {
00547         switch(tx_state_) {
00548         /*
00549          * Sent a RTS, but did not receive a CTS.
00550          */
00551         case MAC_RTS:
00552                 RetransmitRTS();
00553                 break;
00554         /*
00555          * Sent a CTS, but did not receive a DATA packet.
00556          */
00557         case MAC_CTS:
00558                 assert(pktCTRL_);
00559                 Packet::free(pktCTRL_); pktCTRL_ = 0;
00560                 break;
00561         /*
00562          * Sent DATA, but did not receive an ACK packet.
00563          */
00564         case MAC_SEND:
00565                 RetransmitDATA();
00566                 break;
00567         /*
00568          * Sent an ACK, and now ready to resume transmission.
00569          */
00570         case MAC_ACK:
00571                 assert(pktCTRL_);
00572                 Packet::free(pktCTRL_); pktCTRL_ = 0;
00573                 break;
00574         case MAC_IDLE:
00575                 break;
00576         default:
00577                 assert(0);
00578         }
00579         tx_resume();
00580 }

Here is the call graph for this function:

void Mac802_11::sendACK int  dst  )  [private]
 

Definition at line 831 of file mac-802_11.cc.

References Packet::access(), Packet::alloc(), basicRate_, hdr_cmn::error(), ETHER_ACK_LEN, HDR_CMN, hdr_cmn::iface(), MAC_HDR_LEN, MAC_ProtocolVersion, MAC_Subtype_ACK, MAC_Type_Control, hdr_mac::offset_, pktCTRL_, PT_MAC, hdr_cmn::ptype(), hdr_cmn::size(), STORE4BYTE, txtime(), hdr_cmn::txtime(), and hdr_cmn::uid().

Referenced by recvDATA().

00832 {
00833         Packet *p = Packet::alloc();
00834         hdr_cmn* ch = HDR_CMN(p);
00835         struct ack_frame *af = (struct ack_frame*)p->access(hdr_mac::offset_);
00836 
00837         assert(pktCTRL_ == 0);
00838 
00839         ch->uid() = 0;
00840         ch->ptype() = PT_MAC;
00841         ch->size() = ETHER_ACK_LEN;
00842         ch->iface() = -2;
00843         ch->error() = 0;
00844         
00845         bzero(af, MAC_HDR_LEN);
00846 
00847         af->af_fc.fc_protocol_version = MAC_ProtocolVersion;
00848         af->af_fc.fc_type       = MAC_Type_Control;
00849         af->af_fc.fc_subtype    = MAC_Subtype_ACK;
00850         af->af_fc.fc_to_ds      = 0;
00851         af->af_fc.fc_from_ds    = 0;
00852         af->af_fc.fc_more_frag  = 0;
00853         af->af_fc.fc_retry      = 0;
00854         af->af_fc.fc_pwr_mgt    = 0;
00855         af->af_fc.fc_more_data  = 0;
00856         af->af_fc.fc_wep        = 0;
00857         af->af_fc.fc_order      = 0;
00858 
00859         //af->af_duration = ACK_DURATION();
00860         STORE4BYTE(&dst, (af->af_ra));
00861 
00862         /* store ack tx time */
00863         ch->txtime() = txtime(ch->size(), basicRate_);
00864         
00865         /* calculate ack duration */
00866         af->af_duration = 0;    
00867         
00868         pktCTRL_ = p;
00869 }

Here is the call graph for this function:

void Mac802_11::sendCTS int  dst,
double  duration
[private]
 

Definition at line 787 of file mac-802_11.cc.

References Packet::access(), Packet::alloc(), basicRate_, cf, hdr_cmn::error(), ETHER_CTS_LEN, HDR_CMN, hdr_cmn::iface(), MAC_HDR_LEN, MAC_ProtocolVersion, MAC_Subtype_CTS, MAC_Type_Control, hdr_mac::offset_, pktCTRL_, PT_MAC, hdr_cmn::ptype(), sec(), sifs_, hdr_cmn::size(), STORE4BYTE, txtime(), hdr_cmn::txtime(), hdr_cmn::uid(), and usec().

Referenced by recvRTS().

00788 {
00789         Packet *p = Packet::alloc();
00790         hdr_cmn* ch = HDR_CMN(p);
00791         struct cts_frame *cf = (struct cts_frame*)p->access(hdr_mac::offset_);
00792 
00793         assert(pktCTRL_ == 0);
00794 
00795         ch->uid() = 0;
00796         ch->ptype() = PT_MAC;
00797         ch->size() = ETHER_CTS_LEN;
00798         ch->iface() = -2;
00799         ch->error() = 0;
00800         //ch->direction() = hdr_cmn::DOWN;
00801         bzero(cf, MAC_HDR_LEN);
00802 
00803         cf->cf_fc.fc_protocol_version = MAC_ProtocolVersion;
00804         cf->cf_fc.fc_type       = MAC_Type_Control;
00805         cf->cf_fc.fc_subtype    = MAC_Subtype_CTS;
00806         cf->cf_fc.fc_to_ds      = 0;
00807         cf->cf_fc.fc_from_ds    = 0;
00808         cf->cf_fc.fc_more_frag  = 0;
00809         cf->cf_fc.fc_retry      = 0;
00810         cf->cf_fc.fc_pwr_mgt    = 0;
00811         cf->cf_fc.fc_more_data  = 0;
00812         cf->cf_fc.fc_wep        = 0;
00813         cf->cf_fc.fc_order      = 0;
00814         
00815         //cf->cf_duration = CTS_DURATION(rts_duration);
00816         STORE4BYTE(&dst, (cf->cf_ra));
00817         
00818         /* store cts tx time */
00819         ch->txtime() = txtime(ch->size(), basicRate_);
00820         
00821         /* calculate cts duration */
00822         cf->cf_duration = usec(sec(rts_duration)
00823                                - sifs_
00824                                - txtime(ETHER_CTS_LEN, basicRate_));
00825         
00826         pktCTRL_ = p;
00827         
00828 }

Here is the call graph for this function:

void Mac802_11::sendDATA Packet p  )  [private]
 

Definition at line 872 of file mac-802_11.cc.

References basicRate_, dataRate_, dh, ETHER_ACK_LEN, ETHER_ADDR, ETHER_HDR_LEN11, HDR_CMN, HDR_MAC802_11, MAC_BROADCAST, MAC_ProtocolVersion, MAC_Subtype_Data, MAC_Type_Data, Mac::pktTx_, sifs_, hdr_cmn::size(), txtime(), hdr_cmn::txtime(), u_int32_t, and usec().

Referenced by send().

00873 {
00874         hdr_cmn* ch = HDR_CMN(p);
00875         struct hdr_mac802_11* dh = HDR_MAC802_11(p);
00876 
00877         assert(pktTx_ == 0);
00878 
00879         /*
00880          * Update the MAC header
00881          */
00882         ch->size() += ETHER_HDR_LEN11;
00883 
00884         dh->dh_fc.fc_protocol_version = MAC_ProtocolVersion;
00885         dh->dh_fc.fc_type       = MAC_Type_Data;
00886         dh->dh_fc.fc_subtype    = MAC_Subtype_Data;
00887         //printf(".....p = %x, mac-subtype-%d\n",p,dh->dh_fc.fc_subtype);
00888         
00889         dh->dh_fc.fc_to_ds      = 0;
00890         dh->dh_fc.fc_from_ds    = 0;
00891         dh->dh_fc.fc_more_frag  = 0;
00892         dh->dh_fc.fc_retry      = 0;
00893         dh->dh_fc.fc_pwr_mgt    = 0;
00894         dh->dh_fc.fc_more_data  = 0;
00895         dh->dh_fc.fc_wep        = 0;
00896         dh->dh_fc.fc_order      = 0;
00897 
00898         /* store data tx time */
00899         ch->txtime() = txtime(ch->size(), dataRate_);
00900 
00901         if((u_int32_t)ETHER_ADDR(dh->dh_da) != MAC_BROADCAST) {
00902                 /* store data tx time for unicast packets */
00903                 ch->txtime() = txtime(ch->size(), dataRate_);
00904                 
00905                 //dh->dh_duration = DATA_DURATION();
00906                 dh->dh_duration = usec(txtime(ETHER_ACK_LEN, basicRate_)
00907                                        + sifs_);
00908         } else {
00909                 /* store data tx time for broadcast packets (see 9.6) */
00910                 ch->txtime() = txtime(ch->size(), basicRate_);
00911                 
00912                 dh->dh_duration = 0;
00913         }
00914         pktTx_ = p;
00915 }

Here is the call graph for this function:

virtual void BiConnector::sendDown Packet p,
Handler h
[inline, protected, virtual, inherited]
 

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:

void Mac::sendDown Packet p  )  [virtual, inherited]
 

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:

void Mac802_11::sendHandler void   )  [protected]
 

Definition at line 528 of file mac-802_11.cc.

References send_timer().

Referenced by TxTimer::handle().

00529 {
00530         send_timer();
00531 }

Here is the call graph for this function:

void Mac802_11::sendRTS int  dst  )  [private]
 

Definition at line 725 of file mac-802_11.cc.

References Packet::access(), Packet::alloc(), basicRate_, hdr_cmn::error(), ETHER_ACK_LEN, ETHER_CTS_LEN, ETHER_RTS_LEN, Packet::free(), HDR_CMN, hdr_cmn::iface(), Mac::index_, MAC_BROADCAST, MAC_HDR_LEN, MAC_ProtocolVersion, MAC_Subtype_RTS, MAC_Type_Control, macmib_, hdr_mac::offset_, pktRTS_, Mac::pktTx_, PT_MAC, hdr_cmn::ptype(), MAC_MIB::RTSThreshold, sifs_, hdr_cmn::size(), STORE4BYTE, txtime(), hdr_cmn::txtime(), u_int32_t, hdr_cmn::uid(), and usec().

Referenced by check_pktTx(), RetransmitDATA(), and send().

00726 {
00727         Packet *p = Packet::alloc();
00728         hdr_cmn* ch = HDR_CMN(p);
00729         struct rts_frame *rf = (struct rts_frame*)p->access(hdr_mac::offset_);
00730         
00731         assert(pktTx_);
00732         assert(pktRTS_ == 0);
00733 
00734         /*
00735          *  If the size of the packet is larger than the
00736          *  RTSThreshold, then perform the RTS/CTS exchange.
00737          *
00738          *  XXX: also skip if destination is a broadcast
00739          */
00740         if( (u_int32_t) HDR_CMN(pktTx_)->size() < macmib_->RTSThreshold ||
00741             (u_int32_t) dst == MAC_BROADCAST) {
00742                 Packet::free(p);
00743                 //p = 0;
00744                 return;
00745         }
00746 
00747         ch->uid() = 0;
00748         ch->ptype() = PT_MAC;
00749         ch->size() = ETHER_RTS_LEN;
00750         ch->iface() = -2;
00751         ch->error() = 0;
00752 
00753         bzero(rf, MAC_HDR_LEN);
00754 
00755         rf->rf_fc.fc_protocol_version = MAC_ProtocolVersion;
00756         rf->rf_fc.fc_type       = MAC_Type_Control;
00757         rf->rf_fc.fc_subtype    = MAC_Subtype_RTS;
00758         rf->rf_fc.fc_to_ds      = 0;
00759         rf->rf_fc.fc_from_ds    = 0;
00760         rf->rf_fc.fc_more_frag  = 0;
00761         rf->rf_fc.fc_retry      = 0;
00762         rf->rf_fc.fc_pwr_mgt    = 0;
00763         rf->rf_fc.fc_more_data  = 0;
00764         rf->rf_fc.fc_wep        = 0;
00765         rf->rf_fc.fc_order      = 0;
00766 
00767         //rf->rf_duration = RTS_DURATION(pktTx_);
00768         STORE4BYTE(&dst, (rf->rf_ra));
00769         
00770         /* store rts tx time */
00771         ch->txtime() = txtime(ch->size(), basicRate_);
00772         
00773         STORE4BYTE(&index_, (rf->rf_ta));
00774         /* calculate rts duration field */
00775         rf->rf_duration = usec(sifs_
00776                                + txtime(ETHER_CTS_LEN, basicRate_)
00777                                + sifs_
00778                                + txtime(pktTx_)
00779                                + sifs_
00780                                + txtime(ETHER_ACK_LEN, basicRate_));
00781         
00782         
00783         pktRTS_ = p;
00784 }

Here is the call graph for this function:

virtual void BiConnector::sendUp Packet p,
Handler h
[inline, protected, virtual, inherited]
 

Reimplemented in Mac802_3.

Definition at line 57 of file bi-connector.h.

References NsObject::recv(), and BiConnector::uptarget_.

Referenced by BiConnector::recv().

00058                 { uptarget_->recv(p, h); }

Here is the call graph for this function:

void Mac::sendUp Packet p  )  [virtual, inherited]
 

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:

void Mac802_11::set_nav u_int16_t  us  )  [inline, private]
 

Definition at line 318 of file mac-802_11.h.

References MacTimer::busy(), Scheduler::clock(), Scheduler::instance(), mhNav_, nav_, MacTimer::start(), and MacTimer::stop().

Referenced by capture(), and recv_timer().

00318                                           {
00319                 double now = Scheduler::instance().clock();
00320                 double t = us * 1e-6;
00321 
00322                 if((now + t) > nav_) {
00323                         nav_ = now + t;
00324                         if(mhNav_.busy())
00325                                 mhNav_.stop();
00326                         mhNav_.start(t);
00327                 }
00328         }

Here is the call graph for this function:

MacState Mac::state int  m  )  [inline, inherited]
 

Definition at line 192 of file mac.h.

References MacState, and Mac::state_.

00192 { return state_ = (MacState) m; }

MacState Mac::state  )  [inline, inherited]
 

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_; }

void Mac802_11::trace_pkt Packet p  )  [private]
 

Definition at line 222 of file mac-802_11.cc.

References dh, ETHER_ADDR, HDR_CMN, HDR_MAC802_11, Mac::index_, p_info::name(), packet_info, and u_int16_t.

Referenced by discard().

00222                               {
00223         struct hdr_cmn *ch = HDR_CMN(p);
00224         struct hdr_mac802_11* dh = HDR_MAC802_11(p);
00225         u_int16_t *t = (u_int16_t*) &dh->dh_fc;
00226 
00227         fprintf(stderr, "\t[ %2x %2x %2x %2x ] %x %s %d\n",
00228                 *t, dh->dh_duration,
00229                 ETHER_ADDR(dh->dh_da), ETHER_ADDR(dh->dh_sa),
00230                 index_, packet_info.name(ch->ptype()), ch->size());
00231 }

Here is the call graph for this function:

void Mac802_11::tx_resume void   )  [private]
 

Definition at line 429 of file mac-802_11.cc.

References MacTimer::busy(), Mac::callback_, cw_, difs_, ETHER_ADDR, Handler::handle(), HDR_CMN, HDR_MAC802_11, MAC_BROADCAST, MAC_IDLE, macmib_, mhBackoff_, mhDefer_, mhSend_, phymib_, pktCTRL_, pktRTS_, Mac::pktTx_, Random::random(), MAC_MIB::RTSThreshold, SET_TX_STATE, sifs_, hdr_cmn::size(), PHY_MIB::SlotTime, DeferTimer::start(), and u_int32_t.

Referenced by recvACK(), recvCTS(), recvDATA(), recvRTS(), and send_timer().

00430 {
00431         double rTime;
00432         assert(mhSend_.busy() == 0);
00433         assert(mhDefer_.busy() == 0);
00434 
00435         if(pktCTRL_) {
00436                 /*
00437                  *  Need to send a CTS or ACK.
00438                  */
00439                 mhDefer_.start(sifs_);
00440         } else if(pktRTS_) {
00441                 if(mhBackoff_.busy() == 0) {
00442                         rTime = (Random::random() % cw_) * phymib_->SlotTime;
00443                         mhDefer_.start(difs_ + rTime);
00444                 }
00445         } else if(pktTx_) {
00446                 if(mhBackoff_.busy() == 0) {
00447                         hdr_cmn *ch = HDR_CMN(pktTx_);
00448                         struct hdr_mac802_11 *mh = HDR_MAC802_11(pktTx_);
00449                         
00450                         if ((u_int32_t) ch->size() < macmib_->RTSThreshold ||
00451                             (u_int32_t) ETHER_ADDR(mh->dh_da) == MAC_BROADCAST) {
00452                                 rTime = (Random::random() % cw_) * phymib_->SlotTime;
00453                                 mhDefer_.start(difs_ + rTime);
00454                         } else {
00455                                 mhDefer_.start(sifs_);
00456                         }
00457                 }
00458         } else if(callback_) {
00459                 Handler *h = callback_;
00460                 callback_ = 0;
00461                 h->handle((Event*) 0);
00462         }
00463         SET_TX_STATE(MAC_IDLE);
00464 }

Here is the call graph for this function:

void Mac802_11::txHandler void   )  [protected]
 

Definition at line 535 of file mac-802_11.cc.

References tx_active_.

Referenced by IFTimer::handle().

00536 {
00537         tx_active_ = 0;
00538 }

double Mac802_11::txtime int  bytes  )  [inline, private]
 

Reimplemented from Mac.

Definition at line 304 of file mac-802_11.h.

References abort().

00304 { /* clobber inherited txtime() */ abort(); }

Here is the call graph for this function:

double Mac802_11::txtime double  psz,
double  drt
[private]
 

Definition at line 1327 of file mac-802_11.cc.

References phymib_, PLCP_HDR_LEN, and PHY_MIB::PLCPDataRate.

01328 {
01329         double dsz = psz - PLCP_HDR_LEN;
01330         int plcp_hdr = PLCP_HDR_LEN << 3;
01331         int datalen = (int)dsz << 3;
01332         
01333         double t = (((double)plcp_hdr)/phymib_->PLCPDataRate) + (((double)datalen)/drt);
01334         return(t);
01335 }

double Mac802_11::txtime Packet p  )  [private]
 

Reimplemented from Mac.

Definition at line 1310 of file mac-802_11.cc.

References BiConnector::drop(), and HDR_CMN.

Referenced by capture(), check_pktCTRL(), check_pktRTS(), check_pktTx(), collision(), recv(), sendACK(), sendCTS(), sendDATA(), and sendRTS().

01311  {
01312          struct hdr_cmn *ch = HDR_CMN(p);
01313          double t = ch->txtime();
01314          if (t < 0.0) {
01315                  drop(p, "XXX");
01316                 exit(1);
01317          }
01318          return t;
01319  }

Here is the call graph for this function:

NsObject* BiConnector::uptarget  )  [inline, inherited]
 

Definition at line 48 of file bi-connector.h.

References BiConnector::uptarget_.

Referenced by SatChannel::find_peer_mac_addr().

00048 { return uptarget_; }

u_int16_t Mac802_11::usec double  t  )  [inline, private]
 

Definition at line 313 of file mac-802_11.h.

References u_int16_t.

Referenced by capture(), recv_timer(), sendCTS(), sendDATA(), and sendRTS().

00313                                         {
00314                 u_int16_t us = (u_int16_t)floor((t *= 1e6) + 0.5);
00315                 /* u_int16_t us = (u_int16_t)rint(t *= 1e6); */
00316                 return us;
00317         }


Friends And Related Function Documentation

friend class BackoffTimer [friend]
 

Definition at line 230 of file mac-802_11.h.

friend class DeferTimer [friend]
 

Definition at line 229 of file mac-802_11.h.

friend class IFTimer [friend]
 

Definition at line 231 of file mac-802_11.h.

friend class NavTimer [friend]
 

Definition at line 232 of file mac-802_11.h.

friend class RxTimer [friend]
 

Definition at line 233 of file mac-802_11.h.

friend class TxTimer [friend]
 

Definition at line 234 of file mac-802_11.h.


Member Data Documentation

int Mac::abstract_ [protected, inherited]
 

Definition at line 229 of file mac.h.

Referenced by Mac::Mac(), Mac::sendDown(), and Mac::sendUp().

double Mac::bandwidth_ [protected, inherited]
 

Definition at line 227 of file mac.h.

Referenced by Mac::bandwidth(), Mac::Mac(), Mac802_11(), UnslottedAlohaMac::sendDown(), SatMac::sendDown(), and Mac::txtime().

double Mac802_11::basicRate_ [private]
 

Definition at line 335 of file mac-802_11.h.

Referenced by check_pktCTRL(), check_pktRTS(), check_pktTx(), Mac802_11(), sendACK(), sendCTS(), sendDATA(), and sendRTS().

Host* Mac802_11::cache_ [private]
 

Definition at line 381 of file mac-802_11.h.

Referenced by command(), initialized(), Mac802_11(), and recvDATA().

int Mac802_11::cache_node_count_ [private]
 

Definition at line 380 of file mac-802_11.h.

Referenced by command(), Mac802_11(), and recvDATA().

Handler* Mac::callback_ [protected, inherited]
 

Definition at line 236 of file mac.h.

Referenced by MacTdma::dump(), dump(), UnslottedAlohaMac::end_of_contention(), Mac::recv(), MacTdma::recv(), MultihopMac::recv(), Mac::resume(), MacCsma::resume(), Mac802_3::resume(), MultihopMac::send(), send(), Mac802_3::sendDown(), MacTdma::sendHandler(), SMAC::sendMsg(), Mac802_3::transmit(), tx_resume(), and SMAC::txMsgDone().

Channel* Mac::channel_ [protected, inherited]
 

Definition at line 234 of file mac.h.

Referenced by MacCsma::backoff(), Mac::command(), MacCsmaCd::endofContention(), MacCsma::endofContention(), MultihopMac::send(), MacCsmaCa::send(), and MacCsma::send().

u_int32_t Mac802_11::cw_ [private]
 

Definition at line 361 of file mac-802_11.h.

Referenced by check_pktRTS(), check_pktTx(), inc_cw(), Mac802_11(), recvACK(), RetransmitDATA(), RetransmitRTS(), rst_cw(), send(), and tx_resume().

double Mac802_11::dataRate_ [private]
 

Definition at line 336 of file mac-802_11.h.

Referenced by Mac802_11(), and sendDATA().

int NsObject::debug_ [protected, inherited]
 

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().

double Mac::delay_ [protected, inherited]
 

Definition at line 228 of file mac.h.

Referenced by UnslottedAlohaMac::end_of_contention(), Mac::Mac(), MultihopMac::recv(), SatMac::sendUp(), and Mac::sendUp().

double Mac802_11::difs_ [private]
 

Definition at line 366 of file mac-802_11.h.

Referenced by Mac802_11(), navHandler(), send(), and tx_resume().

NsObject* BiConnector::downtarget_ [protected, inherited]
 

Definition at line 63 of file bi-connector.h.

Referenced by Phy::command(), BiConnector::command(), BiConnector::downtarget(), WirelessPhy::initialized(), WiredPhy::initialized(), SMAC::initialized(), Mac::initialized(), FECModel::recv(), MacTdma::send(), UnslottedAlohaMac::sendDown(), SatMac::sendDown(), Mac::sendDown(), BiConnector::sendDown(), SMAC::transmit(), and Mac802_3::transmit().

NsObject* BiConnector::drop_ [protected, inherited]
 

Definition at line 64 of file bi-connector.h.

Referenced by BiConnector::command(), and BiConnector::drop().

double Mac802_11::eifs_ [private]
 

Definition at line 367 of file mac-802_11.h.

Referenced by capture(), Mac802_11(), and recv_timer().

MacHandlerResume Mac::hRes_ [protected, inherited]
 

Definition at line 237 of file mac.h.

Referenced by MacCsma::endofContention(), SatMac::sendDown(), and Mac::sendDown().

MacHandlerSend Mac::hSend_ [protected, inherited]
 

Definition at line 238 of file mac.h.

Referenced by MacCsmaCd::endofContention(), MacCsmaCa::send(), and MacCsma::send().

int Mac::index_ [protected, inherited]
 

Definition at line 226 of file mac.h.

Referenced by Mac::addr(), discard(), SMAC::drop_CTS(), SMAC::drop_DATA(), SMAC::drop_RTS(), MacTdma::dump(), dump(), UnslottedAlohaMac::end_of_contention(), SMAC::handleACK(), SMAC::handleCTS(), SMAC::handleDATA(), SMAC::handleGeneTimer(), SMAC::handleRTS(), SMAC::handleSYNC(), Mac::Mac(), MacTdma::re_schedule(), SMAC::recv(), Mac::recv(), Mac802_3::recv_complete(), recv_timer(), MacTdma::recvHandler(), MacTdma::send(), SMAC::sendACK(), SMAC::sendCTS(), SMAC::sendRTS(), sendRTS(), SMAC::sendSYNC(), UnslottedAlohaMac::sendUp(), SatMac::sendUp(), Mac::sendUp(), MacTdma::sendUp(), SMAC::setMySched(), MacTdma::slotHandler(), MacTdma::trace_pkt(), trace_pkt(), and Mac802_3::transmit().

Event Mac::intr_ [protected, inherited]
 

Definition at line 239 of file mac.h.

Referenced by MacTdma::MacTdma(), Mac::resume(), MacCsma::resume(), MultihopMac::send(), SatMac::sendDown(), and Mac::sendDown().

LL* Mac::ll_ [protected, inherited]
 

Definition at line 233 of file mac.h.

NsObject* Mac802_11::logtarget_ [private]
 

Reimplemented from Mac.

Definition at line 374 of file mac-802_11.h.

Referenced by command(), initialized(), and mac_log().

MAC_MIB* Mac802_11::macmib_ [protected]
 

Definition at line 332 of file mac-802_11.h.

Referenced by initialized(), Mac802_11(), recvACK(), recvDATA(), RetransmitDATA(), RetransmitRTS(), sendRTS(), and tx_resume().

BackoffTimer Mac802_11::mhBackoff_ [private]
 

Definition at line 347 of file mac-802_11.h.

Referenced by check_pktRTS(), check_pktTx(), deferHandler(), dump(), navHandler(), recvACK(), RetransmitDATA(), RetransmitRTS(), send(), and tx_resume().

DeferTimer Mac802_11::mhDefer_ [private]
 

Definition at line 346 of file mac-802_11.h.

Referenced by backoffHandler(), dump(), recvRTS(), send(), and tx_resume().

IFTimer Mac802_11::mhIF_ [private]
 

Definition at line 341 of file mac-802_11.h.

NavTimer Mac802_11::mhNav_ [private]
 

Definition at line 342 of file mac-802_11.h.

Referenced by dump(), and set_nav().

RxTimer Mac802_11::mhRecv_ [private]
 

Definition at line 343 of file mac-802_11.h.

Referenced by collision(), dump(), recv(), and rx_resume().

TxTimer Mac802_11::mhSend_ [private]
 

Definition at line 344 of file mac-802_11.h.

Referenced by backoffHandler(), dump(), recvACK(), recvCTS(), recvDATA(), and tx_resume().

int Mac802_11::min_frame_len_ [private]
 

Definition at line 372 of file mac-802_11.h.

double Mac802_11::nav_ [private]
 

Definition at line 352 of file mac-802_11.h.

Referenced by dump(), is_idle(), Mac802_11(), and set_nav().

Phy* Mac::netif_ [protected, inherited]
 

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(), recv_timer(), MacHandlerRetx::schedule(), send(), Mac802_3::sendDown(), Mac802_3::sendUp(), and Mac802_3::transmit().

PHY_MIB* Mac802_11::phymib_ [protected]
 

Definition at line 331 of file mac-802_11.h.

Referenced by inc_cw(), initialized(), Mac802_11(), BackoffTimer::pause(), rst_cw(), send(), BackoffTimer::start(), tx_resume(), and txtime().

double Mac802_11::pifs_ [private]
 

Definition at line 365 of file mac-802_11.h.

Referenced by Mac802_11().

Packet* Mac802_11::pktCTRL_ [private]
 

Definition at line 359 of file mac-802_11.h.

Referenced by backoffHandler(), check_pktCTRL(), deferHandler(), dump(), Mac802_11(), recvDATA(), recvRTS(), send_timer(), sendACK(), sendCTS(), and tx_resume().

Packet* Mac802_11::pktRTS_ [private]
 

Definition at line 358 of file mac-802_11.h.

Referenced by check_pktRTS(), deferHandler(), dump(), Mac802_11(), recvCTS(), RetransmitDATA(), RetransmitRTS(), sendRTS(), and tx_resume().

Packet* Mac::pktRx_ [protected, inherited]
 

Reimplemented in SMAC.

Definition at line 245 of file mac.h.

Referenced by collision(), MacTdma::dump(), dump(), recv(), recv_timer(), MacTdma::recvHandler(), rx_resume(), and MacTdma::sendUp().

Packet* Mac::pktTx_ [protected, inherited]
 

Reimplemented in SMAC.

Definition at line 246 of file mac.h.

Referenced by check_pktTx(), deferHandler(), MacTdma::dump(), dump(), MacTdma::makePreamble(), recvACK(), recvCTS(), RetransmitDATA(), RetransmitRTS(), MacTdma::send(), sendDATA(), MacTdma::sendDown(), sendRTS(), and tx_resume().

MacState Mac802_11::rx_state_ [private]
 

Definition at line 354 of file mac-802_11.h.

Referenced by collision(), dump(), is_idle(), Mac802_11(), recv(), and recv_timer().

double Mac802_11::sifs_ [private]
 

Definition at line 364 of file mac-802_11.h.

Referenced by check_pktCTRL(), check_pktRTS(), check_pktTx(), Mac802_11(), sendCTS(), sendDATA(), sendRTS(), and tx_resume().

u_int32_t Mac802_11::slrc_ [private]
 

Definition at line 363 of file mac-802_11.h.

Referenced by Mac802_11(), recvACK(), and RetransmitDATA().

u_int32_t Mac802_11::ssrc_ [private]
 

Definition at line 362 of file mac-802_11.h.

Referenced by Mac802_11(), recvACK(), RetransmitDATA(), and RetransmitRTS().

u_int16_t Mac802_11::sta_seqno_ [private]
 

Definition at line 379 of file mac-802_11.h.

Referenced by Mac802_11(), and send().

MacState Mac::state_ [protected, inherited]
 

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().

Tap* Mac::tap_ [protected, inherited]
 

Definition at line 232 of file mac.h.

Referenced by Mac::installTap(), and recv_timer().

int Mac802_11::tx_active_ [private]
 

Definition at line 356 of file mac-802_11.h.

Referenced by Mac802_11(), recv(), recv_timer(), and txHandler().

double Mac802_11::tx_difs_ [private]
 

Definition at line 370 of file mac-802_11.h.

Referenced by Mac802_11().

double Mac802_11::tx_pifs_ [private]
 

Definition at line 369 of file mac-802_11.h.

Referenced by Mac802_11().

double Mac802_11::tx_sifs_ [private]
 

Definition at line 368 of file mac-802_11.h.

Referenced by Mac802_11().

MacState Mac802_11::tx_state_ [private]
 

Definition at line 355 of file mac-802_11.h.

Referenced by check_pktCTRL(), dump(), is_idle(), Mac802_11(), recvACK(), recvCTS(), recvDATA(), recvRTS(), and send_timer().

NsObject* BiConnector::uptarget_ [protected, inherited]
 

Definition at line 60 of file bi-connector.h.

Referenced by BiConnector::command(), Phy::dump(), UnslottedAlohaMac::end_of_contention(), WirelessPhy::initialized(), WiredPhy::initialized(), SMAC::initialized(), Mac::initialized(), God::initialized(), RepeaterPhy::recv(), Phy::recv(), FECModel::recv(), Mac802_3::recv_complete(), MacTdma::recvDATA(), recvDATA(), SMAC::rxMsgDone(), SatMac::sendUp(), Mac::sendUp(), BiConnector::sendUp(), and BiConnector::uptarget().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 12:57:34 2004 for NS2.26SourcesOriginal by doxygen 1.3.3