24 #include "ns3/wifi-psdu.h" 25 #include "ns3/wifi-phy.h" 26 #include "ns3/wifi-utils.h" 28 #include "ns3/assert.h" 58 NS_ABORT_MSG_IF (maxNss == 0 || maxNss > 4,
"Unsupported max Nss " << +maxNss <<
" for HT PHY");
93 if (mcs.GetMcsValue () == index)
100 NS_ABORT_MSG (
"Unsupported MCS index " << +index <<
" for this PHY entity");
109 if (mcs.GetMcsValue () == index)
170 NS_LOG_LOGIC (
"Rebuild mode list since max MCS index per spatial stream has changed");
188 NS_ABORT_MSG_IF (maxNss == 0 || maxNss > 4,
"Unsupported max Nss " << +maxNss <<
" for HT PHY");
191 NS_LOG_LOGIC (
"Rebuild mode list since max number of spatial streams has changed");
212 uint8_t nDataLtf = 8;
227 uint8_t nExtensionLtf = (txVector.
GetNess () < 3) ? txVector.
GetNess () : 4;
246 uint8_t nDataLtf, uint8_t nExtensionLtf )
const 248 NS_ABORT_MSG_IF (nDataLtf == 0 || nDataLtf > 4 || nExtensionLtf > 4 || (nDataLtf + nExtensionLtf) > 5,
249 "Unsupported combination of data (" << +nDataLtf <<
") and extension (" << +nExtensionLtf <<
") LTFs numbers for HT");
251 return MicroSeconds (4) * (1 + nDataLtf + nExtensionLtf);
262 bool incFlag, uint32_t &totalAmpduSize,
double &totalAmpduNumSymbols,
263 uint16_t staId)
const 266 uint8_t stbc = txVector.
IsStbc () ? 2 : 1;
274 double numSymbols = 0;
280 numSymbols = (stbc * (service + size * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol));
283 totalAmpduSize += size;
284 totalAmpduNumSymbols += numSymbols;
291 numSymbols = (stbc * size * 8.0) / (stbc * numDataBitsPerSymbol);
294 totalAmpduSize += size;
295 totalAmpduNumSymbols += numSymbols;
302 uint32_t totalSize = totalAmpduSize + size;
303 numSymbols = lrint (stbc * ceil ((service + totalSize * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol)));
304 NS_ASSERT (totalAmpduNumSymbols <= numSymbols);
305 numSymbols -= totalAmpduNumSymbols;
309 totalAmpduNumSymbols = 0;
319 numSymbols = lrint (stbc * ceil ((service + size * 8.0 + 6.0 * nes) / (stbc * numDataBitsPerSymbol)));
331 return payloadDuration;
344 double maxRatePerCoder = (txVector.
GetGuardInterval () == 800) ? 320e6 : 350e6;
360 return Create<HtPpdu> (psdus.begin ()->second, txVector, ppduDuration,
m_wifiPhy->
GetPhyBand (),
399 NS_LOG_DEBUG (
"Drop packet because HT-SIG reception failed");
422 NS_LOG_DEBUG (
"Packet reception could not be started because not enough RX antennas");
427 NS_LOG_DEBUG (
"Drop packet because it was sent using an unsupported mode (" << txVector.
GetMode () <<
")");
442 std::get<0> (txMaskRejectionParams), std::get<1> (txMaskRejectionParams), std::get<2> (txMaskRejectionParams));
449 for (uint8_t i = 0; i < 32; ++i)
460 return GetHtMcs ## x (); \ 497 NS_ABORT_MSG (
"Inexistent (or not supported) index (" << +index <<
") requested for HT");
503 #define GET_HT_MCS(x) \ 505 HtPhy::GetHtMcs ## x (void) \ 507 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");
double snr
SNR in linear scale.
uint8_t GetNssMax(void) const
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
static void InitializeModes(void)
Initialize all HT modes.
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...
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.
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
PhyRxFailureAction actionIfFailure
action to perform in case of failure
const uint16_t WIFI_CODE_RATE_2_3
2/3 coding rate
uint8_t GetMaxSupportedMcsIndexPerSs(void) const
Set the maximum supported MCS index per spatial stream.
static uint64_t CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate)
Return the PHY rate corresponding to the supplied code rate and data rate.
uint8_t GetNumberServiceBits(void) const
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
static const PpduFormats m_htPpduFormats
HT PPDU formats.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
WifiPhyRxfailureReason reason
failure reason
virtual uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
static WifiCodeRate GetHtCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool IsStbc(void) const
Check if STBC is used or not.
void SetMaxSupportedNss(uint8_t maxNss)
Configure the maximum number of spatial streams supported by this HT PHY.
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...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
uint8_t GetNess(void) const
#define HT_PHY
This defines the BSS membership value for HT PHY.
uint16_t GetGuardInterval(void) const
static class anonymous_namespace{ht-phy.cc}::ConstructorHt g_constructor_ht
the constructor for HT modes
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.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
const uint16_t WIFI_CODE_RATE_3_4
3/4 coding rate
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...
MpduType
The type of an MPDU.
bool IsAllConfigSupported(WifiPpduField field, Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (including bandwidth) is supported by the PHY.
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...
Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype, bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols, uint16_t staId) const override
WifiPreamble GetPreambleType(void) const
SYNC + SFD fields for DSSS or ERP, shortSYNC + shortSFD fields for HR/DSSS or ERP, HT-GF-STF + HT-GF-LTF1 fields for HT-GF, L-STF + L-LTF fields otherwise.
std::tuple< double, double, double > GetTxMaskRejectionParams(void) const
uint8_t m_maxSupportedNss
Maximum supported number of spatial streams (used to build HT MCS indices)
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
static WifiMode CreateWifiMcs(std::string uniqueName, uint8_t mcsValue, WifiModulationClass modClass, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, PhyRateFromTxVectorCallback phyRateFromTxVectorCallback, DataRateCallback dataRateCallback, DataRateFromTxVectorCallback dataRateFromTxVectorCallback, NonHtReferenceRateCallback nonHtReferenceRateCallback, ModeAllowedCallback isModeAllowedCallback)
The MPDU is not part of an A-MPDU.
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate...
Constructor class for HT modes.
virtual Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const
virtual WifiMode GetHtSigMode(void) const
SnrPer GetPhyHeaderSnrPer(WifiPpduField field, Ptr< Event > event) const
Obtain the SNR and PER of the PPDU field from the WifiPhy's InterferenceHelper class.
virtual Time GetLSigDuration(WifiPreamble preamble) const
Status of the reception of the PPDU field.
virtual ~HtPhy()
Destructor for HT PHY.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
HtPhy(uint8_t maxNss=1, bool buildModeList=true)
Constructor for HT PHY.
static bool IsModeAllowed(uint16_t channelWidth, uint8_t nss)
Check whether the combination of <MCS, channel width, NSS> is allowed.
virtual bool IsAllConfigSupported(WifiPpduField field, Ptr< const WifiPpdu > ppdu) const
Checks if the signaled configuration (including bandwidth) is supported by the PHY.
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate...
virtual void BuildModeList(void)
Build mode list.
PhyFieldRxStatus EndReceiveHtSig(Ptr< Event > event)
End receiving the HT-SIG, perform HT-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...
virtual Time GetSymbolDuration(const WifiTxVector &txVector) const
WifiPpduField
The type of PPDU field (grouped for convenience)
bool IsMcsSupported(uint8_t index) const override
Check if the WifiMode corresponding to the given MCS index is supported.
Time GetSignalExtension(WifiPhyBand band) const
bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (excluding 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 m_maxMcsIndexPerSs
the maximum MCS index per spatial stream as defined by the standard
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.
virtual Time GetHtSigDuration(void) const
uint16_t GetCenterFrequencyForChannelWidth(const WifiTxVector &txVector) const
Get the center frequency of the channel corresponding the current TxVector rather than that of the su...
static uint64_t CalculateDataRate(WifiCodeRate codeRate, uint16_t constellationSize, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Calculates data rate from the supplied parameters.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
bool isSuccess
outcome (true if success) of the reception
A struct for both SNR and PER.
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...
const uint16_t WIFI_CODE_RATE_5_6
5/6 coding rate
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
uint8_t GetBssMembershipSelector(void) const
PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event) override
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
Declaration of ns3::HtPhy class.
virtual WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const
Get the WifiMode for the SIG field specified by the PPDU field.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index between 0 and 7...
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class...
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
bool HandlesMcsModes(void) const override
Check if the WifiModes handled by this PHY are MCSs.
void SetMaxSupportedMcsIndexPerSs(uint8_t maxIndex)
Set the maximum supported MCS index per spatial stream.
drop PPDU and set CCA_BUSY
double RatioToDb(double ratio)
Convert from ratio to dB.
static WifiMode CreateHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
PHY entity for OFDM (11a)This class is also used for the 10 MHz and 5 MHz bandwidth variants addressi...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index between 0 and 7, since HT MCS index > 8 is used for higher NSS.
static double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
WifiPhyBand
Identifies the PHY band.
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
static WifiMode GetLSigMode(void)
static uint16_t GetHtConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
bool IsHt(WifiPreamble preamble)
Return whether the preamble is a HT format preamble.
static WifiMode GetOfdmRate6Mbps(void)
Return a WifiMode for OFDM at 6 Mbps.
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
const uint16_t WIFI_CODE_RATE_UNDEFINED
undefined coding rate
STF + LTF fields (excluding those in preamble for HT-GF)
double GetRandomValue(void) const
Obtain a random value from the WifiPhy's generator.
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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
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...
uint16_t GetChannelWidth(void) const
uint8_t m_bssMembershipSelector
the BSS membership selector
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
PHY header field for DSSS or ERP, short PHY header field for HR/DSSS or ERP, field not present for HT...
The MPDU is a single MPDU.
Declaration of ns3::HtPpdu class.
uint8_t GetMcsValue(void) 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...
virtual bool IsModeSupported(WifiMode mode) const
Check if the WifiMode is supported.
static uint16_t GetUsableSubcarriers(uint16_t channelWidth)
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
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...
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
WifiMode GetMcs(uint8_t index) const override
Get the WifiMode corresponding to the given MCS index.
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
uint8_t GetMaxSupportedRxSpatialStreams(void) const
std::list< WifiMode > m_modeList
the list of supported modes
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
const uint16_t WIFI_CODE_RATE_1_2
1/2 coding rate
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const