33#include "ns3/channel.h"
34#include "ns3/dsss-phy.h"
35#include "ns3/eht-phy.h"
36#include "ns3/erp-ofdm-phy.h"
37#include "ns3/error-model.h"
38#include "ns3/ht-configuration.h"
40#include "ns3/mobility-model.h"
41#include "ns3/pointer.h"
42#include "ns3/random-variable-stream.h"
43#include "ns3/simulator.h"
44#include "ns3/string.h"
46#include "ns3/vht-configuration.h"
50#undef NS_LOG_APPEND_CONTEXT
51#define NS_LOG_APPEND_CONTEXT \
52 WIFI_PHY_NS_LOG_APPEND_CONTEXT( \
53 (m_device && (m_device->GetNPhys() > m_phyId) && m_device->GetPhy(m_phyId) \
54 ? m_device->GetPhy(m_phyId) \
75 .AddAttribute(
"Channel",
76 "The channel attached to this PHY",
80 MakePointerChecker<Channel>())
83 "Tuple {channel number, channel width (MHz), PHY band, primary20 index} "
84 "describing the settings of the operating channel. The primary20 index is "
85 "the index of the primary 20 MHz channel within the operating channel "
86 "(0 indicates the 20 MHz subchannel with the lowest center frequency) and "
87 "is only valid if the width of the operating channel is a multiple of 20 MHz. "
88 "If the standard for this object has not been set yet, the value of this "
89 "attribute is saved and will be used to set the operating channel when the "
90 "standard is configured. If the PHY band is left unspecified, the default "
91 "band for the configured standard is used. If the channel width and the "
92 "channel number are both 0, the default channel width for the configured "
93 "standard and band are used. If the channel number is 0, the default "
94 "channel number for the configured standard, band and channel width is used."
95 "Note that the channel width can be left unspecified (0) if the channel "
96 "number uniquely identify a frequency channel for the given standard and band.",
107 MakeUintegerChecker<uint8_t>(0, 233),
108 MakeUintegerChecker<uint16_t>(0, 160),
117 MakeUintegerChecker<uint8_t>(0, 7)))
118 .AddAttribute(
"Frequency",
119 "The center frequency (MHz) of the current operating channel.",
123 MakeUintegerChecker<uint16_t>())
124 .AddAttribute(
"ChannelNumber",
125 "The channel number of the current operating channel.",
129 MakeUintegerChecker<uint8_t>(0, 233))
132 "The width in MHz of the current operating channel (5, 10, 20, 22, 40, 80 or 160).",
136 MakeUintegerChecker<uint16_t>(5, 160))
139 "The index of the primary 20 MHz channel within the current operating channel "
140 "(0 indicates the 20 MHz subchannel with the lowest center frequency).",
143 MakeUintegerChecker<uint8_t>(0, 7))
144 .AddAttribute(
"FixedPhyBand",
145 "If set to true, changing PHY band is prohibited after initialization.",
151 "The energy of a received signal should be higher than "
152 "this threshold (dBm) for the PHY to detect the signal. "
153 "This threshold refers to a width of 20 MHz and will be "
154 "scaled to match the width of the received signal.",
157 MakeDoubleChecker<double>())
160 "The energy of all received signals should be higher than "
161 "this threshold (dBm) in the primary channel to allow the PHY layer "
162 "to declare CCA BUSY state.",
165 MakeDoubleChecker<double>())
166 .AddAttribute(
"CcaSensitivity",
167 "The energy of a received wifi signal should be higher than "
168 "this threshold (dBm) in the primary channel to allow the PHY layer "
169 "to declare CCA BUSY state.",
173 MakeDoubleChecker<double>())
174 .AddAttribute(
"TxGain",
175 "Transmission gain (dB).",
178 MakeDoubleChecker<double>())
179 .AddAttribute(
"RxGain",
180 "Reception gain (dB).",
183 MakeDoubleChecker<double>())
184 .AddAttribute(
"TxPowerLevels",
185 "Number of transmission power levels available between "
186 "TxPowerStart and TxPowerEnd included.",
189 MakeUintegerChecker<uint8_t>())
190 .AddAttribute(
"TxPowerEnd",
191 "Maximum available transmission level (dBm).",
194 MakeDoubleChecker<double>())
195 .AddAttribute(
"TxPowerStart",
196 "Minimum available transmission level (dBm).",
199 MakeDoubleChecker<double>())
202 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
203 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
204 "\"the difference in decibels (dB) between"
205 " the noise output of the actual receiver to the noise output of an "
206 " ideal receiver with the same overall gain and bandwidth when the receivers "
207 " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
210 MakeDoubleChecker<double>())
211 .AddAttribute(
"State",
212 "The state of the PHY layer.",
215 MakePointerChecker<WifiPhyStateHelper>())
216 .AddAttribute(
"ChannelSwitchDelay",
217 "Delay between two short frames transmitted on different frequencies.",
223 "The number of antennas on the device.",
226 MakeUintegerChecker<uint8_t>(1, 8))
227 .AddAttribute(
"MaxSupportedTxSpatialStreams",
228 "The maximum number of supported TX spatial streams."
229 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
233 MakeUintegerChecker<uint8_t>(1, 8))
234 .AddAttribute(
"MaxSupportedRxSpatialStreams",
235 "The maximum number of supported RX spatial streams."
236 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
240 MakeUintegerChecker<uint8_t>(1, 8))
241 .AddAttribute(
"ShortPlcpPreambleSupported",
242 "Whether or not short PHY preamble is supported."
243 "This parameter is only valuable for 802.11b STAs and APs."
244 "Note: 802.11g APs and STAs always support short PHY preamble.",
249 .AddAttribute(
"FrameCaptureModel",
250 "Ptr to an object that implements the frame capture model",
253 MakePointerChecker<FrameCaptureModel>())
254 .AddAttribute(
"PreambleDetectionModel",
255 "Ptr to an object that implements the preamble detection model",
258 MakePointerChecker<PreambleDetectionModel>())
259 .AddAttribute(
"PostReceptionErrorModel",
260 "An optional packet error model can be added to the receive "
261 "packet process after any propagation-based (SNR-based) error "
262 "models have been applied. Typically this is used to force "
263 "specific packet drops, for testing purposes.",
266 MakePointerChecker<ErrorModel>())
267 .AddAttribute(
"InterferenceHelper",
268 "Ptr to an object that implements the interference helper",
271 MakePointerChecker<InterferenceHelper>())
272 .AddAttribute(
"Sifs",
273 "The duration of the Short Interframe Space. "
274 "NOTE that the default value is overwritten by the value defined "
275 "by the standard; if you want to set this attribute, you have to "
276 "do it after that the PHY object is initialized.",
280 .AddAttribute(
"Slot",
281 "The duration of a slot. "
282 "NOTE that the default value is overwritten by the value defined "
283 "by the standard; if you want to set this attribute, you have to "
284 "do it after that the PHY object is initialized.",
288 .AddAttribute(
"Pifs",
289 "The duration of the PCF Interframe Space. "
290 "NOTE that the default value is overwritten by the value defined "
291 "by the standard; if you want to set this attribute, you have to "
292 "do it after that the PHY object is initialized.",
296 .AddAttribute(
"PowerDensityLimit",
297 "The mean equivalent isotropically radiated power density"
298 "limit (in dBm/MHz) set by regulators.",
301 MakeDoubleChecker<double>())
302 .AddTraceSource(
"PhyTxBegin",
303 "Trace source indicating a packet "
304 "has begun transmitting over the channel medium",
306 "ns3::WifiPhy::PhyTxBeginTracedCallback")
307 .AddTraceSource(
"PhyTxPsduBegin",
308 "Trace source indicating a PSDU "
309 "has begun transmitting over the channel medium",
311 "ns3::WifiPhy::PsduTxBeginCallback")
312 .AddTraceSource(
"PhyTxEnd",
313 "Trace source indicating a packet "
314 "has been completely transmitted over the channel.",
316 "ns3::Packet::TracedCallback")
317 .AddTraceSource(
"PhyTxDrop",
318 "Trace source indicating a packet "
319 "has been dropped by the device during transmission",
321 "ns3::Packet::TracedCallback")
322 .AddTraceSource(
"PhyRxBegin",
323 "Trace source indicating a packet "
324 "has begun being received from the channel medium "
327 "ns3::WifiPhy::PhyRxBeginTracedCallback")
328 .AddTraceSource(
"PhyRxPayloadBegin",
329 "Trace source indicating the reception of the "
330 "payload of a PPDU has begun",
332 "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
333 .AddTraceSource(
"PhyRxEnd",
334 "Trace source indicating a packet "
335 "has been completely received from the channel medium "
338 "ns3::Packet::TracedCallback")
339 .AddTraceSource(
"PhyRxDrop",
340 "Trace source indicating a packet "
341 "has been dropped by the device during reception",
343 "ns3::Packet::TracedCallback")
344 .AddTraceSource(
"PhyRxPpduDrop",
345 "Trace source indicating a ppdu "
346 "has been dropped by the device during reception",
348 "ns3::WifiPhy::PhyRxPpduDropTracedCallback")
349 .AddTraceSource(
"MonitorSnifferRx",
350 "Trace source simulating a wifi device in monitor mode "
351 "sniffing all received frames",
353 "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
354 .AddTraceSource(
"MonitorSnifferTx",
355 "Trace source simulating the capability of a wifi device "
356 "in monitor mode to sniff all frames being transmitted",
358 "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
359 .AddTraceSource(
"SignalTransmission",
360 "Trace start of signal transmission",
362 "ns3::SpectrumWifiPhy::SignalTransmissionCallback");
368 m_txMpduReferenceNumber(0xffffffff),
369 m_rxMpduReferenceNumber(0xffffffff),
372 m_currentEvent(nullptr),
373 m_previouslyRxPpduUid(UINT64_MAX),
382 m_powerRestricted(false),
383 m_channelAccessRequested(false),
384 m_txSpatialStreams(1),
385 m_rxSpatialStreams(1),
386 m_wifiRadioEnergyModel(nullptr),
387 m_timeLastPreambleDetected(
Seconds(0))
390 m_random = CreateObject<UniformRandomVariable>();
391 m_state = CreateObject<WifiPhyStateHelper>();
414 "Either install a MobilityModel on this object or ensure that this "
415 "object is part of a Node and NetDevice");
419 NS_LOG_WARN(
"Mobility not found, propagation models might not work properly");
448 phyEntity.second =
nullptr;
453std::map<WifiModulationClass, Ptr<PhyEntity>>&
456 static std::map<WifiModulationClass, Ptr<PhyEntity>> g_staticPhyEntities;
457 return g_staticPhyEntities;
469 m_state->SetReceiveOkCallback(callback);
475 m_state->SetReceiveErrorCallback(callback);
481 m_state->RegisterListener(listener);
487 m_state->UnregisterListener(listener);
716 "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
731 return m_interference->GetErrorRateModel()->CalculateSnr(txVector, ber);
739 "Unimplemented Wi-Fi modulation class " << modulation);
748 "Unsupported Wi-Fi modulation class " << modulation);
768 const auto modulation = ppdu->GetModulation();
788 "The PHY entity has already been added. The setting should only be done once per "
798 "Cannot add an unimplemented PHY to supported list. Update the former first.");
800 "The PHY entity has already been added. The setting should only be done once per "
802 phyEntity->SetOwner(
this);
998 "Cannot change standard");
1124 channel.GetPhyBand(),
1125 channel.GetPrimaryChannelIndex(20));
1133 NS_LOG_FUNCTION(
this << +std::get<0>(channelTuple) << std::get<1>(channelTuple)
1134 <<
static_cast<WifiPhyBand>(std::get<2>(channelTuple))
1135 << +std::get<3>(channelTuple));
1141 NS_LOG_DEBUG(
"Channel information will be applied when a standard is configured");
1148 if (!delay.has_value())
1153 if (delay.value().IsStrictlyPositive())
1177 std::optional<Time> delay;
1181 NS_LOG_DEBUG(
"drop packet because of channel switching while reception");
1186 NS_LOG_DEBUG(
"channel switching postponed until end of current transmission");
1195 NS_LOG_DEBUG(
"channel switching ignored in sleep mode");
1220 if (width == 0 && number == 0)
1239 "Trying to change PHY band while prohibited.");
1249 htConfig && !htConfig->Get40MHzOperationSupported() && chWidth > 20)
1252 <<
" MHz channel on"
1253 "a station only supporting 20 MHz operation");
1260 <<
" MHz channel on"
1261 "a station supporting up to 80 MHz operation");
1269 if (changingPhyBand)
1292 NS_ASSERT_MSG(antennas > 0 && antennas <= 8,
"unsupported number of antennas");
1317 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity->second);
1320 htPhy->SetMaxSupportedNss(
1359 std::list<uint8_t>
list;
1362 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity.second);
1365 list.emplace_back(htPhy->GetBssMembershipSelector());
1380 NS_LOG_DEBUG(
"setting sleep mode postponed until end of current transmission");
1384 NS_LOG_DEBUG(
"setting sleep mode postponed until end of current reception");
1388 NS_LOG_DEBUG(
"setting sleep mode postponed until end of channel switching");
1435 NS_LOG_DEBUG(
"not in sleep mode, there is nothing to resume");
1463 NS_LOG_DEBUG(
"not in off mode, there is nothing to resume");
1499 double totalAmpduNumSymbols;
1506 totalAmpduNumSymbols,
1517 double& totalAmpduNumSymbols,
1521 ->GetPayloadDuration(size,
1527 totalAmpduNumSymbols,
1535 ->CalculatePhyPreambleAndHeaderDuration(txVector);
1564 ->CalculateTxDuration(psduMap, txVector, band);
1578 for (
const auto& psdu : psdus)
1593 for (
const auto& psdu : psdus)
1660 uint16_t channelFreqMhz,
1663 std::vector<bool> statusPerMpdu,
1667 if (psdu->IsAggregate())
1671 "TxVector with aggregate flag expected here according to PSDU");
1673 size_t nMpdus = psdu->GetNMpdus();
1674 NS_ASSERT_MSG(statusPerMpdu.size() == nMpdus,
"Should have one reception status per MPDU");
1678 for (
size_t i = 0; i < nMpdus;)
1680 if (statusPerMpdu.at(i))
1698 "Should have one reception status for normal MPDU");
1714 uint16_t channelFreqMhz,
1719 if (psdu->IsAggregate())
1723 "TxVector with aggregate flag expected here according to PSDU");
1727 size_t nMpdus = psdu->GetNMpdus();
1729 for (
size_t i = 0; i < nMpdus;)
1784 if (txVector.
IsMu())
1809 for (
const auto& psdu : psdus)
1818 bool noEndPreambleDetectionEvent =
true;
1821 noEndPreambleDetectionEvent =
1822 noEndPreambleDetectionEvent && entity->NoEndPreambleDetectionEvents();
1847 NS_LOG_DEBUG(
"Transmission canceled because device is OFF");
1861 for (
const auto& psdu : psdus)
1870 ppdu->SetTruncatedTx();
1877 ppdu->ResetTxVector();
1911 bool noEndPreambleDetectionEvent =
true;
1914 noEndPreambleDetectionEvent =
1915 noEndPreambleDetectionEvent && entity->NoEndPreambleDetectionEvents();
1924 phyEntity.second->CancelAllEvents();
1941 it->second->StartReceivePreamble(ppdu, rxPowersW, rxDuration);
1947 NS_LOG_DEBUG(
"Unsupported modulation received (" << modulation <<
"), consider as noise");
1981 if (phyEntity.second->IsModeSupported(mode))
1996 for (
const auto& mode : *(phyEntity.second))
2001 NS_ASSERT_MSG(
false,
"Should have found at least one default mode");
2013 return phyEntity->second->IsMcsSupported(mcs);
2019 std::list<WifiMode>
list;
2022 if (!phyEntity.second->HandlesMcsModes())
2024 for (
const auto& mode : *(phyEntity.second))
2026 list.emplace_back(mode);
2036 std::list<WifiMode>
list;
2040 if (!phyEntity->second->HandlesMcsModes())
2042 for (
const auto& mode : *(phyEntity->second))
2044 list.emplace_back(mode);
2054 uint16_t numMcs = 0;
2057 if (phyEntity.second->HandlesMcsModes())
2059 numMcs += phyEntity.second->GetNumModes();
2068 std::list<WifiMode>
list;
2071 if (phyEntity.second->HandlesMcsModes())
2073 for (
const auto& mode : *(phyEntity.second))
2075 list.emplace_back(mode);
2085 std::list<WifiMode>
list;
2089 if (phyEntity->second->HandlesMcsModes())
2091 for (
const auto& mode : *(phyEntity->second))
2093 list.emplace_back(mode);
2110 return m_state->IsStateCcaBusy();
2116 return m_state->IsStateIdle();
2134 return m_state->IsStateSwitching();
2140 return m_state->IsStateSleep();
2152 return m_state->GetDelayUntilIdle();
2158 return m_state->GetLastRxStartTime();
2164 return m_state->GetLastRxEndTime();
2198 phyEntity.second->CancelAllEvents();
2234 NS_LOG_FUNCTION(
this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2258 const auto& txVector = ppdu->GetTxVector();
2263 txPowerDbm =
GetPowerDbm(txVector.GetTxPowerLevel());
2267 if (txVector.GetNssMax() > 1 || txVector.GetNssTotal() > 1)
2278 uint16_t channelWidth = ppdu->GetTxChannelWidth();
2279 double txPowerDbmPerMhz =
2281 NS_LOG_INFO(
"txPowerDbm=" << txPowerDbm <<
" with txPowerDbmPerMhz=" << txPowerDbmPerMhz
2282 <<
" over " << channelWidth <<
" MHz");
2301 int64_t currentStream = stream;
2303 currentStream +=
m_interference->GetErrorRateModel()->AssignStreams(currentStream);
2304 return (currentStream - stream);
2311 <<
", RSSI:" << rxSignalInfo.
rssi <<
" dBm";
2332 subcarrierSpacing = 312500;
2337 subcarrierSpacing = 78125;
2341 subcarrierSpacing = 156250;
2346 subcarrierSpacing = 78125;
2352 return subcarrierSpacing;
AttributeValue implementation for Boolean.
bool IsNull() const
Check for null implementation.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsPending() const
This method is syntactic sugar for !IsExpired().
bool IsExpired() const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Keep track of the current position and velocity of an object.
A base class which provides memory management and object aggregation.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
bool IsInitialized() const
Check if the object has been initialized.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
AttributeValue implementation for Time.
bool IsEmpty() const
Checks if the Callbacks list is empty.
a unique identifier for an interface.
@ ATTR_GET
The attribute can be read.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
bool Get160MHzOperationSupported() const
represent a single transmission mode
WifiModulationClass GetModulationClass() const
Ptr< VhtConfiguration > GetVhtConfiguration() const
Ptr< HtConfiguration > GetHtConfiguration() const
Ptr< Node > GetNode() const override
static TypeId GetTypeId()
Get the type ID.
void SetNumberOfAntennas(uint8_t antennas)
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Time GetBlockAckTxTime() const
Return the estimated BlockAck TX time for this PHY.
double GetCcaEdThreshold() const
Return the CCA energy detection threshold (dBm).
double m_rxGainDb
Reception gain (dB)
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
WifiModulationClass GetMaxModulationClassSupported() const
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
bool IsStateCcaBusy() const
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.
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
void Configure80211ax()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard.
Time m_channelSwitchDelay
Time required to switch between channel.
void SetCcaEdThreshold(double threshold)
Sets the CCA energy detection threshold (dBm).
void NotifyCcaBusy(const Ptr< const WifiPpdu > ppdu, Time duration)
Notify PHY state helper to switch to CCA busy state,.
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.
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
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)
Time GetSlot() const
Return the slot duration for this PHY.
uint32_t GetSubcarrierSpacing() const
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
Ptr< const WifiPsdu > GetAddressedPsduInPpdu(Ptr< const WifiPpdu > ppdu) const
Get the PSDU addressed to that PHY in a PPDU (useful for MU PPDU).
void Configure80211g()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
uint8_t GetPrimary20Index() const
void NotifyTxEnd(WifiConstPsduMap psdus)
Public method used to fire a PhyTxEnd trace.
uint16_t GetChannelWidth() const
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...
uint8_t GetNumberOfAntennas() const
Time m_slot
Slot duration.
double m_powerDensityLimit
the power density limit (dBm/MHz)
double GetRxSensitivity() const
Return the receive sensitivity threshold (dBm).
bool GetShortPhyPreambleSupported() const
Return whether short PHY preamble is supported.
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS) for this PHY.
std::list< uint8_t > GetBssMembershipSelectorList() const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
void Configure80211n()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
EventId m_endPhyRxEvent
the end of PHY receive event
double GetTxGain() const
Return the transmission gain (dB).
double m_txPowerBaseDbm
Minimum transmission power (dBm)
void Configure80211be()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11be standard.
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.
Time GetSifs() const
Return the Short Interframe Space (SIFS) for this PHY.
uint16_t GetFrequency() const
Ptr< MobilityModel > GetMobility() const
Return the mobility model this PHY is associated with.
Time m_blockAckTxTime
estimated BlockAck TX time
uint8_t GetPrimaryChannelNumber(uint16_t primaryChannelWidth) const
Get channel number of the primary channel.
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)
void ResumeFromSleep()
Resume from sleep mode.
static Time GetPreambleDetectionDuration()
void Configure80211p()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11p standard.
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.
void NotifyRxBegin(Ptr< const WifiPsdu > psdu, const RxPowerWattPerChannelBand &rxPowersW)
Public method used to fire a PhyRxBegin trace.
Time GetChannelSwitchDelay() const
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
Time m_sifs
Short Interframe Space (SIFS) duration.
void SetReceiveErrorCallback(RxErrorCallback callback)
TracedCallback< Ptr< const WifiPpdu >, const WifiTxVector & > m_signalTransmissionCb
Signal Transmission callback.
uint8_t GetMaxSupportedRxSpatialStreams() const
double GetTxPowerEnd() const
Return the maximum available transmission power level (dBm).
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
void SetPostReceptionErrorModel(const Ptr< ErrorModel > em)
Attach a receive ErrorModel to the WifiPhy.
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.
ChannelTuple m_channelSettings
Store operating channel settings until initialization.
TracedCallback< Ptr< const WifiPpdu >, WifiPhyRxfailureReason > m_phyRxPpduDropTrace
The trace source fired when the PHY layer drops a packet it has received.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
Ptr< WifiPhyStateHelper > GetState() const
Return the WifiPhyStateHelper of this PHY.
virtual Ptr< Channel > GetChannel() const =0
Return the Channel this WifiPhy is connected to.
void NotifyTxBegin(WifiConstPsduMap psdus, double txPowerW)
Public method used to fire a PhyTxBegin trace.
void EndReceiveInterBss()
For HE receptions only, check and possibly modify the transmit power restriction state at the end of ...
void SetSleepMode()
Put in sleep mode.
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...
WifiPhyBand m_band
WifiPhyBand.
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.
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.
double m_txPowerMaxSiso
SISO maximum transmit power due to OBSS PD SR power restriction (dBm)
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
void NotifyRxPpduDrop(Ptr< const WifiPpdu > ppdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxPpduDrop trace.
virtual void StartTx(Ptr< const WifiPpdu > ppdu)=0
void SetMaxModulationClassSupported(WifiModulationClass modClass)
Set the maximum modulation class that has to be supported by this PHY object.
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.
EventId m_endTxEvent
the end of transmit event
double GetRxGain() const
Return the reception gain (dB).
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.
double m_rxSensitivityDbm
Receive sensitivity threshold in dBm.
void RegisterListener(const std::shared_ptr< WifiPhyListener > &listener)
static std::map< WifiModulationClass, Ptr< PhyEntity > > & GetStaticPhyEntities()
void SetSlot(Time slot)
Set the slot duration for this PHY.
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
void SetPreviouslyRxPpduUid(uint64_t uid)
Set the UID of the previously received PPDU.
bool IsReceivingPhyHeader() const
double m_ccaSensitivityThresholdW
Clear channel assessment (CCA) modulation and coding rate sensitivity threshold in watts.
Ptr< Event > m_currentEvent
Hold the current event.
Time GetLastRxStartTime() const
Return the start time of the last received packet.
WifiMode GetDefaultMode() const
Get the default WifiMode supported by the PHY.
void SetCcaSensitivityThreshold(double threshold)
Sets the CCA sensitivity threshold (dBm).
double m_ccaEdThresholdW
Clear channel assessment (CCA) energy detection (ED) 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.
uint8_t GetChannelNumber() const
Return current channel number.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
std::optional< Time > GetDelayUntilChannelSwitch()
Perform any actions necessary when user changes operating channel after initialization.
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.
TracedCallback< Ptr< const Packet >, double > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
virtual void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Time GetPifs() const
Return the PCF Interframe Space (PIFS) for this PHY.
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
void StartReceivePreamble(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
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)
bool IsStateSleep() const
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
WifiStandard m_standard
WifiStandard.
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 DoDispose() override
Destructor implementation.
bool IsStateSwitching() const
void SetPhyId(uint8_t phyId)
Set the index allocated to this PHY.
virtual void DoChannelSwitch()
Actually switch channel based on the stored channel settings.
void SetOffMode()
Put in off mode.
double m_noiseFigureDb
The noise figure in dB.
TracedCallback< Ptr< const Packet >, WifiPhyRxfailureReason > m_phyRxDropTrace
The trace source fired when the PHY layer drops a packet it has received.
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
uint8_t m_phyId
the index of the PHY in the vector of PHYs held by the WifiNetDevice
std::tuple< uint8_t, uint16_t, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying an operating channel.
void SetPifs(Time pifs)
Set the PCF Interframe Space (PIFS) for this PHY.
void Configure80211b()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
static Time GetStartOfPacketDuration(const WifiTxVector &txVector)
virtual FrequencyRange GetCurrentFrequencyRange() const =0
Get the frequency range of the current RF interface.
uint16_t GetTxBandwidth(WifiMode mode, uint16_t maxAllowedBandWidth=std::numeric_limits< uint16_t >::max()) const
Get the bandwidth for a transmission occurring on the current operating channel and using the given W...
void SetRxGain(double gain)
Sets the reception gain (dB).
void SwitchMaybeToCcaBusy(const Ptr< const WifiPpdu > ppdu=nullptr)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
void SetTxGain(double gain)
Sets the transmission gain (dB).
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
double m_txPowerEndDbm
Maximum transmission power (dBm)
double CalculateSnr(const WifiTxVector &txVector, double ber) const
void SetFixedPhyBand(bool enable)
Configure whether it is prohibited to change PHY band after initialization.
void Configure80211ac()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard.
bool HasFixedPhyBand() const
TracedCallback< Ptr< const Packet >, RxPowerWattPerChannelBand > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
Ptr< WifiNetDevice > m_device
Pointer to the device.
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
void DoInitialize() override
Initialize() implementation.
bool m_shortPreamble
Flag if short PHY preamble is supported.
uint8_t GetPhyId() const
Get the index allocated to this PHY.
Time m_pifs
PCF Interframe Space (PIFS) duration.
WifiModulationClass m_maxModClassSupported
max modulation class supported
void SetRxNoiseFigure(double noiseFigureDb)
Sets the RX loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
double GetTxPowerStart() const
Return the minimum available transmission power level (dBm).
double GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
WifiStandard GetStandard() const
Get the configured Wi-Fi standard.
void SetCapabilitiesChangedCallback(Callback< void > callback)
void SetReceiveOkCallback(RxOkCallback callback)
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
void NotifyChannelAccessRequested()
Notify the PHY that an access to the channel was requested.
void ResumeFromOff()
Resume from off mode.
bool m_powerRestricted
Flag whether transmit power is restricted by OBSS PD SR.
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
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.
Ptr< PhyEntity > GetPhyEntityForPpdu(const Ptr< const WifiPpdu > ppdu) const
Get the supported PHY entity to use for a received PPDU.
Time GetAckTxTime() const
Return the estimated Ack TX time for this PHY.
uint64_t GetPreviouslyRxPpduUid() const
void Reset()
Reset data upon end of TX or RX.
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
Time GetLastRxEndTime() const
Return the end time of the last received packet.
uint8_t GetMaxSupportedTxSpatialStreams() const
void Configure80211a()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
std::list< WifiMode > GetMcsList() const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
void TxDone(const WifiConstPsduMap &psdus)
Callback function when a transmission is completed.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
double GetCcaSensitivityThreshold() const
Return the CCA sensitivity threshold (dBm).
bool m_fixedPhyBand
True to prohibit changing PHY band after initialization.
Ptr< PhyEntity > GetLatestPhyEntity() const
Get the latest PHY entity supported by this PHY instance.
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
uint8_t GetNTxPower() const
Return the number of available transmission power levels.
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.
Time m_ackTxTime
estimated Ack TX time
void UnregisterListener(const std::shared_ptr< WifiPhyListener > &listener)
void NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
Class that keeps track of all information about the current PHY operating channel.
bool IsSet() 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...
void Set(uint8_t number, uint16_t frequency, uint16_t width, WifiStandard standard, WifiPhyBand band)
Set the channel according to the specified parameters if a unique frequency channel matches the speci...
uint8_t GetPrimaryChannelNumber(uint16_t primaryChannelWidth, WifiStandard standard) const
Get channel number of the primary channel.
uint16_t GetWidth() const
Return the width of the whole operating channel (in MHz).
static uint8_t GetDefaultChannelNumber(uint16_t width, WifiStandard standard, WifiPhyBand band)
Get the default channel number of the given width and for the given standard and band.
uint8_t GetNumber() const
Return the channel number identifying the whole operating channel.
uint16_t GetFrequency() const
Return the center frequency of the operating channel (in MHz).
void SwitchToSleep()
Switch to sleep mode.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
bool IsValid(WifiPhyBand band=WIFI_PHY_BAND_UNSPECIFIED) const
The standard disallows certain combinations of WifiMode, number of spatial streams,...
uint8_t GetNssTotal() const
WifiModulationClass GetModulationClass() const
Get the modulation class specified by this TXVECTOR.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
uint8_t GetNssMax() const
uint8_t GetTxPowerLevel() const
bool IsAggregation() const
Checks whether the PSDU contains A-MPDU.
bool IsDlMuMimo() const
Return true if this TX vector is used for a downlink multi-user transmission using MU-MIMO.
#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 AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTupleChecker(Ts... checkers)
Create a TupleChecker from AttributeCheckers associated with TupleValue elements.
Ptr< const AttributeAccessor > MakeTupleAccessor(T1 a1)
Create an AttributeAccessor for a class data member of type tuple, or a lone class get functor or set...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#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_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#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_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#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.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be 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_STANDARD_UNSPECIFIED
@ SIGNAL_DETECTION_ABORTED_BY_TX
@ RECEPTION_ABORTED_BY_TX
@ 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_UNKNOWN
Modulation class unknown or unspecified.
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_EHT
EHT (Clause 36)
@ 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.
U * PeekPointer(const Ptr< U > &p)
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.
@ SWITCHING
The PHY layer is switching to other channel.
@ TX
The PHY layer is sending a packet.
@ OFF
The PHY layer is switched off.
@ IDLE
The PHY layer is IDLE.
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
@ SLEEP
The PHY layer is sleeping.
@ RX
The PHY layer is receiving a packet.
uint16_t GetMaximumChannelWidth(WifiModulationClass modulation)
Get the maximum channel width in MHz allowed for the given modulation class.
double WToDbm(double w)
Convert from Watts to dBm.
std::ostream & operator<<(std::ostream &os, const Angles &a)
double DbmToW(double dBm)
Convert from dBm to Watts.
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
std::map< WifiSpectrumBandInfo, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
WifiPhyBand GetDefaultPhyBand(WifiStandard standard)
Get the default PHY band for the given standard.
WifiModulationClass GetModulationClassForStandard(WifiStandard standard)
Return the modulation class corresponding to a given standard.
uint16_t GetDefaultChannelWidth(WifiStandard standard, WifiPhyBand band)
Get the default channel width for the given PHY standard and band.
double DbToRatio(double dB)
Convert from dB to ratio.
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.
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.