23 #include "ns3/simulator.h"
25 #include "ns3/pointer.h"
26 #include "ns3/string.h"
27 #include "ns3/tuple.h"
28 #include "ns3/mobility-model.h"
29 #include "ns3/random-variable-stream.h"
30 #include "ns3/error-model.h"
42 #include "ns3/dsss-phy.h"
43 #include "ns3/erp-ofdm-phy.h"
44 #include "ns3/he-phy.h"
61 .SetGroupName (
"Wifi")
62 .AddAttribute (
"ChannelSettings",
63 "Tuple {channel number, channel width (MHz), PHY band, primary20 index} "
64 "describing the settings of the operating channel. The primary20 index is "
65 "the index of the primary 20 MHz channel within the operating channel "
66 "(0 indicates the 20 MHz subchannel with the lowest center frequency) and "
67 "is only valid if the width of the operating channel is a multiple of 20 MHz. "
68 "If the standard for this object has not been set yet, the value of this "
69 "attribute is saved and will be used to set the operating channel when the "
70 "standard is configured. If the PHY band is left unspecified, the default "
71 "band for the configured standard is used. If the channel width and the "
72 "channel number are both 0, the default channel width for the configured "
73 "standard and band are used. If the channel number is 0, the default "
74 "channel number for the configured standard, band and channel width is used."
75 "Note that the channel width can be left unspecified (0) if the channel "
76 "number uniquely identify a frequency channel for the given standard and band. ",
79 MakeTupleChecker<UintegerValue, UintegerValue, EnumValue, UintegerValue>
80 (MakeUintegerChecker<uint8_t> (0, 233),
81 MakeUintegerChecker<uint16_t> (0, 160),
86 MakeUintegerChecker<uint8_t> (0, 7)))
87 .AddAttribute (
"Frequency",
88 "The center frequency (MHz) of the current operating channel.",
91 MakeUintegerChecker<uint16_t> ())
92 .AddAttribute (
"ChannelNumber",
93 "The channel number of the current operating channel.",
96 MakeUintegerChecker<uint8_t> (0, 233))
97 .AddAttribute (
"ChannelWidth",
98 "The width in MHz of the current operating channel (5, 10, 20, 22, 40, 80 or 160).",
101 MakeUintegerChecker<uint16_t> (5, 160))
102 .AddAttribute (
"Primary20MHzIndex",
103 "The index of the primary 20 MHz channel within the current operating channel "
104 "(0 indicates the 20 MHz subchannel with the lowest center frequency).",
107 MakeUintegerChecker<uint8_t> (0, 7))
108 .AddAttribute (
"RxSensitivity",
109 "The energy of a received signal should be higher than "
110 "this threshold (dBm) for the PHY to detect the signal. "
111 "This threshold refers to a width of 20 MHz and will be "
112 "scaled to match the width of the received signal.",
116 MakeDoubleChecker<double> ())
117 .AddAttribute (
"CcaEdThreshold",
118 "The energy of a non Wi-Fi received signal should be higher than "
119 "this threshold (dBm) to allow the PHY layer to declare CCA BUSY state. "
120 "This check is performed on the 20 MHz primary channel only.",
124 MakeDoubleChecker<double> ())
125 .AddAttribute (
"TxGain",
126 "Transmission gain (dB).",
130 MakeDoubleChecker<double> ())
131 .AddAttribute (
"RxGain",
132 "Reception gain (dB).",
136 MakeDoubleChecker<double> ())
137 .AddAttribute (
"TxPowerLevels",
138 "Number of transmission power levels available between "
139 "TxPowerStart and TxPowerEnd included.",
142 MakeUintegerChecker<uint8_t> ())
143 .AddAttribute (
"TxPowerEnd",
144 "Maximum available transmission level (dBm).",
148 MakeDoubleChecker<double> ())
149 .AddAttribute (
"TxPowerStart",
150 "Minimum available transmission level (dBm).",
154 MakeDoubleChecker<double> ())
155 .AddAttribute (
"RxNoiseFigure",
156 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
157 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
158 "\"the difference in decibels (dB) between"
159 " the noise output of the actual receiver to the noise output of an "
160 " ideal receiver with the same overall gain and bandwidth when the receivers "
161 " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
164 MakeDoubleChecker<double> ())
165 .AddAttribute (
"State",
166 "The state of the PHY layer.",
169 MakePointerChecker<WifiPhyStateHelper> ())
170 .AddAttribute (
"ChannelSwitchDelay",
171 "Delay between two short frames transmitted on different frequencies.",
175 .AddAttribute (
"Antennas",
176 "The number of antennas on the device.",
180 MakeUintegerChecker<uint8_t> (1, 8))
181 .AddAttribute (
"MaxSupportedTxSpatialStreams",
182 "The maximum number of supported TX spatial streams."
183 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
187 MakeUintegerChecker<uint8_t> (1, 8))
188 .AddAttribute (
"MaxSupportedRxSpatialStreams",
189 "The maximum number of supported RX spatial streams."
190 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
194 MakeUintegerChecker<uint8_t> (1, 8))
195 .AddAttribute (
"ShortPlcpPreambleSupported",
196 "Whether or not short PHY preamble is supported."
197 "This parameter is only valuable for 802.11b STAs and APs."
198 "Note: 802.11g APs and STAs always support short PHY preamble.",
203 .AddAttribute (
"FrameCaptureModel",
204 "Ptr to an object that implements the frame capture model",
207 MakePointerChecker <FrameCaptureModel> ())
208 .AddAttribute (
"PreambleDetectionModel",
209 "Ptr to an object that implements the preamble detection model",
212 MakePointerChecker <PreambleDetectionModel> ())
213 .AddAttribute (
"PostReceptionErrorModel",
214 "An optional packet error model can be added to the receive "
215 "packet process after any propagation-based (SNR-based) error "
216 "models have been applied. Typically this is used to force "
217 "specific packet drops, for testing purposes.",
220 MakePointerChecker<ErrorModel> ())
221 .AddAttribute (
"Sifs",
222 "The duration of the Short Interframe Space. "
223 "NOTE that the default value is overwritten by the value defined "
224 "by the standard; if you want to set this attribute, you have to "
225 "do it after that the PHY object is initialized.",
229 .AddAttribute (
"Slot",
230 "The duration of a slot. "
231 "NOTE that the default value is overwritten by the value defined "
232 "by the standard; if you want to set this attribute, you have to "
233 "do it after that the PHY object is initialized.",
237 .AddAttribute (
"Pifs",
238 "The duration of the PCF Interframe Space. "
239 "NOTE that the default value is overwritten by the value defined "
240 "by the standard; if you want to set this attribute, you have to "
241 "do it after that the PHY object is initialized.",
245 .AddAttribute (
"PowerDensityLimit",
246 "The mean equivalent isotropically radiated power density"
247 "limit (in dBm/MHz) set by regulators.",
250 MakeDoubleChecker<double> ())
251 .AddTraceSource (
"PhyTxBegin",
252 "Trace source indicating a packet "
253 "has begun transmitting over the channel medium",
255 "ns3::WifiPhy::PhyTxBeginTracedCallback")
256 .AddTraceSource (
"PhyTxPsduBegin",
257 "Trace source indicating a PSDU "
258 "has begun transmitting over the channel medium",
260 "ns3::WifiPhy::PsduTxBeginCallback")
261 .AddTraceSource (
"PhyTxEnd",
262 "Trace source indicating a packet "
263 "has been completely transmitted over the channel.",
265 "ns3::Packet::TracedCallback")
266 .AddTraceSource (
"PhyTxDrop",
267 "Trace source indicating a packet "
268 "has been dropped by the device during transmission",
270 "ns3::Packet::TracedCallback")
271 .AddTraceSource (
"PhyRxBegin",
272 "Trace source indicating a packet "
273 "has begun being received from the channel medium "
276 "ns3::WifiPhy::PhyRxBeginTracedCallback")
277 .AddTraceSource (
"PhyRxPayloadBegin",
278 "Trace source indicating the reception of the "
279 "payload of a PPDU has begun",
281 "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
282 .AddTraceSource (
"PhyRxEnd",
283 "Trace source indicating a packet "
284 "has been completely received from the channel medium "
287 "ns3::Packet::TracedCallback")
288 .AddTraceSource (
"PhyRxDrop",
289 "Trace source indicating a packet "
290 "has been dropped by the device during reception",
292 "ns3::Packet::TracedCallback")
293 .AddTraceSource (
"MonitorSnifferRx",
294 "Trace source simulating a wifi device in monitor mode "
295 "sniffing all received frames",
297 "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
298 .AddTraceSource (
"MonitorSnifferTx",
299 "Trace source simulating the capability of a wifi device "
300 "in monitor mode to sniff all frames being transmitted",
302 "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
308 : m_txMpduReferenceNumber (0xffffffff),
309 m_rxMpduReferenceNumber (0xffffffff),
313 m_previouslyRxPpduUid (UINT64_MAX),
320 m_blockAckTxTime (
Seconds (0)),
321 m_powerRestricted (false),
322 m_channelAccessRequested (false),
323 m_txSpatialStreams (0),
324 m_rxSpatialStreams (0),
325 m_wifiRadioEnergyModel (0),
326 m_timeLastPreambleDetected (
Seconds (0))
329 m_random = CreateObject<UniformRandomVariable> ();
330 m_state = CreateObject<WifiPhyStateHelper> ();
346 phyEntity.second->CancelAllEvents ();
365 preambleEvent.second = 0;
371 phyEntity.second = 0;
376 std::map<WifiModulationClass, Ptr<PhyEntity> > &
379 static std::map<WifiModulationClass, Ptr<PhyEntity> > g_staticPhyEntities;
380 return g_staticPhyEntities;
392 m_state->SetReceiveOkCallback (callback);
398 m_state->SetReceiveErrorCallback (callback);
404 m_state->RegisterListener (listener);
410 m_state->UnregisterListener (listener);
632 return m_interference->GetErrorRateModel ()->CalculateSnr (txVector, ber);
665 phyEntity->SetOwner (
this);
788 NS_FATAL_ERROR (
"802.11p configured with a wrong channel width!");
840 "Cannot change standard");
933 NS_LOG_FUNCTION (
this << +std::get<0> (channelTuple) << std::get<1> (channelTuple)
934 <<
static_cast<WifiPhyBand> (std::get<2> (channelTuple))
935 << +std::get<3> (channelTuple));
941 NS_LOG_DEBUG (
"Channel information will be applied when a standard is configured");
989 NS_LOG_DEBUG (
"drop packet because of channel switching while reception");
993 phyEntity.second->CancelAllEvents ();
997 NS_LOG_DEBUG (
"channel switching postponed until end of current transmission");
1005 phyEntity.second->CancelAllEvents ();
1009 NS_LOG_DEBUG (
"channel switching ignored in sleep mode");
1032 if (width == 0 && number == 0)
1054 if (changingPhyBand)
1080 NS_ASSERT_MSG (antennas > 0 && antennas <= 4,
"unsupported number of antennas");
1105 Ptr<HtPhy> htPhy = DynamicCast<HtPhy> (phyEntity->second);
1146 std::list<uint8_t>
list;
1149 Ptr<HtPhy> htPhy = DynamicCast<HtPhy> (phyEntity.second);
1152 list.emplace_back (htPhy->GetBssMembershipSelector ());
1169 NS_LOG_FUNCTION (
"Adding " << width <<
" to supported channel width set");
1173 std::vector<uint16_t>
1188 NS_LOG_DEBUG (
"setting sleep mode postponed until end of current transmission");
1192 NS_LOG_DEBUG (
"setting sleep mode postponed until end of current reception");
1196 NS_LOG_DEBUG (
"setting sleep mode postponed until end of channel switching");
1223 phyEntity.second->CancelAllEvents ();
1241 NS_LOG_DEBUG (
"not in sleep mode, there is nothing to resume");
1272 NS_LOG_DEBUG (
"not in off mode, there is nothing to resume");
1305 uint32_t totalAmpduSize;
1306 double totalAmpduNumSymbols;
1307 return GetPayloadDuration (size, txVector, band, mpdutype,
false, totalAmpduSize, totalAmpduNumSymbols, staId);
1312 bool incFlag, uint32_t &totalAmpduSize,
double &totalAmpduNumSymbols,
1316 incFlag, totalAmpduSize, totalAmpduNumSymbols,
1358 for (
auto const& psdu : psdus)
1373 for (
auto const& psdu : psdus)
1433 SignalNoiseDbm signalNoise, std::vector<bool> statusPerMpdu, uint16_t staId)
1442 NS_ASSERT_MSG (statusPerMpdu.size () == nMpdus,
"Should have one reception status per MPDU");
1446 for (
size_t i = 0; i < nMpdus;)
1448 if (statusPerMpdu.at (i))
1459 NS_ASSERT_MSG (statusPerMpdu.size () == 1,
"Should have one reception status for normal MPDU");
1481 for (
size_t i = 0; i < nMpdus;)
1532 NS_LOG_DEBUG (
"Dropping packet because in sleep mode");
1533 for (
auto const& psdu : psdus)
1542 bool noEndPreambleDetectionEvent =
true;
1545 noEndPreambleDetectionEvent &= it.second->NoEndPreambleDetectionEvents ();
1554 it.second->CancelRunningEndPreambleDetectionEvents ();
1570 NS_LOG_DEBUG (
"Transmission canceled because device is OFF");
1583 for (
auto const& psdu : psdus)
1591 ppdu->SetTruncatedTx ();
1618 phyEntity.second->CancelAllEvents ();
1630 it->second->StartReceivePreamble (ppdu, rxPowersW, rxDuration);
1635 NS_LOG_DEBUG (
"Unsupported modulation received (" << modulation <<
"), consider as noise");
1636 m_interference->Add (ppdu, ppdu->GetTxVector (), rxDuration, rxPowersW);
1645 NS_ASSERT_MSG (
false,
"802.11ax can only be used with SpectrumWifiPhy");
1647 return convertedSubcarriers;
1683 if (phyEntity.second->IsModeSupported (mode))
1697 for (
const auto & mode : *(phyEntity.second))
1702 NS_ASSERT_MSG (
false,
"Should have found at least one default mode");
1714 return phyEntity->second->IsMcsSupported (mcs);
1720 std::list<WifiMode>
list;
1723 if (!phyEntity.second->HandlesMcsModes ())
1725 for (
const auto & mode : *(phyEntity.second))
1727 list.emplace_back (mode);
1737 std::list<WifiMode>
list;
1741 if (!phyEntity->second->HandlesMcsModes ())
1743 for (
const auto & mode : *(phyEntity->second))
1745 list.emplace_back (mode);
1755 uint16_t numMcs = 0;
1758 if (phyEntity.second->HandlesMcsModes ())
1760 numMcs += phyEntity.second->GetNumModes ();
1769 std::list<WifiMode>
list;
1772 if (phyEntity.second->HandlesMcsModes ())
1774 for (
const auto & mode : *(phyEntity.second))
1776 list.emplace_back (mode);
1786 std::list<WifiMode>
list;
1790 if (phyEntity->second->HandlesMcsModes ())
1792 for (
const auto & mode : *(phyEntity->second))
1794 list.emplace_back (mode);
1811 return m_state->IsStateCcaBusy ();
1817 return m_state->IsStateIdle ();
1835 return m_state->IsStateSwitching ();
1841 return m_state->IsStateSleep ();
1847 return m_state->IsStateOff ();
1853 return m_state->GetDelayUntilIdle ();
1859 return m_state->GetLastRxStartTime ();
1865 return m_state->GetLastRxEndTime ();
1877 if (!delayUntilCcaEnd.
IsZero ())
1880 m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
1892 phyEntity.second->CancelAllEvents ();
1906 m_state->SwitchFromRxAbort ();
1923 NS_LOG_FUNCTION (
this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
1963 uint16_t channelWidth = ppdu->GetTransmissionChannelWidth ();
1965 NS_LOG_INFO (
"txPowerDbm=" << txPowerDbm <<
" with txPowerDbmPerMhz=" << txPowerDbmPerMhz <<
" over " << channelWidth <<
" MHz");
1976 return GetPhyEntity (ppdu->GetModulation ())->GetAddressedPsduInPpdu (ppdu);
1982 if (ppdu ==
nullptr)
1988 return GetPhyEntity (ppdu->GetModulation ())->GetMeasurementChannelWidth (ppdu);
2015 int64_t currentStream = stream;
2017 currentStream +=
m_interference->GetErrorRateModel ()->AssignStreams (currentStream);
2018 return (currentStream - stream);
2024 <<
", RSSI:" << rxSignalInfo.
rssi <<
" dBm";
AttributeValue implementation for Boolean.
bool IsNull(void) const
Check for null implementation.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
Keep track of the current position and velocity of an object.
A base class which provides memory management and object aggregation.
bool IsInitialized(void) const
Check if the object has been initialized.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Hold objects of type Ptr<T>.
Smart pointer class similar to boost::intrusive_ptr.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
static Time Now(void)
Return the current simulation virtual time.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
bool IsStrictlyNegative(void) const
Exactly equivalent to t < 0.
bool IsZero(void) const
Exactly equivalent to t == 0.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
AttributeValue implementation for Time.
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.
represent a single transmission mode
Ptr< Node > GetNode(void) const override
void SetNumberOfAntennas(uint8_t antennas)
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
double m_rxGainDb
Reception gain (dB)
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
bool IsStateIdle(void) const
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
void Send(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
This function is a wrapper for the Send variant that accepts a WifiConstPsduMap as first argument.
bool IsStateTx(void) const
void StartReceivePreamble(Ptr< WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
uint8_t GetChannelNumber(void) const
Return current channel number.
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
Time m_channelSwitchDelay
Time required to switch between channel.
std::list< WifiMode > GetMcsList(void) const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
void SetCcaEdThreshold(double threshold)
Sets the CCA threshold (dBm).
TracedCallback< Ptr< const Packet >, WifiPhyRxfailureReason > m_phyRxDropTrace
The trace source fired when the PHY layer drops a packet it has received.
WifiPhyOperatingChannel m_operatingChannel
Operating channel.
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the PHY layer drops a packet as it tries to transmit it.
TracedCallback< Ptr< const Packet >, RxPowerWattPerChannelBand > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
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)
TracedCallback< Ptr< const Packet >, double > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
Ptr< MobilityModel > GetMobility(void) const
Return the mobility model this PHY is associated with.
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
Ptr< const WifiPsdu > GetAddressedPsduInPpdu(Ptr< const WifiPpdu > ppdu) const
Get the PSDU addressed to that PHY in a PPDU (useful for MU PPDU).
bool GetShortPhyPreambleSupported(void) const
Return whether short PHY preamble is supported.
void NotifyTxEnd(WifiConstPsduMap psdus)
Public method used to fire a PhyTxEnd trace.
std::map< std::pair< uint64_t, WifiPreamble >, Ptr< Event > > m_currentPreambleEvents
store event associated to a PPDU (that has a unique ID and preamble combination) whose preamble is be...
Time m_slot
Slot duration.
double m_powerDensityLimit
the power density limit (dBm/MHz)
WifiMode GetDefaultMode(void) const
Get the default WifiMode supported by the PHY.
std::vector< uint16_t > GetSupportedChannelWidthSet(void) const
bool IsStateRx(void) const
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS) for this PHY.
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
EventId m_endPhyRxEvent
the end of PHY receive event
double m_txPowerBaseDbm
Minimum transmission power (dBm)
Ptr< WifiPhyStateHelper > GetState(void) const
Return the WifiPhyStateHelper of this PHY.
Ptr< WifiNetDevice > GetDevice(void) const
Return the device this PHY is associated with.
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.
WifiStandard GetStandard(void) const
Get the configured Wi-Fi standard.
virtual void DoDispose(void)
Destructor implementation.
Time m_blockAckTxTime
estimated BlockAck TX time
uint8_t GetPrimaryChannelNumber(uint16_t primaryChannelWidth) const
Get channel number of the primary channel.
void Configure80211a(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
void ResetCca(bool powerRestricted, double txPowerMaxSiso=0, double txPowerMaxMimo=0)
Reset PHY to IDLE, with some potential TX power restrictions for the next transmission.
double m_txPowerMaxMimo
MIMO maximum transmit power due to OBSS PD SR power restriction (dBm)
Time GetSlot(void) const
Return the slot duration for this PHY.
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted.
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
void NotifyRxBegin(Ptr< const WifiPsdu > psdu, const RxPowerWattPerChannelBand &rxPowersW)
Public method used to fire a PhyRxBegin trace.
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const
Return the channel width used to measure the RSSI.
double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
Time m_sifs
Short Interframe Space (SIFS) duration.
void SetReceiveErrorCallback(RxErrorCallback callback)
void ResetReceive(Ptr< Event > event)
Reset PHY at the end of the packet under reception after it has failed the PHY header.
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
uint8_t GetMaxSupportedRxSpatialStreams(void) const
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)
Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
Time GetBlockAckTxTime(void) const
Return the estimated BlockAck TX time for this PHY.
void Configure80211p(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11p standard.
Time GetPifs(void) const
Return the PCF Interframe Space (PIFS) for this PHY.
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
void NotifyTxBegin(WifiConstPsduMap psdus, double txPowerW)
Public method used to fire a PhyTxBegin trace.
void Reset(void)
Reset data upon end of TX or RX.
void SetShortPhyPreambleSupported(bool preamble)
Enable or disable short PHY preamble.
void SetNTxPower(uint8_t n)
Sets the number of transmission power levels available between the minimum level and the maximum leve...
static TypeId GetTypeId(void)
Get the type ID.
WifiPhyBand m_band
WifiPhyBand.
void Configure80211b(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
void SetSleepMode(void)
Put in sleep mode.
void SetRxSensitivity(double threshold)
Sets the receive sensitivity threshold (dBm).
uint8_t GetPrimary20Index(void) const
static const Ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
uint8_t GetMaxSupportedTxSpatialStreams(void) const
void Configure80211g(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
TracedCallback< Ptr< const Packet >, uint16_t, WifiTxVector, MpduInfo, uint16_t > m_phyMonitorSniffTxTrace
A trace source that emulates a Wi-Fi device in monitor mode sniffing a packet being transmitted.
Time GetChannelSwitchDelay(void) const
virtual WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const
double m_txPowerMaxSiso
SISO maximum transmit power due to OBSS PD SR power restriction (dBm)
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
void AddPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of supported PHY entities for the given modulation class for the WifiPh...
TracedCallback< Ptr< const Packet >, uint16_t, WifiTxVector, MpduInfo, SignalNoiseDbm, uint16_t > m_phyMonitorSniffRxTrace
A trace source that emulates a Wi-Fi device in monitor mode sniffing a packet being received.
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
double GetTxPowerStart(void) const
Return the minimum available transmission power level (dBm).
EventId m_endTxEvent
the end of transmit event
static WifiConstPsduMap GetWifiConstPsduMap(Ptr< const WifiPsdu > psdu, const WifiTxVector &txVector)
Get a WifiConstPsduMap from a PSDU and the TXVECTOR to use to send the PSDU.
uint16_t GetNMcs(void) const
void SetSlot(Time slot)
Set the slot duration for this PHY.
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
Ptr< Event > m_currentEvent
Hold the current event.
double m_ccaEdThresholdW
Clear channel assessment (CCA) threshold in watts.
void NotifyMonitorSniffTx(Ptr< const WifiPsdu > psdu, uint16_t channelFreqMhz, WifiTxVector txVector, uint16_t staId=SU_STA_ID)
Public method used to fire a MonitorSniffer trace for a wifi PSDU being transmitted.
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class, for the WifiPhy instance.
virtual WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0)
Get the start band index and the stop band index for a given band.
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
void ResumeFromSleep(void)
Resume from sleep mode.
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
void Configure80211ac(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard.
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU.
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
void NotifyChannelAccessRequested(void)
Notify the PHY that an access to the channel was requested.
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
uint8_t GetNumberOfAntennas(void) const
void SwitchMaybeToCcaBusy(uint16_t channelWidth)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
static std::map< WifiModulationClass, Ptr< PhyEntity > > & GetStaticPhyEntities(void)
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
std::list< WifiMode > GetModeList(void) const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
TracedCallback< WifiConstPsduMap, WifiTxVector, double > m_phyTxPsduBeginTrace
The trace source fired when a PSDU map begins the transmission process on the medium.
double m_txGainDb
Transmission gain (dB)
std::vector< uint16_t > m_supportedChannelWidthSet
Supported channel width set (MHz)
WifiSpectrumBand GetPrimaryBand(uint16_t bandWidth)
If the operating channel width is a multiple of 20 MHz, return the start band index and the stop band...
Time GetDelayUntilIdle(void)
uint64_t GetPreviouslyRxPpduUid(void) const
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.
double m_noiseFigureDb
The noise figure in dB.
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
void SetPifs(Time pifs)
Set the PCF Interframe Space (PIFS) for this PHY.
Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
static Time GetStartOfPacketDuration(const WifiTxVector &txVector)
virtual void StartTx(Ptr< WifiPpdu > ppdu)=0
Time GetAckTxTime(void) const
Return the estimated Ack TX time for this PHY.
void UnregisterListener(WifiPhyListener *listener)
void SetRxGain(double gain)
Sets the reception gain (dB).
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
double GetRxGain(void) const
Return the reception gain (dB).
void SetTxGain(double gain)
Sets the transmission gain (dB).
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
double m_txPowerEndDbm
Maximum transmission power (dBm)
void SetOffMode(void)
Put in off mode.
double CalculateSnr(const WifiTxVector &txVector, double ber) const
void Configure80211n(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
bool IsStateSwitching(void) const
double GetTxGain(void) const
Return the transmission gain (dB).
uint8_t GetNTxPower(void) const
Return the number of available transmission power levels.
Time GetDelayUntilChannelSwitch(void)
Perform any actions necessary when user changes operating channel after initialization.
void EndReceiveInterBss(void)
For HE receptions only, check and possibly modify the transmit power restriction state at the end of ...
double GetCcaEdThreshold(void) const
Return the CCA threshold (dBm).
double GetRxSensitivity(void) const
Return the receive sensitivity threshold (dBm).
void RegisterListener(WifiPhyListener *listener)
Ptr< WifiNetDevice > m_device
Pointer to the device.
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
bool IsStateSleep(void) const
bool IsStateCcaBusy(void) const
bool m_shortPreamble
Flag if short PHY preamble is supported.
Time m_pifs
PCF Interframe Space (PIFS) duration.
void SetRxNoiseFigure(double noiseFigureDb)
Sets the RX loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
double GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
void SetCapabilitiesChangedCallback(Callback< void > callback)
void SetReceiveOkCallback(RxOkCallback callback)
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
void ResumeFromOff(void)
Resume from off mode.
void Configure80211ax(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard.
bool m_powerRestricted
Flag whether transmit power is restricted by OBSS PD SR.
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
void AddSupportedChannelWidth(uint16_t width)
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.
virtual void DoChannelSwitch(void)
Actually switch channel based on the stored channel settings.
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
static Time GetPreambleDetectionDuration(void)
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
double m_rxSensitivityW
Receive sensitivity threshold in watts.
Time GetLastRxEndTime(void) const
Return the end time of the last received packet.
uint16_t GetChannelWidth(void) const
bool IsStateOff(void) const
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
uint16_t GetFrequency(void) const
Time m_ackTxTime
estimated Ack TX time
void NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
receive notifications about PHY events.
Class that keeps track of all information about the current PHY operating channel.
uint8_t GetNumber(void) const
Return the channel number identifying the whole operating channel.
bool IsSet(void) const
Return true if a valid channel has been set, false otherwise.
uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
uint16_t GetWidth(void) const
Return the width of the whole operating channel (in MHz).
void 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.
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.
uint16_t GetFrequency(void) const
Return the center frequency of the operating channel (in MHz).
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Ptr< Packet > GetAmpduSubframe(std::size_t i) const
Get a copy of the i-th A-MPDU subframe (includes subframe header, MPDU, and possibly padding)
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
Ptr< const Packet > GetPacket(void) const
Get the PSDU as a single packet.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint8_t GetTxPowerLevel(void) const
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
uint8_t GetNssMax(void) const
WifiModulationClass GetModulationClass(void) const
Get the modulation class specified by this TXVECTOR.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG_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_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_MOD_CLASS_DSSS
DSSS (Clause 15)
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
@ LAST_MPDU_IN_AGGREGATE
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
@ FIRST_MPDU_IN_AGGREGATE
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate.
@ SINGLE_MPDU
The MPDU is a single MPDU.
@ MIDDLE_MPDU_IN_AGGREGATE
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double RatioToDb(double ratio)
Convert from ratio to dB.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
double WToDbm(double w)
Convert from Watts to dBm.
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
double DbmToW(double dBm)
Convert from dBm to Watts.
Ptr< const AttributeChecker > MakeEnumChecker(int 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.
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.
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.