A Discrete-Event Network Simulator
API
ht-phy.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Orange Labs
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Authors: Rediet <getachew.redieteab@orange.com>
18  * Sébastien Deronne <sebastien.deronne@gmail.com> (for logic ported from wifi-phy)
19  */
20 
21 #ifndef HT_PHY_H
22 #define HT_PHY_H
23 
24 #include "ns3/ofdm-phy.h"
25 
32 namespace ns3
33 {
34 
38 #define HT_PHY 127
39 
41 constexpr uint8_t HT_MAX_NSS = 4;
42 
53 class HtPhy : public OfdmPhy
54 {
55  public:
63  HtPhy(uint8_t maxNss = 1, bool buildModeList = true);
67  ~HtPhy() override;
68 
69  WifiMode GetMcs(uint8_t index) const override;
70  bool IsMcsSupported(uint8_t index) const override;
71  bool HandlesMcsModes() const override;
72  WifiMode GetSigMode(WifiPpduField field, const WifiTxVector& txVector) const override;
73  const PpduFormats& GetPpduFormats() const override;
74  Time GetDuration(WifiPpduField field, const WifiTxVector& txVector) const override;
75  Time GetPayloadDuration(uint32_t size,
76  const WifiTxVector& txVector,
77  WifiPhyBand band,
78  MpduType mpdutype,
79  bool incFlag,
80  uint32_t& totalAmpduSize,
81  double& totalAmpduNumSymbols,
82  uint16_t staId) const override;
84  const WifiTxVector& txVector,
85  Time ppduDuration) override;
86 
90  static WifiMode GetLSigMode();
94  virtual WifiMode GetHtSigMode() const;
95 
99  uint8_t GetBssMembershipSelector() const;
100 
107  uint8_t GetMaxSupportedMcsIndexPerSs() const;
116  void SetMaxSupportedMcsIndexPerSs(uint8_t maxIndex);
123  void SetMaxSupportedNss(uint8_t maxNss);
124 
131  virtual Time GetLSigDuration(WifiPreamble preamble) const;
140  virtual Time GetTrainingDuration(const WifiTxVector& txVector,
141  uint8_t nDataLtf,
142  uint8_t nExtensionLtf = 0) const;
146  virtual Time GetHtSigDuration() const;
147 
151  static void InitializeModes();
159  static WifiMode GetHtMcs(uint8_t index);
160 
166  static WifiMode GetHtMcs0();
172  static WifiMode GetHtMcs1();
178  static WifiMode GetHtMcs2();
184  static WifiMode GetHtMcs3();
190  static WifiMode GetHtMcs4();
196  static WifiMode GetHtMcs5();
202  static WifiMode GetHtMcs6();
208  static WifiMode GetHtMcs7();
214  static WifiMode GetHtMcs8();
220  static WifiMode GetHtMcs9();
353 
363  static WifiCodeRate GetHtCodeRate(uint8_t mcsValue);
373  static WifiCodeRate GetCodeRate(uint8_t mcsValue);
381  static uint16_t GetHtConstellationSize(uint8_t mcsValue);
391  static uint16_t GetConstellationSize(uint8_t mcsValue);
405  static uint64_t GetPhyRate(uint8_t mcsValue,
406  uint16_t channelWidth,
407  uint16_t guardInterval,
408  uint8_t nss);
419  static uint64_t GetPhyRateFromTxVector(const WifiTxVector& txVector, uint16_t staId);
430  static uint64_t GetDataRateFromTxVector(const WifiTxVector& txVector, uint16_t staId);
443  static uint64_t GetDataRate(uint8_t mcsValue,
444  uint16_t channelWidth,
445  uint16_t guardInterval,
446  uint8_t nss);
455  static uint64_t GetNonHtReferenceRate(uint8_t mcsValue);
463  static bool IsAllowed(const WifiTxVector& txVector);
464 
465  protected:
467  bool IsAllConfigSupported(WifiPpduField field, Ptr<const WifiPpdu> ppdu) const override;
468  bool IsConfigSupported(Ptr<const WifiPpdu> ppdu) const override;
470  Ptr<const WifiPpdu> ppdu) const override;
471  uint32_t GetMaxPsduSize() const override;
473 
480  virtual void BuildModeList();
481 
486  virtual uint8_t GetNumberBccEncoders(const WifiTxVector& txVector) const;
491  virtual Time GetSymbolDuration(const WifiTxVector& txVector) const;
492 
501  static uint64_t CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate);
515  static uint64_t CalculateNonHtReferenceRate(WifiCodeRate codeRate, uint16_t constellationSize);
522  static double GetCodeRatio(WifiCodeRate codeRate);
534  static uint64_t CalculateDataRate(Time symbolDuration,
535  uint16_t usableSubCarriers,
536  uint16_t numberOfBitsPerSubcarrier,
537  double codingRate,
538  uint8_t nss);
539 
544  static Time GetSymbolDuration(uint16_t channelWidth);
545 
550  static uint16_t GetUsableSubcarriers(uint16_t channelWidth);
551 
556  static Time GetSymbolDuration(Time guardInterval);
557 
558  uint8_t
562 
563  private:
572 
581  static WifiMode CreateHtMcs(uint8_t index);
582 
585 
587 }; // class HtPhy
588 
589 } // namespace ns3
590 
591 #endif /* HT_PHY_H */
PHY entity for HT (11n)
Definition: ht-phy.h:54
static uint64_t CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate)
Return the PHY rate corresponding to the supplied code rate and data rate.
Definition: ht-phy.cc:657
CcaIndication GetCcaIndication(const Ptr< const WifiPpdu > ppdu) override
Get CCA end time and its corresponding channel list type when a new signal has been received by the P...
Definition: ht-phy.cc:822
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index between 0 and 7,...
Definition: ht-phy.cc:627
static WifiMode GetHtMcs3()
Return MCS 3 from HT MCS values.
static WifiMode GetHtMcs29()
Return MCS 29 from HT MCS values.
uint8_t m_bssMembershipSelector
the BSS membership selector
Definition: ht-phy.h:561
static WifiMode GetHtMcs13()
Return MCS 13 from HT MCS values.
PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event) override
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
Definition: ht-phy.cc:390
~HtPhy() override
Destructor for HT PHY.
Definition: ht-phy.cc:69
static WifiMode GetHtMcs1()
Return MCS 1 from HT MCS values.
static WifiMode GetLSigMode()
Definition: ht-phy.cc:154
static WifiMode GetHtMcs14()
Return MCS 14 from HT MCS values.
static WifiMode GetHtMcs11()
Return MCS 11 from HT MCS values.
static WifiMode GetHtMcs19()
Return MCS 19 from HT MCS values.
static uint16_t GetHtConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:621
static WifiMode GetHtMcs4()
Return MCS 4 from HT MCS values.
uint8_t m_maxMcsIndexPerSs
the maximum MCS index per spatial stream as defined by the standard
Definition: ht-phy.h:559
static WifiMode GetHtMcs27()
Return MCS 27 from HT MCS values.
static WifiMode GetHtMcs0()
Return MCS 0 from HT MCS values.
bool IsAllConfigSupported(WifiPpduField field, Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (including bandwidth) is supported by the PHY.
Definition: ht-phy.cc:432
HtPhy(uint8_t maxNss=1, bool buildModeList=true)
Constructor for HT PHY.
Definition: ht-phy.cc:53
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
Definition: ht-phy.cc:684
static uint64_t GetDataRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the data rate corresponding to the supplied HT MCS index, channel width, guard interval,...
Definition: ht-phy.cc:693
static void InitializeModes()
Initialize all HT modes.
Definition: ht-phy.cc:479
static WifiCodeRate GetHtCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:593
static WifiMode GetHtMcs8()
Return MCS 8 from HT MCS values.
static uint64_t CalculateNonHtReferenceRate(WifiCodeRate codeRate, uint16_t constellationSize)
Return the rate (in bps) of the non-HT Reference Rate which corresponds to the supplied code rate and...
Definition: ht-phy.cc:738
virtual Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const
Definition: ht-phy.cc:256
static WifiMode GetHtMcs5()
Return MCS 5 from HT MCS values.
bool IsMcsSupported(uint8_t index) const override
Check if the WifiMode corresponding to the given MCS index is supported.
Definition: ht-phy.cc:111
Time GetDuration(WifiPpduField field, const WifiTxVector &txVector) const override
Get the duration of the PPDU field (or group of fields) used by this entity for the given transmissio...
Definition: ht-phy.cc:210
Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype, bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols, uint16_t staId) const override
Definition: ht-phy.cc:277
uint8_t GetBssMembershipSelector() const
Definition: ht-phy.cc:166
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
Definition: ht-phy.cc:810
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
Definition: ht-phy.cc:663
static WifiMode GetHtMcs20()
Return MCS 20 from HT MCS values.
static WifiMode GetHtMcs17()
Return MCS 17 from HT MCS values.
WifiMode GetMcs(uint8_t index) const override
Get the WifiMode corresponding to the given MCS index.
Definition: ht-phy.cc:95
static WifiMode GetHtMcs9()
Return MCS 9 from HT MCS values.
virtual uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const
Definition: ht-phy.cc:357
static uint64_t GetNonHtReferenceRate(uint8_t mcsValue)
Calculate the rate in bps of the non-HT Reference Rate corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:730
static WifiMode GetHtMcs24()
Return MCS 24 from HT MCS values.
static WifiMode GetHtMcs22()
Return MCS 22 from HT MCS values.
static WifiMode GetHtMcs12()
Return MCS 12 from HT MCS values.
virtual Time GetLSigDuration(WifiPreamble preamble) const
Definition: ht-phy.cc:250
static WifiMode GetHtMcs2()
Return MCS 2 from HT MCS values.
static WifiMode GetHtMcs15()
Return MCS 15 from HT MCS values.
static uint64_t GetPhyRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the PHY rate corresponding to the supplied HT MCS index, channel width, guard interval,...
Definition: ht-phy.cc:649
void SetMaxSupportedMcsIndexPerSs(uint8_t maxIndex)
Set the maximum supported MCS index per spatial stream.
Definition: ht-phy.cc:172
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:488
static WifiMode GetHtMcs6()
Return MCS 6 from HT MCS values.
static WifiMode GetHtMcs28()
Return MCS 28 from HT MCS values.
static WifiMode CreateHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:577
uint32_t GetMaxPsduSize() const override
Get the maximum PSDU size in bytes.
Definition: ht-phy.cc:816
static WifiMode GetHtMcs30()
Return MCS 30 from HT MCS values.
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index between 0 and 7,...
Definition: ht-phy.cc:599
virtual WifiMode GetHtSigMode() const
Definition: ht-phy.cc:160
static WifiMode GetHtMcs21()
Return MCS 21 from HT MCS values.
static WifiMode GetHtMcs23()
Return MCS 23 from HT MCS values.
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
Definition: ht-phy.cc:136
static WifiMode GetHtMcs16()
Return MCS 16 from HT MCS values.
static uint64_t CalculateDataRate(Time symbolDuration, uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier, double codingRate, uint8_t nss)
Calculates data rate from the supplied parameters.
Definition: ht-phy.cc:705
uint8_t GetMaxSupportedMcsIndexPerSs() const
Set the maximum supported MCS index per spatial stream.
Definition: ht-phy.cc:189
static WifiMode GetHtMcs7()
Return MCS 7 from HT MCS values.
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
Definition: ht-phy.cc:460
bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
Definition: ht-phy.cc:442
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Definition: ht-phy.cc:379
uint8_t m_maxSupportedNss
Maximum supported number of spatial streams (used to build HT MCS indices)
Definition: ht-phy.h:583
virtual void BuildModeList()
Build mode list.
Definition: ht-phy.cc:75
static Time GetSymbolDuration(uint16_t channelWidth)
static double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
Definition: ht-phy.cc:672
static WifiMode GetHtMcs26()
Return MCS 26 from HT MCS values.
bool HandlesMcsModes() const override
Check if the WifiModes handled by this PHY are MCSs.
Definition: ht-phy.cc:124
static WifiMode GetHtMcs25()
Return MCS 25 from HT MCS values.
static WifiMode GetHtMcs18()
Return MCS 18 from HT MCS values.
static const PpduFormats m_htPpduFormats
HT PPDU formats.
Definition: ht-phy.h:586
static WifiMode GetHtMcs31()
Return MCS 31 from HT MCS values.
void SetMaxSupportedNss(uint8_t maxNss)
Configure the maximum number of spatial streams supported by this HT PHY.
Definition: ht-phy.cc:195
PhyFieldRxStatus EndReceiveHtSig(Ptr< Event > event)
End receiving the HT-SIG, perform HT-specific actions, and provide the status of the reception.
Definition: ht-phy.cc:407
virtual Time GetHtSigDuration() const
Definition: ht-phy.cc:271
static WifiMode GetHtMcs10()
Return MCS 10 from HT MCS values.
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
Definition: ht-phy.h:560
const PpduFormats & GetPpduFormats() const override
Return the PPDU formats of the PHY.
Definition: ht-phy.cc:130
virtual Time GetSymbolDuration(const WifiTxVector &txVector) const
Definition: ht-phy.cc:371
PHY entity for OFDM (11a)
Definition: ofdm-phy.h:61
static uint16_t GetUsableSubcarriers()
Definition: ofdm-phy.cc:631
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
Definition: phy-entity.h:561
std::optional< std::pair< Time, WifiChannelListType > > CcaIndication
CCA end time and its corresponding channel list type (can be std::nullopt if IDLE)
Definition: phy-entity.h:969
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
represent a single transmission mode
Definition: wifi-mode.h:51
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:33
WifiPpduField
The type of PPDU field (grouped for convenience)
MpduType
The type of an MPDU.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
constexpr uint8_t HT_MAX_NSS
Maximum number of supported NSS by HT PHY.
Definition: ht-phy.h:41
WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
Status of the reception of the PPDU field.
Definition: phy-entity.h:112