• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/mac/mac-802_11Ext.h

00001 /*
00002  * Copyright (C) 2007 
00003  * Mercedes-Benz Research & Development North America, Inc. and
00004  * University of Karlsruhe (TH)
00005  * All rights reserved.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License,
00009  * version 2, as published by the Free Software Foundation.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License along
00017  * with this program; if not, write to the Free Software Foundation, Inc.,
00018  * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00019  *
00020  *
00021  * The copyright of this module includes the following
00022  * linking-with-specific-other-licenses addition:
00023  *
00024  * In addition, as a special exception, the copyright holders of
00025  * this module give you permission to combine (via static or
00026  * dynamic linking) this module with free software programs or
00027  * libraries that are released under the GNU LGPL and with code
00028  * included in the standard release of ns-2 under the Apache 2.0
00029  * license or under otherwise-compatible licenses with advertising
00030  * requirements (or modified versions of such code, with unchanged
00031  * license).  You may copy and distribute such a system following the
00032  * terms of the GNU GPL for this module and the licenses of the
00033  * other code concerned, provided that you include the source code of
00034  * that other code when and as the GNU GPL requires distribution of
00035  * source code.
00036  *
00037  * Note that people who make modified versions of this module
00038  * are not obligated to grant this special exception for their
00039  * modified versions; it is their choice whether to do so.  The GNU
00040  * General Public License gives permission to release a modified
00041  * version without this exception; this exception also makes it
00042  * possible to release a modified version which carries forward this
00043  * exception.
00044  *
00045  */
00046  
00047 /*
00048  * This code was designed and developed by:
00049  * 
00050  * Qi Chen                 : qi.chen@daimler.com
00051  * Felix Schmidt-Eisenlohr : felix.schmidt-eisenlohr@kit.edu
00052  * Daniel Jiang            : daniel.jiang@daimler.com
00053  * 
00054  * For further information see: 
00055  * http://dsn.tm.uni-karlsruhe.de/english/Overhaul_NS-2.php
00056  */
00057  
00058 #ifndef ns_mac_80211Ext_h
00059 #define ns_mac_80211Ext_h
00060 #include "marshall.h"
00061 #include "timer-handler.h"
00062 #define GET_ETHER_TYPE(x)               GET2BYTE((x))
00063 #define SET_ETHER_TYPE(x,y)            {u_int16_t t = (y); STORE2BYTE(x,&t);}
00064 #include "wireless-phyExt.h"
00065 
00066 /* ======================================================================
00067  Frame Formats
00068  ====================================================================== */
00069 
00070 #define MAC_ProtocolVersion     0x00
00071 #define MAC_Type_Management     0x00
00072 #define MAC_Type_Control        0x01
00073 #define MAC_Type_Data           0x02
00074 #define MAC_Type_Reserved       0x03
00075 #define MAC_Subtype_RTS         0x0B
00076 #define MAC_Subtype_CTS         0x0C
00077 #define MAC_Subtype_ACK         0x0D
00078 #define MAC_Subtype_Data        0x00
00079 
00080 struct frame_control {
00081         u_char fc_subtype : 4;
00082         u_char fc_type : 2;
00083         u_char fc_protocol_version : 2;
00084         u_char fc_order : 1;
00085         u_char fc_wep : 1;
00086         u_char fc_more_data : 1;
00087         u_char fc_pwr_mgt : 1;
00088         u_char fc_retry : 1;
00089         u_char fc_more_frag : 1;
00090         u_char fc_from_ds : 1;
00091         u_char fc_to_ds : 1;
00092 };
00093 
00094 struct rts_frame {
00095         struct frame_control rf_fc;
00096         u_int16_t rf_duration;
00097         u_char rf_ra[ETHER_ADDR_LEN];
00098         u_char rf_ta[ETHER_ADDR_LEN];
00099         u_char rf_fcs[ETHER_FCS_LEN];
00100 };
00101 
00102 struct cts_frame {
00103         struct frame_control cf_fc;
00104         u_int16_t cf_duration;
00105         u_char cf_ra[ETHER_ADDR_LEN];
00106         u_char cf_fcs[ETHER_FCS_LEN];
00107 };
00108 
00109 struct ack_frame {
00110         struct frame_control af_fc;
00111         u_int16_t af_duration;
00112         u_char af_ra[ETHER_ADDR_LEN];
00113         u_char af_fcs[ETHER_FCS_LEN];
00114 };
00115 
00116 // XXX This header does not have its header access function because it shares
00117 // the same header space with hdr_mac.
00118 struct hdr_mac802_11 {
00119         struct frame_control dh_fc;
00120         u_int16_t dh_duration;
00121         u_char dh_ra[ETHER_ADDR_LEN];
00122         u_char dh_ta[ETHER_ADDR_LEN];
00123         u_char dh_3a[ETHER_ADDR_LEN];
00124         u_int16_t dh_scontrol;
00125         u_char dh_body[0]; // size of 1 for ANSI compatibility
00126 };
00127 
00128 /* ======================================================================
00129  Definitions
00130  ====================================================================== */
00131 
00132 // #define DSSS_MaxPropagationDelay        0.000002        // 2us   XXXX
00133 #define DSSS_MaxPropagationDelay          0.000010        // 10us   XXXX
00134 
00135 class Mac802_11Ext;
00136 class PHY_MIBExt {
00137 public:
00138         PHY_MIBExt(Mac802_11Ext *parent);
00139         inline double getSlotTime() {
00140                 return (SlotTime);
00141         }
00142         inline double getHeaderDuration() {
00143                 return (HeaderDuration);
00144         }
00145 
00146         inline double getSymbolDuration() {
00147                 return (SymbolDuration);
00148         }
00149         inline int getBasicModulationScheme() {
00150                 return (BasicModulationScheme);
00151         }
00152 
00153         inline int use_802_11a() {
00154                 return (use_802_11a_flag_);
00155         }
00156 
00157         inline double getBasicDataRate() {
00158                 return (1.0/SymbolDuration
00159                                 * modulation_table[BasicModulationScheme].NDBPS);
00160         }
00161 
00162         inline u_int32_t getRTSlen() {
00163                 return (sizeof(struct rts_frame));
00164         }
00165 
00166         inline u_int32_t getCTSlen() {
00167                 return (sizeof(struct cts_frame));
00168         }
00169 
00170         inline u_int32_t getACKlen() {
00171                 return (sizeof(struct ack_frame));
00172         }
00173 
00174         inline u_int32_t getHdrLen11() {
00175                 return(offsetof(struct hdr_mac802_11, dh_body[0])
00176 +                       ETHER_FCS_LEN);
00177                 }
00178 
00179         private:
00180                 double SlotTime;
00181                 double HeaderDuration;
00182                 double SymbolDuration;
00183                 int BasicModulationScheme;
00184                 int use_802_11a_flag_;
00185         };
00186 
00187         /*---------------------information for Distributed coordination------*/
00188 #define MAC_FragmentationThreshold      2346            // bytes
00189 #define MAC_MaxTransmitMSDULifetime     512             // time units
00190 #define MAC_MaxReceiveLifetime          512             // time units
00191 class MAC_MIBExt {
00192 public:
00193         MAC_MIBExt(Mac802_11Ext *parent);
00194         inline u_int32_t getCWMin() {
00195                 return (CWMin);
00196         }
00197         inline u_int32_t getCWMax() {
00198                 return (CWMax);
00199         }
00200         inline double getSIFS() {
00201                 return (SIFSTime);
00202         }
00203         inline u_int32_t getRTSThreshold() {
00204                 return (RTSThreshold);
00205         }
00206         inline u_int32_t getShortRetryLimit() {
00207                 return (ShortRetryLimit);
00208         }
00209         inline u_int32_t getLongRetryLimit() {
00210                 return (LongRetryLimit);
00211         }
00212 private:
00213         u_int32_t CWMin;
00214         u_int32_t CWMax;
00215         double SIFSTime;
00216         u_int32_t RTSThreshold;
00217         u_int32_t ShortRetryLimit;
00218         u_int32_t LongRetryLimit;
00219 };
00220 
00221 /* ======================================================================
00222  The following destination class is used for duplicate detection.
00223  ====================================================================== */
00224 class Host {
00225 public:
00226         LIST_ENTRY(Host) link;
00227         u_int32_t index;
00228         u_int32_t seqno;
00229 };
00230 
00231 /* the new implementation has following modules*/
00232 
00233 /* ======================================================================
00234  1.0 IFSTimer NAVTimer and ChannelStateMgr
00235  ====================================================================== */
00236 /*
00237  The channel state manager is responsible for maintaining both the physical and virtual carrier sense statuses for the IEEE 802.11 CSMA mechanism.
00238  The channel state manager depends on the PHY to update the physical carrier sense status. It expects the PHY to signal channel busy when the total received signal strength rises above carrier sense threshold or when the PHY is in transmission. Similarly, it expects the PHY to signal channel clear when both conditions are gone.
00239  The channel state manager expects signaling from the reception module for virtual carrier sense status updates as described in the above subsection. Once signaled this way, the channel state manager sets or updates the NAV for the duration specified.
00240  The channel state manager has five states. The combination of both physical and virtual carrier sense statuses result in four states: NoCSnoNAV, NoCSNAV, CSnoNAV and CSNAV. Additionally, the time spent in InterFrame Spacing (IFS) waiting is also modeled as a state within the channel state manager. This is because the IFS mechanism is essentially a self enforced NAV. As such, the channel state manager treats the Wait IFS state as channel being busy as well.The duration of IFS waiting time depends on the ifs_value parameter, which can be set to DIFS and EIFS. When EDCA is incorporated, it will be necessary to add an additional signaling interface from the transmission coordination module to the channel state manager to advise the AIFS values.  SIFS waiting, however, is handled by the transmission and reception coordination modules directly. This is because SIFS is used in a way unlike that of DIFS and EIFS. Any module that sets a SIFS timer will take action as the timer expires regardless of the channel condition during the SIFS.
00241  
00242  The channel state manager reports the joint physical and virtual carrier sense status in response to queries from any other module. That is: it reports CS_IDLE if it is in the NoCSnoNAV state, and CS_BUSY otherwise. It also reports the NAV status to the reception coordination module when queried, to assist the CTS decision.
00243  The channel state manager actively signals the backoff manger whenever it moves in or out of the NoCSnoNAV state to indicate channel status changes. In turn the backoff manager resumes or pauses its backoff process if it is already in one. 
00244 
00245  */
00246 
00247 class ChannelStateMgr;
00248 class IFSTimer : public TimerHandler {
00249 public:
00250         IFSTimer(ChannelStateMgr *c) :
00251                 TimerHandler() {
00252                 csmgr = c;
00253         }
00254 protected:
00255         void expire(Event *e);
00256 private:
00257         ChannelStateMgr * csmgr;
00258 };
00259 
00260 class NAVTimer : public TimerHandler {
00261 public:
00262         NAVTimer(ChannelStateMgr *c) :
00263                 TimerHandler() {
00264                 csmgr = c;
00265         }
00266 protected:
00267         void expire(Event *e);
00268 private:
00269         ChannelStateMgr *csmgr;
00270 };
00271 
00272 typedef enum ChannelState {noCSnoNAV=0, noCSNAV=1, CSnoNAV=2, CSNAV=3, WIFS=4};
00273 
00274 class ChannelStateMgr {
00275         friend class Mac802_11Ext;
00276         friend class BackoffMgr;
00277         friend class IFSTimer;
00278         friend class NAVTimer;
00279 public:
00280         ChannelStateMgr(Mac802_11Ext *m);
00281         void setIFS(double Tifs);
00282         void handlePHYBusyIndication();
00283         void handlePHYIdleIndication();
00284         void handleSetNAV(double Tnav);
00285         inline ChannelState getChannelState() {
00286                 return channel_state_;
00287         }
00288 protected:
00289         void handleIFSTimer();
00290         void handleNAVTimer();
00291 private:
00292         Mac802_11Ext * mac_;
00293         ChannelState channel_state_;
00294         double ifs_value_;
00295         IFSTimer *ifsTimer_;
00296         NAVTimer *navTimer_;
00297 
00298         void setChannelState(ChannelState newState);
00299 };
00300 /* ======================================================================
00301  2.0 Backoff timer and BackoffMgr
00302  ====================================================================== */
00303 
00304 /*
00305  The backoff manager maintains the backoff counter to support the collision avoidance mechanism in the IEEE 802.11 MAC. 
00306  The backoff manager assists the transmission coordination module to run both the regular backoff and post-transmission backoff, but is not aware of the difference between the two. Figure 6 provides a very simplified view on how this is done.
00307  The backoff manager has three states: No Backoff, Backoff Running, and Backoff Pause. It depends on the signaling of channel carrier sense state from the channel state manger to run or pause the backoff counter. It moves back to the No Backoff state and signals Backoff Done to the transmission coordination module when the backoff counter reaches zero. When EDCA is added, it will be necessary for an additional signaling interface to be implemented between the transmission coordination module and the backoff manager. This is used to trigger a reassessment of the backoff process with a different cw (Contention Window) value. In turn, it could cause the ending of the backoff sooner in cases of higher priority pending frames.
00308  */
00309 class BackoffMgr;
00310 class BackoffTimer_t : public TimerHandler {
00311         friend class BackoffMgr;
00312 public:
00313         BackoffTimer_t(BackoffMgr *b);
00314         void pause();
00315         void run();
00316         int init(int CW);
00317         void setSlotTime(double);
00318 protected:
00319         void expire(Event *e);
00320 private:
00321         double tSlot;
00322         BackoffMgr * bkmgr_;
00323         int remainingSlots_;
00324         double startTime;
00325 };
00326 
00327 typedef enum BackoffMgrState {noBackoff,BackoffRunning,BackoffPause};
00328 
00329 class BackoffMgr {
00330         friend class Mac802_11Ext;
00331         friend class ChannelStateMgr;
00332         friend class BackoffTimer_t;
00333 public:
00334         BackoffMgr(Mac802_11Ext *m);
00335         void handleCSIDLE();
00336         void handleCSBUSY();
00337         void handleBKStart(int CW); //the chosen cnt should be passed to BK
00338         void setSlotTime(double);
00339         inline BackoffMgrState getBackoffMgrState() {
00340                 return bk_state_;
00341         }
00342 private:
00343         Mac802_11Ext * mac_;
00344         void handleBackoffTimer();
00345         BackoffMgrState bk_state_;
00346         BackoffTimer_t * bkTimer_;
00347         void BKDone();
00348 
00349         void setBackoffMgrState(BackoffMgrState newState);
00350 };
00351 
00352 /* ======================================================================
00353  3.0 TxTimer for transmission
00354  ====================================================================== */
00355 class Mac802_11Ext;
00356 class TxTimer_t : public TimerHandler {
00357 public:
00358         TxTimer_t(Mac802_11Ext * m) :
00359                 TimerHandler() {
00360                 mac_ = m;
00361         }
00362 protected:
00363         void expire(Event *e);
00364 private:
00365         Mac802_11Ext * mac_;
00366 };
00367 
00368 /* ======================================================================
00369  4.0 TX_Coordination
00370  ====================================================================== */
00371 
00372 /*
00373  The transmission coordination module manages channel access for packets passed down from the upper layer.
00374  The state machine in the transmission coordination module roughly divided into two sides depending on whether the RTS/CTS exchange is needed. If the data frame is a broadcast or a unicast with size less than the RTS threshold, it is entirely processed within the right side of the overall state machine. Otherwise, a RTS frame is generated and a sequence of states on the left side is involved before the data frame would be sent.
00375  
00376  When the transmission coordination module moves out of the TXC_IDLE state because of a packet coming down from the upper layer, it first checks if a RTS frame should be generated. Afterwards, it starts a backoff process at the backoff manager if there is not one going on already and moves into the RTS Pending or Data Pending state according to the RTS decision.
00377  If the transmission coordination module is in the RTS Pending or Data Pending state, it instructs the transmission module to transmit the RTS or data frame respectively as soon as receiving a signal indicating Backoff Done from the backoff manager. 
00378  It is possible for these pending states to be directly bypassed. As shown in Figure 6, if the backoff manager does not have a backoff process currently going on and the channel state manager replies with a CS_IDLE, the transmission coordination module can immediately transmit the RTS or data frame. This is because the standard allows for a radio to start a transmission right away if it has completed a previous post-transmission backoff and the channel, both physically and virtually, has been idle for more than DIFS.
00379  When the transmission of a RTS frame is completed, the transmission coordination module moves into the Wait CTS state and starts a timer TCTS. If the reception coordination module does not signal the arrival of a CTS frame before the timer expires, it starts another backoff process and moves back to the RTS pending state. It can repeat this process until the short retry limit is reached. If a CTS response comes back in time, then the transmission coordination module waits for SIFS before instructing the transmission module to send the data frame.
00380  After the data frame transmission, the transmission coordination module moves into the Wait ACK state and starts a TACK timer. If it does not get an ACK reply indication from the reception coordination module before the timer expires, it starts a new backoff process and moves back to RTS Pending or Data Pending state respectively. Again, this is subject to the short or long retry limit respectively.
00381  In cases of RTS retry or unicast retransmission, the cw parameter is updated before a backoff is requested with the new value.
00382  The attempted transmission of a frame finishes in three possible ways: 1) it is a broadcast frame and it is transmitted once over the air; 2) it is a unicast frame and the transmission coordination module receives an ACK signaling from the reception coordination module; or 3) one of the retry limits is reached. In all three cases, the transmission coordination module resets the retry counters and the cw parameter, and starts a post-transmission backoff. Afterwards, if there is a packet waiting in the queue, it takes the packet and immediately moves into the RTS Pending or Data Pending state. Otherwise it returns back to the TXC_IDLE state.
00383 
00384 
00385  */
00386 class TXC;
00387 
00388 class TXC_SIFSTimer : public TimerHandler {
00389 public:
00390         TXC_SIFSTimer(TXC *t) :
00391                 TimerHandler() {
00392                 txc_ = t;
00393         }
00394 protected:
00395         void expire(Event *e);
00396 private:
00397         TXC * txc_;
00398 };
00399 
00400 class TXC_CTSTimer : public TimerHandler {
00401 public:
00402         TXC_CTSTimer(TXC *t) :
00403                 TimerHandler() {
00404                 txc_ = t;
00405         }
00406 protected:
00407         void expire(Event *e);
00408 private:
00409         TXC * txc_;
00410 };
00411 
00412 class TXC_ACKTimer : public TimerHandler {
00413 public:
00414         TXC_ACKTimer(TXC *t) :
00415                 TimerHandler() {
00416                 txc_ = t;
00417         }
00418 protected:
00419         void expire(Event *e);
00420 private:
00421         TXC * txc_;
00422 };
00423 
00424 typedef enum TXCState {TXC_Idle,TXC_wait_RTSsent, TXC_wait_PDUsent, TXC_RTS_pending, TXC_DATA_pending,TXC_wait_CTS,TXC_wait_SIFS,TXC_wait_ACK};
00425 
00426 class TXC {
00427 public:
00428         TXC(Mac802_11Ext *m);
00429         void setTXCState(TXCState);
00430 
00431         void handleMsgFromUp(Packet *p);
00432         void handleBKDone();
00433         void handleTXConfirm();
00434 
00435         void handleTCTStimeout();
00436         void handleSIFStimeout();
00437         void handleTACKtimeout();
00438 
00439         void handleACKIndication();
00440         void handleCTSIndication();
00441 
00442         void checkQueue();
00443         void prepareMPDU(Packet *p);
00444         void generateRTSFrame(Packet *p);
00445 
00446 private:
00447         TXCState txc_state_;
00448         Packet *pRTS;
00449         Packet *pDATA;
00450         Mac802_11Ext *mac_;
00451         TXC_CTSTimer txcCTSTimer;
00452         TXC_SIFSTimer txcSIFSTimer;
00453         TXC_ACKTimer txcACKTimer;
00454         unsigned int shortretrycounter;
00455         unsigned int longretrycounter;
00456         //      unsigned int rtsretrycounter;
00457         //      unsigned int dataretrycounter;
00458 };
00459 
00460 /* ======================================================================
00461  5.0  RX_Coordination
00462  ====================================================================== */
00463 /*
00464  The reception coordination module takes from the reception module control and data frames meant for this node. It signals the transmission coordination module when CTS and ACK frames arrive. It is responsible to handle the CTS and ACK responses when RTS and data frames arrive. It also filters the data frames before passing them to the upper layer.
00465  
00466  The reception coordination module has only three states: RXC_IDLE, RXC SIFS Wait, and Wait TX Done. The reception coordination module mostly spends time in the RXC_IDLE state and awaits control and data frames from the reception module.
00467  If a RTS frame arrives, the reception coordination module queries the channel state manager for its NAV status. If the response indicates an active NAV, the RTS frame is simply discarded. Otherwise, the reception coordination module creates a CTS frame and moves into the RXC SIFS Wait state with a SIFS timer set. When the timer expires, it immediately instructs the transmission module to transmit the CTS frame. It then moves into the Wait TX Done state for the transmission duration before returning to the TXC_IDLE state.
00468  If a unicast data frame arrives, the reception coordination module starts an ACK process similar to the way it handles the CTS response. However, it does not consult the channel state manager for the NAV status. If a CTS or ACK frame arrives, the reception coordination module simply signals the transmission coordination module accordingly.
00469  The reception coordination module passes data frames to the upper layer. In this process, it is responsible to discard duplicate data frames coming in from the channel, which can be caused by the unicast retransmission mechanism. In these cases, however, it still reacts with an ACK transmission.
00470  */
00471 class RXC;
00472 class RXC_SIFSTimer : public TimerHandler {
00473 public:
00474         RXC_SIFSTimer(RXC *r) :
00475                 TimerHandler() {
00476                 rxc_ = r;
00477         }
00478 protected:
00479         void expire(Event *e);
00480 private:
00481         RXC * rxc_;
00482 };
00483 
00484 typedef enum RXCState {RXC_Idle,RXC_wait_SIFS,RXC_wait_sent};
00485 
00486 class RXC {
00487 public:
00488         RXC(Mac802_11Ext *m);
00489 
00490         void handleMsgFromBelow(Packet *p);
00491         void handleSIFStimeout();
00492         void handleTXConfirm();
00493         void generateACKFrame(Packet *p);
00494         void generateCTSFrame(Packet *p);
00495 private:
00496         RXCState rxc_state_;
00497         void setRXCState(RXCState);
00498         Packet *pCTRL;
00499         Mac802_11Ext *mac_;
00500         RXC_SIFSTimer rxcSIFSTimer_;
00501 };
00502 
00503 /* ======================================================================
00504  6.0 The actual 802.11 MAC class.
00505  ====================================================================== */
00506 typedef enum TXConfirmCallback {Callback_TXC,Callback_RXC};
00507 
00508 class TXC;
00509 class RXC;
00510 class Mac802_11Ext : public Mac {
00511         friend class TxTimer_t;
00512         friend class TxTimeout;
00513         friend class ChannelStateMgr;
00514         friend class BackoffMgr;
00515         friend class BackoffTimer_t;
00516         friend class TXC;
00517         friend class RXC;
00518 
00519 public:
00520         Mac802_11Ext();
00521         void recv(Packet *p, Handler *h);
00522         inline int hdr_dst(char* hdr, int dst = -2);
00523         inline int hdr_src(char* hdr, int src = -2);
00524         inline int hdr_type(char* hdr, u_int16_t type = 0);
00525 
00526         void handlePHYBusyIndication();
00527         void handlePHYIdleIndication();
00528         void handleRXStartIndication();
00529         void handleRXEndIndication(Packet *p);
00530         void handleTXEndIndication();
00531 
00532         int MAC_DBG;
00533 
00534 protected:
00535 
00536         void log(char* event, char* additional);
00537 private:
00538 
00539         void handleBKDone();
00540 
00541         void transmit(Packet *p, TXConfirmCallback);
00542         TXConfirmCallback txConfirmCallback_;
00543 
00544 
00545         BackoffMgr bkmgr;
00546         ChannelStateMgr csmgr;
00547 
00548         TXC txc;
00549         RXC rxc;
00550 
00551         int command(int argc, const char*const* argv);
00552         void sendDATA(Packet *p);
00553         void recvDATA(Packet *p);
00554         void discard(Packet *p, const char* why);
00555 
00556         /*
00557          * Debugging Functions.
00558          */
00559         void trace_pkt(Packet *p);
00560         void dump(char* fname);
00561 
00562         inline int initialized() {
00563                 return (logtarget_ &&Mac::initialized());
00564         }
00565 
00566         inline void mac_log(Packet *p) {
00567                 logtarget_->recv(p, (Handler*) 0);
00568         }
00569 
00570         double txtime(Packet *p);
00571         double txtime(double psz, double drt);
00572         double txtime(double psz, int mod_scheme);
00573         double txtime(int bytes) { /* clobber inherited txtime() */
00574                 abort();
00575         }
00576 
00577         inline void inc_cw() {
00578                 cw_ = (cw_ << 1) + 1;
00579                 if (cw_ > macmib_.getCWMax())
00580                         cw_ = macmib_.getCWMax();
00581         }
00582         inline void rst_cw() {
00583                 cw_ = macmib_.getCWMin();
00584         }
00585         inline double sec(double t) {
00586                 return (t *= 1.0e-6);
00587         }
00588         inline u_int16_t usec(double t) {
00589                 u_int16_t us = (u_int16_t)floor((t *= 1e6) + 0.5);
00590                 return us;
00591         }
00592 
00593 protected:
00594         PHY_MIBExt phymib_;
00595         MAC_MIBExt macmib_;
00596 
00597 private:
00598 
00599         /* ============================================================
00600          Internal MAC State
00601          ============================================================ */
00602 
00603         u_int32_t cw_; // Contention Window
00604         u_int32_t ssrc_; // STA Short Retry Count
00605         u_int32_t slrc_; // STA Long Retry Count
00606         double sifs_; // Short Interface Space
00607         double pifs_; // PCF Interframe Space
00608         double difs_; // DCF Interframe Space
00609         double eifs_; // Extended Interframe Space
00610 
00611         NsObject* logtarget_;
00612 
00613 };
00614 
00615 #endif /* ns_mac_80211Ext_h */
00616 

Generated on Tue Aug 10 2010 16:16:07 for ns-2.33 by  doxygen 1.7.1