25 #include "ns3/assert.h"
26 #include "ns3/interference-helper.h"
28 #include "ns3/wifi-phy.h"
29 #include "ns3/wifi-psdu.h"
30 #include "ns3/wifi-utils.h"
64 "Unsupported max Nss " << +maxNss <<
" for HT PHY");
99 if (mcs.GetMcsValue() == index)
106 NS_ABORT_MSG(
"Unsupported MCS index " << +index <<
" for this PHY entity");
115 if (mcs.GetMcsValue() == index)
176 "Provided max MCS index " << +maxIndex
177 <<
" per SS greater than max standard-defined value "
181 NS_LOG_LOGIC(
"Rebuild mode list since max MCS index per spatial stream has changed");
202 NS_LOG_LOGIC(
"Rebuild mode list since max number of spatial streams has changed");
222 uint8_t nDataLtf = 8;
238 uint8_t nExtensionLtf = (txVector.
GetNess() < 3) ? txVector.
GetNess() : 4;
258 uint8_t nExtensionLtf )
const
261 (nDataLtf + nExtensionLtf) > 5,
262 "Unsupported combination of data ("
263 << +nDataLtf <<
") and extension (" << +nExtensionLtf
264 <<
") LTFs numbers for HT");
267 return MicroSeconds(4) * (1 + nDataLtf + nExtensionLtf);
282 uint32_t& totalAmpduSize,
283 double& totalAmpduNumSymbols,
284 uint16_t staId)
const
287 uint8_t stbc = txVector.
IsStbc() ? 2 : 1;
293 double numDataBitsPerSymbol =
297 double numSymbols = 0;
302 numSymbols = (stbc * (service + size * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol));
305 totalAmpduSize += size;
306 totalAmpduNumSymbols += numSymbols;
312 numSymbols = (stbc * size * 8.0) / (stbc * numDataBitsPerSymbol);
315 totalAmpduSize += size;
316 totalAmpduNumSymbols += numSymbols;
322 uint32_t totalSize = totalAmpduSize + size;
324 stbc * ceil((service + totalSize * 8.0 + 6 * nes) / (stbc * numDataBitsPerSymbol)));
325 NS_ASSERT(totalAmpduNumSymbols <= numSymbols);
326 numSymbols -= totalAmpduNumSymbols;
330 totalAmpduNumSymbols = 0;
340 lrint(stbc * ceil((service + size * 8.0 + 6.0 * nes) / (stbc * numDataBitsPerSymbol)));
347 Time payloadDuration =
353 return payloadDuration;
366 double maxRatePerCoder = (txVector.
GetGuardInterval() == 800) ? 320e6 : 350e6;
382 return Create<HtPpdu>(psdus.begin()->second,
424 NS_LOG_DEBUG(
"Drop packet because HT-SIG reception failed");
444 const auto& txVector = ppdu->GetTxVector();
447 NS_LOG_DEBUG(
"Packet reception could not be started because not enough RX antennas");
452 NS_LOG_DEBUG(
"Drop packet because it was sent using an unsupported mode ("
453 << txVector.GetMode() <<
")");
462 const auto& txVector = ppdu->GetTxVector();
464 uint16_t channelWidth = txVector.GetChannelWidth();
472 std::get<0>(txMaskRejectionParams),
473 std::get<1>(txMaskRejectionParams),
474 std::get<2>(txMaskRejectionParams));
481 for (uint8_t i = 0; i < 32; ++i)
492 return GetHtMcs##x();
529 NS_ABORT_MSG(
"Inexistent (or not supported) index (" << +index <<
") requested for HT");
535 #define GET_HT_MCS(x) \
536 WifiMode HtPhy::GetHtMcs##x() \
538 static WifiMode mcs = CreateHtMcs(x); \
652 uint64_t dataRate =
GetDataRate(mcsValue, channelWidth, guardInterval, nss);
695 NS_ASSERT(guardInterval == 800 || guardInterval == 400);
706 uint16_t usableSubCarriers,
707 uint16_t numberOfBitsPerSubcarrier,
713 numberOfBitsPerSubcarrier,
720 return (channelWidth == 40) ? 108 : 52;
741 switch (constellationSize)
754 NS_FATAL_ERROR(
"Trying to get reference rate for a MCS with wrong combination of "
755 "coding rate and modulation");
769 NS_FATAL_ERROR(
"Trying to get reference rate for a MCS with wrong combination of "
770 "coding rate and modulation");
784 NS_FATAL_ERROR(
"Trying to get reference rate for a MCS with wrong combination of "
785 "coding rate and modulation");
799 NS_FATAL_ERROR(
"Trying to get reference rate for a MCS with wrong combination of "
800 "coding rate and modulation");
833 return std::make_pair(
839 const uint16_t primaryWidth = 20;
840 uint16_t p20MinFreq =
843 uint16_t p20MaxFreq =
846 if (ppdu->DoesOverlapChannel(p20MinFreq, p20MaxFreq))
856 const uint16_t secondaryWidth = 20;
857 uint16_t s20MinFreq =
859 (secondaryWidth / 2);
860 uint16_t s20MaxFreq =
862 (secondaryWidth / 2);
863 if (!ppdu || ppdu->DoesOverlapChannel(s20MinFreq, s20MaxFreq))
891 ns3::Create<ns3::HtPhy>());
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.
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...
~HtPhy() override
Destructor for HT PHY.
static WifiMode GetLSigMode()
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 void InitializeModes()
Initialize all HT modes.
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
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
uint8_t GetBssMembershipSelector() const
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.
static WifiMode CreateHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
uint32_t GetMaxPsduSize() const override
Get the maximum PSDU size in bytes.
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index between 0 and 7,...
virtual WifiMode GetHtSigMode() const
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.
uint8_t GetMaxSupportedMcsIndexPerSs() const
Set the maximum supported MCS index per spatial stream.
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)
virtual void BuildModeList()
Build mode list.
static double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
bool HandlesMcsModes() const override
Check if the WifiModes handled by this PHY are MCSs.
static const PpduFormats m_htPpduFormats
HT PPDU formats.
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.
virtual Time GetHtSigDuration() const
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
const PpduFormats & GetPpduFormats() const override
Return the PPDU formats of the PHY.
virtual Time GetSymbolDuration(const WifiTxVector &txVector) const
PHY entity for OFDM (11a)
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6 Mbps.
uint8_t GetNumberServiceBits() const
double GetCcaThreshold(const Ptr< const WifiPpdu > ppdu, WifiChannelListType channelType) const override
Return the CCA threshold in dBm for a given channel type.
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.
static uint16_t GetUsableSubcarriers()
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...
PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event) override
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
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.
Time GetSignalExtension(WifiPhyBand band) const
std::tuple< double, double, double > GetTxMaskRejectionParams() const
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.
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const
virtual bool IsModeSupported(WifiMode mode) const
Check if the WifiMode is supported.
std::optional< std::pair< Time, WifiChannelListType > > CcaIndication
CCA end time and its corresponding channel list type (can be std::nullopt if IDLE)
virtual CcaIndication GetCcaIndication(const Ptr< const WifiPpdu > ppdu)
Get CCA end time and its corresponding channel list type when a new signal has been received by the P...
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.
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
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.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetFemtoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
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
uint16_t GetChannelWidth() const
uint8_t GetMaxSupportedRxSpatialStreams() 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.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
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.
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...
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.
bool IsStbc() const
Check if STBC is used or not.
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.
uint8_t GetNssMax() const
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.
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_CHANLIST_SECONDARY
@ 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.
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.
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.
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...
constexpr uint8_t HT_MAX_NSS
Maximum number of supported NSS by HT PHY.
WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
@ WIFI_CODE_RATE_2_3
2/3 coding rate
@ WIFI_CODE_RATE_1_2
1/2 coding rate
@ WIFI_CODE_RATE_3_4
3/4 coding rate
@ WIFI_CODE_RATE_UNDEFINED
undefined 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.