23 #include "ns3/simulator.h" 25 #include "ns3/pointer.h" 26 #include "ns3/mobility-model.h" 27 #include "ns3/random-variable-stream.h" 28 #include "ns3/error-model.h" 38 #include "ns3/ht-configuration.h" 39 #include "ns3/he-configuration.h" 44 #include "ns3/dsss-phy.h" 45 #include "ns3/erp-ofdm-phy.h" 46 #include "ns3/he-phy.h" 301 .SetGroupName (
"Wifi")
302 .AddAttribute (
"Frequency",
303 "The center frequency (MHz) of the operating channel. " 304 "If the operating channel for this object has not been set yet, the " 305 "value of this attribute is saved and will be used, along with the channel " 306 "number and width configured via other attributes, to set the operating " 307 "channel when the standard and band are configured. The default value of " 308 "this attribute is 0, which means unspecified center frequency. Note that " 309 "if center frequency and channel number are both 0 when the standard and " 310 "band are configured, a default channel (of the configured width, if any, " 311 "or the default width for the current standard and band, otherwise) is set. " 312 "If the operating channel for this object has been already set, the " 313 "specified center frequency must uniquely identify a channel in the " 318 MakeUintegerChecker<uint16_t> ())
319 .AddAttribute (
"ChannelNumber",
320 "The channel number of the operating channel. " 321 "If the operating channel for this object has not been set yet, the " 322 "value of this attribute is saved and will be used, along with the center " 323 "frequency and width configured via other attributes, to set the operating " 324 "channel when the standard and band are configured. The default value of " 325 "this attribute is 0, which means unspecified channel number. Note that " 326 "if center frequency and channel number are both 0 when the standard and " 327 "band are configured, a default channel (of the configured width, if any, " 328 "or the default width for the current standard and band, otherwise) is set. " 329 "If the operating channel for this object has been already set, the " 330 "specified channel number must uniquely identify a channel in the " 335 MakeUintegerChecker<uint8_t> (0, 233))
336 .AddAttribute (
"ChannelWidth",
337 "The width in MHz of the operating channel (5, 10, 20, 22, 40, 80 or 160). " 338 "If the operating channel for this object has not been set yet, the " 339 "value of this attribute is saved and will be used, along with the center " 340 "frequency and channel number configured via other attributes, to set the " 341 "operating channel when the standard and band are configured. The default value " 342 "of this attribute is 0, which means unspecified channel width. Note that " 343 "if center frequency and channel number are both 0 when the standard and " 344 "band are configured, a default channel (of the configured width, if any, " 345 "or the default width for the current standard and band, otherwise) is set. " 346 "Do not set this attribute when the standard and band of this object have " 347 "been already configured, because it cannot uniquely identify a channel in " 348 "the band being used.",
352 MakeUintegerChecker<uint16_t> (5, 160))
353 .AddAttribute (
"Primary20MHzIndex",
354 "The index of the primary 20 MHz channel within the operating channel " 355 "(0 indicates the 20 MHz subchannel with the lowest center frequency). " 356 "This attribute is only valid if the width of the operating channel is " 357 "a multiple of 20 MHz.",
360 MakeUintegerChecker<uint8_t> (0, 7))
361 .AddAttribute (
"RxSensitivity",
362 "The energy of a received signal should be higher than " 363 "this threshold (dBm) for the PHY to detect the signal. " 364 "This threshold refers to a width of 20 MHz and will be " 365 "scaled to match the width of the received signal.",
369 MakeDoubleChecker<double> ())
370 .AddAttribute (
"CcaEdThreshold",
371 "The energy of a non Wi-Fi received signal should be higher than " 372 "this threshold (dBm) to allow the PHY layer to declare CCA BUSY state. " 373 "This check is performed on the 20 MHz primary channel only.",
377 MakeDoubleChecker<double> ())
378 .AddAttribute (
"TxGain",
379 "Transmission gain (dB).",
383 MakeDoubleChecker<double> ())
384 .AddAttribute (
"RxGain",
385 "Reception gain (dB).",
389 MakeDoubleChecker<double> ())
390 .AddAttribute (
"TxPowerLevels",
391 "Number of transmission power levels available between " 392 "TxPowerStart and TxPowerEnd included.",
395 MakeUintegerChecker<uint8_t> ())
396 .AddAttribute (
"TxPowerEnd",
397 "Maximum available transmission level (dBm).",
401 MakeDoubleChecker<double> ())
402 .AddAttribute (
"TxPowerStart",
403 "Minimum available transmission level (dBm).",
407 MakeDoubleChecker<double> ())
408 .AddAttribute (
"RxNoiseFigure",
409 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver." 410 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is " 411 "\"the difference in decibels (dB) between" 412 " the noise output of the actual receiver to the noise output of an " 413 " ideal receiver with the same overall gain and bandwidth when the receivers " 414 " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
417 MakeDoubleChecker<double> ())
418 .AddAttribute (
"State",
419 "The state of the PHY layer.",
422 MakePointerChecker<WifiPhyStateHelper> ())
423 .AddAttribute (
"ChannelSwitchDelay",
424 "Delay between two short frames transmitted on different frequencies.",
428 .AddAttribute (
"Antennas",
429 "The number of antennas on the device.",
433 MakeUintegerChecker<uint8_t> (1, 8))
434 .AddAttribute (
"MaxSupportedTxSpatialStreams",
435 "The maximum number of supported TX spatial streams." 436 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
440 MakeUintegerChecker<uint8_t> (1, 8))
441 .AddAttribute (
"MaxSupportedRxSpatialStreams",
442 "The maximum number of supported RX spatial streams." 443 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
447 MakeUintegerChecker<uint8_t> (1, 8))
448 .AddAttribute (
"ShortPlcpPreambleSupported",
449 "Whether or not short PHY preamble is supported." 450 "This parameter is only valuable for 802.11b STAs and APs." 451 "Note: 802.11g APs and STAs always support short PHY preamble.",
456 .AddAttribute (
"FrameCaptureModel",
457 "Ptr to an object that implements the frame capture model",
460 MakePointerChecker <FrameCaptureModel> ())
461 .AddAttribute (
"PreambleDetectionModel",
462 "Ptr to an object that implements the preamble detection model",
465 MakePointerChecker <PreambleDetectionModel> ())
466 .AddAttribute (
"PostReceptionErrorModel",
467 "An optional packet error model can be added to the receive " 468 "packet process after any propagation-based (SNR-based) error " 469 "models have been applied. Typically this is used to force " 470 "specific packet drops, for testing purposes.",
473 MakePointerChecker<ErrorModel> ())
474 .AddAttribute (
"Sifs",
475 "The duration of the Short Interframe Space. " 476 "NOTE that the default value is overwritten by the value defined " 477 "by the standard; if you want to set this attribute, you have to " 478 "do it after that the PHY object is initialized.",
482 .AddAttribute (
"Slot",
483 "The duration of a slot. " 484 "NOTE that the default value is overwritten by the value defined " 485 "by the standard; if you want to set this attribute, you have to " 486 "do it after that the PHY object is initialized.",
490 .AddAttribute (
"Pifs",
491 "The duration of the PCF Interframe Space. " 492 "NOTE that the default value is overwritten by the value defined " 493 "by the standard; if you want to set this attribute, you have to " 494 "do it after that the PHY object is initialized.",
498 .AddAttribute (
"PowerDensityLimit",
499 "The mean equivalent isotropically radiated power density" 500 "limit (in dBm/MHz) set by regulators.",
503 MakeDoubleChecker<double> ())
504 .AddTraceSource (
"PhyTxBegin",
505 "Trace source indicating a packet " 506 "has begun transmitting over the channel medium",
508 "ns3::Packet::TracedCallback")
509 .AddTraceSource (
"PhyTxPsduBegin",
510 "Trace source indicating a PSDU " 511 "has begun transmitting over the channel medium",
513 "ns3::WifiPhy::PsduTxBeginCallback")
514 .AddTraceSource (
"PhyTxEnd",
515 "Trace source indicating a packet " 516 "has been completely transmitted over the channel.",
518 "ns3::Packet::TracedCallback")
519 .AddTraceSource (
"PhyTxDrop",
520 "Trace source indicating a packet " 521 "has been dropped by the device during transmission",
523 "ns3::Packet::TracedCallback")
524 .AddTraceSource (
"PhyRxBegin",
525 "Trace source indicating a packet " 526 "has begun being received from the channel medium " 529 "ns3::Packet::TracedCallback")
530 .AddTraceSource (
"PhyRxPayloadBegin",
531 "Trace source indicating the reception of the " 532 "payload of a PPDU has begun",
534 "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
535 .AddTraceSource (
"PhyRxEnd",
536 "Trace source indicating a packet " 537 "has been completely received from the channel medium " 540 "ns3::Packet::TracedCallback")
541 .AddTraceSource (
"PhyRxDrop",
542 "Trace source indicating a packet " 543 "has been dropped by the device during reception",
545 "ns3::Packet::TracedCallback")
546 .AddTraceSource (
"MonitorSnifferRx",
547 "Trace source simulating a wifi device in monitor mode " 548 "sniffing all received frames",
550 "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
551 .AddTraceSource (
"MonitorSnifferTx",
552 "Trace source simulating the capability of a wifi device " 553 "in monitor mode to sniff all frames being transmitted",
555 "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
561 : m_txMpduReferenceNumber (0xffffffff),
562 m_rxMpduReferenceNumber (0xffffffff),
566 m_previouslyRxPpduUid (UINT64_MAX),
569 m_initialFrequency (0),
570 m_initialChannelNumber (0),
571 m_initialChannelWidth (0),
572 m_initialPrimary20Index (0),
577 m_blockAckTxTime (
Seconds (0)),
578 m_powerRestricted (false),
579 m_channelAccessRequested (false),
580 m_txSpatialStreams (0),
581 m_rxSpatialStreams (0),
582 m_wifiRadioEnergyModel (0),
583 m_timeLastPreambleDetected (
Seconds (0))
586 m_random = CreateObject<UniformRandomVariable> ();
587 m_state = CreateObject<WifiPhyStateHelper> ();
603 phyEntity.second->CancelAllEvents ();
617 preambleEvent.second = 0;
623 phyEntity.second = 0;
637 m_state->SetReceiveOkCallback (callback);
643 m_state->SetReceiveErrorCallback (callback);
649 m_state->RegisterListener (listener);
655 m_state->UnregisterListener (listener);
899 phyEntity->SetOwner (
this);
1022 NS_FATAL_ERROR (
"802.11p configured with a wrong channel width!");
1151 NS_LOG_DEBUG (
"Saving frequency configuration for initialization");
1182 NS_LOG_DEBUG (
"Saving channel number configuration for initialization");
1209 if (channelWidth != 0)
1218 NS_LOG_DEBUG (
"Saving channel width configuration for initialization");
1229 NS_ABORT_MSG (
"The channel width does not uniquely identify an operating channel.");
1247 NS_LOG_DEBUG (
"Saving primary20 index configuration for initialization");
1278 uint16_t prevChannelWidth = 0;
1318 NS_LOG_DEBUG (
"drop packet because of channel switching while reception");
1322 phyEntity.second->CancelAllEvents ();
1326 NS_LOG_DEBUG (
"channel switching postponed until end of current transmission");
1333 phyEntity.second->CancelAllEvents ();
1337 NS_LOG_DEBUG (
"channel switching ignored in sleep mode");
1366 NS_ASSERT_MSG (antennas > 0 && antennas <= 4,
"unsupported number of antennas");
1388 Ptr<HtPhy> htPhy = DynamicCast<HtPhy> (phyEntity->second);
1429 std::list<uint8_t>
list;
1432 Ptr<HtPhy> htPhy = DynamicCast<HtPhy> (phyEntity.second);
1435 list.emplace_back (htPhy->GetBssMembershipSelector ());
1452 NS_LOG_FUNCTION (
"Adding " << width <<
" to supported channel width set");
1456 std::vector<uint16_t>
1471 NS_LOG_DEBUG (
"setting sleep mode postponed until end of current transmission");
1475 NS_LOG_DEBUG (
"setting sleep mode postponed until end of current reception");
1479 NS_LOG_DEBUG (
"setting sleep mode postponed until end of channel switching");
1506 phyEntity.second->CancelAllEvents ();
1524 NS_LOG_DEBUG (
"not in sleep mode, there is nothing to resume");
1531 m_state->SwitchFromSleep (delayUntilCcaEnd);
1555 NS_LOG_DEBUG (
"not in off mode, there is nothing to resume");
1562 m_state->SwitchFromOff (delayUntilCcaEnd);
1588 uint32_t totalAmpduSize;
1589 double totalAmpduNumSymbols;
1590 return GetPayloadDuration (size, txVector, band, mpdutype,
false, totalAmpduSize, totalAmpduNumSymbols, staId);
1595 bool incFlag, uint32_t &totalAmpduSize,
double &totalAmpduNumSymbols,
1599 incFlag, totalAmpduSize, totalAmpduNumSymbols,
1639 for (
auto const& psdu : psdus)
1651 for (
auto const& psdu : psdus)
1707 SignalNoiseDbm signalNoise, std::vector<bool> statusPerMpdu, uint16_t staId)
1716 NS_ASSERT_MSG (statusPerMpdu.size () == nMpdus,
"Should have one reception status per MPDU");
1718 for (
size_t i = 0; i < nMpdus;)
1720 if (statusPerMpdu.at (i))
1731 NS_ASSERT_MSG (statusPerMpdu.size () == 1,
"Should have one reception status for normal MPDU");
1747 for (
size_t i = 0; i < nMpdus;)
1794 NS_LOG_DEBUG (
"Dropping packet because in sleep mode");
1795 for (
auto const& psdu : psdus)
1803 if (txVector.
IsMu ())
1814 bool noEndPreambleDetectionEvent =
true;
1817 noEndPreambleDetectionEvent &= it.second->NoEndPreambleDetectionEvents ();
1828 it.second->CancelRunningEndPreambleDetectionEvents ();
1844 NS_LOG_DEBUG (
"Transmission canceled because device is OFF");
1854 for (
auto const& psdu : psdus)
1862 ppdu->SetTruncatedTx ();
1889 phyEntity.second->CancelAllEvents ();
1900 it->second->StartReceivePreamble (ppdu, rxPowersW, rxDuration);
1905 NS_LOG_DEBUG (
"Unsupported modulation received (" << modulation <<
"), consider as noise");
1906 if (ppdu->GetTxDuration () >
m_state->GetDelayUntilIdle ())
1921 if (!delayUntilCcaEnd.
IsZero ())
1923 m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
1931 NS_ASSERT_MSG (
false,
"802.11ax can only be used with SpectrumWifiPhy");
1933 return convertedSubcarriers;
1969 if (phyEntity.second->IsModeSupported (mode))
1983 for (
const auto & mode : *(phyEntity.second))
1988 NS_ASSERT_MSG (
false,
"Should have found at least one default mode");
2000 return phyEntity->second->IsMcsSupported (mcs);
2006 std::list<WifiMode>
list;
2009 if (!phyEntity.second->HandlesMcsModes ())
2011 for (
const auto & mode : *(phyEntity.second))
2013 list.emplace_back (mode);
2023 std::list<WifiMode>
list;
2027 if (!phyEntity->second->HandlesMcsModes ())
2029 for (
const auto & mode : *(phyEntity->second))
2031 list.emplace_back (mode);
2041 uint16_t numMcs = 0;
2044 if (phyEntity.second->HandlesMcsModes ())
2046 numMcs += phyEntity.second->GetNumModes ();
2055 std::list<WifiMode>
list;
2058 if (phyEntity.second->HandlesMcsModes ())
2060 for (
const auto & mode : *(phyEntity.second))
2062 list.emplace_back (mode);
2072 std::list<WifiMode>
list;
2076 if (phyEntity->second->HandlesMcsModes ())
2078 for (
const auto & mode : *(phyEntity->second))
2080 list.emplace_back (mode);
2097 return m_state->IsStateCcaBusy ();
2103 return m_state->IsStateIdle ();
2121 return m_state->IsStateSwitching ();
2127 return m_state->IsStateSleep ();
2133 return m_state->IsStateOff ();
2139 return m_state->GetDelayUntilIdle ();
2145 return m_state->GetLastRxStartTime ();
2151 return m_state->GetLastRxEndTime ();
2163 if (!delayUntilCcaEnd.
IsZero ())
2166 m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
2178 phyEntity.second->CancelAllEvents ();
2192 m_state->SwitchFromRxAbort ();
2209 NS_LOG_FUNCTION (
this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2249 uint16_t channelWidth = ppdu->GetTransmissionChannelWidth ();
2251 NS_LOG_INFO (
"txPowerDbm=" << txPowerDbm <<
" with txPowerDbmPerMhz=" << txPowerDbmPerMhz <<
" over " << channelWidth <<
" MHz");
2268 if (ppdu ==
nullptr)
2301 int64_t currentStream = stream;
2304 return (currentStream - stream);
2310 <<
", RSSI:" << rxSignalInfo.
rssi <<
" dBm";
ERP-OFDM PHY (Clause 19, Section 19.5)
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802...
void NotifyRxDrop(Ptr< const WifiPsdu > psdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxDrop trace.
Ptr< NetDevice > m_device
Pointer to the device.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
void NotifyRxEnd(Time endTime)
Notify that RX has ended.
uint8_t GetNTxPower(void) const
Return the number of available transmission power levels.
bool IsStateSwitching(void) const
void SetPifs(Time pifs)
Set the PCF Interframe Space (PIFS) for this PHY.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
bool IsStateOff(void) const
TracedCallback< Ptr< const Packet >, RxPowerWattPerChannelBand > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
static Time GetStartOfPacketDuration(const WifiTxVector &txVector)
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.
uint8_t GetNssMax(void) const
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
Simulation virtual time values and global simulation resolution.
void NotifyTxBegin(WifiConstPsduMap psdus, double txPowerW)
Public method used to fire a PhyTxBegin trace.
Time GetEnergyDuration(double energyW, WifiSpectrumBand band)
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class, for the WifiPhy instance...
Ptr< Packet > GetAmpduSubframe(std::size_t i) const
Get a copy of the i-th A-MPDU subframe (includes subframe header, MPDU, and possibly padding) ...
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 "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
void SetNTxPower(uint8_t n)
Sets the number of transmission power levels available between the minimum level and the maximum leve...
double m_rxGainDb
Reception gain (dB)
AttributeValue implementation for Boolean.
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
double GetRxGain(void) const
Return the reception gain (dB).
static std::map< WifiModulationClass, Ptr< PhyEntity > > m_staticPhyEntities
Map of implemented PHY entities.
bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
void AddSupportedChannelWidth(uint16_t width)
double GetCcaEdThreshold(void) const
Return the CCA threshold (dBm).
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
void NotifyTxEnd(WifiConstPsduMap psdus)
Public method used to fire a PhyTxEnd trace.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
double m_txGainDb
Transmission gain (dB)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted...
Time DoChannelSwitch(void)
Perform any actions necessary when user changes operating channel after initialization.
void ResumeFromOff(void)
Resume from off mode.
Ptr< WifiPhyStateHelper > GetState(void) const
Return the WifiPhyStateHelper of this PHY.
void ResumeFromSleep(void)
Resume from sleep mode.
double m_rxSensitivityW
Receive sensitivity threshold in watts.
void SetOperatingChannel(uint8_t number, uint16_t frequency, uint16_t width)
Set the operating channel according to the specified parameters.
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Ptr< const WifiPsdu > GetAddressedPsduInPpdu(Ptr< const WifiPpdu > ppdu) const
Get the PSDU addressed to that PHY in a PPDU (useful for MU PPDU).
void SetTxGain(double gain)
Sets the transmission gain (dB).
void Configure80211ax(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard...
double DbmToW(double dBm)
Convert from dBm to Watts.
void SetRxSensitivity(double threshold)
Sets the receive sensitivity threshold (dBm).
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
virtual void DoDispose(void)
Destructor implementation.
double m_powerDensityLimit
the power density limit (dBm/MHz)
The PHY layer is sleeping.
std::list< WifiMode > GetModeList(void) const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
WifiSpectrumBand GetPrimaryBand(uint16_t bandWidth)
If the operating channel width is a multiple of 20 MHz, return the start band index and the stop band...
bool IsStateCcaBusy(void) const
void SetReceiveErrorCallback(RxErrorCallback callback)
WifiModulationClass GetModulationClass(void) const
Get the modulation class specified by this TXVECTOR.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
bool IsInitialized(void) const
Check if the object has been initialized.
U * PeekPointer(const Ptr< U > &p)
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
void SetSlot(Time slot)
Set the slot duration for this PHY.
void SetShortPhyPreambleSupported(bool preamble)
Enable or disable short PHY preamble.
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
uint16_t GetFrequency(void) const
Return the center frequency of the operating channel (in MHz).
EventId m_endPhyRxEvent
the end of PHY receive event
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
void UnregisterListener(WifiPhyListener *listener)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void SetRxNoiseFigure(double noiseFigureDb)
Sets the RX loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
bool IsMu(void) const
Return true if this TX vector is used for a multi-user transmission.
bool IsStateIdle(void) const
Class that keeps track of all information about the current PHY operating channel.
void Reset(void)
Reset data upon end of TX or RX.
TracedCallback< Ptr< const Packet >, WifiPhyRxfailureReason > m_phyRxDropTrace
The trace source fired when the PHY layer drops a packet it has received.
virtual WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const
uint8_t m_nTxPower
Number of available transmission power levels.
TracedCallback< Ptr< const Packet >, uint16_t, WifiTxVector, MpduInfo, SignalNoiseDbm, uint16_t > m_phyMonitorSniffRxTrace
A trace source that emulates a Wi-Fi device in monitor mode sniffing a packet being received...
std::list< WifiMode > GetMcsList(void) const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
virtual void SetFrequency(uint16_t freq)
If the operating channel for this object has not been set yet, the given center frequency is saved an...
double CalculateSnr(const WifiTxVector &txVector, double ber) const
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
void ResetCca(bool powerRestricted, double txPowerMaxSiso=0, double txPowerMaxMimo=0)
Reset PHY to IDLE, with some potential TX power restrictions for the next transmission.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
uint8_t m_initialChannelNumber
Store channel number until initialization.
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
bool IsStateSleep(void) const
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
MpduType
The type of an MPDU.
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
double GetRxSensitivity(void) const
Return the receive sensitivity threshold (dBm).
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
uint16_t GetChannelWidth(void) const
bool m_powerRestricted
Flag whether transmit power is restricted by OBSS PD SR.
std::ostream & operator<<(std::ostream &os, const Angles &a)
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
void SwitchMaybeToCcaBusy(uint16_t channelWidth)
Check if PHY state should move to CCA busy state based on current state of interference tracker...
Keep track of the current position and velocity of an object.
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
The MPDU is not part of an A-MPDU.
Ptr< const Packet > GetPacket(void) const
Get the PSDU as a single packet.
RxSignalInfo structure containing info on the received signal.
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate...
static const Ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
WifiMode GetMcs(WifiModulationClass modulation, uint8_t mcs) const
Get the WifiMode object corresponding to the given MCS of the given modulation class.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Time m_slot
Slot duration.
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
bool IsZero(void) const
Exactly equivalent to t == 0.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
AttributeValue implementation for Time.
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
Time m_blockAckTxTime
estimated BlockAck TX time
receive notifications about PHY events.
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the PHY layer drops a packet as it tries to transmit it.
double m_txPowerMaxMimo
MIMO maximum transmit power due to OBSS PD SR power restriction (dBm)
bool m_shortPreamble
Flag if short PHY preamble is supported.
uint16_t GetWidth(void) const
Return the width of the whole operating channel (in MHz).
static WifiConstPsduMap GetWifiConstPsduMap(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Get a WifiConstPsduMap from a PSDU and the TXVECTOR to use to send the PSDU.
Hold an unsigned integer type.
EventId m_endTxEvent
the end of transmit event
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate...
void NotifyChannelAccessRequested(void)
Notify the PHY that an access to the channel was requested.
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const
Return the channel width used to measure the RSSI.
The PHY layer has sense the medium busy through the CCA mechanism.
Time GetDelayUntilIdle(void)
OFDM PHY (Clause 17 - amendment for 10 MHz and 5 MHz channels)
uint8_t m_initialPrimary20Index
Store the index of primary20 until initialization.
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU...
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
void SetCapabilitiesChangedCallback(Callback< void > callback)
void SetOffMode(void)
Put in off mode.
void AddPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of supported PHY entities for the given modulation class for the WifiPh...
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
WifiPhyStandard GetPhyStandard(void) const
Get the configured Wi-Fi standard.
Time GetBlockAckTxTime(void) const
Return the estimated BlockAck TX time for this PHY.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
TracedCallback< WifiConstPsduMap, WifiTxVector, double > m_phyTxPsduBeginTrace
The trace source fired when a PSDU map begins the transmission process on the medium.
Ptr< MobilityModel > GetMobility(void) const
Return the mobility model this PHY is associated with.
static Time GetPreambleDetectionDuration(void)
Time m_pifs
PCF Interframe Space (PIFS) duration.
void Set(uint8_t number, uint16_t frequency, uint16_t width, WifiPhyStandard standard, WifiPhyBand band)
Set the channel according to the specified parameters if a unique frequency channel matches the speci...
void SetPostReceptionErrorModel(const Ptr< ErrorModel > em)
Attach a receive ErrorModel to the WifiPhy.
static TypeId GetTypeId(void)
Get the type ID.
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Time GetChannelSwitchDelay(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiPhyBand m_band
WifiPhyBand.
Hold objects of type Ptr<T>.
static const std::set< FrequencyChannelInfo > m_frequencyChannels
Available frequency channels.
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
void EraseEvents(void)
Erase all events.
uint16_t GetFrequency(void) const
uint8_t GetNumberOfAntennas(void) const
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
void NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
Time m_sifs
Short Interframe Space (SIFS) duration.
TracedCallback< Ptr< const Packet >, double > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
virtual void StartTx(Ptr< WifiPpdu > ppdu)=0
uint8_t GetNumber(void) const
Return the channel number identifying the whole operating channel.
void SetDefault(uint16_t width, WifiPhyStandard standard, WifiPhyBand band)
Set the default channel of the given width and for the given PHY standard and band.
void StartReceivePreamble(Ptr< WifiPpdu > ppdu, RxPowerWattPerChannelBand rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
std::map< std::pair< uint64_t, WifiPreamble >, Ptr< Event > > m_currentPreambleEvents
store event associated to a PPDU (that has a unique ID and preamble combination) whose preamble is be...
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
bool GetShortPhyPreambleSupported(void) const
Return whether short PHY preamble is supported.
double m_ccaEdThresholdW
Clear channel assessment (CCA) threshold in watts.
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Time GetPifs(void) const
Return the PCF Interframe Space (PIFS) for this PHY.
Time GetAckTxTime(void) const
Return the estimated Ack TX time for this PHY.
void Configure80211ac(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard...
WifiMode GetDefaultMode(void) const
Get the default WifiMode supported by the PHY.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
double WToDbm(double w)
Convert from Watts to dBm.
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 GetChannelNumber(void) const
Return current channel number.
WifiPhyStandard m_standard
WifiPhyStandard.
static Time Now(void)
Return the current simulation virtual time.
bool m_channelAccessRequested
Flag if channels access has been requested (used for OBSS_PD SR)
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
double DbToRatio(double dB)
Convert from dB to ratio.
uint64_t GetPreviouslyRxPpduUid(void) const
bool IsSet(void) const
Return true if a valid channel has been set, false otherwise.
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
double GetTxPowerStart(void) const
Return the minimum available transmission power level (dBm).
Time m_ackTxTime
estimated Ack TX time
double RatioToDb(double ratio)
Convert from ratio to dB.
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
std::vector< uint16_t > GetSupportedChannelWidthSet(void) const
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void SetRxGain(double gain)
Sets the reception gain (dB).
void Configure80211b(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard...
WifiPhyBand
Identifies the PHY band.
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS) for this PHY.
void SetReceiveOkCallback(RxOkCallback callback)
void RegisterListener(WifiPhyListener *listener)
bool IsStateTx(void) const
void NotifyRxBegin(Ptr< const WifiPsdu > psdu, RxPowerWattPerChannelBand rxPowersW)
Public method used to fire a PhyRxBegin trace.
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
The PHY layer is sending a packet.
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
void Configure80211n(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard...
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
double m_txPowerBaseDbm
Minimum transmission power (dBm)
Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
uint16_t GetDefaultChannelWidth(WifiPhyStandard standard, WifiPhyBand band)
Get the default channel width for the given PHY standard and band.
void SetNoiseFigure(double value)
Set the noise figure.
void ResetReceive(Ptr< Event > event)
Reset PHY at the end of the packet under reception after it has failed the PHY header.
double GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
SignalNoiseDbm structure.
uint32_t mpduRefNumber
MPDU ref number.
InterferenceHelper m_interference
the class handling interference computations
double snr
SNR in linear scale.
virtual void SetChannelWidth(uint16_t channelWidth)
If the operating channel for this object has not been set yet, the given channel width is saved and w...
bool IsStrictlyNegative(void) const
Exactly equivalent to t < 0.
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.
Time Seconds(double value)
Construct a Time in the indicated unit.
The PHY layer is receiving a packet.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
WifiPhyOperatingChannel m_operatingChannel
Operating channel.
static Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype=NORMAL_MPDU, uint16_t staId=SU_STA_ID)
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
Time GetSlot(void) const
Return the slot duration for this PHY.
void EndReceiveInterBss(void)
For HE receptions only, check and possibly modify the transmit power restriction state at the end of ...
void NotifyMonitorSniffTx(Ptr< const WifiPsdu > psdu, uint16_t channelFreqMhz, WifiTxVector txVector, uint16_t staId=SU_STA_ID)
Public method used to fire a MonitorSniffer trace for a wifi PSDU being transmitted.
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
void Send(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
This function is a wrapper for the Send variant that accepts a WifiConstPsduMap as first argument...
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
The PHY layer is switched off.
void Configure80211g(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard...
Ptr< NetDevice > GetDevice(void) const
Return the device this PHY is associated with.
uint8_t GetTxPowerLevel(void) const
double GetTxGain(void) const
Return the transmission gain (dB).
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
The PHY layer is switching to other channel.
void SetSleepMode(void)
Put in sleep mode.
void NotifyMonitorSniffRx(Ptr< const WifiPsdu > psdu, uint16_t channelFreqMhz, WifiTxVector txVector, SignalNoiseDbm signalNoise, std::vector< bool > statusPerMpdu, uint16_t staId=SU_STA_ID)
Public method used to fire a MonitorSniffer trace for a wifi PSDU being received. ...
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
void SetNumberOfAntennas(uint8_t antennas)
uint16_t GetChannelWidth(void) const
uint16_t m_initialChannelWidth
Store channel width (MHz) until initialization.
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
A base class which provides memory management and object aggregation.
double m_txPowerEndDbm
Maximum transmission power (dBm)
bool IsNull(void) const
Check for null implementation.
const HeMuUserInfoMap & GetHeMuUserInfoMap(void) const
Get a const reference to the map HE MU user-specific transmission information indexed by STA-ID...
void Configure80211p(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11p standard...
This class can be used to hold variables of floating point type such as 'double' or 'float'...
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
The MPDU is a single MPDU.
MpduType type
type of MPDU
Time m_channelSwitchDelay
Time required to switch between channel.
Time GetLastRxEndTime(void) const
Return the end time of the last received packet.
void MaybeCcaBusyDuration(uint16_t channelWidth)
Eventually switch to CCA busy.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
uint8_t m_numberOfAntennas
Number of transmitters.
uint8_t GetMaxSupportedTxSpatialStreams(void) const
a unique identifier for an interface.
uint16_t GetNMcs(void) const
Ptr< Event > m_currentEvent
Hold the current event.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
double m_txPowerMaxSiso
SISO maximum transmit power due to OBSS PD SR power restriction (dBm)
bool IsStateRx(void) const
bool IsMcsSupported(WifiModulationClass modulation, uint8_t mcs) const
Check if the given MCS of the given modulation class is supported by the PHY.
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
std::vector< uint16_t > m_supportedChannelWidthSet
Supported channel width set (MHz)
TracedCallback< Ptr< const Packet >, uint16_t, WifiTxVector, MpduInfo, uint16_t > m_phyMonitorSniffTxTrace
A trace source that emulates a Wi-Fi device in monitor mode sniffing a packet being transmitted...
void SetCcaEdThreshold(double threshold)
Sets the CCA threshold (dBm).
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
void Configure80211a(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard...
uint8_t GetMaxSupportedRxSpatialStreams(void) const
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...
uint16_t m_initialFrequency
Store frequency until initialization (MHz)
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
virtual WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0)
Get the start band index and the stop band index for a given band.