src/wifi/model/wifi-phy.h
changeset 10139 17a71cd49da3
parent 8981 7e1c95c4d1a7
child 10424 9d29c9a5ddcb
equal deleted inserted replaced
10138:2f8e35b43d11 10139:17a71cd49da3
    29 #include "ns3/ptr.h"
    29 #include "ns3/ptr.h"
    30 #include "wifi-mode.h"
    30 #include "wifi-mode.h"
    31 #include "wifi-preamble.h"
    31 #include "wifi-preamble.h"
    32 #include "wifi-phy-standard.h"
    32 #include "wifi-phy-standard.h"
    33 #include "ns3/traced-callback.h"
    33 #include "ns3/traced-callback.h"
    34 
    34 #include "wifi-tx-vector.h"
    35 
    35 
    36 namespace ns3 {
    36 namespace ns3 {
    37 
    37 
    38 class WifiChannel;
    38 class WifiChannel;
    39 class NetDevice;
    39 class NetDevice;
   182 
   182 
   183   /**
   183   /**
   184    * \param packet the packet to send
   184    * \param packet the packet to send
   185    * \param mode the transmission mode to use to send this packet
   185    * \param mode the transmission mode to use to send this packet
   186    * \param preamble the type of preamble to use to send this packet.
   186    * \param preamble the type of preamble to use to send this packet.
   187    * \param txPowerLevel a power level to use to send this packet. The real
   187    * \param txvector the txvector that has tx parameters as txPowerLevel a power level to use to send this packet. The real
   188    *        transmission power is calculated as txPowerMin + txPowerLevel * (txPowerMax - txPowerMin) / nTxLevels
   188    *        transmission power is calculated as txPowerMin + txPowerLevel * (txPowerMax - txPowerMin) / nTxLevels
   189    */
   189    */
   190   virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, uint8_t txPowerLevel) = 0;
   190   virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, WifiTxVector txvector) = 0;
   191 
   191 
   192   /**
   192   /**
   193    * \param listener the new listener
   193    * \param listener the new listener
   194    *
   194    *
   195    * Add the input listener to the list of objects to be notified of
   195    * Add the input listener to the list of objects to be notified of
   235 
   235 
   236   virtual Time GetLastRxStartTime (void) const = 0;
   236   virtual Time GetLastRxStartTime (void) const = 0;
   237 
   237 
   238   /**
   238   /**
   239    * \param size the number of bytes in the packet to send
   239    * \param size the number of bytes in the packet to send
   240    * \param payloadMode the transmission mode to use for this packet
   240    * \param txvector the transmission parameters used for this packet
   241    * \param preamble the type of preamble to use for this packet.
   241    * \param preamble the type of preamble to use for this packet.
   242    * \return the total amount of time this PHY will stay busy for
   242    * \return the total amount of time this PHY will stay busy for
   243    *          the transmission of these bytes.
   243    *          the transmission of these bytes.
   244    */
   244    */
   245   static Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble);
   245   static Time CalculateTxDuration (uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble);
       
   246 
       
   247 /** 
       
   248    * \param payloadMode the WifiMode use for the transmission of the payload
       
   249    * \param preamble the type of preamble
       
   250    * \param txvector the transmission parameters used for this packet
       
   251 
       
   252    * \return the training symbol duration
       
   253    */
       
   254   static uint32_t GetPlcpHtTrainingSymbolDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble, WifiTxVector txvector);
       
   255 /** 
       
   256    * \param payloadMode the WifiMode use for the transmission of the payload
       
   257    * \param preamble the type of preamble
       
   258    * 
       
   259    * \return the WifiMode used for the transmission of the HT-SIG in Mixed Format and greenfield format PLCP header 
       
   260    */
       
   261   static WifiMode GetMFPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble);
       
   262 /** 
       
   263    * \param payloadMode the WifiMode use for the transmission of the payload
       
   264    * \param preamble the type of preamble
       
   265    * 
       
   266    * \return the duration of the GT-SIG in Mixed Format and greenfield format PLCP header 
       
   267    */
       
   268   static uint32_t GetPlcpHtSigHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
       
   269 
   246 
   270 
   247   /** 
   271   /** 
   248    * \param payloadMode the WifiMode use for the transmission of the payload
   272    * \param payloadMode the WifiMode use for the transmission of the payload
   249    * \param preamble the type of preamble
   273    * \param preamble the type of preamble
   250    * 
   274    * 
   268    */
   292    */
   269   static uint32_t GetPlcpPreambleDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
   293   static uint32_t GetPlcpPreambleDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
   270 
   294 
   271   /** 
   295   /** 
   272    * \param size the number of bytes in the packet to send
   296    * \param size the number of bytes in the packet to send
   273    * \param payloadMode the WifiMode use for the transmission of the payload
   297    * \param txvector the transmission parameters used for this packet
   274    * 
   298    * 
   275    * \return the duration of the payload in microseconds
   299    * \return the duration of the payload in microseconds
   276    */
   300    */
   277   static uint32_t GetPayloadDurationMicroSeconds (uint32_t size, WifiMode payloadMode);
   301   static double GetPayloadDurationMicroSeconds (uint32_t size, WifiTxVector txvector);
   278 
   302 
   279   /**
   303   /**
   280    * The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used
   304    * The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used
   281    * (e.g., by a WifiRemoteStationManager) to determine the set of
   305    * (e.g., by a WifiRemoteStationManager) to determine the set of
   282    * transmission/reception modes that this WifiPhy(-derived class)
   306    * transmission/reception modes that this WifiPhy(-derived class)
   318    * \param ber the probability of bit error rate
   342    * \param ber the probability of bit error rate
   319    * \returns the minimum snr which is required to achieve
   343    * \returns the minimum snr which is required to achieve
   320    *          the requested ber for the specified transmission mode. (W/W)
   344    *          the requested ber for the specified transmission mode. (W/W)
   321    */
   345    */
   322   virtual double CalculateSnr (WifiMode txMode, double ber) const = 0;
   346   virtual double CalculateSnr (WifiMode txMode, double ber) const = 0;
   323 
   347    /**
       
   348    * The WifiPhy::NBssMembershipSelectors() and WifiPhy::BssMembershipSelector() methods are used
       
   349    * (e.g., by a WifiRemoteStationManager) to determine the set of
       
   350    * transmission/reception modes that this WifiPhy(-derived class)
       
   351    * can support - a set of WifiMode objects which we call the
       
   352    * BssMemebershipSelectorSet, and which is stored as WifiPhy::m_bssMembershipSelectorSet.
       
   353    *
       
   354    * This was introduced with 11n
       
   355    *
       
   356    * \param selector index in array of supported memeberships
       
   357    * \returns the memebership selector whose index is specified.
       
   358    *
       
   359    * \sa WifiPhy::NBssMembershipSelectors()
       
   360    */
       
   361   virtual uint32_t GetNBssMembershipSelectors (void) const=0;
       
   362 
       
   363   virtual uint32_t GetBssMembershipSelector (uint32_t selector) const=0;
       
   364   /**
       
   365    * The WifiPhy::GetMembershipSelectorModes() method is used
       
   366    * (e.g., by a WifiRemoteStationManager) to determine the set of
       
   367    * transmission/reception modes that this WifiPhy(-derived class)
       
   368    * can support - a set of WifiMode objects which we call the
       
   369    * BssMemebershipSelectorSet, and which is stored as WifiPhy::m_bssMembershipSelectorSet.
       
   370    *
       
   371    * This was introduced with 11n
       
   372    *
       
   373    * \param selector index in array of supported memeberships
       
   374    * \returns a WifiModeList that contains the WifiModes associrated with the selected index.
       
   375    *
       
   376    * \sa WifiPhy::GetMembershipSelectorModes()
       
   377    */
       
   378   virtual WifiModeList GetMembershipSelectorModes(uint32_t selector)=0;
       
   379   /**
       
   380    * The WifiPhy::GetNMcs() and  WifiPhy::GetMcs() methods are used
       
   381    * (e.g., by a WifiRemoteStationManager) to determine the set of
       
   382    * transmission/reception MCS indexes that this WifiPhy(-derived class)
       
   383    * can support - a set of Mcs indexes which we call the
       
   384    * DeviceMcsSet, and which is stored as WifiPhy::m_deviceMcsSet.
       
   385    *
       
   386    * This was introduced with 11n
       
   387    *
       
   388    * \param Mcs index in array of supported Mcs
       
   389    * \returns the Mcs index whose index is specified.
       
   390    *
       
   391    * \sa WifiPhy::GetNMcs()
       
   392    */
       
   393   virtual uint8_t GetNMcs (void) const=0;
       
   394   virtual uint8_t GetMcs (uint8_t mcs) const=0;
       
   395 
       
   396   /* Converts from DataRate to MCS index and vice versa */
       
   397   virtual uint32_t WifiModeToMcs (WifiMode mode)=0;
       
   398   virtual WifiMode McsToWifiMode (uint8_t mcs)=0;
       
   399 
       
   400   
   324   /**
   401   /**
   325    * \brief Set channel number.
   402    * \brief Set channel number.
   326    *
   403    *
   327    * Channel center frequency = Channel starting frequency + 5 MHz * (nch - 1)
   404    * Channel center frequency = Channel starting frequency + 5 MHz * (nch - 1)
   328    *
   405    *
   371   static WifiMode GetOfdmRate4_5MbpsBW5MHz ();
   448   static WifiMode GetOfdmRate4_5MbpsBW5MHz ();
   372   static WifiMode GetOfdmRate6MbpsBW5MHz ();
   449   static WifiMode GetOfdmRate6MbpsBW5MHz ();
   373   static WifiMode GetOfdmRate9MbpsBW5MHz ();
   450   static WifiMode GetOfdmRate9MbpsBW5MHz ();
   374   static WifiMode GetOfdmRate12MbpsBW5MHz ();
   451   static WifiMode GetOfdmRate12MbpsBW5MHz ();
   375   static WifiMode GetOfdmRate13_5MbpsBW5MHz ();
   452   static WifiMode GetOfdmRate13_5MbpsBW5MHz ();
       
   453   static WifiMode GetOfdmRate6_5MbpsBW20MHz ();
       
   454   static WifiMode GetOfdmRate13MbpsBW20MHz ();
       
   455   static WifiMode GetOfdmRate19_5MbpsBW20MHz ();
       
   456   static WifiMode GetOfdmRate26MbpsBW20MHz ();
       
   457   static WifiMode GetOfdmRate39MbpsBW20MHz ();
       
   458   static WifiMode GetOfdmRate52MbpsBW20MHz ();
       
   459   static WifiMode GetOfdmRate58_5MbpsBW20MHz ();
       
   460   static WifiMode GetOfdmRate65MbpsBW20MHz ();
       
   461   static WifiMode GetOfdmRate13_5MbpsBW40MHz ();
       
   462   static WifiMode GetOfdmRate27MbpsBW40MHz (); 
       
   463   static WifiMode GetOfdmRate40_5MbpsBW40MHz ();
       
   464   static WifiMode GetOfdmRate54MbpsBW40MHz ();
       
   465   static WifiMode GetOfdmRate81MbpsBW40MHz ();
       
   466   static WifiMode GetOfdmRate108MbpsBW40MHz ();
       
   467   static WifiMode GetOfdmRate121_5MbpsBW40MHz ();
       
   468   static WifiMode GetOfdmRate135MbpsBW40MHz ();
       
   469   //Rates for clause 20 with short guard interval
       
   470   static WifiMode GetOfdmRate7_2MbpsBW20MHz ();
       
   471   static WifiMode GetOfdmRate14_4MbpsBW20MHz ();
       
   472   static WifiMode GetOfdmRate21_7MbpsBW20MHz ();
       
   473   static WifiMode GetOfdmRate28_9MbpsBW20MHz ();
       
   474   static WifiMode GetOfdmRate43_3MbpsBW20MHz ();
       
   475   static WifiMode GetOfdmRate57_8MbpsBW20MHz ();
       
   476   static WifiMode GetOfdmRate65MbpsBW20MHzShGi ();
       
   477   static WifiMode GetOfdmRate72_2MbpsBW20MHz ();
       
   478   static WifiMode GetOfdmRate15MbpsBW40MHz ();
       
   479   static WifiMode GetOfdmRate30MbpsBW40MHz (); 
       
   480   static WifiMode GetOfdmRate45MbpsBW40MHz ();
       
   481   static WifiMode GetOfdmRate60MbpsBW40MHz ();
       
   482   static WifiMode GetOfdmRate90MbpsBW40MHz ();
       
   483   static WifiMode GetOfdmRate120MbpsBW40MHz ();
       
   484   static WifiMode GetOfdmRate135MbpsBW40MHzShGi ();
       
   485   static WifiMode GetOfdmRate150MbpsBW40MHz ();
   376 
   486 
   377 
   487 
   378   /**
   488   /**
   379    * Public method used to fire a PhyTxBegin trace.  Implemented for encapsulation
   489    * Public method used to fire a PhyTxBegin trace.  Implemented for encapsulation
   380    * purposes.
   490    * purposes.
   445    * @param channelNumber the channel on which the packet is transmitted
   555    * @param channelNumber the channel on which the packet is transmitted
   446    * @param rate the PHY data rate in units of 500kbps (i.e., the same
   556    * @param rate the PHY data rate in units of 500kbps (i.e., the same
   447    * units used both for the radiotap and for the prism header)
   557    * units used both for the radiotap and for the prism header)
   448    * @param isShortPreamble true if short preamble is used, false otherwise
   558    * @param isShortPreamble true if short preamble is used, false otherwise
   449    */
   559    */
   450   void NotifyMonitorSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble);
   560   void NotifyMonitorSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, uint8_t txPower);
   451 
   561 
   452  /**
   562  /**
   453   * Assign a fixed random variable stream number to the random variables
   563   * Assign a fixed random variable stream number to the random variables
   454   * used by this model.  Return the number of streams (possibly zero) that
   564   * used by this model.  Return the number of streams (possibly zero) that
   455   * have been assigned.
   565   * have been assigned.
   457   * \param stream first stream index to use
   567   * \param stream first stream index to use
   458   * \return the number of stream indices assigned by this model
   568   * \return the number of stream indices assigned by this model
   459   */
   569   */
   460   virtual int64_t AssignStreams (int64_t stream) = 0;
   570   virtual int64_t AssignStreams (int64_t stream) = 0;
   461 
   571 
       
   572   /**
       
   573    * \param the operating frequency on this node.
       
   574    */
       
   575   virtual void SetFrequency (uint32_t freq)=0;
       
   576   virtual uint32_t GetFrequency (void) const=0;
       
   577   /**
       
   578    * \param the number of transmitters on this node.
       
   579    */
       
   580   virtual void SetNumberOfTransmitAntennas (uint32_t tx)=0;
       
   581 
       
   582   virtual uint32_t GetNumberOfTransmitAntennas (void) const=0;
       
   583    /**
       
   584    * \param the number of recievers on this node.
       
   585    */
       
   586   virtual void SetNumberOfReceiveAntennas (uint32_t rx)=0 ;
       
   587   /**
       
   588    * \returns the number of recievers on this node.
       
   589    */
       
   590   virtual uint32_t GetNumberOfReceiveAntennas (void) const=0;
       
   591   /**
       
   592    * \paramif short guard interval is supported or not
       
   593    */
       
   594    virtual void SetGuardInterval (bool GuardInterval)=0;
       
   595    /**
       
   596    *  \returns if short guard interval is supported or not
       
   597    */
       
   598   virtual bool GetGuardInterval (void) const = 0;
       
   599   /**
       
   600    * \paramif LDPC is supported or not
       
   601    */
       
   602   virtual void SetLdpc (bool Ldpc)=0;
       
   603   /**
       
   604    * \returns if LDPC is supported or not
       
   605    */
       
   606   virtual bool GetLdpc (void) const=0;
       
   607   /**
       
   608    * \paramif STBC is supported or not
       
   609    */
       
   610   virtual void SetStbc (bool stbc)=0;
       
   611   /**
       
   612    *  \returns if STBC is supported or not
       
   613    */
       
   614   virtual bool GetStbc (void) const=0;
       
   615    
       
   616   /**
       
   617    * \paramif GreenField is supported or not
       
   618    */
       
   619   virtual void SetGreenfield (bool greenfield)=0;
       
   620   /**
       
   621    *  \returns if Green field is supported or not
       
   622    */
       
   623   virtual bool GetGreenfield (void) const=0;
       
   624   /**
       
   625    * \paramif channel bonding 40 MHz is supported or not
       
   626    */
       
   627   virtual bool GetChannelBonding (void) const = 0;
       
   628   /**
       
   629    *  \returns if channel bonding is supported or not
       
   630    */
       
   631   virtual void SetChannelBonding (bool channelbonding) = 0 ;
   462 
   632 
   463 private:
   633 private:
   464   /**
   634   /**
   465    * The trace source fired when a packet begins the transmission process on
   635    * The trace source fired when a packet begins the transmission process on
   466    * the medium.
   636    * the medium.
   528    * corresponds in the madwifi driver to calling the function
   698    * corresponds in the madwifi driver to calling the function
   529    * ieee80211_input_monitor()
   699    * ieee80211_input_monitor()
   530    *
   700    *
   531    * \see class CallBackTraceSource
   701    * \see class CallBackTraceSource
   532    */
   702    */
   533   TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool> m_phyMonitorSniffTxTrace;
   703   TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool,uint8_t> m_phyMonitorSniffTxTrace;
   534 
   704 
   535 };
   705 };
   536 
   706 
   537 /**
   707 /**
   538  * \param os          output stream
   708  * \param os          output stream