24 #include "ns3/wifi-psdu.h"
25 #include "ns3/wifi-phy.h"
26 #include "ns3/wifi-utils.h"
27 #include "ns3/interference-helper.h"
29 #include "ns3/assert.h"
56 { std::make_tuple ( 80, 7, 2), 3 },
57 { std::make_tuple ( 80, 7, 7), 6 },
58 { std::make_tuple ( 80, 7, 8), 6 },
59 { std::make_tuple ( 80, 8, 7), 6 },
60 { std::make_tuple (160, 4, 7), 6 },
61 { std::make_tuple (160, 5, 8), 8 },
62 { std::make_tuple (160, 6, 7), 8 },
63 { std::make_tuple (160, 7, 3), 4 },
64 { std::make_tuple (160, 7, 4), 6 },
65 { std::make_tuple (160, 7, 5), 7 },
66 { std::make_tuple (160, 7, 7), 9 },
67 { std::make_tuple (160, 7, 8), 12 },
68 { std::make_tuple (160, 7, 9), 12 }
173 uint8_t nDataLtf, uint8_t nExtensionLtf )
const
175 NS_ABORT_MSG_IF (nDataLtf > 8,
"Unsupported number of LTFs " << +nDataLtf <<
" for VHT");
176 NS_ABORT_MSG_IF (nExtensionLtf > 0,
"No extension LTFs expected for VHT");
204 double maxRatePerCoder = (txVector.
GetGuardInterval () == 800) ? 540e6 : 600e6;
205 uint8_t nes = ceil (payloadMode.
GetDataRate (txVector) / maxRatePerCoder);
222 return Create<VhtPpdu> (psdus.begin ()->second, txVector, ppduDuration,
m_wifiPhy->
GetPhyBand (),
260 NS_LOG_DEBUG (
"Drop packet because SIG-A reception failed");
294 NS_LOG_DEBUG (
"Drop reception because SIG-B reception failed");
322 for (uint8_t i = 0; i < 10; ++i)
333 return GetVhtMcs ## x (); \
348 NS_ABORT_MSG (
"Inexistent index (" << +index <<
") requested for VHT");
354 #define GET_VHT_MCS(x) \
356 VhtPhy::GetVhtMcs ## x (void) \
358 static WifiMode mcs = CreateVhtMcs (x); \
421 uint64_t dataRate =
GetDataRate (mcsValue, channelWidth, guardInterval, nss);
446 NS_ASSERT (guardInterval == 800 || guardInterval == 400);
458 switch (channelWidth)
481 switch (constellationSize)
490 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
510 if (mcsValue == 9 && channelWidth == 20 && nss != 3)
514 if (mcsValue == 6 && channelWidth == 80 && nss == 3)
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.
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...
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 WifiMode GetLSigMode(void)
static uint64_t CalculateDataRate(double symbolDuration, uint16_t guardInterval, uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier, double codingRate, uint8_t nss)
Calculates data rate from the supplied parameters.
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 double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
static uint16_t GetUsableSubcarriers(uint16_t channelWidth)
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
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.
double GetRandomValue(void) const
Obtain a random value from the WifiPhy's generator.
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
std::list< WifiMode > m_modeList
the list of supported modes
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
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
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.
static uint16_t GetUsableSubcarriers(uint16_t channelWidth)
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)
Time GetHtSigDuration(void) const override
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.
void BuildModeList(void) override
Build mode list.
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.
uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const override
Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const override
virtual WifiMode GetSigAMode(void) const
static WifiMode GetVhtMcs0(void)
Return MCS 0 from VHT MCS values.
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 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...
virtual PhyFieldRxStatus ProcessSigB(Ptr< Event > event, PhyFieldRxStatus status)
Process SIG-B, perform amendment-specific actions, and provide an updated status of the reception.
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,...
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
WifiMode GetHtSigMode(void) const override
Time GetLSigDuration(WifiPreamble preamble) const override
PhyFieldRxStatus EndReceiveSigA(Ptr< Event > event)
End receiving the SIG-A, perform VHT-specific actions, and provide the status of the reception.
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(void)
Initialize all VHT modes.
virtual PhyFieldRxStatus ProcessSigA(Ptr< Event > event, PhyFieldRxStatus status)
Process SIG-A, perform amendment-specific actions, and provide an updated status of the reception.
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.
virtual ~VhtPhy()
Destructor for VHT PHY.
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied VHT MCS index.
PhyFieldRxStatus EndReceiveSigB(Ptr< Event > event)
End receiving the SIG-B, perform VHT-specific actions, and provide the status of the reception.
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
VhtPhy(bool buildModeList=true)
Constructor for VHT PHY.
virtual WifiMode GetSigBMode(const WifiTxVector &txVector) const
const PpduFormats & GetPpduFormats(void) const override
Return the PPDU formats of the PHY.
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
uint8_t GetMcsValue(void) const
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
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(void) 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(void) const
uint16_t GetGuardInterval(void) 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 ",...
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiPpduField
The type of PPDU field (grouped for convenience)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ 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.
static 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.
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.
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
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
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.