⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mac80211.h

📁 基于omnet++开发的Mf框架下的802.11协议仿真。
💻 H
字号:
/* -*- mode:c++ -*- ******************************************************** * file:        Mac80211.h * * author:      David Raguin/Marc L鯾bers * * copyright:   (C) 2004 Telecommunication Networks Group (TKN) at *              Technische Universitaet Berlin, Germany. * *              This program is free software; you can redistribute it  *              and/or modify it under the terms of the GNU General Public  *              License as published by the Free Software Foundation; either *              version 2 of the License, or (at your option) any later  *              version. *              For further information see file COPYING  *              in the top level directory *************************************************************************** * part of:     framework implementation developed by tkn * description: MAC layer class for 802.11b * *************************************************************************** * changelog:   $Revision$ *              last modified:   $Date: 2005-01-15 21:52:51 +0100 (Sat, 15 Jan 2005) $ *              by:              $Author: koepke $ **************************************************************************/#ifndef MAC_80211_H#define MAC_80211_H#include <BasicMacLayer.h>#include <list>#include "Mac80211Pkt_m.h"#include "Consts80211.h"/** * @class Mac80211  * @brief An implementation of the 802.11b protocol * * This is an implementation of the 802.11b protocol with the help of * a state machine. For each type of event, the state of the MAC is * checked and the appropriate actions are taken and state updates are * done. This module is intended to be used in combination with the * SnrEval802.11 and Decider802.11 modules as physical layer. This * implementation does not support fragmentation, RTS threshold and * duplication detection and recovery. * * @ingroup macLayer * @author David Raguin */class Mac80211 : public BasicMacLayer{  Module_Class_Members( Mac80211, BasicMacLayer, 0 );  typedef std::list<Mac80211Pkt*> cMacPktList;  /** @enum Definition of the timer types*/  enum timerType{    TIMEOUT,    NAV,    CONTENSION,    END_TRANSMISSION,    END_SIFS  };    /** @enum Definition of the states*/  enum State {    WFDATA = 0,//waiting for data packet    QUIET = 1,//waiting until the communication between two other nodes ends    IDLE = 2,//no packet to send, no packet heared    CONTEND = 3,//contension state ... battle for the channel    WFCTS = 4,//RTS sent ... waiting for CTS    WFACK =5, //DATA packet sent ... waiting for ACK    BUSY= 6//during transmission of an ACK or a BROADCAST packet  };  public:  /** @brief Initialization of the module and some variables*/  virtual void initialize(int);  protected:   virtual bool blackboardItemChanged( BBItemRef );  /** @brief Handle self messages such as timer... */  virtual void handleSelfMsg(cMessage*);  /** @brief Handle messages from upper layer */  virtual void handleUpperMsg(MacPkt*);  /** @brief Handle messages from lower layer */  virtual void handleLowerMsg(MacPkt*);  /**\brief handle end of contension */  virtual void handleEndContensionTimer();  /**\brief handle a message that is not for me or errornous*/  void handleMsgNotForMe(Mac80211Pkt*);  /**\brief handle a message that was meant for me*/  void handleMsgForMe(Mac80211Pkt*);  //**\brief handle a Broadcast message*/  void handleBroadcastMsg(Mac80211Pkt*);  /** \brief handle the end of a transmission...*/  void handleEndTransmissionTimer();  /**\brief handle end of SIFS*/  void handleEndSifsTimer();  /**\brief handle time out*/  void handleTimeOutTimer();  /**\brief NAV timer expired, the exchange of messages of other     stations is done*/  void handleNavTimer();  void handleRTSframe(Mac80211Pkt*);  void handleDATAframe(Mac80211Pkt*);  void handleACKframe(Mac80211Pkt*);  void handleCTSframe(Mac80211Pkt*);  /**\brief send data frame */  virtual void sendDATAframe();  /**\brief send Acknoledgement */  void sendACKframe(Mac80211Pkt*);  /**\brief send CTS frame */  void sendCTSframe(Mac80211Pkt*);  /**\brief send RTS frame */  virtual void sendRTSframe();  /**\brief send broadcast frame */  void sendBROADCASTframe();  /**\brief build a data frame */  virtual Mac80211Pkt* buildDATAframe();  /**\brief build an ACK */  Mac80211Pkt* buildACKframe(Mac80211Pkt*);  /**\brief build a CTS frame*/  Mac80211Pkt* buildCTSframe(Mac80211Pkt*);  /**\brief build an RTS frame */  virtual Mac80211Pkt* buildRTSframe();  /**\brief build a broadcast frame*/  Mac80211Pkt* buildBROADCASTframe();  /**\brief start a new contension period */  virtual void beginNewCycle();  /**\brief Compute a backoff value */  double backoff();  /**\brief Compute a new contension window */  int CW();  /**\brief Test if maximum number of retries to transmit is exceeded */  void testMaxAttempts();  /**\brief return a timeOut value for a certain type of frame*/  double timeOut(_802_11frameType type, double last_frame_duration);  /**\brief computes the duration of a transmission over the physical channel*/  double packetDuration(int bits);  void finish();protected:    double txEnergy;  double rxEnergy;  double idleEnergy;  double energyConsumption;  int reCounter; //重发次数  double idleTimeStamp;//开始空闲的时间点  int retryLimit;//最大重发次数    /** @brief Pointer to RadioState published on the Blackboard*/  BBItemRef bbRs;  //TIMERS:  /**\brief Timer used for time-outs after the transmission of a RTS,     a CTS, or a DATA packet*/  cMessage* timeout;    /**\brief Timer used for the defer time of a node. Also called NAV :     networks allocation vector*/  cMessage* nav;    /**\brief Timer used for contension periods*/  cMessage* contension;    /**\brief Timer used to indicate the end of the transmission of an     ACK or a BROADCAST packet*/  cMessage* endTransmission;    /**\brief Timer used to indicate the end of a SIFS*/  cMessage* endSifs;    /**\brief extended interframe space*/  double EIFS;  /**\brief Variable to store the current backoff value*/  double BW;  /**\brief Current state of the MAC*/  int state;  /**\brief Maximal number of packets in the queue; should be set in     the omnetpp.ini*/  int maxQueueSize;  /**\brief Boolean used to know if the next packet is a broadcast packet.*/  bool nextIsBroadcast;  /**\brief Buffering of messages from upper layer*/  cMacPktList fromUpperLayer;  /**\brief Number of frame transmission attempt*/  int retryCounter;  /**\brief If there's a new packet to send and the channel is free, no      backoff is needed.*/  bool tryWithoutBackoff;  /**\brief true if Rts/Cts is used, false if not; can be set in omnetpp.ini*/  bool rtsCts;  /**\brief Very small value used in timer scheduling in order to avoid     multiple changements of state in the same simulation time.*/  double delta;  /**\brief A variable needed to identify messages from the Blackboard*/  int radioStateId;  /**\brief The bitrate should be set in omnetpp.ini; be sure to use a     valid 802.11 bitrate*/  double bitrate;  /**\brief Should be set in the omnetpp.ini*/  int broadcastBackoff;  /**\brief This variable stores wether the physical layer signalises  that it's receiving or not*/  bool phy_receiving;    /**      * @name Abstraction layer     * @brief Function to create a user defined MAC packet     *     * 802.11 uses its own MAC packet -- naturally. Here is how.     *     **/    /*@{*/    virtual MacPkt* createCapsulePkt() {        return new Mac80211Pkt;    };        /*@}*/};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -