src/wifi/model/yans-wifi-phy.h
changeset 10139 17a71cd49da3
parent 9818 cfb12f56257a
child 10204 7a102bb70a36
equal deleted inserted replaced
10138:2f8e35b43d11 10139:17a71cd49da3
    14  * You should have received a copy of the GNU General Public License
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    17  *
    17  *
    18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
    18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
       
    19  * Author: ghada Badawy <gbadawy@gmail.com>
    19  */
    20  */
    20 
    21 
    21 #ifndef YANS_WIFI_PHY_H
    22 #ifndef YANS_WIFI_PHY_H
    22 #define YANS_WIFI_PHY_H
    23 #define YANS_WIFI_PHY_H
    23 
    24 
    37 #include "interference-helper.h"
    38 #include "interference-helper.h"
    38 
    39 
    39 
    40 
    40 namespace ns3 {
    41 namespace ns3 {
    41 
    42 
       
    43 #define HT_PHY 127
       
    44 
    42 class YansWifiChannel;
    45 class YansWifiChannel;
    43 class WifiPhyStateHelper;
    46 class WifiPhyStateHelper;
    44 
    47 
    45 
    48 
    46 /**
    49 /**
    89   /// Return current center channel frequency in MHz, see SetChannelNumber()
    92   /// Return current center channel frequency in MHz, see SetChannelNumber()
    90   double GetChannelFrequencyMhz () const;
    93   double GetChannelFrequencyMhz () const;
    91 
    94 
    92   void StartReceivePacket (Ptr<Packet> packet,
    95   void StartReceivePacket (Ptr<Packet> packet,
    93                            double rxPowerDbm,
    96                            double rxPowerDbm,
    94                            WifiMode mode,
    97                            WifiTxVector txVector,
    95                            WifiPreamble preamble);
    98                            WifiPreamble preamble);
    96 
    99 
    97   void SetRxNoiseFigure (double noiseFigureDb);
   100   void SetRxNoiseFigure (double noiseFigureDb);
    98   void SetTxPowerStart (double start);
   101   void SetTxPowerStart (double start);
    99   void SetTxPowerEnd (double end);
   102   void SetTxPowerEnd (double end);
   120   virtual double GetTxPowerStart (void) const;
   123   virtual double GetTxPowerStart (void) const;
   121   virtual double GetTxPowerEnd (void) const;
   124   virtual double GetTxPowerEnd (void) const;
   122   virtual uint32_t GetNTxPower (void) const;
   125   virtual uint32_t GetNTxPower (void) const;
   123   virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
   126   virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
   124   virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
   127   virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
   125   virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, uint8_t txPowerLevel);
   128   virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, WifiTxVector txvector);
   126   virtual void RegisterListener (WifiPhyListener *listener);
   129   virtual void RegisterListener (WifiPhyListener *listener);
   127   virtual bool IsStateCcaBusy (void);
   130   virtual bool IsStateCcaBusy (void);
   128   virtual bool IsStateIdle (void);
   131   virtual bool IsStateIdle (void);
   129   virtual bool IsStateBusy (void);
   132   virtual bool IsStateBusy (void);
   130   virtual bool IsStateRx (void);
   133   virtual bool IsStateRx (void);
   147   * \param stream first stream index to use
   150   * \param stream first stream index to use
   148   * \return the number of stream indices assigned by this model
   151   * \return the number of stream indices assigned by this model
   149   */
   152   */
   150   int64_t AssignStreams (int64_t stream);
   153   int64_t AssignStreams (int64_t stream);
   151 
   154 
       
   155   /**
       
   156    * \param the operating frequency on this node (2.4 GHz or 5GHz).
       
   157    */
       
   158   virtual void SetFrequency (uint32_t freq);
       
   159   /**
       
   160    * \returns the operating frequency on this node
       
   161    */
       
   162   virtual uint32_t GetFrequency (void) const;
       
   163   /**
       
   164    * \param the number of transmitters on this node.
       
   165    */
       
   166   virtual void SetNumberOfTransmitAntennas (uint32_t tx);
       
   167   virtual uint32_t GetNumberOfTransmitAntennas (void) const;
       
   168   /**
       
   169    * \param the number of recievers on this node.
       
   170    */
       
   171   virtual void SetNumberOfReceiveAntennas (uint32_t rx) ;
       
   172   /**
       
   173    * \returns the number of recievers on this node.
       
   174    */
       
   175   virtual uint32_t GetNumberOfReceiveAntennas (void) const;
       
   176   /**
       
   177    * \param set short/long guard interval.
       
   178    */
       
   179   virtual void SetGuardInterval (bool GuardInterval);
       
   180    virtual bool GetGuardInterval (void) const;
       
   181   /**
       
   182    * \param sets LDPC is supported or not
       
   183    */
       
   184   virtual void SetLdpc (bool Ldpc);
       
   185   /**
       
   186    * \returns if LDPC is supported or not
       
   187    */
       
   188   virtual bool GetLdpc (void) const;
       
   189   /**
       
   190    * \param sets STBC is supported or not
       
   191    */
       
   192   virtual void SetStbc (bool stbc);
       
   193  /**
       
   194    * \returns if STBC is supported or not
       
   195    */
       
   196   virtual bool GetStbc (void) const;
       
   197   /**
       
   198    * \param sets Greenfield is supported or not
       
   199    */
       
   200   virtual void SetGreenfield (bool greenfield);
       
   201   /**
       
   202    * \returns if Greenfield is supported or not
       
   203    */
       
   204   virtual bool GetGreenfield (void) const;
       
   205   /**
       
   206    * \param sets channel bonding is supported or not
       
   207    */
       
   208   virtual bool GetChannelBonding (void) const ;
       
   209   /**
       
   210    * \returns if channel bonding is supported or not
       
   211    */
       
   212   virtual void SetChannelBonding (bool channelbonding) ;
       
   213 
       
   214   virtual uint32_t GetNBssMembershipSelectors (void) const;
       
   215   virtual uint32_t GetBssMembershipSelector (uint32_t selector) const;
       
   216   virtual WifiModeList GetMembershipSelectorModes(uint32_t selector);
       
   217   /**
       
   218    * \returns the number of MCS supported by this phy
       
   219    */
       
   220   virtual uint8_t GetNMcs (void) const;
       
   221   virtual uint8_t GetMcs (uint8_t mcs) const;
       
   222   /**
       
   223   * For a given WifiMode finds the corresponding MCS value and returns it 
       
   224   * as defined in the IEEE 802.11n standard 
       
   225   *
       
   226   * \param mode the WifiMode
       
   227   * \returns the MCS number that corresponds to the given WifiMode
       
   228   */
       
   229   virtual uint32_t WifiModeToMcs (WifiMode mode);
       
   230  /**
       
   231   * For a given MCS finds the corresponding WifiMode and returns it 
       
   232   * as defined in the IEEE 802.11n standard. 
       
   233   * 
       
   234   * \param mcs the MCS number 
       
   235   * \returns the WifiMode that corresponds to the given mcs number
       
   236   */
       
   237   virtual WifiMode McsToWifiMode (uint8_t mcs);
       
   238 
   152 private:
   239 private:
   153   YansWifiPhy (const YansWifiPhy &o);
   240   YansWifiPhy (const YansWifiPhy &o);
   154   virtual void DoDispose (void);
   241   virtual void DoDispose (void);
   155   void Configure80211a (void);
   242   void Configure80211a (void);
   156   void Configure80211b (void);
   243   void Configure80211b (void);
   158   void Configure80211_10Mhz (void);
   245   void Configure80211_10Mhz (void);
   159   void Configure80211_5Mhz ();
   246   void Configure80211_5Mhz ();
   160   void ConfigureHolland (void);
   247   void ConfigureHolland (void);
   161   void Configure80211p_CCH (void);
   248   void Configure80211p_CCH (void);
   162   void Configure80211p_SCH (void);
   249   void Configure80211p_SCH (void);
       
   250   void Configure80211n (void);
   163   double GetEdThresholdW (void) const;
   251   double GetEdThresholdW (void) const;
   164   double DbmToW (double dbm) const;
   252   double DbmToW (double dbm) const;
   165   double DbToRatio (double db) const;
   253   double DbToRatio (double db) const;
   166   double WToDbm (double w) const;
   254   double WToDbm (double w) const;
   167   double RatioToDb (double ratio) const;
   255   double RatioToDb (double ratio) const;
   176   double   m_txPowerBaseDbm;
   264   double   m_txPowerBaseDbm;
   177   double   m_txPowerEndDbm;
   265   double   m_txPowerEndDbm;
   178   uint32_t m_nTxPower;
   266   uint32_t m_nTxPower;
   179 
   267 
   180   Ptr<YansWifiChannel> m_channel;
   268   Ptr<YansWifiChannel> m_channel;
   181   uint16_t m_channelNumber;
   269   uint16_t             m_channelNumber;
   182   Ptr<Object> m_device;
   270   Ptr<Object>          m_device;
   183   Ptr<Object> m_mobility;
   271   Ptr<Object>          m_mobility;
       
   272 
       
   273   // number of transmitters
       
   274   uint32_t m_numberOfTransmitters;
       
   275   // number of recievers
       
   276   uint32_t m_numberOfReceivers;
       
   277   //if true use LDPC
       
   278   bool     m_ldpc;
       
   279   // True if STBC is used
       
   280   bool     m_stbc;
       
   281   //True if GreenField format is supported
       
   282   bool     m_greenfield;
       
   283   //True is short guard interval is used
       
   284   bool     m_guardInterval;
       
   285   //True if channel bonding is used
       
   286   bool     m_channelBonding;
       
   287 
   184 
   288 
   185   /**
   289   /**
   186    * This vector holds the set of transmission modes that this
   290    * This vector holds the set of transmission modes that this
   187    * WifiPhy(-derived class) can support. In conversation we call this
   291    * WifiPhy(-derived class) can support. In conversation we call this
   188    * the DeviceRateSet (not a term you'll find in the standard), and
   292    * the DeviceRateSet (not a term you'll find in the standard), and
   217    * future. Basically, the key point is that we can't be making
   321    * future. Basically, the key point is that we can't be making
   218    * assumptions like "the Operational Rate Set will contain all the
   322    * assumptions like "the Operational Rate Set will contain all the
   219    * mandatory rates".
   323    * mandatory rates".
   220    */
   324    */
   221   WifiModeList m_deviceRateSet;
   325   WifiModeList m_deviceRateSet;
   222 
   326   
       
   327   std::vector<uint32_t> m_bssMembershipSelectorSet;
       
   328   std::vector<uint8_t> m_deviceMcsSet;
   223   EventId m_endRxEvent;
   329   EventId m_endRxEvent;
   224   /// Provides uniform random variables.
   330   /// Provides uniform random variables.
   225   Ptr<UniformRandomVariable> m_random;
   331   Ptr<UniformRandomVariable> m_random;
   226   /// Standard-dependent center frequency of 0-th channel, MHz
   332   /// Standard-dependent center frequency of 0-th channel, MHz
   227   double m_channelStartingFrequency;
   333   double m_channelStartingFrequency;