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",
72 MakePointerChecker<Channel>())
75 "Tuple {channel number, channel width (MHz), PHY band, primary20 index} "
76 "describing the settings of the operating channel. The primary20 index is "
77 "the index of the primary 20 MHz channel within the operating channel "
78 "(0 indicates the 20 MHz subchannel with the lowest center frequency) and "
79 "is only valid if the width of the operating channel is a multiple of 20 MHz. "
80 "If the standard for this object has not been set yet, the value of this "
81 "attribute is saved and will be used to set the operating channel when the "
82 "standard is configured. If the PHY band is left unspecified, the default "
83 "band for the configured standard is used. If the channel width and the "
84 "channel number are both 0, the default channel width for the configured "
85 "standard and band are used. If the channel number is 0, the default "
86 "channel number for the configured standard, band and channel width is used."
87 "Note that the channel width can be left unspecified (0) if the channel "
88 "number uniquely identify a frequency channel for the given standard and band.",
90 MakeTupleAccessor<UintegerValue, UintegerValue, EnumValue, UintegerValue>(
92 MakeTupleChecker<UintegerValue, UintegerValue, EnumValue, UintegerValue>(
93 MakeUintegerChecker<uint8_t>(0, 233),
94 MakeUintegerChecker<uint16_t>(0, 160),
103 MakeUintegerChecker<uint8_t>(0, 7)))
104 .AddAttribute(
"Frequency",
105 "The center frequency (MHz) of the current operating channel.",
108 MakeUintegerChecker<uint16_t>())
109 .AddAttribute(
"ChannelNumber",
110 "The channel number of the current operating channel.",
113 MakeUintegerChecker<uint8_t>(0, 233))
116 "The width in MHz of the current operating channel (5, 10, 20, 22, 40, 80 or 160).",
119 MakeUintegerChecker<uint16_t>(5, 160))
122 "The index of the primary 20 MHz channel within the current operating channel "
123 "(0 indicates the 20 MHz subchannel with the lowest center frequency).",
126 MakeUintegerChecker<uint8_t>(0, 7))
127 .AddAttribute(
"FixedPhyBand",
128 "If set to true, changing PHY band is prohibited after initialization.",
134 "The energy of a received signal should be higher than "
135 "this threshold (dBm) for the PHY to detect the signal. "
136 "This threshold refers to a width of 20 MHz and will be "
137 "scaled to match the width of the received signal.",
140 MakeDoubleChecker<double>())
143 "The energy of all received signals should be higher than "
144 "this threshold (dBm) in the primary channel to allow the PHY layer "
145 "to declare CCA BUSY state.",
148 MakeDoubleChecker<double>())
149 .AddAttribute(
"CcaSensitivity",
150 "The energy of a received wifi signal should be higher than "
151 "this threshold (dBm) in the primary channel to allow the PHY layer "
152 "to declare CCA BUSY state.",
156 MakeDoubleChecker<double>())
157 .AddAttribute(
"TxGain",
158 "Transmission gain (dB).",
161 MakeDoubleChecker<double>())
162 .AddAttribute(
"RxGain",
163 "Reception gain (dB).",
166 MakeDoubleChecker<double>())
167 .AddAttribute(
"TxPowerLevels",
168 "Number of transmission power levels available between "
169 "TxPowerStart and TxPowerEnd included.",
172 MakeUintegerChecker<uint8_t>())
173 .AddAttribute(
"TxPowerEnd",
174 "Maximum available transmission level (dBm).",
177 MakeDoubleChecker<double>())
178 .AddAttribute(
"TxPowerStart",
179 "Minimum available transmission level (dBm).",
182 MakeDoubleChecker<double>())
185 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
186 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
187 "\"the difference in decibels (dB) between"
188 " the noise output of the actual receiver to the noise output of an "
189 " ideal receiver with the same overall gain and bandwidth when the receivers "
190 " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
193 MakeDoubleChecker<double>())
194 .AddAttribute(
"State",
195 "The state of the PHY layer.",
198 MakePointerChecker<WifiPhyStateHelper>())
199 .AddAttribute(
"ChannelSwitchDelay",
200 "Delay between two short frames transmitted on different frequencies.",
206 "The number of antennas on the device.",
209 MakeUintegerChecker<uint8_t>(1, 8))
210 .AddAttribute(
"MaxSupportedTxSpatialStreams",
211 "The maximum number of supported TX spatial streams."
212 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
216 MakeUintegerChecker<uint8_t>(1, 8))
217 .AddAttribute(
"MaxSupportedRxSpatialStreams",
218 "The maximum number of supported RX spatial streams."
219 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
223 MakeUintegerChecker<uint8_t>(1, 8))
224 .AddAttribute(
"ShortPlcpPreambleSupported",
225 "Whether or not short PHY preamble is supported."
226 "This parameter is only valuable for 802.11b STAs and APs."
227 "Note: 802.11g APs and STAs always support short PHY preamble.",
232 .AddAttribute(
"FrameCaptureModel",
233 "Ptr to an object that implements the frame capture model",
236 MakePointerChecker<FrameCaptureModel>())
237 .AddAttribute(
"PreambleDetectionModel",
238 "Ptr to an object that implements the preamble detection model",
241 MakePointerChecker<PreambleDetectionModel>())
242 .AddAttribute(
"PostReceptionErrorModel",
243 "An optional packet error model can be added to the receive "
244 "packet process after any propagation-based (SNR-based) error "
245 "models have been applied. Typically this is used to force "
246 "specific packet drops, for testing purposes.",
249 MakePointerChecker<ErrorModel>())
250 .AddAttribute(
"Sifs",
251 "The duration of the Short Interframe Space. "
252 "NOTE that the default value is overwritten by the value defined "
253 "by the standard; if you want to set this attribute, you have to "
254 "do it after that the PHY object is initialized.",
258 .AddAttribute(
"Slot",
259 "The duration of a slot. "
260 "NOTE that the default value is overwritten by the value defined "
261 "by the standard; if you want to set this attribute, you have to "
262 "do it after that the PHY object is initialized.",
266 .AddAttribute(
"Pifs",
267 "The duration of the PCF Interframe Space. "
268 "NOTE that the default value is overwritten by the value defined "
269 "by the standard; if you want to set this attribute, you have to "
270 "do it after that the PHY object is initialized.",
274 .AddAttribute(
"PowerDensityLimit",
275 "The mean equivalent isotropically radiated power density"
276 "limit (in dBm/MHz) set by regulators.",
279 MakeDoubleChecker<double>())
280 .AddTraceSource(
"PhyTxBegin",
281 "Trace source indicating a packet "
282 "has begun transmitting over the channel medium",
284 "ns3::WifiPhy::PhyTxBeginTracedCallback")
285 .AddTraceSource(
"PhyTxPsduBegin",
286 "Trace source indicating a PSDU "
287 "has begun transmitting over the channel medium",
289 "ns3::WifiPhy::PsduTxBeginCallback")
290 .AddTraceSource(
"PhyTxEnd",
291 "Trace source indicating a packet "
292 "has been completely transmitted over the channel.",
294 "ns3::Packet::TracedCallback")
295 .AddTraceSource(
"PhyTxDrop",
296 "Trace source indicating a packet "
297 "has been dropped by the device during transmission",
299 "ns3::Packet::TracedCallback")
300 .AddTraceSource(
"PhyRxBegin",
301 "Trace source indicating a packet "
302 "has begun being received from the channel medium "
305 "ns3::WifiPhy::PhyRxBeginTracedCallback")
306 .AddTraceSource(
"PhyRxPayloadBegin",
307 "Trace source indicating the reception of the "
308 "payload of a PPDU has begun",
310 "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
311 .AddTraceSource(
"PhyRxEnd",
312 "Trace source indicating a packet "
313 "has been completely received from the channel medium "
316 "ns3::Packet::TracedCallback")
317 .AddTraceSource(
"PhyRxDrop",
318 "Trace source indicating a packet "
319 "has been dropped by the device during reception",
321 "ns3::Packet::TracedCallback")
322 .AddTraceSource(
"MonitorSnifferRx",
323 "Trace source simulating a wifi device in monitor mode "
324 "sniffing all received frames",
326 "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
327 .AddTraceSource(
"MonitorSnifferTx",
328 "Trace source simulating the capability of a wifi device "
329 "in monitor mode to sniff all frames being transmitted",
331 "ns3::WifiPhy::MonitorSnifferTxTracedCallback");
336 : m_txMpduReferenceNumber(0xffffffff),
337 m_rxMpduReferenceNumber(0xffffffff),
340 m_currentEvent(nullptr),
341 m_previouslyRxPpduUid(UINT64_MAX),
349 m_powerRestricted(false),
350 m_channelAccessRequested(false),
351 m_txSpatialStreams(1),
352 m_rxSpatialStreams(1),
353 m_wifiRadioEnergyModel(nullptr),
354 m_timeLastPreambleDetected(
Seconds(0))
357 m_random = CreateObject<UniformRandomVariable>();
358 m_state = CreateObject<WifiPhyStateHelper>();
374 phyEntity.second->CancelAllEvents();
392 preambleEvent.second =
nullptr;
398 phyEntity.second =
nullptr;
403std::map<WifiModulationClass, Ptr<PhyEntity>>&
406 static std::map<WifiModulationClass, Ptr<PhyEntity>> g_staticPhyEntities;
407 return g_staticPhyEntities;
419 m_state->SetReceiveOkCallback(callback);
425 m_state->SetReceiveErrorCallback(callback);
431 m_state->RegisterListener(listener);
437 m_state->UnregisterListener(listener);
658 "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
673 return m_interference->GetErrorRateModel()->CalculateSnr(txVector, ber);
703 "The PHY entity has already been added. The setting should only be done once per "
713 "Cannot add an unimplemented PHY to supported list. Update the former first.");
715 "The PHY entity has already been added. The setting should only be done once per "
717 phyEntity->SetOwner(
this);
900 "Cannot change standard");
1007 NS_LOG_FUNCTION(
this << +std::get<0>(channelTuple) << std::get<1>(channelTuple)
1008 <<
static_cast<WifiPhyBand>(std::get<2>(channelTuple))
1009 << +std::get<3>(channelTuple));
1015 NS_LOG_DEBUG(
"Channel information will be applied when a standard is configured");
1062 NS_LOG_DEBUG(
"drop packet because of channel switching while reception");
1066 phyEntity.second->CancelAllEvents();
1070 NS_LOG_DEBUG(
"channel switching postponed until end of current transmission");
1078 phyEntity.second->CancelAllEvents();
1082 NS_LOG_DEBUG(
"channel switching ignored in sleep mode");
1105 if (width == 0 && number == 0)
1124 "Trying to change PHY band while prohibited.");
1134 htConfig && !htConfig->Get40MHzOperationSupported() && chWidth > 20)
1137 <<
" MHz channel on"
1138 "a station only supporting 20 MHz operation");
1145 <<
" MHz channel on"
1146 "a station supporting up to 80 MHz operation");
1154 if (changingPhyBand)
1178 NS_ASSERT_MSG(antennas > 0 && antennas <= 4,
"unsupported number of antennas");
1203 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity->second);
1206 htPhy->SetMaxSupportedNss(
1245 std::list<uint8_t>
list;
1248 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity.second);
1251 list.emplace_back(htPhy->GetBssMembershipSelector());
1266 NS_LOG_DEBUG(
"setting sleep mode postponed until end of current transmission");
1270 NS_LOG_DEBUG(
"setting sleep mode postponed until end of current reception");
1274 NS_LOG_DEBUG(
"setting sleep mode postponed until end of channel switching");
1301 phyEntity.second->CancelAllEvents();
1318 NS_LOG_DEBUG(
"not in sleep mode, there is nothing to resume");
1346 NS_LOG_DEBUG(
"not in off mode, there is nothing to resume");
1382 double totalAmpduNumSymbols;
1389 totalAmpduNumSymbols,
1400 double& totalAmpduNumSymbols,
1404 ->GetPayloadDuration(size,
1410 totalAmpduNumSymbols,
1418 ->CalculatePhyPreambleAndHeaderDuration(txVector);
1447 ->CalculateTxDuration(psduMap, txVector, band);
1461 for (
const auto& psdu : psdus)
1476 for (
const auto& psdu : psdus)
1536 uint16_t channelFreqMhz,
1539 std::vector<bool> statusPerMpdu,
1547 "TxVector with aggregate flag expected here according to PSDU");
1550 NS_ASSERT_MSG(statusPerMpdu.size() == nMpdus,
"Should have one reception status per MPDU");
1554 for (
size_t i = 0; i < nMpdus;)
1556 if (statusPerMpdu.at(i))
1574 "Should have one reception status for normal MPDU");
1590 uint16_t channelFreqMhz,
1599 "TxVector with aggregate flag expected here according to PSDU");
1605 for (
size_t i = 0; i < nMpdus;)
1662 for (
const auto& psdu : psdus)
1671 bool noEndPreambleDetectionEvent =
true;
1674 noEndPreambleDetectionEvent &= it.second->NoEndPreambleDetectionEvents();
1676 if (!noEndPreambleDetectionEvent ||
1685 it.second->CancelRunningEndPreambleDetectionEvents();
1701 NS_LOG_DEBUG(
"Transmission canceled because device is OFF");
1715 for (
const auto& psdu : psdus)
1724 ppdu->SetTruncatedTx();
1752 phyEntity.second->CancelAllEvents();
1766 it->second->StartReceivePreamble(ppdu, rxPowersW, rxDuration);
1772 NS_LOG_DEBUG(
"Unsupported modulation received (" << modulation <<
"), consider as noise");
1773 m_interference->Add(ppdu, ppdu->GetTxVector(), rxDuration, rxPowersW);
1780 uint16_t guardBandwidth,
1782 uint8_t bandIndex)
const
1784 NS_ASSERT_MSG(
false,
"802.11ax can only be used with SpectrumWifiPhy");
1786 return convertedSubcarriers;
1811 if (phyEntity.second->IsModeSupported(mode))
1826 for (
const auto& mode : *(phyEntity.second))
1831 NS_ASSERT_MSG(
false,
"Should have found at least one default mode");
1843 return phyEntity->second->IsMcsSupported(mcs);
1849 std::list<WifiMode>
list;
1852 if (!phyEntity.second->HandlesMcsModes())
1854 for (
const auto& mode : *(phyEntity.second))
1856 list.emplace_back(mode);
1866 std::list<WifiMode>
list;
1870 if (!phyEntity->second->HandlesMcsModes())
1872 for (
const auto& mode : *(phyEntity->second))
1874 list.emplace_back(mode);
1884 uint16_t numMcs = 0;
1887 if (phyEntity.second->HandlesMcsModes())
1889 numMcs += phyEntity.second->GetNumModes();
1898 std::list<WifiMode>
list;
1901 if (phyEntity.second->HandlesMcsModes())
1903 for (
const auto& mode : *(phyEntity.second))
1905 list.emplace_back(mode);
1915 std::list<WifiMode>
list;
1919 if (phyEntity->second->HandlesMcsModes())
1921 for (
const auto& mode : *(phyEntity->second))
1923 list.emplace_back(mode);
1940 return m_state->IsStateCcaBusy();
1946 return m_state->IsStateIdle();
1964 return m_state->IsStateSwitching();
1970 return m_state->IsStateSleep();
1982 return m_state->GetDelayUntilIdle();
1988 return m_state->GetLastRxStartTime();
1994 return m_state->GetLastRxEndTime();
2020 phyEntity.second->CancelAllEvents();
2051 NS_LOG_FUNCTION(
this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2095 uint16_t channelWidth = ppdu->GetTransmissionChannelWidth();
2096 double txPowerDbmPerMhz =
2098 NS_LOG_INFO(
"txPowerDbm=" << txPowerDbm <<
" with txPowerDbmPerMhz=" << txPowerDbmPerMhz
2099 <<
" over " << channelWidth <<
" MHz");
2111 return GetPhyEntity(ppdu->GetModulation())->GetAddressedPsduInPpdu(ppdu);
2127 int64_t currentStream = stream;
2129 currentStream +=
m_interference->GetErrorRateModel()->AssignStreams(currentStream);
2130 return (currentStream - stream);
2137 <<
", RSSI:" << rxSignalInfo.
rssi <<
" dBm";
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().
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
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.
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
bool IsStrictlyNegative() const
Exactly equivalent to t < 0.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
AttributeValue implementation for Time.
bool IsEmpty() const
Checks if the Callbacks list is empty.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
bool Get160MHzOperationSupported() const
represent a single transmission mode
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.
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.
virtual WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const
double m_txPowerMaxSiso
SISO maximum transmit power due to OBSS PD SR power restriction (dBm)
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
void AddPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of supported PHY entities for the given modulation class for the WifiPh...
TracedCallback< Ptr< const Packet >, uint16_t, WifiTxVector, MpduInfo, SignalNoiseDbm, uint16_t > m_phyMonitorSniffRxTrace
A trace source that emulates a Wi-Fi device in monitor mode sniffing a packet being received.
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
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.
virtual WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0)
Get the start band index and the stop band index for a given band.
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.
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)
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.
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.
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.
virtual void StartTx(Ptr< const WifiPpdu > ppdu, const WifiTxVector &txVector)=0
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.
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).
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...
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 AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
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.
double WToDbm(double w)
Convert from Watts to dBm.
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
std::ostream & operator<<(std::ostream &os, const Angles &a)
double DbmToW(double dBm)
Convert from dBm to Watts.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
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.
@ 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.