A Discrete-Event Network Simulator
API
eht-phy.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 DERONNE SOFTWARE ENGINEERING
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 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
18 */
19
20#include "eht-phy.h"
21
22#include "eht-ppdu.h"
23
24#include "ns3/interference-helper.h"
25#include "ns3/wifi-phy.h"
26#include "ns3/wifi-psdu.h"
27#include "ns3/wifi-utils.h"
28
29namespace ns3
30{
31
33
34/*******************************************************
35 * EHT PHY (P802.11be/D1.5)
36 *******************************************************/
37
38// clang-format off
39
42 WIFI_PPDU_FIELD_NON_HT_HEADER, // L-SIG + RL-SIG
43 WIFI_PPDU_FIELD_U_SIG, // U-SIG
44 WIFI_PPDU_FIELD_EHT_SIG, // EHT-SIG
45 WIFI_PPDU_FIELD_TRAINING, // EHT-STF + EHT-LTFs
48 WIFI_PPDU_FIELD_NON_HT_HEADER, // L-SIG + RL-SIG
49 WIFI_PPDU_FIELD_U_SIG, // U-SIG
50 WIFI_PPDU_FIELD_TRAINING, // EHT-STF + EHT-LTFs
52};
53
54// clang-format on
55
56EhtPhy::EhtPhy(bool buildModeList /* = true */)
57 : HePhy(false) // don't add HE modes to list
58{
59 NS_LOG_FUNCTION(this << buildModeList);
63 if (buildModeList)
64 {
66 }
67}
68
70{
71 NS_LOG_FUNCTION(this);
72}
73
74void
76{
77 NS_LOG_FUNCTION(this);
78 NS_ASSERT(m_modeList.empty());
80 for (uint8_t index = 0; index <= m_maxSupportedMcsIndexPerSs; ++index)
81 {
82 NS_LOG_LOGIC("Add EhtMcs" << +index << " to list");
83 m_modeList.emplace_back(CreateEhtMcs(index));
84 }
85}
86
88EhtPhy::GetSigMode(WifiPpduField field, const WifiTxVector& txVector) const
89{
90 switch (field)
91 {
93 return GetSigAMode(); // U-SIG is similar to SIG-A
95 return GetSigBMode(txVector); // EHT-SIG is similar to SIG-B
96 default:
97 return HePhy::GetSigMode(field, txVector);
98 }
99}
100
101Time
102EhtPhy::GetDuration(WifiPpduField field, const WifiTxVector& txVector) const
103{
104 switch (field)
105 {
107 return GetSigADuration(txVector.GetPreambleType()); // U-SIG is similar to SIG-A
109 return GetSigBDuration(txVector); // EHT-SIG is similar to SIG-B
111 [[fallthrough]];
113 return NanoSeconds(0);
114 default:
115 return HePhy::GetDuration(field, txVector);
116 }
117}
118
121{
122 return m_ehtPpduFormats;
123}
124
126EhtPhy::BuildPpdu(const WifiConstPsduMap& psdus, const WifiTxVector& txVector, Time ppduDuration)
127{
128 NS_LOG_FUNCTION(this << psdus << txVector << ppduDuration);
129 return Create<EhtPpdu>(psdus,
130 txVector,
132 txVector.GetChannelWidth()),
133 ppduDuration,
135 ObtainNextUid(txVector),
138}
139
142{
143 NS_LOG_FUNCTION(this << field << *event);
144 switch (field)
145 {
147 [[fallthrough]];
149 return EndReceiveSig(event, field);
150 default:
151 return HePhy::DoEndReceiveField(field, event);
152 }
153}
154
157{
158 NS_LOG_FUNCTION(this << *event << status << field);
159 switch (field)
160 {
162 return ProcessSigA(event, status); // U-SIG is similar to SIG-A
164 return ProcessSigB(event, status); // EHT-SIG is similar to SIG-B
165 default:
166 return HePhy::ProcessSig(event, status, field);
167 }
168 return status;
169}
170
173{
174 switch (field)
175 {
177 return U_SIG_FAILURE;
179 return EHT_SIG_FAILURE;
180 default:
181 return HePhy::GetFailureReason(field);
182 }
183}
184
185void
187{
188 for (uint8_t i = 0; i <= 13; ++i)
189 {
190 GetEhtMcs(i);
191 }
192}
193
195EhtPhy::GetEhtMcs(uint8_t index)
196{
197#define CASE(x) \
198 case x: \
199 return GetEhtMcs##x();
200
201 switch (index)
202 {
203 CASE(0)
204 CASE(1)
205 CASE(2)
206 CASE(3)
207 CASE(4)
208 CASE(5)
209 CASE(6)
210 CASE(7)
211 CASE(8)
212 CASE(9)
213 CASE(10)
214 CASE(11)
215 CASE(12)
216 CASE(13)
217 default:
218 NS_ABORT_MSG("Inexistent index (" << +index << ") requested for EHT");
219 return WifiMode();
220 }
221#undef CASE
222}
223
224#define GET_EHT_MCS(x) \
225 WifiMode EhtPhy::GetEhtMcs##x() \
226 { \
227 static WifiMode mcs = CreateEhtMcs(x); \
228 return mcs; \
229 };
230
241GET_EHT_MCS(10)
242GET_EHT_MCS(11)
243GET_EHT_MCS(12)
244GET_EHT_MCS(13)
245#undef GET_EHT_MCS
246
247WifiMode
249{
250 NS_ASSERT_MSG(index <= 13, "EhtMcs index must be <= 13!");
251 return WifiModeFactory::CreateWifiMcs("EhtMcs" + std::to_string(index),
252 index,
254 false,
261}
262
264EhtPhy::GetCodeRate(uint8_t mcsValue)
265{
266 switch (mcsValue)
267 {
268 case 12:
269 return WIFI_CODE_RATE_3_4;
270 case 13:
271 return WIFI_CODE_RATE_5_6;
272 default:
273 return HePhy::GetCodeRate(mcsValue);
274 }
275}
276
277uint16_t
279{
280 switch (mcsValue)
281 {
282 case 12:
283 [[fallthrough]];
284 case 13:
285 return 4096;
286 default:
287 return HePhy::GetConstellationSize(mcsValue);
288 }
289}
290
291uint64_t
292EhtPhy::GetPhyRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
293{
294 WifiCodeRate codeRate = GetCodeRate(mcsValue);
295 uint64_t dataRate = GetDataRate(mcsValue, channelWidth, guardInterval, nss);
296 return HtPhy::CalculatePhyRate(codeRate, dataRate);
297}
298
299uint64_t
300EhtPhy::GetPhyRateFromTxVector(const WifiTxVector& txVector, uint16_t staId /* = SU_STA_ID */)
301{
302 uint16_t bw = txVector.GetChannelWidth();
303 if (txVector.IsMu())
304 {
305 bw = HeRu::GetBandwidth(txVector.GetRu(staId).GetRuType());
306 }
307 return EhtPhy::GetPhyRate(txVector.GetMode(staId).GetMcsValue(),
308 bw,
309 txVector.GetGuardInterval(),
310 txVector.GetNss(staId));
311}
312
313uint64_t
314EhtPhy::GetDataRateFromTxVector(const WifiTxVector& txVector, uint16_t staId /* = SU_STA_ID */)
315{
316 uint16_t bw = txVector.GetChannelWidth();
317 if (txVector.IsMu())
318 {
319 bw = HeRu::GetBandwidth(txVector.GetRu(staId).GetRuType());
320 }
321 return EhtPhy::GetDataRate(txVector.GetMode(staId).GetMcsValue(),
322 bw,
323 txVector.GetGuardInterval(),
324 txVector.GetNss(staId));
325}
326
327uint64_t
328EhtPhy::GetDataRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
329{
330 NS_ASSERT(guardInterval == 800 || guardInterval == 1600 || guardInterval == 3200);
331 NS_ASSERT(nss <= 8);
333 GetUsableSubcarriers(channelWidth),
334 static_cast<uint16_t>(log2(GetConstellationSize(mcsValue))),
336 nss);
337}
338
339uint64_t
341{
342 WifiCodeRate codeRate = GetCodeRate(mcsValue);
343 uint16_t constellationSize = GetConstellationSize(mcsValue);
344 return CalculateNonHtReferenceRate(codeRate, constellationSize);
345}
346
347uint64_t
348EhtPhy::CalculateNonHtReferenceRate(WifiCodeRate codeRate, uint16_t constellationSize)
349{
350 uint64_t dataRate;
351 switch (constellationSize)
352 {
353 case 4096:
354 if (codeRate == WIFI_CODE_RATE_3_4 || codeRate == WIFI_CODE_RATE_5_6)
355 {
356 dataRate = 54000000;
357 }
358 else
359 {
360 NS_FATAL_ERROR("Trying to get reference rate for a MCS with wrong combination of "
361 "coding rate and modulation");
362 }
363 break;
364 default:
365 dataRate = HePhy::CalculateNonHtReferenceRate(codeRate, constellationSize);
366 }
367 return dataRate;
368}
369
370} // namespace ns3
371
372namespace
373{
374
379{
380 public:
382 {
385 }
387
388} // namespace
Constructor class for EHT modes.
Definition: eht-phy.cc:379
static const PpduFormats m_ehtPpduFormats
EHT PPDU formats.
Definition: eht-phy.h:287
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: eht-phy.cc:348
PhyFieldRxStatus ProcessSig(Ptr< Event > event, PhyFieldRxStatus status, WifiPpduField field) override
Process SIG-A or SIG-B, perform amendment-specific actions, and provide an updated status of the rece...
Definition: eht-phy.cc:156
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied EHT MCS index.
Definition: eht-phy.cc:264
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
Definition: eht-phy.cc:88
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied EHT MCS index.
Definition: eht-phy.cc:278
WifiPhyRxfailureReason GetFailureReason(WifiPpduField field) const override
Get the failure reason corresponding to the unsuccessful processing of a given PPDU field.
Definition: eht-phy.cc:172
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: eht-phy.cc:300
static WifiMode GetEhtMcs(uint8_t index)
Return the EHT MCS corresponding to the provided index.
Definition: eht-phy.cc:195
void BuildModeList() override
Build mode list.
Definition: eht-phy.cc:75
static void InitializeModes()
Initialize all EHT modes.
Definition: eht-phy.cc:186
static WifiMode CreateEhtMcs(uint8_t index)
Create and return the EHT MCS corresponding to the provided index.
Definition: eht-phy.cc:248
const PpduFormats & GetPpduFormats() const override
Return the PPDU formats of the PHY.
Definition: eht-phy.cc:120
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: eht-phy.cc:314
~EhtPhy() override
Destructor for EHT PHY.
Definition: eht-phy.cc:69
EhtPhy(bool buildModeList=true)
Constructor for EHT PHY.
Definition: eht-phy.cc:56
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
Definition: eht-phy.cc:126
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: eht-phy.cc:340
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: eht-phy.cc:102
static uint64_t GetDataRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the data rate corresponding to the supplied EHT MCS index, channel width, guard interval,...
Definition: eht-phy.cc:328
static uint64_t GetPhyRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the PHY rate corresponding to the supplied EHT MCS index, channel width, guard interval,...
Definition: eht-phy.cc:292
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: eht-phy.cc:141
PHY entity for HE (11ax)
Definition: he-phy.h:64
virtual PhyFieldRxStatus ProcessSigB(Ptr< Event > event, PhyFieldRxStatus status)
Process SIG-B, perform amendment-specific actions, and provide an updated status of the reception.
Definition: he-phy.cc:694
Time GetSigBDuration(const WifiTxVector &txVector) const override
Definition: he-phy.cc:219
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:1621
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HE MCS index.
Definition: he-phy.cc:1509
PhyFieldRxStatus ProcessSig(Ptr< Event > event, PhyFieldRxStatus status, WifiPpduField field) override
Process SIG-A or SIG-B, perform amendment-specific actions, and provide an updated status of the rece...
Definition: he-phy.cc:569
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:116
uint64_t ObtainNextUid(const WifiTxVector &txVector) override
Obtain the next UID for the PPDU to transmit.
Definition: he-phy.cc:1226
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
Definition: he-phy.cc:1644
static Time GetSymbolDuration(Time guardInterval)
Definition: he-phy.cc:1607
WifiMode GetSigBMode(const WifiTxVector &txVector) const override
Definition: he-phy.cc:145
virtual PhyFieldRxStatus ProcessSigA(Ptr< Event > event, PhyFieldRxStatus status)
Process SIG-A, perform amendment-specific actions, and provide an updated status of the reception.
Definition: he-phy.cc:586
WifiMode GetSigAMode() const override
Definition: he-phy.cc:139
Time GetSigADuration(WifiPreamble preamble) const override
Definition: he-phy.cc:211
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HE MCS index.
Definition: he-phy.cc:1523
@ PSD_NON_HE_PORTION
Non-HE portion of an HE PPDU.
Definition: he-ppdu.h:158
RuType GetRuType() const
Get the RU type.
Definition: he-ru.cc:435
static uint16_t GetBandwidth(RuType ruType)
Get the approximate bandwidth occupied by a RU.
Definition: he-ru.cc:760
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:660
uint8_t m_bssMembershipSelector
the BSS membership selector
Definition: ht-phy.h:559
uint8_t m_maxMcsIndexPerSs
the maximum MCS index per spatial stream as defined by the standard
Definition: ht-phy.h:557
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:708
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:675
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
Definition: ht-phy.h:558
static uint16_t GetUsableSubcarriers()
Definition: ofdm-phy.cc:616
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
Definition: phy-entity.h:942
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
Definition: phy-entity.h:524
std::list< WifiMode > m_modeList
the list of supported modes
Definition: phy-entity.h:946
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
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: vht-phy.cc:173
PhyFieldRxStatus EndReceiveSig(Ptr< Event > event, WifiPpduField field)
End receiving the SIG-A or SIG-B, perform VHT-specific actions, and provide the status of the recepti...
Definition: vht-phy.cc:276
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: vht-phy.cc:261
virtual WifiPhyRxfailureReason GetFailureReason(WifiPpduField field) const
Get the failure reason corresponding to the unsuccessful processing of a given PPDU field.
Definition: vht-phy.cc:301
static WifiMode CreateWifiMcs(std::string uniqueName, uint8_t mcsValue, WifiModulationClass modClass, bool isMandatory, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, DataRateCallback dataRateCallback, NonHtReferenceRateCallback nonHtReferenceRateCallback, AllowedCallback isAllowedCallback)
Definition: wifi-mode.cc:318
represent a single transmission mode
Definition: wifi-mode.h:50
uint8_t GetMcsValue() const
Definition: wifi-mode.cc:163
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:950
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
Definition: wifi-phy.cc:699
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:962
uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
uint16_t GetPrimaryChannelCenterFrequency(uint16_t primaryChannelWidth) const
Get the center frequency of the primary channel of the given width.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint16_t GetGuardInterval() const
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
WifiPreamble GetPreambleType() const
HeRu::RuSpec GetRu(uint16_t staId) const
Get the RU specification for the STA-ID.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
bool IsMu() const
Return true if this TX vector is used for a multi-user transmission.
uint16_t GetChannelWidth() const
#define GET_EHT_MCS(x)
Definition: eht-phy.cc:224
#define CASE(x)
Declaration of ns3::EhtPhy class.
#define EHT_PHY
This defines the BSS membership value for EHT PHY.
Definition: eht-phy.h:37
Declaration of ns3::EhtPpdu class.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:160
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:49
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs... bargs)
Make Callbacks with varying number of bound arguments.
Definition: callback.h:752
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1374
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
WifiPpduField
The type of PPDU field (grouped for convenience)
@ U_SIG_FAILURE
@ EHT_SIG_FAILURE
@ WIFI_PREAMBLE_EHT_TB
@ WIFI_PREAMBLE_EHT_MU
@ WIFI_MOD_CLASS_EHT
EHT (Clause 36)
@ WIFI_PPDU_FIELD_SIG_B
SIG-B field.
@ WIFI_PPDU_FIELD_TRAINING
STF + LTF fields (excluding those in preamble for HT-GF)
@ WIFI_PPDU_FIELD_NON_HT_HEADER
PHY header field for DSSS or ERP, short PHY header field for HR/DSSS or ERP, field not present for HT...
@ WIFI_PPDU_FIELD_EHT_SIG
EHT-SIG field.
@ WIFI_PPDU_FIELD_PREAMBLE
SYNC + SFD fields for DSSS or ERP, shortSYNC + shortSFD fields for HR/DSSS or ERP,...
@ WIFI_PPDU_FIELD_U_SIG
U-SIG field.
@ WIFI_PPDU_FIELD_DATA
data field
@ WIFI_PPDU_FIELD_SIG_A
SIG-A field.
class anonymous_namespace{eht-phy.cc}::ConstructorEht g_constructor_eht
the constructor for EHT modes
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const uint16_t WIFI_CODE_RATE_3_4
3/4 coding rate
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:691
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
const uint16_t WIFI_CODE_RATE_5_6
5/6 coding rate
Status of the reception of the PPDU field.
Definition: phy-entity.h:113