|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
25 #include "ns3/wifi-psdu.h"
26 #include "ns3/wifi-phy.h"
27 #include "ns3/wifi-utils.h"
28 #include "ns3/simulator.h"
78 { 6000000, 9000000, 12000000, 18000000,
79 24000000, 36000000, 48000000, 54000000 }},
81 { 3000000, 4500000, 6000000, 9000000,
82 12000000, 18000000, 24000000, 27000000 }},
84 { 1500000, 2250000, 3000000, 4500000,
85 6000000, 9000000, 12000000, 13500000 }}};
111 for (
const auto & rate : bwRatesMap.at (20))
119 for (
const auto & rate : bwRatesMap.at (10))
127 for (
const auto & rate : bwRatesMap.at (5))
243 bool , uint32_t & ,
double & ,
254 double numSymbols = lrint (ceil ((
GetNumberServiceBits () + size * 8.0 + 6.0) / (numDataBitsPerSymbol)));
258 return payloadDuration;
309 NS_LOG_DEBUG (
"Abort reception because non-HT PHY header reception failed");
319 uint16_t channelWidth = ppdu->GetTxVector ().GetChannelWidth ();
347 std::get<0> (txMaskRejectionParams), std::get<1> (txMaskRejectionParams), std::get<2> (txMaskRejectionParams));
356 for (
const auto & rate : ratesPerBw.second)
388 NS_ABORT_MSG (
"Inexistent rate (" << rate <<
" bps) requested for 11a OFDM (default)");
412 NS_ABORT_MSG (
"Inexistent rate (" << rate <<
" bps) requested for 11a OFDM (10 MHz)");
436 NS_ABORT_MSG (
"Inexistent rate (" << rate <<
" bps) requested for 11a OFDM (5 MHz)");
441 NS_ABORT_MSG (
"Inexistent bandwidth (" << +bw <<
" MHz) requested for 11a OFDM");
446 #define GET_OFDM_MODE(x, f) \
448 OfdmPhy::Get ## x (void) \
450 static WifiMode mode = CreateOfdmMode (#x, f); \
518 uint64_t dataRate =
GetDataRate (name, channelWidth, guardInterval, nss);
550 NS_FATAL_ERROR (
"trying to get code ratio for undefined coding rate");
569 return CalculateDataRate (codeRate, constellationSize, channelWidth, guardInterval, nss);
575 double symbolDuration = 3.2;
576 uint16_t guardInterval = 800;
577 if (channelWidth == 10)
579 symbolDuration = 6.4;
580 guardInterval = 1600;
582 else if (channelWidth == 5)
584 symbolDuration = 12.8;
585 guardInterval = 3200;
588 48,
static_cast<uint16_t
> (log2 (constellationSize)),
594 uint16_t usableSubCarriers, uint16_t numberOfBitsPerSubcarrier,
597 double symbolRate = (1 / (symbolDuration + (
static_cast<double> (guardInterval) / 1000))) * 1e6;
598 return lrint (ceil (symbolRate * usableSubCarriers * numberOfBitsPerSubcarrier * codingRate));
static WifiMode GetOfdmRate24MbpsBW10MHz(void)
Return a WifiMode for OFDM at 24 Mbps with 10 MHz channel spacing.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static WifiMode GetOfdmRate12Mbps(void)
Return a WifiMode for OFDM at 12Mbps.
static WifiMode GetOfdmRate2_25MbpsBW5MHz(void)
Return a WifiMode for OFDM at 2.25 Mbps with 5 MHz channel spacing.
std::map< WifiPreamble, std::vector< WifiPpduField > > PpduFormats
A map of PPDU field elements per preamble type.
static WifiMode GetOfdmRate13_5MbpsBW5MHz(void)
Return a WifiMode for OFDM at 13.5 Mbps with 5 MHz channel spacing.
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 bool IsAllConfigSupported(WifiPpduField field, Ptr< const WifiPpdu > ppdu) const
Checks if the signaled configuration (including bandwidth) is supported by the PHY.
OfdmPhy(OfdmPhyVariant variant=OFDM_PHY_DEFAULT, bool buildModeList=true)
Constructor for OFDM PHY.
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
std::list< WifiMode > m_modeList
the list of supported modes
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.
static uint64_t CalculatePhyRate(WifiCodeRate codeRate, uint64_t dataRate)
Calculate the PHY rate in bps from code rate and data rate.
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.
double snr
SNR in linear scale.
static class anonymous_namespace{ofdm-phy.cc}::ConstructorOfdm g_constructor_ofdm
the constructor for OFDM modes
static uint64_t GetPhyRate(const std::string &name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the PHY rate from the OFDM mode's unique name and the supplied parameters.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
PhyRxFailureAction actionIfFailure
action to perform in case of failure
static WifiMode GetOfdmRate6MbpsBW10MHz(void)
Return a WifiMode for OFDM at 6 Mbps with 10 MHz channel spacing.
const uint16_t WIFI_CODE_RATE_UNDEFINED
undefined coding rate
static WifiMode GetOfdmRate1_5MbpsBW5MHz(void)
Return a WifiMode for OFDM at 1.5 Mbps with 5 MHz channel spacing.
static WifiMode GetOfdmRate9MbpsBW10MHz(void)
Return a WifiMode for OFDM at 9 Mbps with 10 MHz channel spacing.
@ ABORT
abort reception of PPDU
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
static uint64_t GetDataRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the data rate corresponding to the supplied TXVECTOR.
static WifiMode GetOfdmRate9MbpsBW5MHz(void)
Return a WifiMode for OFDM at 9 Mbps with 5 MHz channel spacing.
@ 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
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 void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
static WifiMode GetOfdmRate12MbpsBW10MHz(void)
Return a WifiMode for OFDM at 12 Mbps with 10 MHz channel spacing.
static WifiMode GetOfdmRate6Mbps(void)
Return a WifiMode for OFDM at 6 Mbps.
static Ptr< SpectrumValue > CreateOfdmTxPowerSpectralDensity(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 (802.11a/g).
virtual Time GetHeaderDuration(const WifiTxVector &txVector) const
static WifiMode GetOfdmRate36Mbps(void)
Return a WifiMode for OFDM at 36 Mbps.
Time GetSignalExtension(WifiPhyBand band) const
virtual Time GetPreambleDuration(const WifiTxVector &txVector) const
Smart pointer class similar to boost::intrusive_ptr.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
uint16_t WifiCodeRate
These constants define the various convolutional coding rates used for the OFDM transmission modes in...
static WifiMode GetOfdmRate9Mbps(void)
Return a WifiMode for OFDM at 9 Mbps.
static WifiMode GetOfdmRate6MbpsBW5MHz(void)
Return a WifiMode for OFDM at 6 Mbps with 5 MHz channel spacing.
OfdmPhyVariant
The OFDM (11a) PHY variants.
PhyFieldRxStatus EndReceiveHeader(Ptr< Event > event)
End receiving the header, perform OFDM-specific actions, and provide the status of the reception.
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...
represent a single transmission mode
static uint64_t GetPhyRateFromTxVector(const WifiTxVector &txVector, uint16_t staId)
Return the PHY rate corresponding to the supplied TXVECTOR.
WifiPhyRxfailureReason reason
failure reason
Status of the reception of the PPDU field.
static const PpduFormats m_ofdmPpduFormats
OFDM PPDU formats.
static WifiMode CreateWifiMode(std::string uniqueName, WifiModulationClass modClass, bool isMandatory, CodeRateCallback codeRateCallback, ConstellationSizeCallback constellationSizeCallback, PhyRateCallback phyRateCallback, PhyRateFromTxVectorCallback phyRateFromTxVectorCallback, DataRateCallback dataRateCallback, DataRateFromTxVectorCallback dataRateFromTxVectorCallback, ModeAllowedCallback isModeAllowedCallback)
static WifiMode GetOfdmRate27MbpsBW10MHz(void)
Return a WifiMode for OFDM at 27 Mbps with 10 MHz channel spacing.
const std::map< uint16_t, std::array< uint64_t, 8 > > & GetOfdmRatesBpsList(void)
Get the array of possible OFDM rates for each bandwidth (MHz).
Ptr< WifiPhy > m_wifiPhy
Pointer to the owning WifiPhy.
const uint16_t WIFI_CODE_RATE_2_3
2/3 coding rate
static WifiMode GetOfdmRate3MbpsBW10MHz(void)
Return a WifiMode for OFDM at 3 Mbps with 10 MHz channel spacing.
std::string GetUniqueName(void) const
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Simulation virtual time values and global simulation resolution.
static WifiMode CreateOfdmMode(std::string uniqueName, bool isMandatory)
Create an OFDM mode from a unique name, the unique name must already be contained inside ModulationLo...
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static uint16_t GetConstellationSize(const std::string &name)
Return the constellation size from the OFDM mode's unique name using ModulationLookupTable.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual PhyFieldRxStatus DoEndReceiveField(WifiPpduField field, Ptr< Event > event)
End receiving a given field, perform amendment-specific actions, and provide the status of the recept...
Declaration of ns3::OfdmPhy class and ns3::OfdmPhyVariant enum.
uint16_t GetChannelWidth(void) const
WifiPpduField
The type of PPDU field (grouped for convenience)
static void InitializeModes(void)
Initialize all OFDM modes (for all variants).
bool isSuccess
outcome (true if success) of the reception
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.
double RatioToDb(double ratio)
Convert from ratio to dB.
static WifiMode GetOfdmRate48Mbps(void)
Return a WifiMode for OFDM at 48 Mbps.
virtual bool IsChannelWidthSupported(Ptr< const WifiPpdu > ppdu) const
Checks if the PPDU's bandwidth is supported by the PHY.
const PpduFormats & GetPpduFormats(void) const override
Return the PPDU formats of the PHY.
virtual ~OfdmPhy()
Destructor for OFDM PHY.
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.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
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 WifiMode GetOfdmRate3MbpsBW5MHz(void)
Return a WifiMode for OFDM at 3 Mbps with 5 MHz channel spacing.
Ptr< WifiPpdu > BuildPpdu(const WifiConstPsduMap &psdus, const WifiTxVector &txVector, Time ppduDuration) override
Build amendment-specific PPDU.
static WifiMode GetOfdmRate4_5MbpsBW10MHz(void)
Return a WifiMode for OFDM at 4.5 Mbps with 10 MHz channel spacing.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Declaration of ns3::OfdmPpdu class.
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...
static const ModulationLookupTable m_ofdmModulationLookupTable
lookup table to retrieve code rate and constellation size corresponding to a unique name of modulatio...
static WifiMode GetOfdmRate(uint64_t rate, uint16_t bw=20)
Return a WifiMode for OFDM corresponding to the provided rate and the channel bandwidth (20,...
static WifiMode GetOfdmRate24Mbps(void)
Return a WifiMode for OFDM at 24 Mbps.
Constructor class for OFDM modes.
static WifiMode GetOfdmRate54Mbps(void)
Return a WifiMode for OFDM at 54 Mbps.
uint16_t GetChannelWidth(void) const
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
std::map< std::string, CodeRateConstellationSizePair > ModulationLookupTable
A modulation lookup table using unique name of modulation as key.
virtual WifiMode GetHeaderMode(const WifiTxVector &txVector) const
#define GET_OFDM_MODE(x, f)
static WifiMode GetOfdmRate18MbpsBW10MHz(void)
Return a WifiMode for OFDM at 18 Mbps with 10 MHz channel spacing.
static WifiMode GetOfdmRate4_5MbpsBW5MHz(void)
Return a WifiMode for OFDM at 4.5 Mbps with 5 MHz channel spacing.
@ WIFI_PPDU_FIELD_DATA
data field
A struct for both SNR and PER.
static WifiMode GetOfdmRate18Mbps(void)
Return a WifiMode for OFDM at 18 Mbps.
static uint64_t GetDataRate(const std::string &name, uint16_t channelWidth, uint16_t guardInterval, uint8_t nss)
Return the data rate from the OFDM mode's unique name and the supplied parameters.
WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const override
Get the WifiMode for the SIG field specified by the PPDU field.
WifiPhyBand
Identifies the PHY band.
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
Ptr< SpectrumValue > GetTxPowerSpectralDensity(double txPowerW, Ptr< const WifiPpdu > ppdu) const override
const std::map< uint16_t, std::array< uint64_t, 8 > > s_ofdmRatesBpsList
OFDM rates in bits per second for each bandwidth (MHz)
virtual WifiMode GetSigMode(WifiPpduField field, const WifiTxVector &txVector) const
Get the WifiMode for the SIG field specified by the PPDU field.
virtual bool IsConfigSupported(Ptr< const WifiPpdu > ppdu) const
Checks if the signaled configuration (excluding bandwidth) is supported by the PHY.
std::tuple< double, double, double > GetTxMaskRejectionParams(void) const
static WifiCodeRate GetCodeRate(const std::string &name)
Return the WifiCodeRate from the OFDM mode's unique name using ModulationLookupTable.
static bool IsModeAllowed(uint16_t channelWidth, uint8_t nss)
Check whether the combination of <WifiMode, channel width, NSS> is allowed.
@ 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...
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.
@ 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.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
uint32_t GetMaxPsduSize(void) const override
Get the maximum PSDU size in bytes.
static WifiMode GetOfdmRate12MbpsBW5MHz(void)
Return a WifiMode for OFDM at 12 Mbps with 5 MHz channel spacing.