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");
2262 return GetPhyEntity (ppdu->GetModulation ())->GetAddressedPsduInPpdu (ppdu);
2268 if (ppdu ==
nullptr)
2274 return GetPhyEntity (ppdu->GetModulation ())->GetMeasurementChannelWidth (ppdu);
2301 int64_t currentStream = stream;
2304 return (currentStream - stream);
2310 <<
", RSSI:" << rxSignalInfo.
rssi <<
" dBm";
AttributeValue implementation for Boolean.
bool IsNull(void) const
Check for null implementation.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
void SetNoiseFigure(double value)
Set the noise figure.
void EraseEvents(void)
Erase all events.
void NotifyRxEnd(Time endTime)
Notify that RX has ended.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
Time GetEnergyDuration(double energyW, WifiSpectrumBand band)
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model.
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
Keep track of the current position and velocity of an object.
A base class which provides memory management and object aggregation.
bool IsInitialized(void) const
Check if the object has been initialized.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
static Time Now(void)
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
bool IsStrictlyNegative(void) const
Exactly equivalent to t < 0.
bool IsZero(void) const
Exactly equivalent to t == 0.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
represent a single transmission mode
void SetNumberOfAntennas(uint8_t antennas)
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
double m_rxGainDb
Reception gain (dB)
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
bool IsStateIdle(void) const
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
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.
bool IsStateTx(void) const
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
uint8_t GetChannelNumber(void) const
Return current channel number.
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
Time DoChannelSwitch(void)
Perform any actions necessary when user changes operating channel after initialization.
Time m_channelSwitchDelay
Time required to switch between channel.
std::list< WifiMode > GetMcsList(void) const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
void SetCcaEdThreshold(double threshold)
Sets the CCA threshold (dBm).
TracedCallback< Ptr< const Packet >, WifiPhyRxfailureReason > m_phyRxDropTrace
The trace source fired when the PHY layer drops a packet it has received.
WifiPhyOperatingChannel m_operatingChannel
Operating channel.
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the PHY layer drops a packet as it tries to transmit it.
TracedCallback< Ptr< const Packet >, RxPowerWattPerChannelBand > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
bool m_channelAccessRequested
Flag if channels access has been requested (used for OBSS_PD SR)
static Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype=NORMAL_MPDU, uint16_t staId=SU_STA_ID)
TracedCallback< Ptr< const Packet >, double > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
static std::map< WifiModulationClass, Ptr< PhyEntity > > m_staticPhyEntities
Map of implemented PHY entities.
void MaybeCcaBusyDuration(uint16_t channelWidth)
Eventually switch to CCA busy.
Ptr< MobilityModel > GetMobility(void) const
Return the mobility model this PHY is associated with.
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
Ptr< const WifiPsdu > GetAddressedPsduInPpdu(Ptr< const WifiPpdu > ppdu) const
Get the PSDU addressed to that PHY in a PPDU (useful for MU PPDU).
bool GetShortPhyPreambleSupported(void) const
Return whether short PHY preamble is supported.
void NotifyTxEnd(WifiConstPsduMap psdus)
Public method used to fire a PhyTxEnd trace.
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...
Time m_slot
Slot duration.
double m_powerDensityLimit
the power density limit (dBm/MHz)
WifiMode GetDefaultMode(void) const
Get the default WifiMode supported by the PHY.
std::vector< uint16_t > GetSupportedChannelWidthSet(void) const
bool IsStateRx(void) const
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS) for this PHY.
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
EventId m_endPhyRxEvent
the end of PHY receive event
double m_txPowerBaseDbm
Minimum transmission power (dBm)
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Ptr< WifiPhyStateHelper > GetState(void) const
Return the WifiPhyStateHelper of this PHY.
uint8_t m_initialChannelNumber
Store channel number until initialization.
void NotifyRxDrop(Ptr< const WifiPsdu > psdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxDrop trace.
bool IsMcsSupported(WifiModulationClass modulation, uint8_t mcs) const
Check if the given MCS of the given modulation class is supported by the PHY.
virtual void DoDispose(void)
Destructor implementation.
Time m_blockAckTxTime
estimated BlockAck TX time
void Configure80211a(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
void ResetCca(bool powerRestricted, double txPowerMaxSiso=0, double txPowerMaxMimo=0)
Reset PHY to IDLE, with some potential TX power restrictions for the next transmission.
double m_txPowerMaxMimo
MIMO maximum transmit power due to OBSS PD SR power restriction (dBm)
Time GetSlot(void) const
Return the slot duration for this PHY.
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted.
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Ptr< NetDevice > m_device
Pointer to the device.
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const
Return the channel width used to measure the RSSI.
double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
Time m_sifs
Short Interframe Space (SIFS) duration.
void SetReceiveErrorCallback(RxErrorCallback callback)
void ResetReceive(Ptr< Event > event)
Reset PHY at the end of the packet under reception after it has failed the PHY header.
InterferenceHelper m_interference
the class handling interference computations
uint8_t GetMaxSupportedRxSpatialStreams(void) const
void SetPostReceptionErrorModel(const Ptr< ErrorModel > em)
Attach a receive ErrorModel to the WifiPhy.
uint16_t m_initialFrequency
Store frequency until initialization (MHz)
WifiMode GetMcs(WifiModulationClass modulation, uint8_t mcs) const
Get the WifiMode object corresponding to the given MCS of the given modulation class.
uint8_t m_numberOfAntennas
Number of transmitters.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
Time GetBlockAckTxTime(void) const
Return the estimated BlockAck TX time for this PHY.
void Configure80211p(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11p standard.
Time GetPifs(void) const
Return the PCF Interframe Space (PIFS) for this PHY.
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
void NotifyTxBegin(WifiConstPsduMap psdus, double txPowerW)
Public method used to fire a PhyTxBegin trace.
void Reset(void)
Reset data upon end of TX or RX.
void SetShortPhyPreambleSupported(bool preamble)
Enable or disable short PHY preamble.
void SetNTxPower(uint8_t n)
Sets the number of transmission power levels available between the minimum level and the maximum leve...
uint8_t m_initialPrimary20Index
Store the index of primary20 until initialization.
static TypeId GetTypeId(void)
Get the type ID.
WifiPhyBand m_band
WifiPhyBand.
void Configure80211b(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
void SetSleepMode(void)
Put in sleep mode.
void SetRxSensitivity(double threshold)
Sets the receive sensitivity threshold (dBm).
static const Ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
uint8_t GetMaxSupportedTxSpatialStreams(void) const
void Configure80211g(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
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.
Time GetChannelSwitchDelay(void) const
virtual WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const
double m_txPowerMaxSiso
SISO maximum transmit power due to OBSS PD SR power restriction (dBm)
WifiPhyStandard GetPhyStandard(void) const
Get the configured Wi-Fi standard.
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
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...
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.
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
double GetTxPowerStart(void) const
Return the minimum available transmission power level (dBm).
WifiPhyStandard m_standard
WifiPhyStandard.
EventId m_endTxEvent
the end of transmit event
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.
uint16_t GetNMcs(void) const
void SetSlot(Time slot)
Set the slot duration for this PHY.
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
void StartReceivePreamble(Ptr< WifiPpdu > ppdu, RxPowerWattPerChannelBand rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Ptr< Event > m_currentEvent
Hold the current event.
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...
double m_ccaEdThresholdW
Clear channel assessment (CCA) threshold in watts.
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.
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class, for the WifiPhy instance.
virtual WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0)
Get the start band index and the stop band index for a given band.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
void ResumeFromSleep(void)
Resume from sleep mode.
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
void Configure80211ac(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard.
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU.
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
void NotifyChannelAccessRequested(void)
Notify the PHY that an access to the channel was requested.
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
uint8_t GetNumberOfAntennas(void) const
void SwitchMaybeToCcaBusy(uint16_t channelWidth)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (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.
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
std::list< WifiMode > GetModeList(void) const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
TracedCallback< WifiConstPsduMap, WifiTxVector, double > m_phyTxPsduBeginTrace
The trace source fired when a PSDU map begins the transmission process on the medium.
double m_txGainDb
Transmission gain (dB)
std::vector< uint16_t > m_supportedChannelWidthSet
Supported channel width set (MHz)
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...
Time GetDelayUntilIdle(void)
uint64_t GetPreviouslyRxPpduUid(void) const
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
uint8_t m_nTxPower
Number of available transmission power levels.
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
void SetPifs(Time pifs)
Set the PCF Interframe Space (PIFS) for this PHY.
Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
static Time GetStartOfPacketDuration(const WifiTxVector &txVector)
virtual void StartTx(Ptr< WifiPpdu > ppdu)=0
Time GetAckTxTime(void) const
Return the estimated Ack TX time for this PHY.
void UnregisterListener(WifiPhyListener *listener)
void SetRxGain(double gain)
Sets the reception gain (dB).
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
double GetRxGain(void) const
Return the reception gain (dB).
void SetTxGain(double gain)
Sets the transmission gain (dB).
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
void NotifyRxBegin(Ptr< const WifiPsdu > psdu, RxPowerWattPerChannelBand rxPowersW)
Public method used to fire a PhyRxBegin trace.
double m_txPowerEndDbm
Maximum transmission power (dBm)
void SetOffMode(void)
Put in off mode.
double CalculateSnr(const WifiTxVector &txVector, double ber) const
void Configure80211n(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
bool IsStateSwitching(void) const
double GetTxGain(void) const
Return the transmission gain (dB).
uint8_t GetNTxPower(void) const
Return the number of available transmission power levels.
void EndReceiveInterBss(void)
For HE receptions only, check and possibly modify the transmit power restriction state at the end of ...
double GetCcaEdThreshold(void) const
Return the CCA threshold (dBm).
double GetRxSensitivity(void) const
Return the receive sensitivity threshold (dBm).
void RegisterListener(WifiPhyListener *listener)
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
bool IsStateSleep(void) const
bool IsStateCcaBusy(void) const
bool m_shortPreamble
Flag if short PHY preamble is supported.
Time m_pifs
PCF Interframe Space (PIFS) duration.
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
void SetRxNoiseFigure(double noiseFigureDb)
Sets the RX loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
double GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
void SetCapabilitiesChangedCallback(Callback< void > callback)
void SetReceiveOkCallback(RxOkCallback callback)
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
void ResumeFromOff(void)
Resume from off mode.
void Configure80211ax(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard.
bool m_powerRestricted
Flag whether transmit power is restricted by OBSS PD SR.
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
void AddSupportedChannelWidth(uint16_t width)
Ptr< NetDevice > GetDevice(void) const
Return the device this PHY is associated with.
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.
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
void SetOperatingChannel(uint8_t number, uint16_t frequency, uint16_t width)
Set the operating channel according to the specified parameters.
static Time GetPreambleDetectionDuration(void)
double m_rxSensitivityW
Receive sensitivity threshold in watts.
static const std::set< FrequencyChannelInfo > m_frequencyChannels
Available frequency channels.
uint16_t m_initialChannelWidth
Store channel width (MHz) until initialization.
Time GetLastRxEndTime(void) const
Return the end time of the last received packet.
uint16_t GetChannelWidth(void) const
bool IsStateOff(void) const
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
uint16_t GetFrequency(void) const
Time m_ackTxTime
estimated Ack TX time
void NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
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...
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
receive notifications about PHY events.
Class that keeps track of all information about the current PHY operating channel.
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...
uint8_t GetNumber(void) const
Return the channel number identifying the whole operating channel.
bool IsSet(void) const
Return true if a valid channel has been set, false otherwise.
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 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 GetWidth(void) const
Return the width of the whole operating channel (in MHz).
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.
uint16_t GetFrequency(void) const
Return the center frequency of the operating channel (in MHz).
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
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)
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
Ptr< const Packet > GetPacket(void) const
Get the PSDU as a single packet.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint8_t GetTxPowerLevel(void) const
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
const HeMuUserInfoMap & GetHeMuUserInfoMap(void) const
Get a const reference to the map HE MU user-specific transmission information indexed by STA-ID.
bool IsMu(void) const
Return true if this TX vector is used for a multi-user transmission.
uint16_t GetChannelWidth(void) const
uint8_t GetNssMax(void) const
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,...
#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 AttributeChecker > MakeBooleanChecker(void)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
WifiPhyBand
Identifies the PHY band.
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
MpduType
The type of an MPDU.
@ WIFI_PHY_STANDARD_80211a
OFDM PHY (Clause 17)
@ WIFI_PHY_STANDARD_80211b
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
@ WIFI_PHY_STANDARD_80211ac
VHT PHY (clause 22)
@ WIFI_PHY_STANDARD_UNSPECIFIED
Unspecified.
@ WIFI_PHY_STANDARD_80211ax
HE PHY (clause 26)
@ WIFI_PHY_STANDARD_80211p
OFDM PHY (Clause 17 - amendment for 10 MHz and 5 MHz channels)
@ WIFI_PHY_STANDARD_80211g
ERP-OFDM PHY (Clause 19, Section 19.5)
@ WIFI_PHY_STANDARD_80211n
HT PHY (clause 20)
@ RECEPTION_ABORTED_BY_TX
@ WIFI_PHY_80211p_CHANNEL
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_MOD_CLASS_DSSS
DSSS (Clause 15)
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
@ 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.
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.
double WToDbm(double w)
Convert from Watts to dBm.
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
uint16_t GetDefaultChannelWidth(WifiPhyStandard standard, WifiPhyBand band)
Get the default channel width for the given PHY standard and band.
double DbmToW(double dBm)
Convert from dBm to Watts.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
std::ostream & operator<<(std::ostream &os, const Angles &a)
double DbToRatio(double dB)
Convert from dB to ratio.
U * PeekPointer(const Ptr< U > &p)
MpduType type
type of MPDU
uint32_t mpduRefNumber
MPDU ref number.
RxSignalInfo structure containing info on the received signal.
double snr
SNR in linear scale.
SignalNoiseDbm structure.
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
@ SWITCHING
The PHY layer is switching to other channel.
@ RX
The PHY layer is receiving a packet.
@ TX
The PHY layer is sending a packet.
@ OFF
The PHY layer is switched off.
@ SLEEP
The PHY layer is sleeping.
@ IDLE
The PHY layer is IDLE.
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.