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"
59 NS_ABORT_MSG_IF (maxNss == 0 || maxNss > 4,
"Unsupported max Nss " << +maxNss <<
" for HT PHY");
94 if (mcs.GetMcsValue () == index)
101 NS_ABORT_MSG (
"Unsupported MCS index " << +index <<
" for this PHY entity");
110 if (mcs.GetMcsValue () == index)
171 NS_LOG_LOGIC (
"Rebuild mode list since max MCS index per spatial stream has changed");
189 NS_ABORT_MSG_IF (maxNss == 0 || maxNss > 4,
"Unsupported max Nss " << +maxNss <<
" for HT PHY");
192 NS_LOG_LOGIC (
"Rebuild mode list since max number of spatial streams has changed");
213 uint8_t nDataLtf = 8;
228 uint8_t nExtensionLtf = (txVector.
GetNess () < 3) ? txVector.
GetNess () : 4;
247 uint8_t nDataLtf, uint8_t nExtensionLtf )
const
249 NS_ABORT_MSG_IF (nDataLtf == 0 || nDataLtf > 4 || nExtensionLtf > 4 || (nDataLtf + nExtensionLtf) > 5,
250 "Unsupported combination of data (" << +nDataLtf <<
") and extension (" << +nExtensionLtf <<
") LTFs numbers for HT");
252 return MicroSeconds (4) * (1 + nDataLtf + nExtensionLtf);
263 bool incFlag, uint32_t &totalAmpduSize,
double &totalAmpduNumSymbols,
264 uint16_t staId)
const
267 uint8_t stbc = txVector.
IsStbc () ? 2 : 1;
275 double numSymbols = 0;
281 numSymbols = (stbc * (service + size * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol));
284 totalAmpduSize += size;
285 totalAmpduNumSymbols += numSymbols;
292 numSymbols = (stbc * size * 8.0) / (stbc * numDataBitsPerSymbol);
295 totalAmpduSize += size;
296 totalAmpduNumSymbols += numSymbols;
303 uint32_t totalSize = totalAmpduSize + size;
304 numSymbols = lrint (stbc * ceil ((service + totalSize * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol)));
305 NS_ASSERT (totalAmpduNumSymbols <= numSymbols);
306 numSymbols -= totalAmpduNumSymbols;
310 totalAmpduNumSymbols = 0;
320 numSymbols = lrint (stbc * ceil ((service + size * 8.0 + 6.0 * nes) / (stbc * numDataBitsPerSymbol)));
332 return payloadDuration;
345 double maxRatePerCoder = (txVector.
GetGuardInterval () == 800) ? 320e6 : 350e6;
361 return Create<HtPpdu> (psdus.begin ()->second, txVector, ppduDuration,
m_wifiPhy->
GetPhyBand (),
400 NS_LOG_DEBUG (
"Drop packet because HT-SIG reception failed");
423 NS_LOG_DEBUG (
"Packet reception could not be started because not enough RX antennas");
428 NS_LOG_DEBUG (
"Drop packet because it was sent using an unsupported mode (" << txVector.
GetMode () <<
")");
443 std::get<0> (txMaskRejectionParams), std::get<1> (txMaskRejectionParams), std::get<2> (txMaskRejectionParams));
450 for (uint8_t i = 0; i < 32; ++i)
461 return GetHtMcs ## x (); \
498 NS_ABORT_MSG (
"Inexistent (or not supported) index (" << +index <<
") requested for HT");
504 #define GET_HT_MCS(x) \
506 HtPhy::GetHtMcs ## x (void) \
508 static WifiMode mcs = CreateHtMcs (x); \
619 HtPhy::GetPhyRate (uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
622 uint64_t dataRate =
GetDataRate (mcsValue, channelWidth, guardInterval, nss);
665 NS_ASSERT (guardInterval == 800 || guardInterval == 400);
675 uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier,
676 double codingRate, uint8_t nss)
679 usableSubCarriers, numberOfBitsPerSubcarrier,
686 return (channelWidth == 40) ? 108 : 52;
701 switch (constellationSize)
714 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
728 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
742 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
756 NS_FATAL_ERROR (
"Trying to get reference rate for a MCS with wrong combination of coding rate and modulation");
Constructor class for HT 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 GetMaxSupportedMcsIndexPerSs(void) const
Set the maximum supported MCS index per spatial stream.
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
uint8_t GetBssMembershipSelector(void) const
static uint16_t GetHtConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index.
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.
HtPhy(uint8_t maxNss=1, bool buildModeList=true)
Constructor for HT PHY.
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
static uint64_t GetDataRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the data rate corresponding to the supplied HT MCS index, channel width, guard interval,...
static WifiCodeRate GetHtCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS 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 Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const
virtual ~HtPhy()
Destructor for HT PHY.
bool IsMcsSupported(uint8_t index) const override
Check if the WifiMode corresponding to the given MCS index is supported.
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...
Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype, bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols, uint16_t staId) const override
static bool IsAllowed(const WifiTxVector &txVector)
Check whether the combination in TXVECTOR is allowed.
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
WifiMode GetMcs(uint8_t index) const override
Get the WifiMode corresponding to the given MCS index.
virtual uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const
static uint64_t GetNonHtReferenceRate(uint8_t mcsValue)
Calculate the rate in bps of the non-HT Reference Rate corresponding to the supplied HT MCS index.
virtual Time GetLSigDuration(WifiPreamble preamble) const
static uint64_t GetPhyRate(uint8_t mcsValue, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the PHY rate corresponding to the supplied HT MCS index, channel width, guard interval,...
void SetMaxSupportedMcsIndexPerSs(uint8_t maxIndex)
Set the maximum supported MCS index per spatial stream.
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
virtual WifiMode GetHtSigMode(void) const
static WifiMode GetLSigMode(void)
static WifiMode CreateHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
static void InitializeModes(void)
Initialize all HT modes.
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.
virtual void BuildModeList(void)
Build mode list.
bool HandlesMcsModes(void) const override
Check if the WifiModes handled by this PHY are MCSs.
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
uint8_t m_maxSupportedNss
Maximum supported number of spatial streams (used to build HT MCS indices)
static double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
static const PpduFormats m_htPpduFormats
HT PPDU formats.
virtual Time GetHtSigDuration(void) const
void SetMaxSupportedNss(uint8_t maxNss)
Configure the maximum number of spatial streams supported by this HT PHY.
PhyFieldRxStatus EndReceiveHtSig(Ptr< Event > event)
End receiving the HT-SIG, perform HT-specific actions, and provide the status of the reception.
const PpduFormats & GetPpduFormats(void) const override
Return the PPDU formats of the PHY.
static uint16_t GetUsableSubcarriers(uint16_t channelWidth)
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
virtual Time GetSymbolDuration(const WifiTxVector &txVector) const
PHY entity for OFDM (11a)
static WifiMode GetOfdmRate6Mbps(void)
Return a WifiMode for OFDM at 6 Mbps.
uint8_t GetNumberServiceBits(void) const
static uint64_t CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth)
Calculates data rate from the supplied parameters.
virtual bool IsAllConfigSupported(WifiPpduField field, Ptr< const WifiPpdu > ppdu) const
Checks if the signaled configuration (including bandwidth) is supported by the PHY.
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 double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
Time GetSignalExtension(WifiPhyBand band) const
virtual Time GetDuration(WifiPpduField field, const WifiTxVector &txVector) const
Get the duration of the PPDU field (or group of fields) used by this entity for the given transmissio...
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::tuple< double, double, double > GetTxMaskRejectionParams(void) const
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
virtual WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const
Get the WifiMode for the SIG field specified by the PPDU field.
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const
virtual bool IsModeSupported(WifiMode mode) const
Check if the WifiMode is supported.
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.
uint16_t GetCenterFrequencyForChannelWidth(const WifiTxVector &txVector) const
Get the center frequency of the channel corresponding the current TxVector rather than that of the su...
@ DROP
drop PPDU and set CCA_BUSY
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
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.
uint8_t GetMaxSupportedRxSpatialStreams(void) 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.
static Ptr< SpectrumValue > CreateHtOfdmTxPowerSpectralDensity(uint32_t centerFrequency, uint16_t channelWidth, double txPowerW, uint16_t guardBandwidth, double minInnerBandDbr=-20, double minOuterbandDbr=-28, double lowestPointDbr=-40)
Create a transmit power spectral density corresponding to OFDM High Throughput (HT) (802....
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.
uint8_t GetNess(void) const
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
bool IsStbc(void) const
Check if STBC is used or not.
uint16_t GetGuardInterval(void) const
uint8_t GetNssMax(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.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
WifiPhyBand
Identifies the PHY band.
WifiPpduField
The type of PPDU field (grouped for convenience)
MpduType
The type of an MPDU.
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ 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_HT_SIG
HT-SIG field.
@ 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
@ LAST_MPDU_IN_AGGREGATE
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
@ FIRST_MPDU_IN_AGGREGATE
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate.
@ SINGLE_MPDU
The MPDU is a single MPDU.
@ MIDDLE_MPDU_IN_AGGREGATE
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate.
Declaration of ns3::HtPhy class.
#define HT_PHY
This defines the BSS membership value for HT PHY.
Declaration of ns3::HtPpdu class.
static class anonymous_namespace{ht-phy.cc}::ConstructorHt g_constructor_ht
the constructor for HT 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.
const uint16_t WIFI_CODE_RATE_UNDEFINED
undefined coding rate
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.
const uint16_t WIFI_CODE_RATE_1_2
1/2 coding rate
const uint16_t WIFI_CODE_RATE_2_3
2/3 coding rate
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.