A Discrete-Event Network Simulator
API
ofdm-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  * Mathieu Lacage <mathieu.lacage@sophia.inria.fr> (for logic ported from wifi-phy)
21  */
22 
23 #ifndef OFDM_PHY_H
24 #define OFDM_PHY_H
25 
26 #include "ns3/phy-entity.h"
27 
35 namespace ns3 {
36 
44 {
48 };
49 
60 class OfdmPhy : public PhyEntity
61 {
62 public:
70  OfdmPhy (OfdmPhyVariant variant = OFDM_PHY_DEFAULT, bool buildModeList = true);
74  virtual ~OfdmPhy ();
75 
76  WifiMode GetSigMode (WifiPpduField field, const WifiTxVector& txVector) const override;
77  const PpduFormats & GetPpduFormats (void) const override;
78  Time GetDuration (WifiPpduField field, const WifiTxVector& txVector) const override;
79  Time GetPayloadDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, MpduType mpdutype,
80  bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols,
81  uint16_t staId) const override;
82  Ptr<WifiPpdu> BuildPpdu (const WifiConstPsduMap & psdus, const WifiTxVector& txVector, Time ppduDuration) override;
83 
87  static void InitializeModes (void);
97  static WifiMode GetOfdmRate (uint64_t rate, uint16_t bw = 20);
103  static WifiMode GetOfdmRate6Mbps (void);
109  static WifiMode GetOfdmRate9Mbps (void);
242 
251  static WifiCodeRate GetCodeRate (const std::string& name);
260  static uint16_t GetConstellationSize (const std::string& name);
273  static uint64_t GetPhyRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss);
274 
285  static uint64_t GetPhyRateFromTxVector (const WifiTxVector& txVector, uint16_t staId);
296  static uint64_t GetDataRateFromTxVector (const WifiTxVector& txVector, uint16_t staId);
309  static uint64_t GetDataRate (const std::string& name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss);
319  static bool IsModeAllowed (uint16_t channelWidth, uint8_t nss);
320 
321 protected:
323  Ptr<SpectrumValue> GetTxPowerSpectralDensity (double txPowerW, Ptr<const WifiPpdu> ppdu) const override;
324  uint32_t GetMaxPsduSize (void) const override;
325 
330  virtual WifiMode GetHeaderMode (const WifiTxVector& txVector) const;
331 
338  virtual Time GetPreambleDuration (const WifiTxVector& txVector) const;
343  virtual Time GetHeaderDuration (const WifiTxVector& txVector) const;
344 
348  uint8_t GetNumberServiceBits (void) const;
353  Time GetSignalExtension (WifiPhyBand band) const;
354 
363 
370  virtual bool IsChannelWidthSupported (Ptr<const WifiPpdu> ppdu) const;
379  virtual bool IsAllConfigSupported (WifiPpduField field, Ptr<const WifiPpdu> ppdu) const;
380 
388  static uint64_t CalculatePhyRate (WifiCodeRate codeRate, uint64_t dataRate);
395  static double GetCodeRatio (WifiCodeRate codeRate);
407  static uint64_t CalculateDataRate (WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth,
408  uint16_t guardInterval, uint8_t nss);
420  static uint64_t CalculateDataRate (double symbolDuration, uint16_t guardInterval,
421  uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier,
422  double codingRate);
423 
424 private:
434  static WifiMode CreateOfdmMode (std::string uniqueName, bool isMandatory);
435 
437 
439 }; //class OfdmPhy
440 
441 } //namespace ns3
442 
443 #endif /* OFDM_PHY_H */
ns3::OfdmPhy::GetOfdmRate24MbpsBW10MHz
static WifiMode GetOfdmRate24MbpsBW10MHz(void)
Return a WifiMode for OFDM at 24 Mbps with 10 MHz channel spacing.
ns3::OfdmPhy::GetOfdmRate12Mbps
static WifiMode GetOfdmRate12Mbps(void)
Return a WifiMode for OFDM at 12Mbps.
ns3::OfdmPhy::GetOfdmRate2_25MbpsBW5MHz
static WifiMode GetOfdmRate2_25MbpsBW5MHz(void)
Return a WifiMode for OFDM at 2.25 Mbps with 5 MHz channel spacing.
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::OfdmPhy::GetOfdmRate13_5MbpsBW5MHz
static WifiMode GetOfdmRate13_5MbpsBW5MHz(void)
Return a WifiMode for OFDM at 13.5 Mbps with 5 MHz channel spacing.
ns3::OfdmPhy::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: ofdm-phy.cc:282
ns3::OFDM_PHY_5_MHZ
@ OFDM_PHY_5_MHZ
Definition: ofdm-phy.h:47
ns3::OfdmPhy::IsAllConfigSupported
virtual bool IsAllConfigSupported(WifiPpduField field, Ptr< const WifiPpdu > ppdu) const
Checks if the signaled configuration (including bandwidth) is supported by the PHY.
Definition: ofdm-phy.cc:329
ns3::OfdmPhy::OfdmPhy
OfdmPhy(OfdmPhyVariant variant=OFDM_PHY_DEFAULT, bool buildModeList=true)
Constructor for OFDM PHY.
Definition: ofdm-phy.cc:100
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::OfdmPhy::CalculatePhyRate
static uint64_t CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate)
Calculate the PHY rate in bps from code rate and data rate.
Definition: ofdm-phy.cc:523
ns3::OfdmPhy::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: ofdm-phy.cc:538
ns3::OfdmPhy::GetPhyRate
static uint64_t GetPhyRate(const std::string &name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the PHY rate from the OFDM mode's unique name and the supplied parameters.
Definition: ofdm-phy.cc:515
ns3::OfdmPhy::GetOfdmRate6MbpsBW10MHz
static WifiMode GetOfdmRate6MbpsBW10MHz(void)
Return a WifiMode for OFDM at 6 Mbps with 10 MHz channel spacing.
ns3::OfdmPhy::GetOfdmRate1_5MbpsBW5MHz
static WifiMode GetOfdmRate1_5MbpsBW5MHz(void)
Return a WifiMode for OFDM at 1.5 Mbps with 5 MHz channel spacing.
ns3::OfdmPhy::GetOfdmRate9MbpsBW10MHz
static WifiMode GetOfdmRate9MbpsBW10MHz(void)
Return a WifiMode for OFDM at 9 Mbps with 10 MHz channel spacing.
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::OfdmPhy::GetDataRateFromTxVector
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
Definition: ofdm-phy.cc:556
ns3::OfdmPhy::GetOfdmRate9MbpsBW5MHz
static WifiMode GetOfdmRate9MbpsBW5MHz(void)
Return a WifiMode for OFDM at 9 Mbps with 5 MHz channel spacing.
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::OfdmPhy::GetNumberServiceBits
uint8_t GetNumberServiceBits(void) const
Definition: ofdm-phy.cc:262
ns3::OfdmPhy::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: ofdm-phy.cc:242
ns3::OfdmPhy::GetOfdmRate12MbpsBW10MHz
static WifiMode GetOfdmRate12MbpsBW10MHz(void)
Return a WifiMode for OFDM at 12 Mbps with 10 MHz channel spacing.
ns3::OfdmPhy::GetOfdmRate6Mbps
static WifiMode GetOfdmRate6Mbps(void)
Return a WifiMode for OFDM at 6 Mbps.
ns3::OfdmPhy::GetHeaderDuration
virtual Time GetHeaderDuration(const WifiTxVector &txVector) const
Definition: ofdm-phy.cc:219
ns3::OfdmPhy::GetOfdmRate36Mbps
static WifiMode GetOfdmRate36Mbps(void)
Return a WifiMode for OFDM at 36 Mbps.
ns3::OfdmPhy::GetSignalExtension
Time GetSignalExtension(WifiPhyBand band) const
Definition: ofdm-phy.cc:268
ns3::OfdmPhy::GetPreambleDuration
virtual Time GetPreambleDuration(const WifiTxVector &txVector) const
Definition: ofdm-phy.cc:198
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::OfdmPhy::GetOfdmRate9Mbps
static WifiMode GetOfdmRate9Mbps(void)
Return a WifiMode for OFDM at 9 Mbps.
ns3::OfdmPhy::GetOfdmRate6MbpsBW5MHz
static WifiMode GetOfdmRate6MbpsBW5MHz(void)
Return a WifiMode for OFDM at 6 Mbps with 5 MHz channel spacing.
ns3::OfdmPhyVariant
OfdmPhyVariant
The OFDM (11a) PHY variants.
Definition: ofdm-phy.h:44
ns3::OfdmPhy::EndReceiveHeader
PhyFieldRxStatus EndReceiveHeader(Ptr< Event > event)
End receiving the header, perform OFDM-specific actions, and provide the status of the reception.
Definition: ofdm-phy.cc:293
ns3::OfdmPhy::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: ofdm-phy.cc:184
ns3::WifiMode
represent a single transmission mode
Definition: wifi-mode.h:48
ns3::OfdmPhy::GetPhyRateFromTxVector
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
Definition: ofdm-phy.cc:529
ns3::PhyEntity::PhyFieldRxStatus
Status of the reception of the PPDU field.
Definition: phy-entity.h:111
ns3::OfdmPhy::m_ofdmPpduFormats
static const PpduFormats m_ofdmPpduFormats
OFDM PPDU formats.
Definition: ofdm-phy.h:436
ns3::OfdmPhy::GetOfdmRate27MbpsBW10MHz
static WifiMode GetOfdmRate27MbpsBW10MHz(void)
Return a WifiMode for OFDM at 27 Mbps with 10 MHz channel spacing.
ns3::OfdmPhy::GetOfdmRate3MbpsBW10MHz
static WifiMode GetOfdmRate3MbpsBW10MHz(void)
Return a WifiMode for OFDM at 3 Mbps with 10 MHz channel spacing.
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::OfdmPhy::CreateOfdmMode
static WifiMode CreateOfdmMode(std::string uniqueName, bool isMandatory)
Create an OFDM mode from a unique name, the unique name must already be contained inside ModulationLo...
Definition: ofdm-phy.cc:484
ns3::OfdmPhy::GetConstellationSize
static uint16_t GetConstellationSize(const std::string &name)
Return the constellation size from the OFDM mode's unique name using ModulationLookupTable.
Definition: ofdm-phy.cc:509
ns3::WifiPpduField
WifiPpduField
The type of PPDU field (grouped for convenience)
Definition: wifi-phy-common.h:171
ns3::OfdmPhy::InitializeModes
static void InitializeModes(void)
Initialize all OFDM modes (for all variants).
Definition: ofdm-phy.cc:352
ns3::OfdmPhy
PHY entity for OFDM (11a)
Definition: ofdm-phy.h:61
ns3::OfdmPhy::GetOfdmRate48Mbps
static WifiMode GetOfdmRate48Mbps(void)
Return a WifiMode for OFDM at 48 Mbps.
ns3::OfdmPhy::IsChannelWidthSupported
virtual bool IsChannelWidthSupported(Ptr< const WifiPpdu > ppdu) const
Checks if the PPDU's bandwidth is supported by the PHY.
Definition: ofdm-phy.cc:317
ns3::OfdmPhy::GetPpduFormats
const PpduFormats & GetPpduFormats(void) const override
Return the PPDU formats of the PHY.
Definition: ofdm-phy.cc:178
ns3::OfdmPhy::~OfdmPhy
virtual ~OfdmPhy()
Destructor for OFDM PHY.
Definition: ofdm-phy.cc:140
ns3::OfdmPhy::CalculateDataRate
static uint64_t CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Calculates data rate from the supplied parameters.
Definition: ofdm-phy.cc:573
ns3::OfdmPhy::GetOfdmRate3MbpsBW5MHz
static WifiMode GetOfdmRate3MbpsBW5MHz(void)
Return a WifiMode for OFDM at 3 Mbps with 5 MHz channel spacing.
ns3::OfdmPhy::BuildPpdu
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Definition: ofdm-phy.cc:274
ns3::OfdmPhy::GetOfdmRate4_5MbpsBW10MHz
static WifiMode GetOfdmRate4_5MbpsBW10MHz(void)
Return a WifiMode for OFDM at 4.5 Mbps with 10 MHz channel spacing.
ns3::OfdmPhy::m_ofdmModulationLookupTable
static const ModulationLookupTable m_ofdmModulationLookupTable
lookup table to retrieve code rate and constellation size corresponding to a unique name of modulatio...
Definition: ofdm-phy.h:438
ns3::OfdmPhy::GetOfdmRate
static WifiMode GetOfdmRate(uint64_t rate, uint16_t bw=20)
Return a WifiMode for OFDM corresponding to the provided rate and the channel bandwidth (20,...
Definition: ofdm-phy.cc:364
ns3::OfdmPhy::GetOfdmRate24Mbps
static WifiMode GetOfdmRate24Mbps(void)
Return a WifiMode for OFDM at 24 Mbps.
ns3::OfdmPhy::GetOfdmRate54Mbps
static WifiMode GetOfdmRate54Mbps(void)
Return a WifiMode for OFDM at 54 Mbps.
ns3::PhyEntity::ModulationLookupTable
std::map< std::string, CodeRateConstellationSizePair > ModulationLookupTable
A modulation lookup table using unique name of modulation as key.
Definition: phy-entity.h:487
ns3::OFDM_PHY_DEFAULT
@ OFDM_PHY_DEFAULT
Definition: ofdm-phy.h:45
ns3::OfdmPhy::GetHeaderMode
virtual WifiMode GetHeaderMode(const WifiTxVector &txVector) const
Definition: ofdm-phy.cc:159
ns3::OfdmPhy::GetOfdmRate18MbpsBW10MHz
static WifiMode GetOfdmRate18MbpsBW10MHz(void)
Return a WifiMode for OFDM at 18 Mbps with 10 MHz channel spacing.
ns3::OfdmPhy::GetOfdmRate4_5MbpsBW5MHz
static WifiMode GetOfdmRate4_5MbpsBW5MHz(void)
Return a WifiMode for OFDM at 4.5 Mbps with 5 MHz channel spacing.
ns3::OFDM_PHY_10_MHZ
@ OFDM_PHY_10_MHZ
Definition: ofdm-phy.h:46
ns3::OfdmPhy::GetOfdmRate18Mbps
static WifiMode GetOfdmRate18Mbps(void)
Return a WifiMode for OFDM at 18 Mbps.
ns3::OfdmPhy::GetDataRate
static uint64_t GetDataRate(const std::string &name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the data rate from the OFDM mode's unique name and the supplied parameters.
Definition: ofdm-phy.cc:565
ns3::OfdmPhy::GetSigMode
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
Definition: ofdm-phy.cc:146
ns3::WifiPhyBand
WifiPhyBand
Identifies the PHY band.
Definition: wifi-phy-band.h:33
ns3::OfdmPhy::GetTxPowerSpectralDensity
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
Definition: ofdm-phy.cc:339
ns3::PhyEntity
Abstract class for PHY entities.
Definition: phy-entity.h:94
ns3::OfdmPhy::GetCodeRate
static WifiCodeRate GetCodeRate(const std::string &name)
Return the WifiCodeRate from the OFDM mode's unique name using ModulationLookupTable.
Definition: ofdm-phy.cc:503
ns3::OfdmPhy::IsModeAllowed
static bool IsModeAllowed(uint16_t channelWidth, uint8_t nss)
Check whether the combination of <WifiMode, channel width, NSS> is allowed.
Definition: ofdm-phy.cc:602
ns3::MpduType
MpduType
The type of an MPDU.
Definition: wifi-mpdu-type.h:31
ns3::OfdmPhy::GetMaxPsduSize
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
Definition: ofdm-phy.cc:608
ns3::OfdmPhy::GetOfdmRate12MbpsBW5MHz
static WifiMode GetOfdmRate12MbpsBW5MHz(void)
Return a WifiMode for OFDM at 12 Mbps with 5 MHz channel spacing.