A Discrete-Event Network Simulator
API
he-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 and spectrum-wifi-phy)
20  */
21 
22 #ifndef HE_PHY_H
23 #define HE_PHY_H
24 
25 #include "ns3/vht-phy.h"
26 #include "ns3/wifi-phy-band.h"
27 #include "ns3/callback.h"
28 
36 namespace ns3 {
37 
41 #define HE_PHY 125
42 
47 {
48  double rssiW;
49  uint8_t bssColor;
50 };
51 
60 class HePhy : public VhtPhy
61 {
62 public:
69 
76  HePhy (bool buildModeList = true);
80  virtual ~HePhy ();
81 
82  WifiMode GetSigMode (WifiPpduField field, const WifiTxVector& txVector) const override;
83  WifiMode GetSigAMode (void) const override;
84  WifiMode GetSigBMode (const WifiTxVector& txVector) const override;
85  const PpduFormats & GetPpduFormats (void) const override;
86  Time GetLSigDuration (WifiPreamble preamble) const override;
87  Time GetTrainingDuration (const WifiTxVector& txVector,
88  uint8_t nDataLtf,
89  uint8_t nExtensionLtf = 0) const override;
90  Time GetSigADuration (WifiPreamble preamble) const override;
91  Time GetSigBDuration (const WifiTxVector& txVector) const override;
93  const WifiTxVector& txVector,
94  Time ppduDuration) override;
97  RxPowerWattPerChannelBand& rxPowersW,
98  Time rxDuration) override;
99  void CancelAllEvents (void) override;
100  uint16_t GetStaId (const Ptr<const WifiPpdu> ppdu) const override;
101  uint16_t GetMeasurementChannelWidth (const Ptr<const WifiPpdu> ppdu) const override;
102  void StartTx (Ptr<WifiPpdu> ppdu) override;
103  Time CalculateTxDuration (WifiConstPsduMap psduMap, const WifiTxVector& txVector, WifiPhyBand band) const override;
104 
108  uint8_t GetBssColor (void) const;
109 
121  static std::pair<uint16_t, Time> ConvertHeTbPpduDurationToLSigLength (Time ppduDuration,
122  const WifiTxVector& txVector,
123  WifiPhyBand band);
131  static Time ConvertLSigLengthToHeTbPpduDuration (uint16_t length, const WifiTxVector& txVector, WifiPhyBand band);
137  Time CalculateNonOfdmaDurationForHeTb (const WifiTxVector& txVector) const;
138 
148  WifiSpectrumBand GetRuBandForTx (const WifiTxVector& txVector, uint16_t staId) const;
158  WifiSpectrumBand GetRuBandForRx (const WifiTxVector& txVector, uint16_t staId) const;
167  WifiSpectrumBand GetNonOfdmaBand (const WifiTxVector& txVector, uint16_t staId) const;
174  uint16_t GetNonOfdmaWidth (HeRu::RuSpec ru) const;
175 
179  uint64_t GetCurrentHeTbPpduUid (void) const;
180 
188  void SetTrigVector (const WifiTxVector& trigVector, Time validity);
189 
199  uint16_t GetCenterFrequencyForNonOfdmaPart (const WifiTxVector& txVector, uint16_t staId) const;
200 
207 
215  void NotifyEndOfHeSigA (HeSigAParameters params);
216 
220  static void InitializeModes (void);
228  static WifiMode GetHeMcs (uint8_t index);
229 
235  static WifiMode GetHeMcs0 (void);
241  static WifiMode GetHeMcs1 (void);
247  static WifiMode GetHeMcs2 (void);
253  static WifiMode GetHeMcs3 (void);
259  static WifiMode GetHeMcs4 (void);
265  static WifiMode GetHeMcs5 (void);
271  static WifiMode GetHeMcs6 (void);
277  static WifiMode GetHeMcs7 (void);
283  static WifiMode GetHeMcs8 (void);
289  static WifiMode GetHeMcs9 (void);
295  static WifiMode GetHeMcs10 (void);
301  static WifiMode GetHeMcs11 (void);
302 
311  static WifiCodeRate GetCodeRate (uint8_t mcsValue);
320  static uint16_t GetConstellationSize (uint8_t mcsValue);
334  static uint64_t GetPhyRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss);
343  static uint64_t GetPhyRateFromTxVector (const WifiTxVector& txVector, uint16_t staId = SU_STA_ID);
352  static uint64_t GetDataRateFromTxVector (const WifiTxVector& txVector, uint16_t staId = SU_STA_ID);
365  static uint64_t GetDataRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss);
374  static uint64_t GetNonHtReferenceRate (uint8_t mcsValue);
382  static bool IsAllowed (const WifiTxVector& txVector);
383 
384 protected:
385  PhyFieldRxStatus ProcessSigA (Ptr<Event> event, PhyFieldRxStatus status) override;
386  PhyFieldRxStatus ProcessSigB (Ptr<Event> event, PhyFieldRxStatus status) override;
388  bool IsConfigSupported (Ptr<const WifiPpdu> ppdu) const override;
389  void DoStartReceivePayload (Ptr<Event> event) override;
390  std::pair<uint16_t, WifiSpectrumBand> GetChannelWidthAndBand (const WifiTxVector& txVector, uint16_t staId) const override;
391  void DoEndReceivePayload (Ptr<const WifiPpdu> ppdu) override;
392  void DoResetReceive (Ptr<Event> event) override;
393  void DoAbortCurrentReception (WifiPhyRxfailureReason reason) override;
394  uint64_t ObtainNextUid (const WifiTxVector& txVector) override;
395  Ptr<SpectrumValue> GetTxPowerSpectralDensity (double txPowerW, Ptr<const WifiPpdu> ppdu) const override;
396  uint32_t GetMaxPsduSize (void) const override;
397  WifiConstPsduMap GetWifiConstPsduMap (Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector) const override;
398 
406 
420  static uint64_t CalculateNonHtReferenceRate (WifiCodeRate codeRate, uint16_t constellationSize);
425  static uint16_t GetUsableSubcarriers (uint16_t channelWidth);
426 
429 
430  std::map <uint16_t /* STA-ID */, EventId> m_beginOfdmaPayloadRxEvents;
431 
435 
436 private:
437  void BuildModeList (void) override;
438  uint8_t GetNumberBccEncoders (const WifiTxVector& txVector) const override;
439  Time GetSymbolDuration (const WifiTxVector& txVector) const override;
440 
449  static WifiMode CreateHeMcs (uint8_t index);
450 
461  static Time GetValidPpduDuration (Time ppduDuration, const WifiTxVector& txVector,
462  WifiPhyBand band);
463 
465 }; //class HePhy
466 
467 } //namespace ns3
468 
469 #endif /* HE_PHY_H */
An identifier for simulation events.
Definition: event-id.h:54
PHY entity for HE (11ax)
Definition: he-phy.h:61
const PpduFormats & GetPpduFormats(void) const override
Return the PPDU formats of the PHY.
Definition: he-phy.cc:167
PhyFieldRxStatus ProcessSigA(Ptr< Event > event, PhyFieldRxStatus status) override
Process SIG-A, perform amendment-specific actions, and provide an updated status of the reception.
Definition: he-phy.cc:522
static WifiMode GetHeMcs10(void)
Return MCS 10 from HE MCS values.
Time GetLSigDuration(WifiPreamble preamble) const override
Definition: he-phy.cc:173
static Time ConvertLSigLengthToHeTbPpduDuration(uint16_t length, const WifiTxVector &txVector, WifiPhyBand band)
Definition: he-phy.cc:287
void StartReceiveOfdmaPayload(Ptr< Event > event)
Start receiving the PSDU (i.e.
Definition: he-phy.cc:738
WifiMode GetSigAMode(void) const override
Definition: he-phy.cc:128
static WifiMode GetHeMcs5(void)
Return MCS 5 from HE MCS values.
Ptr< Event > DoGetEvent(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW) override
Get the event corresponding to the incoming PPDU.
Definition: he-phy.cc:434
static WifiMode GetHeMcs4(void)
Return MCS 4 from HE MCS values.
Time GetSymbolDuration(const WifiTxVector &txVector) const override
Definition: he-phy.cc:314
WifiSpectrumBand GetNonOfdmaBand(const WifiTxVector &txVector, uint16_t staId) const
Get the band used to transmit the non-OFDMA part of an HE TB PPDU.
Definition: he-phy.cc:823
static WifiMode GetHeMcs3(void)
Return MCS 3 from HE MCS values.
void StartReceivePreamble(Ptr< WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration) override
Start receiving the PHY preamble of a PPDU (i.e.
Definition: he-phy.cc:349
void DoAbortCurrentReception(WifiPhyRxfailureReason reason) override
Perform amendment-specific actions before aborting the current reception.
Definition: he-phy.cc:401
static WifiMode GetHeMcs8(void)
Return MCS 8 from HE MCS values.
uint64_t m_currentHeTbPpduUid
UID of the HE TB PPDU being received.
Definition: he-phy.h:428
Time CalculateTxDuration(WifiConstPsduMap psduMap, const WifiTxVector &txVector, WifiPhyBand band) const override
Definition: he-phy.cc:977
std::pair< uint16_t, WifiSpectrumBand > GetChannelWidthAndBand(const WifiTxVector &txVector, uint16_t staId) const override
Get the channel width and band to use (will be overloaded by child classes).
Definition: he-phy.cc:775
uint8_t GetBssColor(void) const
Definition: he-phy.cc:489
Time GetSigBDuration(const WifiTxVector &txVector) const override
Definition: he-phy.cc:205
static WifiMode CreateHeMcs(uint8_t index)
Create and return the HE MCS corresponding to the provided index.
Definition: he-phy.cc:1065
static WifiMode GetHeMcs(uint8_t index)
Return the HE MCS corresponding to the provided index.
Definition: he-phy.cc:1015
static uint16_t GetUsableSubcarriers(uint16_t channelWidth)
Definition: he-phy.cc:1155
WifiConstPsduMap GetWifiConstPsduMap(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector) const override
Get a WifiConstPsduMap from a PSDU and the TXVECTOR to use to send the PSDU.
Definition: he-phy.cc:1214
uint16_t GetNonOfdmaWidth(HeRu::RuSpec ru) const
Get the width in MHz of the non-OFDMA portion of an HE TB PPDU.
Definition: he-phy.cc:843
void BuildModeList(void) override
Build mode list.
Definition: he-phy.cc:93
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: he-phy.cc:1186
void StartTx(Ptr< WifiPpdu > ppdu) override
This function is called by SpectrumWifiPhy to send the PPDU while performing amendment-specific actio...
Definition: he-phy.cc:954
std::map< uint16_t, EventId > m_beginOfdmaPayloadRxEvents
the beginning of the OFDMA payload reception events (indexed by STA-ID)
Definition: he-phy.h:430
void SetEndOfHeSigACallback(EndOfHeSigACallback callback)
Set a callback for a end of HE-SIG-A.
Definition: he-phy.cc:600
Time m_trigVectorExpirationTime
expiration time of the TRIGVECTOR
Definition: he-phy.h:434
uint64_t GetCurrentHeTbPpduUid(void) const
Definition: he-phy.cc:855
uint64_t m_previouslyTxPpduUid
UID of the previously sent PPDU, used by AP to recognize response HE TB PPDUs.
Definition: he-phy.h:427
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HE MCS index.
Definition: he-phy.cc:1081
WifiSpectrumBand GetRuBandForRx(const WifiTxVector &txVector, uint16_t staId) const
Get the band in the RX spectrum associated with the RU used by the PSDU transmitted to/by a given STA...
Definition: he-phy.cc:806
PhyFieldRxStatus ProcessSigB(Ptr< Event > event, PhyFieldRxStatus status) override
Process SIG-B, perform amendment-specific actions, and provide an updated status of the reception.
Definition: he-phy.cc:615
EndOfHeSigACallback m_endOfHeSigACallback
end of HE-SIG-A callback
Definition: he-phy.h:432
Ptr< const WifiPsdu > GetAddressedPsduInPpdu(Ptr< const WifiPpdu > ppdu) const override
Get the PSDU addressed to that PHY in a PPDU (useful for MU PPDU).
Definition: he-phy.cc:477
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
Definition: he-phy.cc:106
uint64_t ObtainNextUid(const WifiTxVector &txVector) override
Obtain the next UID for the PPDU to transmit.
Definition: he-phy.cc:879
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
Definition: he-phy.cc:1228
WifiTxVector m_trigVector
the TRIGVECTOR
Definition: he-phy.h:433
Callback< void, HeSigAParameters > EndOfHeSigACallback
Callback upon end of HE-SIG-A.
Definition: he-phy.h:68
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId=SU_STA_ID)
Return the PHY rate corresponding to the supplied TXVECTOR for the STA-ID.
Definition: he-phy.cc:1116
void CancelAllEvents(void) override
Cancel and clear all running events.
Definition: he-phy.cc:389
static WifiMode GetHeMcs0(void)
Return MCS 0 from HE MCS values.
uint16_t GetCenterFrequencyForNonOfdmaPart(const WifiTxVector &txVector, uint16_t staId) const
Get the center frequency of the non-OFDMA part of the current TxVector for the given STA-ID.
Definition: he-phy.cc:932
static void InitializeModes(void)
Initialize all HE modes.
Definition: he-phy.cc:1006
Time CalculateNonOfdmaDurationForHeTb(const WifiTxVector &txVector) const
Definition: he-phy.cc:298
static Time GetValidPpduDuration(Time ppduDuration, const WifiTxVector &txVector, WifiPhyBand band)
Given a PPDU duration value, the TXVECTOR used to transmit the PPDU and the PHY band,...
Definition: he-phy.cc:263
uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const override
Definition: he-phy.cc:308
static WifiMode GetHeMcs6(void)
Return MCS 6 from HE MCS values.
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
Definition: he-phy.cc:1208
static WifiMode GetHeMcs2(void)
Return MCS 2 from HE MCS values.
static WifiMode GetHeMcs7(void)
Return MCS 7 from HE MCS values.
static WifiMode GetHeMcs1(void)
Return MCS 1 from HE MCS values.
static WifiMode GetHeMcs9(void)
Return MCS 9 from HE MCS values.
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Definition: he-phy.cc:330
void NotifyEndOfHeSigA(HeSigAParameters params)
Fire a EndOfHeSigA callback (if connected) once HE-SIG-A field has been received.
Definition: he-phy.cc:606
static uint64_t GetDataRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the data rate corresponding to the supplied HE MCS index, channel width, guard interval,...
Definition: he-phy.cc:1144
static uint64_t GetPhyRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the PHY rate corresponding to the supplied HE MCS index, channel width, guard interval,...
Definition: he-phy.cc:1108
virtual ~HePhy()
Destructor for HE PHY.
Definition: he-phy.cc:87
void DoStartReceivePayload(Ptr< Event > event) override
Start receiving the PSDU (i.e.
Definition: he-phy.cc:664
static const PpduFormats m_hePpduFormats
HE PPDU formats.
Definition: he-phy.h:464
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId=SU_STA_ID)
Return the data rate corresponding to the supplied TXVECTOR for the STA-ID.
Definition: he-phy.cc:1130
HePhy(bool buildModeList=true)
Constructor for HE PHY.
Definition: he-phy.cc:71
bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
Definition: he-phy.cc:631
uint16_t GetStaId(const Ptr< const WifiPpdu > ppdu) const override
Return the STA ID that has been assigned to the station this PHY belongs to.
Definition: he-phy.cc:504
void SetTrigVector(const WifiTxVector &trigVector, Time validity)
Set the TRIGVECTOR and the associated expiration time.
Definition: he-phy.cc:322
static std::pair< uint16_t, Time > ConvertHeTbPpduDurationToLSigLength(Time ppduDuration, const WifiTxVector &txVector, WifiPhyBand band)
Compute the L-SIG length value corresponding to the given HE TB PPDU duration.
Definition: he-phy.cc:274
static uint64_t GetNonHtReferenceRate(uint8_t mcsValue)
Calculate the rate in bps of the non-HT Reference Rate corresponding to the supplied HE MCS index.
Definition: he-phy.cc:1178
WifiSpectrumBand GetRuBandForTx(const WifiTxVector &txVector, uint16_t staId) const
Get the band in the TX spectrum associated with the RU used by the PSDU transmitted to/by a given STA...
Definition: he-phy.cc:789
WifiMode GetSigBMode(const WifiTxVector &txVector) const override
Definition: he-phy.cc:134
void DoEndReceivePayload(Ptr< const WifiPpdu > ppdu) override
Perform amendment-specific actions at the end of the reception of the payload.
Definition: he-phy.cc:708
void DoResetReceive(Ptr< Event > event) override
Perform amendment-specific actions before resetting PHY at the end of the PPDU under reception after ...
Definition: he-phy.cc:419
static WifiMode GetHeMcs11(void)
Return MCS 11 from HE MCS values.
Time GetSigADuration(WifiPreamble preamble) const override
Definition: he-phy.cc:199
Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const override
Definition: he-phy.cc:179
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
Definition: he-phy.cc:899
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const override
Return the channel width used to measure the RSSI.
Definition: he-phy.cc:861
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HE MCS index.
Definition: he-phy.cc:1095
RU Specification.
Definition: he-ru.h:68
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
Definition: phy-entity.h:477
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
PHY entity for VHT (11ac)
Definition: vht-phy.h:49
represent a single transmission mode
Definition: wifi-mode.h:48
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
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)
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.
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:75
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
Parameters for received HE-SIG-A for OBSS_PD based SR.
Definition: he-phy.h:47
uint8_t bssColor
BSS color.
Definition: he-phy.h:49
double rssiW
RSSI in W.
Definition: he-phy.h:48
Status of the reception of the PPDU field.
Definition: phy-entity.h:111
#define SU_STA_ID
Definition: wifi-mode.h:32