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"
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.",
91 MakeTupleAccessor<UintegerValue, UintegerValue, EnumValue, UintegerValue>(
93 MakeTupleChecker<UintegerValue, UintegerValue, EnumValue, UintegerValue>(
94 MakeUintegerChecker<uint8_t>(0, 233),
95 MakeUintegerChecker<uint16_t>(0, 160),
104 MakeUintegerChecker<uint8_t>(0, 7)))
105 .AddAttribute(
"Frequency",
106 "The center frequency (MHz) of the current operating channel.",
110 MakeUintegerChecker<uint16_t>())
111 .AddAttribute(
"ChannelNumber",
112 "The channel number of the current operating channel.",
116 MakeUintegerChecker<uint8_t>(0, 233))
119 "The width in MHz of the current operating channel (5, 10, 20, 22, 40, 80 or 160).",
123 MakeUintegerChecker<uint16_t>(5, 160))
126 "The index of the primary 20 MHz channel within the current operating channel "
127 "(0 indicates the 20 MHz subchannel with the lowest center frequency).",
130 MakeUintegerChecker<uint8_t>(0, 7))
131 .AddAttribute(
"FixedPhyBand",
132 "If set to true, changing PHY band is prohibited after initialization.",
138 "The energy of a received signal should be higher than "
139 "this threshold (dBm) for the PHY to detect the signal. "
140 "This threshold refers to a width of 20 MHz and will be "
141 "scaled to match the width of the received signal.",
144 MakeDoubleChecker<double>())
147 "The energy of all received signals should be higher than "
148 "this threshold (dBm) in the primary channel to allow the PHY layer "
149 "to declare CCA BUSY state.",
152 MakeDoubleChecker<double>())
153 .AddAttribute(
"CcaSensitivity",
154 "The energy of a received wifi signal should be higher than "
155 "this threshold (dBm) in the primary channel to allow the PHY layer "
156 "to declare CCA BUSY state.",
160 MakeDoubleChecker<double>())
161 .AddAttribute(
"TxGain",
162 "Transmission gain (dB).",
165 MakeDoubleChecker<double>())
166 .AddAttribute(
"RxGain",
167 "Reception gain (dB).",
170 MakeDoubleChecker<double>())
171 .AddAttribute(
"TxPowerLevels",
172 "Number of transmission power levels available between "
173 "TxPowerStart and TxPowerEnd included.",
176 MakeUintegerChecker<uint8_t>())
177 .AddAttribute(
"TxPowerEnd",
178 "Maximum available transmission level (dBm).",
181 MakeDoubleChecker<double>())
182 .AddAttribute(
"TxPowerStart",
183 "Minimum available transmission level (dBm).",
186 MakeDoubleChecker<double>())
189 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
190 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
191 "\"the difference in decibels (dB) between"
192 " the noise output of the actual receiver to the noise output of an "
193 " ideal receiver with the same overall gain and bandwidth when the receivers "
194 " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
197 MakeDoubleChecker<double>())
198 .AddAttribute(
"State",
199 "The state of the PHY layer.",
202 MakePointerChecker<WifiPhyStateHelper>())
203 .AddAttribute(
"ChannelSwitchDelay",
204 "Delay between two short frames transmitted on different frequencies.",
210 "The number of antennas on the device.",
213 MakeUintegerChecker<uint8_t>(1, 8))
214 .AddAttribute(
"MaxSupportedTxSpatialStreams",
215 "The maximum number of supported TX spatial streams."
216 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
220 MakeUintegerChecker<uint8_t>(1, 8))
221 .AddAttribute(
"MaxSupportedRxSpatialStreams",
222 "The maximum number of supported RX spatial streams."
223 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
227 MakeUintegerChecker<uint8_t>(1, 8))
228 .AddAttribute(
"ShortPlcpPreambleSupported",
229 "Whether or not short PHY preamble is supported."
230 "This parameter is only valuable for 802.11b STAs and APs."
231 "Note: 802.11g APs and STAs always support short PHY preamble.",
236 .AddAttribute(
"FrameCaptureModel",
237 "Ptr to an object that implements the frame capture model",
240 MakePointerChecker<FrameCaptureModel>())
241 .AddAttribute(
"PreambleDetectionModel",
242 "Ptr to an object that implements the preamble detection model",
245 MakePointerChecker<PreambleDetectionModel>())
246 .AddAttribute(
"PostReceptionErrorModel",
247 "An optional packet error model can be added to the receive "
248 "packet process after any propagation-based (SNR-based) error "
249 "models have been applied. Typically this is used to force "
250 "specific packet drops, for testing purposes.",
253 MakePointerChecker<ErrorModel>())
254 .AddAttribute(
"InterferenceHelper",
255 "Ptr to an object that implements the interference helper",
258 MakePointerChecker<InterferenceHelper>())
259 .AddAttribute(
"Sifs",
260 "The duration of the Short Interframe Space. "
261 "NOTE that the default value is overwritten by the value defined "
262 "by the standard; if you want to set this attribute, you have to "
263 "do it after that the PHY object is initialized.",
267 .AddAttribute(
"Slot",
268 "The duration of a slot. "
269 "NOTE that the default value is overwritten by the value defined "
270 "by the standard; if you want to set this attribute, you have to "
271 "do it after that the PHY object is initialized.",
275 .AddAttribute(
"Pifs",
276 "The duration of the PCF Interframe Space. "
277 "NOTE that the default value is overwritten by the value defined "
278 "by the standard; if you want to set this attribute, you have to "
279 "do it after that the PHY object is initialized.",
283 .AddAttribute(
"PowerDensityLimit",
284 "The mean equivalent isotropically radiated power density"
285 "limit (in dBm/MHz) set by regulators.",
288 MakeDoubleChecker<double>())
289 .AddTraceSource(
"PhyTxBegin",
290 "Trace source indicating a packet "
291 "has begun transmitting over the channel medium",
293 "ns3::WifiPhy::PhyTxBeginTracedCallback")
294 .AddTraceSource(
"PhyTxPsduBegin",
295 "Trace source indicating a PSDU "
296 "has begun transmitting over the channel medium",
298 "ns3::WifiPhy::PsduTxBeginCallback")
299 .AddTraceSource(
"PhyTxEnd",
300 "Trace source indicating a packet "
301 "has been completely transmitted over the channel.",
303 "ns3::Packet::TracedCallback")
304 .AddTraceSource(
"PhyTxDrop",
305 "Trace source indicating a packet "
306 "has been dropped by the device during transmission",
308 "ns3::Packet::TracedCallback")
309 .AddTraceSource(
"PhyRxBegin",
310 "Trace source indicating a packet "
311 "has begun being received from the channel medium "
314 "ns3::WifiPhy::PhyRxBeginTracedCallback")
315 .AddTraceSource(
"PhyRxPayloadBegin",
316 "Trace source indicating the reception of the "
317 "payload of a PPDU has begun",
319 "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
320 .AddTraceSource(
"PhyRxEnd",
321 "Trace source indicating a packet "
322 "has been completely received from the channel medium "
325 "ns3::Packet::TracedCallback")
326 .AddTraceSource(
"PhyRxDrop",
327 "Trace source indicating a packet "
328 "has been dropped by the device during reception",
330 "ns3::Packet::TracedCallback")
331 .AddTraceSource(
"MonitorSnifferRx",
332 "Trace source simulating a wifi device in monitor mode "
333 "sniffing all received frames",
335 "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
336 .AddTraceSource(
"MonitorSnifferTx",
337 "Trace source simulating the capability of a wifi device "
338 "in monitor mode to sniff all frames being transmitted",
340 "ns3::WifiPhy::MonitorSnifferTxTracedCallback");
345 : m_txMpduReferenceNumber(0xffffffff),
346 m_rxMpduReferenceNumber(0xffffffff),
349 m_currentEvent(nullptr),
350 m_previouslyRxPpduUid(UINT64_MAX),
358 m_powerRestricted(false),
359 m_channelAccessRequested(false),
360 m_txSpatialStreams(1),
361 m_rxSpatialStreams(1),
362 m_wifiRadioEnergyModel(nullptr),
363 m_timeLastPreambleDetected(
Seconds(0))
366 m_random = CreateObject<UniformRandomVariable>();
367 m_state = CreateObject<WifiPhyStateHelper>();
390 "Either install a MobilityModel on this object or ensure that this "
391 "object is part of a Node and NetDevice");
395 NS_LOG_WARN(
"Mobility not found, propagation models might not work properly");
408 phyEntity.second->CancelAllEvents();
426 preambleEvent.second =
nullptr;
432 phyEntity.second =
nullptr;
437std::map<WifiModulationClass, Ptr<PhyEntity>>&
440 static std::map<WifiModulationClass, Ptr<PhyEntity>> g_staticPhyEntities;
441 return g_staticPhyEntities;
453 m_state->SetReceiveOkCallback(callback);
459 m_state->SetReceiveErrorCallback(callback);
465 m_state->RegisterListener(listener);
471 m_state->UnregisterListener(listener);
685 "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
700 return m_interference->GetErrorRateModel()->CalculateSnr(txVector, ber);
708 "Unimplemented Wi-Fi modulation class " << modulation);
717 "Unsupported Wi-Fi modulation class " << modulation);
737 const auto modulation = ppdu->GetModulation();
758 "The PHY entity has already been added. The setting should only be done once per "
768 "Cannot add an unimplemented PHY to supported list. Update the former first.");
770 "The PHY entity has already been added. The setting should only be done once per "
772 phyEntity->SetOwner(
this);
955 "Cannot change standard");
1076 channel.GetPhyBand(),
1077 channel.GetPrimaryChannelIndex(20));
1085 NS_LOG_FUNCTION(
this << +std::get<0>(channelTuple) << std::get<1>(channelTuple)
1086 <<
static_cast<WifiPhyBand>(std::get<2>(channelTuple))
1087 << +std::get<3>(channelTuple));
1093 NS_LOG_DEBUG(
"Channel information will be applied when a standard is configured");
1140 case WifiPhyState::RX:
1141 NS_LOG_DEBUG(
"drop packet because of channel switching while reception");
1144 case WifiPhyState::TX:
1145 NS_LOG_DEBUG(
"channel switching postponed until end of current transmission");
1148 case WifiPhyState::CCA_BUSY:
1149 case WifiPhyState::IDLE:
1153 phyEntity.second->CancelAllEvents();
1156 case WifiPhyState::SLEEP:
1157 NS_LOG_DEBUG(
"channel switching ignored in sleep mode");
1180 if (width == 0 && number == 0)
1199 "Trying to change PHY band while prohibited.");
1209 htConfig && !htConfig->Get40MHzOperationSupported() && chWidth > 20)
1212 <<
" MHz channel on"
1213 "a station only supporting 20 MHz operation");
1220 <<
" MHz channel on"
1221 "a station supporting up to 80 MHz operation");
1229 if (changingPhyBand)
1252 NS_ASSERT_MSG(antennas > 0 && antennas <= 4,
"unsupported number of antennas");
1277 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity->second);
1280 htPhy->SetMaxSupportedNss(
1319 std::list<uint8_t>
list;
1322 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity.second);
1325 list.emplace_back(htPhy->GetBssMembershipSelector());
1339 case WifiPhyState::TX:
1340 NS_LOG_DEBUG(
"setting sleep mode postponed until end of current transmission");
1343 case WifiPhyState::RX:
1344 NS_LOG_DEBUG(
"setting sleep mode postponed until end of current reception");
1347 case WifiPhyState::SWITCHING:
1348 NS_LOG_DEBUG(
"setting sleep mode postponed until end of channel switching");
1351 case WifiPhyState::CCA_BUSY:
1352 case WifiPhyState::IDLE:
1356 case WifiPhyState::SLEEP:
1375 phyEntity.second->CancelAllEvents();
1387 case WifiPhyState::TX:
1388 case WifiPhyState::RX:
1389 case WifiPhyState::IDLE:
1390 case WifiPhyState::CCA_BUSY:
1391 case WifiPhyState::SWITCHING: {
1392 NS_LOG_DEBUG(
"not in sleep mode, there is nothing to resume");
1395 case WifiPhyState::SLEEP: {
1414 case WifiPhyState::TX:
1415 case WifiPhyState::RX:
1416 case WifiPhyState::IDLE:
1417 case WifiPhyState::CCA_BUSY:
1418 case WifiPhyState::SWITCHING:
1419 case WifiPhyState::SLEEP: {
1420 NS_LOG_DEBUG(
"not in off mode, there is nothing to resume");
1423 case WifiPhyState::OFF: {
1456 double totalAmpduNumSymbols;
1463 totalAmpduNumSymbols,
1474 double& totalAmpduNumSymbols,
1478 ->GetPayloadDuration(size,
1484 totalAmpduNumSymbols,
1492 ->CalculatePhyPreambleAndHeaderDuration(txVector);
1521 ->CalculateTxDuration(psduMap, txVector, band);
1535 for (
const auto& psdu : psdus)
1550 for (
const auto& psdu : psdus)
1610 uint16_t channelFreqMhz,
1613 std::vector<bool> statusPerMpdu,
1617 if (psdu->IsAggregate())
1621 "TxVector with aggregate flag expected here according to PSDU");
1623 size_t nMpdus = psdu->GetNMpdus();
1624 NS_ASSERT_MSG(statusPerMpdu.size() == nMpdus,
"Should have one reception status per MPDU");
1628 for (
size_t i = 0; i < nMpdus;)
1630 if (statusPerMpdu.at(i))
1648 "Should have one reception status for normal MPDU");
1664 uint16_t channelFreqMhz,
1669 if (psdu->IsAggregate())
1673 "TxVector with aggregate flag expected here according to PSDU");
1677 size_t nMpdus = psdu->GetNMpdus();
1679 for (
size_t i = 0; i < nMpdus;)
1736 for (
const auto& psdu : psdus)
1745 bool noEndPreambleDetectionEvent =
true;
1748 noEndPreambleDetectionEvent &= it.second->NoEndPreambleDetectionEvents();
1750 if (!noEndPreambleDetectionEvent ||
1759 it.second->CancelRunningEndPreambleDetectionEvents();
1773 if (
m_state->GetState() == WifiPhyState::OFF)
1775 NS_LOG_DEBUG(
"Transmission canceled because device is OFF");
1789 for (
const auto& psdu : psdus)
1798 ppdu->SetTruncatedTx();
1805 ppdu->ResetTxVector();
1827 phyEntity.second->CancelAllEvents();
1842 it->second->StartReceivePreamble(ppdu, rxPowersW, rxDuration);
1848 NS_LOG_DEBUG(
"Unsupported modulation received (" << modulation <<
"), consider as noise");
1849 m_interference->Add(ppdu, ppdu->GetTxVector(), rxDuration, rxPowersW);
1876 if (phyEntity.second->IsModeSupported(mode))
1891 for (
const auto& mode : *(phyEntity.second))
1896 NS_ASSERT_MSG(
false,
"Should have found at least one default mode");
1908 return phyEntity->second->IsMcsSupported(mcs);
1914 std::list<WifiMode>
list;
1917 if (!phyEntity.second->HandlesMcsModes())
1919 for (
const auto& mode : *(phyEntity.second))
1921 list.emplace_back(mode);
1931 std::list<WifiMode>
list;
1935 if (!phyEntity->second->HandlesMcsModes())
1937 for (
const auto& mode : *(phyEntity->second))
1939 list.emplace_back(mode);
1949 uint16_t numMcs = 0;
1952 if (phyEntity.second->HandlesMcsModes())
1954 numMcs += phyEntity.second->GetNumModes();
1963 std::list<WifiMode>
list;
1966 if (phyEntity.second->HandlesMcsModes())
1968 for (
const auto& mode : *(phyEntity.second))
1970 list.emplace_back(mode);
1980 std::list<WifiMode>
list;
1984 if (phyEntity->second->HandlesMcsModes())
1986 for (
const auto& mode : *(phyEntity->second))
1988 list.emplace_back(mode);
2005 return m_state->IsStateCcaBusy();
2011 return m_state->IsStateIdle();
2029 return m_state->IsStateSwitching();
2035 return m_state->IsStateSleep();
2047 return m_state->GetDelayUntilIdle();
2053 return m_state->GetLastRxStartTime();
2059 return m_state->GetLastRxEndTime();
2085 phyEntity.second->CancelAllEvents();
2116 NS_LOG_FUNCTION(
this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2140 const auto& txVector = ppdu->GetTxVector();
2145 txPowerDbm =
GetPowerDbm(txVector.GetTxPowerLevel());
2149 if (txVector.GetNssMax() > 1)
2160 uint16_t channelWidth = ppdu->GetTransmissionChannelWidth();
2161 double txPowerDbmPerMhz =
2163 NS_LOG_INFO(
"txPowerDbm=" << txPowerDbm <<
" with txPowerDbmPerMhz=" << txPowerDbmPerMhz
2164 <<
" over " << channelWidth <<
" MHz");
2183 int64_t currentStream = stream;
2185 currentStream +=
m_interference->GetErrorRateModel()->AssignStreams(currentStream);
2186 return (currentStream - stream);
2193 <<
", RSSI:" << rxSignalInfo.
rssi <<
" dBm";
2214 subcarrierSpacing = 312500;
2219 subcarrierSpacing = 78125;
2223 subcarrierSpacing = 156250;
2228 subcarrierSpacing = 78125;
2234 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'.
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 IsStrictlyNegative() 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.
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)
Time GetDelayUntilChannelSwitch()
Perform any actions necessary when user changes operating channel after initialization.
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.
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.
virtual void StartTx(Ptr< const WifiPpdu > ppdu)=0
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.
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.
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.
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.
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 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
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.
void RegisterListener(WifiPhyListener *listener)
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.
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.
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
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 SwitchMaybeToCcaBusy(const Ptr< const WifiPpdu > ppdu)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
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 NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
receive notifications about PHY events.
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).
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
WifiModulationClass GetModulationClass() const
Get the modulation class specified by this TXVECTOR.
uint8_t GetNssMax() const
uint8_t GetTxPowerLevel() const
bool IsAggregation() const
Checks whether the PSDU contains A-MPDU.
#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 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
@ 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_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.
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.
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.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
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.