A Discrete-Event Network Simulator
API
ht-phy.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2020 Orange Labs
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
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
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Rediet <getachew.redieteab@orange.com>
19  * Sébastien Deronne <sebastien.deronne@gmail.com> (for logic ported from wifi-phy)
20  */
21 
22 #ifndef HT_PHY_H
23 #define HT_PHY_H
24 
25 #include "ns3/ofdm-phy.h"
26 
33 namespace ns3 {
34 
38 #define HT_PHY 127
39 
50 class HtPhy : public OfdmPhy
51 {
52 public:
60  HtPhy (uint8_t maxNss = 1, bool buildModeList = true);
64  virtual ~HtPhy ();
65 
66  WifiMode GetMcs (uint8_t index) const override;
67  bool IsMcsSupported (uint8_t index) const override;
68  bool HandlesMcsModes (void) const override;
69  WifiMode GetSigMode (WifiPpduField field, const WifiTxVector& txVector) const override;
70  const PpduFormats & GetPpduFormats (void) const override;
71  Time GetDuration (WifiPpduField field, const WifiTxVector& txVector) const override;
72  Time GetPayloadDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, MpduType mpdutype,
73  bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols,
74  uint16_t staId) const override;
75  Ptr<WifiPpdu> BuildPpdu (const WifiConstPsduMap & psdus, const WifiTxVector& txVector, Time ppduDuration) override;
76 
80  static WifiMode GetLSigMode (void);
84  virtual WifiMode GetHtSigMode (void) const;
85 
89  uint8_t GetBssMembershipSelector (void) const;
90 
97  uint8_t GetMaxSupportedMcsIndexPerSs (void) const;
106  void SetMaxSupportedMcsIndexPerSs (uint8_t maxIndex);
113  void SetMaxSupportedNss (uint8_t maxNss);
114 
121  virtual Time GetLSigDuration (WifiPreamble preamble) const;
130  virtual Time GetTrainingDuration (const WifiTxVector& txVector,
131  uint8_t nDataLtf, uint8_t nExtensionLtf = 0) const;
135  virtual Time GetHtSigDuration (void) const;
136 
140  static void InitializeModes (void);
148  static WifiMode GetHtMcs (uint8_t index);
149 
155  static WifiMode GetHtMcs0 (void);
161  static WifiMode GetHtMcs1 (void);
167  static WifiMode GetHtMcs2 (void);
173  static WifiMode GetHtMcs3 (void);
179  static WifiMode GetHtMcs4 (void);
185  static WifiMode GetHtMcs5 (void);
191  static WifiMode GetHtMcs6 (void);
197  static WifiMode GetHtMcs7 (void);
203  static WifiMode GetHtMcs8 (void);
209  static WifiMode GetHtMcs9 (void);
215  static WifiMode GetHtMcs10 (void);
221  static WifiMode GetHtMcs11 (void);
227  static WifiMode GetHtMcs12 (void);
233  static WifiMode GetHtMcs13 (void);
239  static WifiMode GetHtMcs14 (void);
245  static WifiMode GetHtMcs15 (void);
251  static WifiMode GetHtMcs16 (void);
257  static WifiMode GetHtMcs17 (void);
263  static WifiMode GetHtMcs18 (void);
269  static WifiMode GetHtMcs19 (void);
275  static WifiMode GetHtMcs20 (void);
281  static WifiMode GetHtMcs21 (void);
287  static WifiMode GetHtMcs22 (void);
293  static WifiMode GetHtMcs23 (void);
299  static WifiMode GetHtMcs24 (void);
305  static WifiMode GetHtMcs25 (void);
311  static WifiMode GetHtMcs26 (void);
317  static WifiMode GetHtMcs27 (void);
323  static WifiMode GetHtMcs28 (void);
329  static WifiMode GetHtMcs29 (void);
335  static WifiMode GetHtMcs30 (void);
341  static WifiMode GetHtMcs31 (void);
342 
352  static WifiCodeRate GetHtCodeRate (uint8_t mcsValue);
362  static WifiCodeRate GetCodeRate (uint8_t mcsValue);
370  static uint16_t GetHtConstellationSize (uint8_t mcsValue);
380  static uint16_t GetConstellationSize (uint8_t mcsValue);
394  static uint64_t GetPhyRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss);
405  static uint64_t GetPhyRateFromTxVector (const WifiTxVector& txVector, uint16_t staId);
416  static uint64_t GetDataRateFromTxVector (const WifiTxVector& txVector, uint16_t staId);
429  static uint64_t GetDataRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss);
438  static uint64_t GetNonHtReferenceRate (uint8_t mcsValue);
448  static bool IsModeAllowed (uint16_t channelWidth, uint8_t nss);
449 
450 protected:
452  bool IsAllConfigSupported (WifiPpduField field, Ptr<const WifiPpdu> ppdu) const override;
453  bool IsConfigSupported (Ptr<const WifiPpdu> ppdu) const override;
454  Ptr<SpectrumValue> GetTxPowerSpectralDensity (double txPowerW, Ptr<const WifiPpdu> ppdu) const override;
455  uint32_t GetMaxPsduSize (void) const override;
456 
463  virtual void BuildModeList (void);
464 
469  virtual uint8_t GetNumberBccEncoders (const WifiTxVector& txVector) const;
474  virtual Time GetSymbolDuration (const WifiTxVector& txVector) const;
475 
484  static uint64_t CalculatePhyRate (WifiCodeRate codeRate, uint64_t dataRate);
498  static uint64_t CalculateNonHtReferenceRate (WifiCodeRate codeRate, uint16_t constellationSize);
505  static double GetCodeRatio (WifiCodeRate codeRate);
518  static uint64_t CalculateDataRate (double symbolDuration, uint16_t guardInterval,
519  uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier,
520  double codingRate, uint8_t nss);
525  static uint16_t GetUsableSubcarriers (uint16_t channelWidth);
526 
530 
531 private:
540 
549  static WifiMode CreateHtMcs (uint8_t index);
550 
552 
554 }; //class HtPhy
555 
556 } //namespace ns3
557 
558 #endif /* HT_PHY_H */
ns3::HtPhy::EndReceiveHtSig
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:382
ns3::PhyEntity::PpduFormats
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
Definition: phy-entity.h:477
ns3::HtPhy::GetTxPowerSpectralDensity
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
Definition: ht-phy.cc:434
ns3::HtPhy::GetHtMcs9
static WifiMode GetHtMcs9(void)
Return MCS 9 from HT MCS values.
ns3::HtPhy::BuildModeList
virtual void BuildModeList(void)
Build mode list.
Definition: ht-phy.cc:69
ns3::HtPhy::IsModeAllowed
static bool IsModeAllowed(uint16_t channelWidth, uint8_t nss)
Check whether the combination of <MCS, channel width, NSS> is allowed.
Definition: ht-phy.cc:766
ns3::HtPhy::GetHtMcs6
static WifiMode GetHtMcs6(void)
Return MCS 6 from HT MCS values.
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::HtPhy::CalculateNonHtReferenceRate
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:698
ns3::HtPhy::SetMaxSupportedMcsIndexPerSs
void SetMaxSupportedMcsIndexPerSs(uint8_t maxIndex)
Set the maximum supported MCS index per spatial stream.
Definition: ht-phy.cc:164
ns3::HtPhy::GetHtMcs11
static WifiMode GetHtMcs11(void)
Return MCS 11 from HT MCS values.
ns3::HtPhy::CreateHtMcs
static WifiMode CreateHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:546
ns3::HtPhy::GetHtMcs26
static WifiMode GetHtMcs26(void)
Return MCS 26 from HT MCS values.
ns3::HtPhy::GetHtMcs25
static WifiMode GetHtMcs25(void)
Return MCS 25 from HT MCS values.
ns3::HtPhy::GetHtMcs15
static WifiMode GetHtMcs15(void)
Return MCS 15 from HT MCS values.
ns3::HtPhy::GetPhyRateFromTxVector
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
Definition: ht-phy.cc:633
ns3::HtPhy::GetDataRate
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:663
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
ns3::HtPhy::IsMcsSupported
bool IsMcsSupported(uint8_t index) const override
Check if the WifiMode corresponding to the given MCS index is supported.
Definition: ht-phy.cc:105
ns3::WifiConstPsduMap
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition: he-frame-exchange-manager.h:43
ns3::HtPhy::~HtPhy
virtual ~HtPhy()
Destructor for HT PHY.
Definition: ht-phy.cc:63
ns3::HtPhy::GetHtMcs2
static WifiMode GetHtMcs2(void)
Return MCS 2 from HT MCS values.
ns3::HtPhy::GetHtCodeRate
static WifiCodeRate GetHtCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:563
ns3::HtPhy::GetHtMcs17
static WifiMode GetHtMcs17(void)
Return MCS 17 from HT MCS values.
ns3::HtPhy::GetHtMcs18
static WifiMode GetHtMcs18(void)
Return MCS 18 from HT MCS values.
ns3::HtPhy::HandlesMcsModes
bool HandlesMcsModes(void) const override
Check if the WifiModes handled by this PHY are MCSs.
Definition: ht-phy.cc:118
ns3::HtPhy::GetHtMcs28
static WifiMode GetHtMcs28(void)
Return MCS 28 from HT MCS values.
ns3::HtPhy::GetHtMcs23
static WifiMode GetHtMcs23(void)
Return MCS 23 from HT MCS values.
ns3::HtPhy::GetHtConstellationSize
static uint16_t GetHtConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index.
Definition: ht-phy.cc:591
ns3::HtPhy::GetLSigMode
static WifiMode GetLSigMode(void)
Definition: ht-phy.cc:146
ns3::HtPhy::InitializeModes
static void InitializeModes(void)
Initialize all HT modes.
Definition: ht-phy.cc:447
ns3::HtPhy::m_bssMembershipSelector
uint8_t m_bssMembershipSelector
the BSS membership selector
Definition: ht-phy.h:529
ns3::HtPhy::GetDataRateFromTxVector
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
Definition: ht-phy.cc:654
ns3::HtPhy::GetHtMcs
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
Definition: ht-phy.cc:456
ns3::HtPhy::m_maxMcsIndexPerSs
uint8_t m_maxMcsIndexPerSs
the maximum MCS index per spatial stream as defined by the standard
Definition: ht-phy.h:527
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::WifiCodeRate
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
Definition: wifi-phy-common.h:45
ns3::HtPhy::GetHtMcs20
static WifiMode GetHtMcs20(void)
Return MCS 20 from HT MCS values.
ns3::HtPhy::GetPpduFormats
const PpduFormats & GetPpduFormats(void) const override
Return the PPDU formats of the PHY.
Definition: ht-phy.cc:124
ns3::HtPhy::m_maxSupportedMcsIndexPerSs
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
Definition: ht-phy.h:528
ns3::WifiMode
represent a single transmission mode
Definition: wifi-mode.h:48
ns3::HtPhy::IsAllConfigSupported
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:407
ns3::PhyEntity::PhyFieldRxStatus
Status of the reception of the PPDU field.
Definition: phy-entity.h:111
ns3::HtPhy::GetHtMcs7
static WifiMode GetHtMcs7(void)
Return MCS 7 from HT MCS values.
ns3::HtPhy::GetPhyRate
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:619
ns3::HtPhy::GetNonHtReferenceRate
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:690
ns3::HtPhy::GetMcs
WifiMode GetMcs(uint8_t index) const override
Get the WifiMode corresponding to the given MCS index.
Definition: ht-phy.cc:89
ns3::HtPhy::GetHtMcs22
static WifiMode GetHtMcs22(void)
Return MCS 22 from HT MCS values.
ns3::HtPhy::GetCodeRate
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:569
ns3::HtPhy::CalculateDataRate
static uint64_t CalculateDataRate(double symbolDuration, uint16_t guardInterval, uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier, double codingRate, uint8_t nss)
Calculates data rate from the supplied parameters.
Definition: ht-phy.cc:674
ns3::HtPhy::GetHtSigMode
virtual WifiMode GetHtSigMode(void) const
Definition: ht-phy.cc:152
ns3::HtPhy::GetHtMcs13
static WifiMode GetHtMcs13(void)
Return MCS 13 from HT MCS values.
ns3::HtPhy::GetDuration
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:199
ns3::HtPhy::GetHtMcs16
static WifiMode GetHtMcs16(void)
Return MCS 16 from HT MCS values.
ns3::HtPhy::GetBssMembershipSelector
uint8_t GetBssMembershipSelector(void) const
Definition: ht-phy.cc:158
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::HtPhy::GetHtMcs24
static WifiMode GetHtMcs24(void)
Return MCS 24 from HT MCS values.
ns3::HtPhy::GetUsableSubcarriers
static uint16_t GetUsableSubcarriers(uint16_t channelWidth)
Definition: ht-phy.cc:684
ns3::HtPhy::GetHtMcs4
static WifiMode GetHtMcs4(void)
Return MCS 4 from HT MCS values.
ns3::WifiPpduField
WifiPpduField
The type of PPDU field (grouped for convenience)
Definition: wifi-phy-common.h:171
ns3::HtPhy::GetHtMcs29
static WifiMode GetHtMcs29(void)
Return MCS 29 from HT MCS values.
ns3::HtPhy::m_htPpduFormats
static const PpduFormats m_htPpduFormats
HT PPDU formats.
Definition: ht-phy.h:553
ns3::OfdmPhy
PHY entity for OFDM (11a)
Definition: ofdm-phy.h:61
ns3::HtPhy::GetSigMode
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:130
ns3::HtPhy::GetHtSigDuration
virtual Time GetHtSigDuration(void) const
Definition: ht-phy.cc:255
ns3::WifiPreamble
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-phy-common.h:68
ns3::HtPhy::GetHtMcs14
static WifiMode GetHtMcs14(void)
Return MCS 14 from HT MCS values.
ns3::HtPhy::CalculatePhyRate
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:627
ns3::HtPhy::GetNumberBccEncoders
virtual uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const
Definition: ht-phy.cc:335
ns3::HtPhy::GetHtMcs8
static WifiMode GetHtMcs8(void)
Return MCS 8 from HT MCS values.
ns3::HtPhy::GetHtMcs3
static WifiMode GetHtMcs3(void)
Return MCS 3 from HT MCS values.
ns3::HtPhy::GetHtMcs27
static WifiMode GetHtMcs27(void)
Return MCS 27 from HT MCS values.
ns3::HtPhy::GetHtMcs5
static WifiMode GetHtMcs5(void)
Return MCS 5 from HT MCS values.
ns3::HtPhy::GetHtMcs31
static WifiMode GetHtMcs31(void)
Return MCS 31 from HT MCS values.
ns3::HtPhy::DoEndReceiveField
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:365
ns3::HtPhy::m_maxSupportedNss
uint8_t m_maxSupportedNss
Maximum supported number of spatial streams (used to build HT MCS indices)
Definition: ht-phy.h:551
ns3::HtPhy::GetMaxPsduSize
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
Definition: ht-phy.cc:772
ns3::HtPhy::GetHtMcs21
static WifiMode GetHtMcs21(void)
Return MCS 21 from HT MCS values.
ns3::HtPhy::GetConstellationSize
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:597
ns3::HtPhy::GetHtMcs10
static WifiMode GetHtMcs10(void)
Return MCS 10 from HT MCS values.
ns3::HtPhy::GetCodeRatio
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:642
ns3::WifiPhyBand
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:33
ns3::HtPhy::BuildPpdu
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Definition: ht-phy.cc:357
ns3::HtPhy::GetMaxSupportedMcsIndexPerSs
uint8_t GetMaxSupportedMcsIndexPerSs(void) const
Set the maximum supported MCS index per spatial stream.
Definition: ht-phy.cc:178
ns3::HtPhy::GetLSigDuration
virtual Time GetLSigDuration(WifiPreamble preamble) const
Definition: ht-phy.cc:239
ns3::HtPhy
PHY entity for HT (11n)
Definition: ht-phy.h:51
ns3::HtPhy::GetHtMcs12
static WifiMode GetHtMcs12(void)
Return MCS 12 from HT MCS values.
ns3::HtPhy::GetPayloadDuration
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:261
ns3::HtPhy::HtPhy
HtPhy(uint8_t maxNss=1, bool buildModeList=true)
Constructor for HT PHY.
Definition: ht-phy.cc:48
ns3::HtPhy::GetHtMcs30
static WifiMode GetHtMcs30(void)
Return MCS 30 from HT MCS values.
ns3::HtPhy::GetSymbolDuration
virtual Time GetSymbolDuration(const WifiTxVector &txVector) const
Definition: ht-phy.cc:349
ns3::HtPhy::GetHtMcs0
static WifiMode GetHtMcs0(void)
Return MCS 0 from HT MCS values.
ns3::HtPhy::GetTrainingDuration
virtual Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const
Definition: ht-phy.cc:245
ns3::HtPhy::IsConfigSupported
bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
Definition: ht-phy.cc:417
ns3::HtPhy::GetHtMcs19
static WifiMode GetHtMcs19(void)
Return MCS 19 from HT MCS values.
ns3::HtPhy::SetMaxSupportedNss
void SetMaxSupportedNss(uint8_t maxNss)
Configure the maximum number of spatial streams supported by this HT PHY.
Definition: ht-phy.cc:184
ns3::MpduType
MpduType
The type of an MPDU.
Definition: wifi-mpdu-type.h:31
ns3::HtPhy::GetHtMcs1
static WifiMode GetHtMcs1(void)
Return MCS 1 from HT MCS values.