|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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");
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
PhyFieldRxStatus EndReceiveHtSig(Ptr< Event > event)
End receiving the HT-SIG, perform HT-specific actions, and provide the status of the reception.
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
bool IsStbc(void) const
Check if STBC is used or not.
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 void BuildModeList(void)
Build mode list.
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.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
@ WIFI_PPDU_FIELD_HT_SIG
HT-SIG field.
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Constructor class for HT modes.
std::list< WifiMode > m_modeList
the list of supported modes
const uint16_t WIFI_CODE_RATE_5_6
5/6 coding rate
uint16_t GetCenterFrequencyForChannelWidth(const WifiTxVector &txVector) const
Get the center frequency of the channel corresponding the current TxVector rather than that of the su...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t GetGuardBandwidth(uint16_t currentChannelWidth) const
static double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
double snr
SNR in linear scale.
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 MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
void SetMaxSupportedMcsIndexPerSs(uint8_t maxIndex)
Set the maximum supported MCS index per spatial stream.
uint8_t GetNssMax(void) const
static class anonymous_namespace{ht-phy.cc}::ConstructorHt g_constructor_ht
the constructor for HT modes
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
virtual bool IsModeSupported(WifiMode mode) const
Check if the WifiMode is supported.
PhyRxFailureAction actionIfFailure
action to perform in case of failure
static WifiMode CreateHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
const uint16_t WIFI_CODE_RATE_UNDEFINED
undefined coding rate
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY 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,...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
bool IsMcsSupported(uint8_t index) const override
Check if the WifiMode corresponding to the given MCS index is supported.
@ WIFI_PPDU_FIELD_PREAMBLE
SYNC + SFD fields for DSSS or ERP, shortSYNC + shortSFD fields for HR/DSSS or ERP,...
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
uint8_t GetNumberServiceBits(void) const
virtual ~HtPhy()
Destructor for HT PHY.
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
@ FIRST_MPDU_IN_AGGREGATE
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate.
static WifiCodeRate GetHtCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index.
bool HandlesMcsModes(void) const override
Check if the WifiModes handled by this PHY are MCSs.
static WifiMode GetOfdmRate6Mbps(void)
Return a WifiMode for OFDM at 6 Mbps.
static uint16_t GetHtConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index.
static WifiMode GetLSigMode(void)
static void InitializeModes(void)
Initialize all HT modes.
uint8_t m_bssMembershipSelector
the BSS membership selector
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
Time GetSignalExtension(WifiPhyBand band) const
static WifiMode GetHtMcs(uint8_t index)
Return the HT MCS corresponding to the provided index.
uint8_t m_maxMcsIndexPerSs
the maximum MCS index per spatial stream as defined by the standard
Smart pointer class similar to boost::intrusive_ptr.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
@ MIDDLE_MPDU_IN_AGGREGATE
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate.
const PpduFormats & GetPpduFormats(void) const override
Return the PPDU formats of the PHY.
uint8_t m_maxSupportedMcsIndexPerSs
the maximum supported MCS index per spatial stream
Declaration of ns3::HtPpdu class.
represent a single transmission mode
WifiPhyRxfailureReason reason
failure reason
bool IsAllConfigSupported(WifiPpduField field, Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (including bandwidth) is supported by the PHY.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Status of the reception of the PPDU field.
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,...
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.
WifiMode GetMcs(uint8_t index) const override
Get the WifiMode corresponding to the given MCS index.
static WifiCodeRate GetCodeRate(uint8_t mcsValue)
Return the coding rate corresponding to the supplied HT MCS index between 0 and 7,...
#define HT_PHY
This defines the BSS membership value for HT PHY.
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< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
const uint16_t WIFI_CODE_RATE_2_3
2/3 coding rate
virtual WifiMode GetHtSigMode(void) const
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 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)
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
uint8_t GetBssMembershipSelector(void) const
uint8_t GetNess(void) const
WifiPreamble GetPreambleType(void) const
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
static uint16_t GetUsableSubcarriers(uint16_t channelWidth)
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
uint16_t GetChannelWidth(void) const
WifiPpduField
The type of PPDU field (grouped for convenience)
bool isSuccess
outcome (true if success) of the reception
static const PpduFormats m_htPpduFormats
HT PPDU formats.
PHY entity for OFDM (11a)
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...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
double RatioToDb(double ratio)
Convert from ratio to dB.
virtual Time GetHtSigDuration(void) const
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
const uint16_t WIFI_CODE_RATE_1_2
1/2 coding rate
double GetRandomValue(void) 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 GetGuardInterval(void) const
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.
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.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
static uint64_t CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate)
Return the PHY rate corresponding to the supplied code rate and data rate.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
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 uint8_t GetNumberBccEncoders(const WifiTxVector &txVector) const
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
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 GetMaxSupportedRxSpatialStreams(void) const
uint8_t m_maxSupportedNss
Maximum supported number of spatial streams (used to build HT MCS indices)
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
@ WIFI_PPDU_FIELD_DATA
data field
A struct for both SNR and PER.
static uint16_t GetConstellationSize(uint8_t mcsValue)
Return the constellation size corresponding to the supplied HT MCS index between 0 and 7,...
@ LAST_MPDU_IN_AGGREGATE
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
static double GetCodeRatio(WifiCodeRate codeRate)
Convert WifiCodeRate to a ratio, e.g., code ratio of WIFI_CODE_RATE_1_2 is 0.5.
@ WIFI_PPDU_FIELD_TRAINING
STF + LTF fields (excluding those in preamble for HT-GF)
WifiPhyBand
Identifies the PHY band.
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
uint8_t GetMaxSupportedMcsIndexPerSs(void) const
Set the maximum supported MCS index per spatial stream.
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....
const uint16_t WIFI_CODE_RATE_3_4
3/4 coding rate
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
virtual Time GetLSigDuration(WifiPreamble preamble) const
virtual WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const
Get the WifiMode for the SIG field specified by the PPDU field.
std::tuple< double, double, double > GetTxMaskRejectionParams(void) const
Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype, bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols, uint16_t staId) const override
HtPhy(uint8_t maxNss=1, bool buildModeList=true)
Constructor for HT PHY.
Declaration of ns3::HtPhy class.
virtual Time GetSymbolDuration(const WifiTxVector &txVector) const
virtual Time GetTrainingDuration(const WifiTxVector &txVector, uint8_t nDataLtf, uint8_t nExtensionLtf=0) const
@ 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...
bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const override
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
@ SINGLE_MPDU
The MPDU is a single MPDU.
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.
void SetMaxSupportedNss(uint8_t maxNss)
Configure the maximum number of spatial streams supported by this HT PHY.
@ DROP
drop PPDU and set CCA_BUSY
virtual uint64_t ObtainNextUid(const WifiTxVector &txVector)
Obtain the next UID for the PPDU to transmit.
MpduType
The type of an MPDU.
uint8_t GetMcsValue(void) const
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.