15#include "ns3/assert.h"
16#include "ns3/interference-helper.h"
18#include "ns3/wifi-net-device.h"
19#include "ns3/wifi-phy.h"
20#include "ns3/wifi-psdu.h"
21#include "ns3/wifi-utils.h"
23#undef NS_LOG_APPEND_CONTEXT
24#define NS_LOG_APPEND_CONTEXT WIFI_PHY_NS_LOG_APPEND_CONTEXT(m_wifiPhy)
53 { std::make_tuple ( 80, 7, 2), 3 },
54 { std::make_tuple ( 80, 7, 7), 6 },
55 { std::make_tuple ( 80, 7, 8), 6 },
56 { std::make_tuple ( 80, 8, 7), 6 },
57 { std::make_tuple (160, 4, 7), 6 },
58 { std::make_tuple (160, 5, 8), 8 },
59 { std::make_tuple (160, 6, 7), 8 },
60 { std::make_tuple (160, 7, 3), 4 },
61 { std::make_tuple (160, 7, 4), 6 },
62 { std::make_tuple (160, 7, 5), 7 },
63 { std::make_tuple (160, 7, 7), 9 },
64 { std::make_tuple (160, 7, 8), 12 },
65 { std::make_tuple (160, 7, 9), 12 },
160 "VHT-SIG-B only available for VHT MU");
193 uint8_t nExtensionLtf )
const
195 NS_ABORT_MSG_IF(nDataLtf > 8,
"Unsupported number of LTFs " << +nDataLtf <<
" for VHT");
196 NS_ABORT_MSG_IF(nExtensionLtf > 0,
"No extension LTFs expected for VHT");
227 uint8_t nes = ceil(payloadMode.
GetDataRate(txVector) / maxRatePerCoder);
283 NS_LOG_DEBUG(
"Drop packet because " << field <<
" reception failed");
327 for (uint8_t i = 0; i < 10; ++i)
338 return GetVhtMcs##x();
353 NS_ABORT_MSG(
"Inexistent index (" << +index <<
") requested for VHT");
359#define GET_VHT_MCS(x) \
360 WifiMode VhtPhy::GetVhtMcs##x() \
362 static WifiMode mcs = CreateVhtMcs(x); \
425 uint64_t dataRate =
GetDataRate(mcsValue, channelWidth, guardInterval, nss);
454 "VHT MCS " << +mcsValue <<
" forbidden at " << channelWidth <<
" MHz when NSS is "
466 switch (
static_cast<uint16_t
>(channelWidth))
489 switch (constellationSize)
498 NS_FATAL_ERROR(
"Trying to get reference rate for a MCS with wrong combination of "
499 "coding rate and modulation");
519 if (mcsValue == 9 && channelWidth == 20 && nss != 3)
523 if (mcsValue == 6 && channelWidth == 80 && nss == 3)
541 const auto ppduBw = ppdu->GetTxVector().GetChannelWidth();
550 NS_ASSERT_MSG(ppduBw == 20,
"Invalid channel width " << ppduBw);
553 NS_ASSERT_MSG(ppduBw <= 40,
"Invalid channel width " << ppduBw);
556 NS_ASSERT_MSG(ppduBw <= 80,
"Invalid channel width " << ppduBw);
563 const auto thresholds = vhtConfiguration->GetSecondaryCcaSensitivityThresholdsPerBw();
564 const auto it = thresholds.find(ppduBw);
565 NS_ASSERT_MSG(it != std::end(thresholds),
"Invalid channel width " << ppduBw);
586 if (delayUntilCcaEnd.IsStrictlyPositive())
588 return std::make_pair(
595 const MHz_u primaryWidth = 20;
596 const MHz_u p20MinFreq =
599 const MHz_u p20MaxFreq =
602 if (ppdu->DoesOverlapChannel(p20MinFreq, p20MaxFreq))
612 std::vector<MHz_u> secondaryWidthsToCheck;
617 const auto secondaryWidth = secondaryChannel.first;
618 const MHz_u secondaryMinFreq =
621 (secondaryWidth / 2);
622 const MHz_u secondaryMaxFreq =
625 (secondaryWidth / 2);
627 ppdu->DoesOverlapChannel(secondaryMinFreq, secondaryMaxFreq))
629 secondaryWidthsToCheck.push_back(secondaryWidth);
635 secondaryWidthsToCheck.push_back(20);
636 secondaryWidthsToCheck.push_back(40);
639 secondaryWidthsToCheck.push_back(80);
643 for (
auto secondaryWidth : secondaryWidthsToCheck)
648 if (delayUntilCcaEnd.IsStrictlyPositive())
650 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.
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
std::optional< std::pair< Time, WifiChannelListType > > CcaIndication
CCA end time and its corresponding channel list type (can be std::nullopt if IDLE)
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
WifiSpectrumBandInfo GetPrimaryBand(MHz_u bandWidth) const
If the operating channel width is a multiple of 20 MHz, return the info corresponding to the primary ...
Time GetDelayUntilCcaEnd(dBm_u threshold, const WifiSpectrumBandInfo &band)
Return the delay until CCA busy is ended for a given sensitivity threshold and a given band.
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 GetSecondaryBand(MHz_u bandWidth) const
If the channel bonding is used, return the info corresponding to the secondary channel of the given b...
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
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.
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.
static const PpduFormats m_vhtPpduFormats
VHT PPDU formats.
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.
static bool IsCombinationAllowed(uint8_t mcsValue, MHz_u channelWidth, uint8_t nss)
Check whether the combination of <MCS, channel width, NSS> is allowed.
static uint64_t GetDataRate(uint8_t mcsValue, MHz_u channelWidth, Time guardInterval, uint8_t nss)
Return the data rate corresponding to the supplied VHT MCS index, channel width, guard interval,...
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.
dBm_u GetCcaThreshold(const Ptr< const WifiPpdu > ppdu, WifiChannelListType channelType) const override
Return the CCA threshold for a given channel type.
static uint64_t GetPhyRate(uint8_t mcsValue, MHz_u channelWidth, Time 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
std::map< std::tuple< MHz_u, uint8_t, uint8_t >, uint8_t > NesExceptionMap
Typedef for storing exceptions in the number of BCC encoders for VHT MCSs.
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 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(MHz_u channelWidth, Time guardInterval, uint8_t nss) const
uint8_t GetMcsValue() const
dBm_u GetCcaEdThreshold() const
Return the CCA energy detection threshold.
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
MHz_u GetChannelWidth() const
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
dBm_u GetCcaSensitivityThreshold() const
Return the CCA sensitivity threshold.
MHz_u GetSecondaryChannelCenterFrequency(MHz_u secondaryChannelWidth) const
Get the center frequency of the secondary channel of the given width.
MHz_u GetPrimaryChannelCenterFrequency(MHz_u 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...
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.
MHz_u GetChannelWidth() const
Time GetGuardInterval() 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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time MicroSeconds(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
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.
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, dBm_u > channelTypeToScalingFactor
map a given channel list type to the corresponding scaling factor
dB_u RatioToDb(double ratio)
Convert from ratio to dB.
double dBm_u
dBm weak type
const std::map< MHz_u, WifiChannelListType > secondaryChannels
map a given secondary channel width to its channel list type
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.