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"
45 #include "ns3/tuple.h"
46 #include "ns3/vht-configuration.h"
68 .AddAttribute(
"Channel",
69 "The channel attached to this PHY",
73 MakePointerChecker<Channel>())
76 "Tuple {channel number, channel width (MHz), PHY band, primary20 index} "
77 "describing the settings of the operating channel. The primary20 index is "
78 "the index of the primary 20 MHz channel within the operating channel "
79 "(0 indicates the 20 MHz subchannel with the lowest center frequency) and "
80 "is only valid if the width of the operating channel is a multiple of 20 MHz. "
81 "If the standard for this object has not been set yet, the value of this "
82 "attribute is saved and will be used to set the operating channel when the "
83 "standard is configured. If the PHY band is left unspecified, the default "
84 "band for the configured standard is used. If the channel width and the "
85 "channel number are both 0, the default channel width for the configured "
86 "standard and band are used. If the channel number is 0, the default "
87 "channel number for the configured standard, band and channel width is used."
88 "Note that the channel width can be left unspecified (0) if the channel "
89 "number uniquely identify a frequency channel for the given standard and band.",
100 MakeUintegerChecker<uint8_t>(0, 233),
101 MakeUintegerChecker<uint16_t>(0, 160),
110 MakeUintegerChecker<uint8_t>(0, 7)))
111 .AddAttribute(
"Frequency",
112 "The center frequency (MHz) of the current operating channel.",
116 MakeUintegerChecker<uint16_t>())
117 .AddAttribute(
"ChannelNumber",
118 "The channel number of the current operating channel.",
122 MakeUintegerChecker<uint8_t>(0, 233))
125 "The width in MHz of the current operating channel (5, 10, 20, 22, 40, 80 or 160).",
129 MakeUintegerChecker<uint16_t>(5, 160))
132 "The index of the primary 20 MHz channel within the current operating channel "
133 "(0 indicates the 20 MHz subchannel with the lowest center frequency).",
136 MakeUintegerChecker<uint8_t>(0, 7))
137 .AddAttribute(
"FixedPhyBand",
138 "If set to true, changing PHY band is prohibited after initialization.",
144 "The energy of a received signal should be higher than "
145 "this threshold (dBm) for the PHY to detect the signal. "
146 "This threshold refers to a width of 20 MHz and will be "
147 "scaled to match the width of the received signal.",
150 MakeDoubleChecker<double>())
153 "The energy of all received signals should be higher than "
154 "this threshold (dBm) in the primary channel to allow the PHY layer "
155 "to declare CCA BUSY state.",
158 MakeDoubleChecker<double>())
159 .AddAttribute(
"CcaSensitivity",
160 "The energy of a received wifi signal should be higher than "
161 "this threshold (dBm) in the primary channel to allow the PHY layer "
162 "to declare CCA BUSY state.",
166 MakeDoubleChecker<double>())
167 .AddAttribute(
"TxGain",
168 "Transmission gain (dB).",
171 MakeDoubleChecker<double>())
172 .AddAttribute(
"RxGain",
173 "Reception gain (dB).",
176 MakeDoubleChecker<double>())
177 .AddAttribute(
"TxPowerLevels",
178 "Number of transmission power levels available between "
179 "TxPowerStart and TxPowerEnd included.",
182 MakeUintegerChecker<uint8_t>())
183 .AddAttribute(
"TxPowerEnd",
184 "Maximum available transmission level (dBm).",
187 MakeDoubleChecker<double>())
188 .AddAttribute(
"TxPowerStart",
189 "Minimum available transmission level (dBm).",
192 MakeDoubleChecker<double>())
195 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
196 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
197 "\"the difference in decibels (dB) between"
198 " the noise output of the actual receiver to the noise output of an "
199 " ideal receiver with the same overall gain and bandwidth when the receivers "
200 " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
203 MakeDoubleChecker<double>())
204 .AddAttribute(
"State",
205 "The state of the PHY layer.",
208 MakePointerChecker<WifiPhyStateHelper>())
209 .AddAttribute(
"ChannelSwitchDelay",
210 "Delay between two short frames transmitted on different frequencies.",
216 "The number of antennas on the device.",
219 MakeUintegerChecker<uint8_t>(1, 8))
220 .AddAttribute(
"MaxSupportedTxSpatialStreams",
221 "The maximum number of supported TX spatial streams."
222 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
226 MakeUintegerChecker<uint8_t>(1, 8))
227 .AddAttribute(
"MaxSupportedRxSpatialStreams",
228 "The maximum number of supported RX spatial streams."
229 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
233 MakeUintegerChecker<uint8_t>(1, 8))
234 .AddAttribute(
"ShortPlcpPreambleSupported",
235 "Whether or not short PHY preamble is supported."
236 "This parameter is only valuable for 802.11b STAs and APs."
237 "Note: 802.11g APs and STAs always support short PHY preamble.",
242 .AddAttribute(
"FrameCaptureModel",
243 "Ptr to an object that implements the frame capture model",
246 MakePointerChecker<FrameCaptureModel>())
247 .AddAttribute(
"PreambleDetectionModel",
248 "Ptr to an object that implements the preamble detection model",
251 MakePointerChecker<PreambleDetectionModel>())
252 .AddAttribute(
"PostReceptionErrorModel",
253 "An optional packet error model can be added to the receive "
254 "packet process after any propagation-based (SNR-based) error "
255 "models have been applied. Typically this is used to force "
256 "specific packet drops, for testing purposes.",
259 MakePointerChecker<ErrorModel>())
260 .AddAttribute(
"InterferenceHelper",
261 "Ptr to an object that implements the interference helper",
264 MakePointerChecker<InterferenceHelper>())
265 .AddAttribute(
"Sifs",
266 "The duration of the Short Interframe Space. "
267 "NOTE that the default value is overwritten by the value defined "
268 "by the standard; if you want to set this attribute, you have to "
269 "do it after that the PHY object is initialized.",
273 .AddAttribute(
"Slot",
274 "The duration of a slot. "
275 "NOTE that the default value is overwritten by the value defined "
276 "by the standard; if you want to set this attribute, you have to "
277 "do it after that the PHY object is initialized.",
281 .AddAttribute(
"Pifs",
282 "The duration of the PCF Interframe Space. "
283 "NOTE that the default value is overwritten by the value defined "
284 "by the standard; if you want to set this attribute, you have to "
285 "do it after that the PHY object is initialized.",
289 .AddAttribute(
"PowerDensityLimit",
290 "The mean equivalent isotropically radiated power density"
291 "limit (in dBm/MHz) set by regulators.",
294 MakeDoubleChecker<double>())
295 .AddTraceSource(
"PhyTxBegin",
296 "Trace source indicating a packet "
297 "has begun transmitting over the channel medium",
299 "ns3::WifiPhy::PhyTxBeginTracedCallback")
300 .AddTraceSource(
"PhyTxPsduBegin",
301 "Trace source indicating a PSDU "
302 "has begun transmitting over the channel medium",
304 "ns3::WifiPhy::PsduTxBeginCallback")
305 .AddTraceSource(
"PhyTxEnd",
306 "Trace source indicating a packet "
307 "has been completely transmitted over the channel.",
309 "ns3::Packet::TracedCallback")
310 .AddTraceSource(
"PhyTxDrop",
311 "Trace source indicating a packet "
312 "has been dropped by the device during transmission",
314 "ns3::Packet::TracedCallback")
315 .AddTraceSource(
"PhyRxBegin",
316 "Trace source indicating a packet "
317 "has begun being received from the channel medium "
320 "ns3::WifiPhy::PhyRxBeginTracedCallback")
321 .AddTraceSource(
"PhyRxPayloadBegin",
322 "Trace source indicating the reception of the "
323 "payload of a PPDU has begun",
325 "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
326 .AddTraceSource(
"PhyRxEnd",
327 "Trace source indicating a packet "
328 "has been completely received from the channel medium "
331 "ns3::Packet::TracedCallback")
332 .AddTraceSource(
"PhyRxDrop",
333 "Trace source indicating a packet "
334 "has been dropped by the device during reception",
336 "ns3::Packet::TracedCallback")
337 .AddTraceSource(
"MonitorSnifferRx",
338 "Trace source simulating a wifi device in monitor mode "
339 "sniffing all received frames",
341 "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
342 .AddTraceSource(
"MonitorSnifferTx",
343 "Trace source simulating the capability of a wifi device "
344 "in monitor mode to sniff all frames being transmitted",
346 "ns3::WifiPhy::MonitorSnifferTxTracedCallback");
351 : m_txMpduReferenceNumber(0xffffffff),
352 m_rxMpduReferenceNumber(0xffffffff),
355 m_currentEvent(nullptr),
356 m_previouslyRxPpduUid(UINT64_MAX),
365 m_powerRestricted(false),
366 m_channelAccessRequested(false),
367 m_txSpatialStreams(1),
368 m_rxSpatialStreams(1),
369 m_wifiRadioEnergyModel(nullptr),
370 m_timeLastPreambleDetected(
Seconds(0))
373 m_random = CreateObject<UniformRandomVariable>();
374 m_state = CreateObject<WifiPhyStateHelper>();
397 "Either install a MobilityModel on this object or ensure that this "
398 "object is part of a Node and NetDevice");
402 NS_LOG_WARN(
"Mobility not found, propagation models might not work properly");
430 phyEntity.second =
nullptr;
435 std::map<WifiModulationClass, Ptr<PhyEntity>>&
438 static std::map<WifiModulationClass, Ptr<PhyEntity>> g_staticPhyEntities;
439 return g_staticPhyEntities;
451 m_state->SetReceiveOkCallback(callback);
457 m_state->SetReceiveErrorCallback(callback);
463 m_state->RegisterListener(listener);
469 m_state->UnregisterListener(listener);
683 "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
698 return m_interference->GetErrorRateModel()->CalculateSnr(txVector, ber);
706 "Unimplemented Wi-Fi modulation class " << modulation);
715 "Unsupported Wi-Fi modulation class " << modulation);
735 const auto modulation = ppdu->GetModulation();
756 "The PHY entity has already been added. The setting should only be done once per "
766 "Cannot add an unimplemented PHY to supported list. Update the former first.");
768 "The PHY entity has already been added. The setting should only be done once per "
770 phyEntity->SetOwner(
this);
966 "Cannot change standard");
1093 channel.GetPrimaryChannelIndex(20));
1101 NS_LOG_FUNCTION(
this << +std::get<0>(channelTuple) << std::get<1>(channelTuple)
1102 <<
static_cast<WifiPhyBand>(std::get<2>(channelTuple))
1103 << +std::get<3>(channelTuple));
1109 NS_LOG_DEBUG(
"Channel information will be applied when a standard is configured");
1116 if (!delay.has_value())
1121 if (delay.value().IsStrictlyPositive())
1145 std::optional<Time> delay;
1149 NS_LOG_DEBUG(
"drop packet because of channel switching while reception");
1154 NS_LOG_DEBUG(
"channel switching postponed until end of current transmission");
1163 NS_LOG_DEBUG(
"channel switching ignored in sleep mode");
1188 if (width == 0 && number == 0)
1207 "Trying to change PHY band while prohibited.");
1217 htConfig && !htConfig->Get40MHzOperationSupported() && chWidth > 20)
1220 <<
" MHz channel on"
1221 "a station only supporting 20 MHz operation");
1228 <<
" MHz channel on"
1229 "a station supporting up to 80 MHz operation");
1237 if (changingPhyBand)
1260 NS_ASSERT_MSG(antennas > 0 && antennas <= 8,
"unsupported number of antennas");
1285 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity->second);
1288 htPhy->SetMaxSupportedNss(
1327 std::list<uint8_t>
list;
1330 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity.second);
1333 list.emplace_back(htPhy->GetBssMembershipSelector());
1348 NS_LOG_DEBUG(
"setting sleep mode postponed until end of current transmission");
1352 NS_LOG_DEBUG(
"setting sleep mode postponed until end of current reception");
1356 NS_LOG_DEBUG(
"setting sleep mode postponed until end of channel switching");
1403 NS_LOG_DEBUG(
"not in sleep mode, there is nothing to resume");
1431 NS_LOG_DEBUG(
"not in off mode, there is nothing to resume");
1466 uint32_t totalAmpduSize;
1467 double totalAmpduNumSymbols;
1474 totalAmpduNumSymbols,
1484 uint32_t& totalAmpduSize,
1485 double& totalAmpduNumSymbols,
1489 ->GetPayloadDuration(size,
1495 totalAmpduNumSymbols,
1503 ->CalculatePhyPreambleAndHeaderDuration(txVector);
1532 ->CalculateTxDuration(psduMap, txVector, band);
1546 for (
const auto& psdu : psdus)
1561 for (
const auto& psdu : psdus)
1621 uint16_t channelFreqMhz,
1624 std::vector<bool> statusPerMpdu,
1632 "TxVector with aggregate flag expected here according to PSDU");
1635 NS_ASSERT_MSG(statusPerMpdu.size() == nMpdus,
"Should have one reception status per MPDU");
1639 for (
size_t i = 0; i < nMpdus;)
1641 if (statusPerMpdu.at(i))
1659 "Should have one reception status for normal MPDU");
1675 uint16_t channelFreqMhz,
1684 "TxVector with aggregate flag expected here according to PSDU");
1690 for (
size_t i = 0; i < nMpdus;)
1745 if (txVector.
IsMu())
1770 for (
const auto& psdu : psdus)
1779 bool noEndPreambleDetectionEvent =
true;
1782 noEndPreambleDetectionEvent &= it.second->NoEndPreambleDetectionEvents();
1800 NS_LOG_DEBUG(
"Transmission canceled because device is OFF");
1814 for (
const auto& psdu : psdus)
1823 ppdu->SetTruncatedTx();
1830 ppdu->ResetTxVector();
1861 phyEntity.second->CancelAllEvents();
1878 it->second->StartReceivePreamble(ppdu, rxPowersW, rxDuration);
1884 NS_LOG_DEBUG(
"Unsupported modulation received (" << modulation <<
"), consider as noise");
1918 if (phyEntity.second->IsModeSupported(mode))
1933 for (
const auto& mode : *(phyEntity.second))
1938 NS_ASSERT_MSG(
false,
"Should have found at least one default mode");
1950 return phyEntity->second->IsMcsSupported(mcs);
1956 std::list<WifiMode>
list;
1959 if (!phyEntity.second->HandlesMcsModes())
1961 for (
const auto& mode : *(phyEntity.second))
1963 list.emplace_back(mode);
1973 std::list<WifiMode>
list;
1977 if (!phyEntity->second->HandlesMcsModes())
1979 for (
const auto& mode : *(phyEntity->second))
1981 list.emplace_back(mode);
1991 uint16_t numMcs = 0;
1994 if (phyEntity.second->HandlesMcsModes())
1996 numMcs += phyEntity.second->GetNumModes();
2005 std::list<WifiMode>
list;
2008 if (phyEntity.second->HandlesMcsModes())
2010 for (
const auto& mode : *(phyEntity.second))
2012 list.emplace_back(mode);
2022 std::list<WifiMode>
list;
2026 if (phyEntity->second->HandlesMcsModes())
2028 for (
const auto& mode : *(phyEntity->second))
2030 list.emplace_back(mode);
2047 return m_state->IsStateCcaBusy();
2053 return m_state->IsStateIdle();
2071 return m_state->IsStateSwitching();
2077 return m_state->IsStateSleep();
2089 return m_state->GetDelayUntilIdle();
2095 return m_state->GetLastRxStartTime();
2101 return m_state->GetLastRxEndTime();
2127 phyEntity.second->CancelAllEvents();
2163 NS_LOG_FUNCTION(
this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2187 const auto& txVector = ppdu->GetTxVector();
2192 txPowerDbm =
GetPowerDbm(txVector.GetTxPowerLevel());
2196 if (txVector.GetNssMax() > 1 || txVector.GetNssTotal() > 1)
2207 uint16_t channelWidth = ppdu->GetTxChannelWidth();
2208 double txPowerDbmPerMhz =
2210 NS_LOG_INFO(
"txPowerDbm=" << txPowerDbm <<
" with txPowerDbmPerMhz=" << txPowerDbmPerMhz
2211 <<
" over " << channelWidth <<
" MHz");
2230 int64_t currentStream = stream;
2232 currentStream +=
m_interference->GetErrorRateModel()->AssignStreams(currentStream);
2233 return (currentStream - stream);
2240 <<
", RSSI:" << rxSignalInfo.
rssi <<
" dBm";
2253 uint32_t subcarrierSpacing = 0;
2261 subcarrierSpacing = 312500;
2266 subcarrierSpacing = 78125;
2270 subcarrierSpacing = 156250;
2275 subcarrierSpacing = 78125;
2281 return subcarrierSpacing;
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 IsExpired() const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
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.
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(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.
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)
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.
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.
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.
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.
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
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.
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.
virtual Ptr< Channel > GetChannel() const =0
Return the Channel this WifiPhy is connected to.
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.
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 ...
double m_rxSensitivityW
Receive sensitivity threshold in watts.
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.
Ptr< const Packet > GetPacket() const
Get the PSDU as a single packet.
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() const
Return true if the PSDU is an S-MPDU or A-MPDU.
bool IsSingle() const
Return true if the PSDU is an S-MPDU.
std::size_t GetNMpdus() const
Return the number of MPDUs constituting the PSDU.
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...
#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
@ 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.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeChecker > MakeTupleChecker(Ts... checkers)
Create a TupleChecker from AttributeCheckers associated with TupleValue elements.
double RatioToDb(double ratio)
Convert from ratio to dB.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
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.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
double DbmToW(double dBm)
Convert from dBm to Watts.
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 AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
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.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
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.
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.