26 #include "ns3/assert.h"
27 #include "ns3/interference-helper.h"
29 #include "ns3/wifi-net-device.h"
30 #include "ns3/wifi-phy.h"
31 #include "ns3/wifi-psdu.h"
32 #include "ns3/wifi-utils.h"
61 { std::make_tuple ( 80, 7, 2), 3 },
62 { std::make_tuple ( 80, 7, 7), 6 },
63 { std::make_tuple ( 80, 7, 8), 6 },
64 { std::make_tuple ( 80, 8, 7), 6 },
65 { std::make_tuple (160, 4, 7), 6 },
66 { std::make_tuple (160, 5, 8), 8 },
67 { std::make_tuple (160, 6, 7), 8 },
68 { std::make_tuple (160, 7, 3), 4 },
69 { std::make_tuple (160, 7, 4), 6 },
70 { std::make_tuple (160, 7, 5), 7 },
71 { std::make_tuple (160, 7, 7), 9 },
72 { std::make_tuple (160, 7, 8), 12 },
73 { std::make_tuple (160, 7, 9), 12 },
168 "VHT-SIG-B only available for VHT MU");
201 uint8_t nExtensionLtf )
const
203 NS_ABORT_MSG_IF(nDataLtf > 8,
"Unsupported number of LTFs " << +nDataLtf <<
" for VHT");
204 NS_ABORT_MSG_IF(nExtensionLtf > 0,
"No extension LTFs expected for VHT");
234 double maxRatePerCoder = (txVector.
GetGuardInterval() == 800) ? 540e6 : 600e6;
235 uint8_t nes = ceil(payloadMode.
GetDataRate(txVector) / maxRatePerCoder);
251 return Create<VhtPpdu>(psdus.begin()->second,
291 NS_LOG_DEBUG(
"Drop packet because " << field <<
" reception failed");
335 for (uint8_t i = 0; i < 10; ++i)
346 return GetVhtMcs##x();
361 NS_ABORT_MSG(
"Inexistent index (" << +index <<
") requested for VHT");
367 #define GET_VHT_MCS(x) \
368 WifiMode VhtPhy::GetVhtMcs##x() \
370 static WifiMode mcs = CreateVhtMcs(x); \
433 uint64_t dataRate =
GetDataRate(mcsValue, channelWidth, guardInterval, nss);
458 NS_ASSERT(guardInterval == 800 || guardInterval == 400);
461 "VHT MCS " << +mcsValue <<
" forbidden at " << channelWidth <<
" MHz when NSS is "
473 switch (channelWidth)
496 switch (constellationSize)
505 NS_FATAL_ERROR(
"Trying to get reference rate for a MCS with wrong combination of "
506 "coding rate and modulation");
526 if (mcsValue == 9 && channelWidth == 20 && nss != 3)
530 if (mcsValue == 6 && channelWidth == 80 && nss == 3)
548 const uint16_t ppduBw = ppdu->GetTxVector().GetChannelWidth();
557 NS_ASSERT_MSG(ppduBw == 20,
"Invalid channel width " << ppduBw);
560 NS_ASSERT_MSG(ppduBw <= 40,
"Invalid channel width " << ppduBw);
563 NS_ASSERT_MSG(ppduBw <= 80,
"Invalid channel width " << ppduBw);
570 const auto thresholds = vhtConfiguration->GetSecondaryCcaSensitivityThresholdsPerBw();
571 const auto it = thresholds.find(ppduBw);
572 NS_ASSERT_MSG(it != std::end(thresholds),
"Invalid channel width " << ppduBw);
597 return std::make_pair(
604 const uint16_t primaryWidth = 20;
605 uint16_t p20MinFreq =
608 uint16_t p20MaxFreq =
611 if (ppdu->DoesOverlapChannel(p20MinFreq, p20MaxFreq))
621 std::vector<uint16_t> secondaryWidthsToCheck;
626 uint16_t secondaryWidth = secondaryChannel.first;
627 uint16_t secondaryMinFreq =
630 (secondaryWidth / 2);
631 uint16_t secondaryMaxFreq =
634 (secondaryWidth / 2);
636 ppdu->DoesOverlapChannel(secondaryMinFreq, secondaryMaxFreq))
638 secondaryWidthsToCheck.push_back(secondaryWidth);
644 secondaryWidthsToCheck.push_back(20);
645 secondaryWidthsToCheck.push_back(40);
648 secondaryWidthsToCheck.push_back(80);
652 for (
auto secondaryWidth : secondaryWidthsToCheck)
659 return std::make_pair(delayUntilCcaEnd, channelType);
Constructor class for VHT modes.
static uint64_t CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate)
Return the PHY rate corresponding to the supplied code rate and data rate.
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...
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index between 0 and 7,...
uint8_t m_bssMembershipSelector
the BSS membership selector
PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event) override
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
static WifiMode GetLSigMode()
uint8_t m_maxMcsIndexPerSs
the maximum MCS index per spatial stream as defined by the standard
bool IsAllConfigSupported(WifiPpduField field, Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (including bandwidth) is supported by the PHY.
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...
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...
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index between 0 and 7,...
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
static uint64_t CalculateDataRate(Time symbolDuration, uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier, double codingRate, uint8_t nss)
Calculates data rate from the supplied parameters.
static double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
virtual Time GetSymbolDuration(const WifiTxVector &txVector) const
static uint16_t GetUsableSubcarriers()
virtual bool IsChannelWidthSupported(Ptr< const WifiPpdu > ppdu) const
Checks if the PPDU's bandwidth is supported by the PHY.
virtual uint64_t ObtainNextUid(const WifiTxVector &txVector)
Obtain the next UID for the PPDU to transmit.
Time GetDelayUntilCcaEnd(double thresholdDbm, const WifiSpectrumBandInfo &band)
Return the delay until CCA busy is ended for a given sensitivity threshold (in dBm) and a given band.
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
WifiSpectrumBandInfo GetSecondaryBand(uint16_t bandWidth) const
If the channel bonding is used, return the info corresponding to the secondary channel of the given b...
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
std::optional< std::pair< Time, WifiChannelListType > > CcaIndication
CCA end time and its corresponding channel list type (can be std::nullopt if IDLE)
std::list< WifiMode > m_modeList
the list of supported modes
double GetRandomValue() const
Obtain a random value from the WifiPhy's generator.
SnrPer GetPhyHeaderSnrPer(WifiPpduField field, Ptr< Event > event) const
Obtain the SNR and PER of the PPDU field from the WifiPhy's InterferenceHelper class.
@ DROP
drop PPDU and set CCA_BUSY
WifiSpectrumBandInfo GetPrimaryBand(uint16_t bandWidth) const
If the operating channel width is a multiple of 20 MHz, return the info corresponding to the primary ...
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
static WifiMode GetVhtMcs0()
Return MCS 0 from VHT MCS values.
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied VHT MCS index.
static bool IsCombinationAllowed(uint8_t mcsValue, uint16_t channelWidth, uint8_t nss)
Check whether the combination of <MCS, channel width, NSS> is allowed.
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...
static const NesExceptionMap m_exceptionsMap
exception map for number of BCC encoders (extracted from VHT-MCS tables)
~VhtPhy() override
Destructor for VHT PHY.
double GetCcaThreshold(const Ptr< const WifiPpdu > ppdu, WifiChannelListType channelType) const override
Return the CCA threshold in dBm for a given channel type.
static const PpduFormats m_vhtPpduFormats
VHT PPDU formats.
std::map< std::tuple< uint16_t, uint8_t, uint8_t >, uint8_t > NesExceptionMap
Typedef for storing exceptions in the number of BCC encoders for VHT MCSs.
bool IsAllConfigSupported(WifiPpduField field, Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (including bandwidth) is supported by the PHY.
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
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...
uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const override
Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const override
virtual Time GetSigBDuration(const WifiTxVector &txVector) const
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
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...
static WifiMode GetVhtMcs(uint8_t index)
Return the VHT MCS corresponding to the provided index.
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...
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
static uint64_t GetPhyRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the PHY rate corresponding to the supplied VHT MCS index, channel width, guard interval,...
void BuildModeList() override
Build mode list.
virtual WifiMode GetSigAMode() const
Time GetLSigDuration(WifiPreamble preamble) const override
virtual PhyFieldRxStatus ProcessSig(Ptr< Event > event, PhyFieldRxStatus status, WifiPpduField field)
Process SIG-A or SIG-B, perform amendment-specific actions, and provide an updated status of the rece...
PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event) override
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
static void InitializeModes()
Initialize all VHT modes.
static uint64_t GetDataRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the data rate corresponding to the supplied VHT MCS index, channel width, guard interval,...
static WifiMode CreateVhtMcs(uint8_t index)
Return the VHT MCS corresponding to the provided index.
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied VHT MCS index.
uint32_t GetMaxPsduSize() const override
Get the maximum PSDU size in bytes.
static uint64_t GetNonHtReferenceRate(uint8_t mcsValue)
Calculate the rate in bps of the non-HT Reference Rate corresponding to the supplied VHT MCS index.
virtual Time GetSigADuration(WifiPreamble preamble) const
const PpduFormats & GetPpduFormats() const override
Return the PPDU formats of the PHY.
WifiMode GetHtSigMode() const override
VhtPhy(bool buildModeList=true)
Constructor for VHT PHY.
virtual WifiMode GetSigBMode(const WifiTxVector &txVector) const
virtual WifiPhyRxfailureReason GetFailureReason(WifiPpduField field) const
Get the failure reason corresponding to the unsuccessful processing of a given PPDU field.
Time GetHtSigDuration() const override
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
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)
represent a single transmission mode
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
uint8_t GetMcsValue() const
Ptr< VhtConfiguration > GetVhtConfiguration() const
double GetCcaEdThreshold() const
Return the CCA energy detection threshold (dBm).
uint16_t GetChannelWidth() const
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
double GetCcaSensitivityThreshold() const
Return the CCA sensitivity threshold (dBm).
uint16_t GetSecondaryChannelCenterFrequency(uint16_t secondaryChannelWidth) const
Get the center frequency of the secondary channel of the given width.
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
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.
uint16_t GetChannelWidth() const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiChannelListType
Enumeration of the possible channel-list parameter elements defined in Table 8-5 of IEEE 802....
WifiPpduField
The type of PPDU field (grouped for convenience)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_CHANLIST_SECONDARY40
@ WIFI_CHANLIST_SECONDARY
@ WIFI_CHANLIST_SECONDARY80
@ 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_PREAMBLE
SYNC + SFD fields for DSSS or ERP, shortSYNC + shortSFD fields for HR/DSSS or ERP,...
@ WIFI_PPDU_FIELD_DATA
data field
@ WIFI_PPDU_FIELD_SIG_A
SIG-A field.
#define HT_PHY
This defines the BSS membership value for HT PHY.
class anonymous_namespace{vht-phy.cc}::ConstructorVht g_constructor_vht
the constructor for VHT modes
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double RatioToDb(double ratio)
Convert from ratio to dB.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
const std::map< uint16_t, WifiChannelListType > secondaryChannels
map a given secondary channel width to its channel list type
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...
const std::map< WifiChannelListType, double > channelTypeToScalingFactorDbm
map a given channel list type to the corresponding scaling factor in dBm
WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
@ WIFI_CODE_RATE_3_4
3/4 coding rate
@ WIFI_CODE_RATE_5_6
5/6 coding rate
Status of the reception of the PPDU field.
WifiPhyRxfailureReason reason
failure reason
PhyRxFailureAction actionIfFailure
action to perform in case of failure
bool isSuccess
outcome (true if success) of the reception
A struct for both SNR and PER.
double snr
SNR in linear scale.
Declaration of ns3::VhtPhy class.
#define VHT_PHY
This defines the BSS membership value for VHT PHY.
Declaration of ns3::VhtPpdu class.