A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-phy.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 * Sébastien Deronne <sebastien.deronne@gmail.com>
19 */
20
21#include "wifi-phy.h"
22
23#include "error-rate-model.h"
24#include "frame-capture-model.h"
25#include "interference-helper.h"
27#include "wifi-net-device.h"
28#include "wifi-ppdu.h"
29#include "wifi-psdu.h"
31#include "wifi-utils.h"
32
33#include "ns3/channel.h"
34#include "ns3/dsss-phy.h"
35#include "ns3/eht-phy.h" //also includes OFDM, HT, VHT and HE
36#include "ns3/erp-ofdm-phy.h"
37#include "ns3/error-model.h"
38#include "ns3/ht-configuration.h"
39#include "ns3/log.h"
40#include "ns3/mobility-model.h"
41#include "ns3/pointer.h"
42#include "ns3/random-variable-stream.h"
43#include "ns3/simulator.h"
44#include "ns3/string.h"
45#include "ns3/tuple.h"
46#include "ns3/vht-configuration.h"
47
48#include <algorithm>
49
50#undef NS_LOG_APPEND_CONTEXT
51#define NS_LOG_APPEND_CONTEXT \
52 WIFI_PHY_NS_LOG_APPEND_CONTEXT( \
53 (m_device && (m_device->GetNPhys() > m_phyId) && m_device->GetPhy(m_phyId) \
54 ? m_device->GetPhy(m_phyId) \
55 : nullptr))
56
57namespace ns3
58{
59
61
62/****************************************************************
63 * The actual WifiPhy class
64 ****************************************************************/
65
67
68TypeId
70{
71 static TypeId tid =
72 TypeId("ns3::WifiPhy")
74 .SetGroupName("Wifi")
75 .AddAttribute("Channel",
76 "The channel attached to this PHY",
80 MakePointerChecker<Channel>())
81 .AddAttribute(
82 "ChannelSettings",
83 "Tuple {channel number, channel width (MHz), PHY band, primary20 index} "
84 "describing the settings of the operating channel. The primary20 index is "
85 "the index of the primary 20 MHz channel within the operating channel "
86 "(0 indicates the 20 MHz subchannel with the lowest center frequency) and "
87 "is only valid if the width of the operating channel is a multiple of 20 MHz. "
88 "If the standard for this object has not been set yet, the value of this "
89 "attribute is saved and will be used to set the operating channel when the "
90 "standard is configured. If the PHY band is left unspecified, the default "
91 "band for the configured standard is used. If the channel width and the "
92 "channel number are both 0, the default channel width for the configured "
93 "standard and band are used. If the channel number is 0, the default "
94 "channel number for the configured standard, band and channel width is used."
95 "Note that the channel width can be left unspecified (0) if the channel "
96 "number uniquely identify a frequency channel for the given standard and band.",
97 StringValue("{0, 0, BAND_UNSPECIFIED, 0}"),
101 UintegerValue>((void(WifiPhy::*)(const ChannelTuple&)) &
107 MakeUintegerChecker<uint8_t>(0, 233),
108 MakeUintegerChecker<uint16_t>(0, 160),
110 "BAND_2_4GHZ",
112 "BAND_5GHZ",
114 "BAND_6GHZ",
116 "BAND_UNSPECIFIED"),
117 MakeUintegerChecker<uint8_t>(0, 7)))
118 .AddAttribute("Frequency",
119 "The center frequency (MHz) of the current operating channel.",
121 UintegerValue(0),
123 MakeUintegerChecker<uint16_t>())
124 .AddAttribute("ChannelNumber",
125 "The channel number of the current operating channel.",
127 UintegerValue(0),
129 MakeUintegerChecker<uint8_t>(0, 233))
130 .AddAttribute(
131 "ChannelWidth",
132 "The width in MHz of the current operating channel (5, 10, 20, 22, 40, 80 or 160).",
134 UintegerValue(0),
136 MakeUintegerChecker<uint16_t>(5, 160))
137 .AddAttribute(
138 "Primary20MHzIndex",
139 "The index of the primary 20 MHz channel within the current operating channel "
140 "(0 indicates the 20 MHz subchannel with the lowest center frequency).",
141 UintegerValue(0),
143 MakeUintegerChecker<uint8_t>(0, 7))
144 .AddAttribute("FixedPhyBand",
145 "If set to true, changing PHY band is prohibited after initialization.",
146 BooleanValue(false),
149 .AddAttribute(
150 "RxSensitivity",
151 "The energy of a received signal should be higher than "
152 "this threshold (dBm) for the PHY to detect the signal. "
153 "This threshold refers to a width of 20 MHz and will be "
154 "scaled to match the width of the received signal.",
155 DoubleValue(-101.0),
157 MakeDoubleChecker<double>())
158 .AddAttribute(
159 "CcaEdThreshold",
160 "The energy of all received signals should be higher than "
161 "this threshold (dBm) in the primary channel to allow the PHY layer "
162 "to declare CCA BUSY state.",
163 DoubleValue(-62.0),
165 MakeDoubleChecker<double>())
166 .AddAttribute("CcaSensitivity",
167 "The energy of a received wifi signal should be higher than "
168 "this threshold (dBm) in the primary channel to allow the PHY layer "
169 "to declare CCA BUSY state.",
170 DoubleValue(-82.0),
173 MakeDoubleChecker<double>())
174 .AddAttribute("TxGain",
175 "Transmission gain (dB).",
176 DoubleValue(0.0),
178 MakeDoubleChecker<double>())
179 .AddAttribute("RxGain",
180 "Reception gain (dB).",
181 DoubleValue(0.0),
183 MakeDoubleChecker<double>())
184 .AddAttribute("TxPowerLevels",
185 "Number of transmission power levels available between "
186 "TxPowerStart and TxPowerEnd included.",
187 UintegerValue(1),
189 MakeUintegerChecker<uint8_t>())
190 .AddAttribute("TxPowerEnd",
191 "Maximum available transmission level (dBm).",
192 DoubleValue(16.0206),
194 MakeDoubleChecker<double>())
195 .AddAttribute("TxPowerStart",
196 "Minimum available transmission level (dBm).",
197 DoubleValue(16.0206),
199 MakeDoubleChecker<double>())
200 .AddAttribute(
201 "RxNoiseFigure",
202 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
203 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
204 "\"the difference in decibels (dB) between"
205 " the noise output of the actual receiver to the noise output of an "
206 " ideal receiver with the same overall gain and bandwidth when the receivers "
207 " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
208 DoubleValue(7),
210 MakeDoubleChecker<double>())
211 .AddAttribute("State",
212 "The state of the PHY layer.",
213 PointerValue(),
215 MakePointerChecker<WifiPhyStateHelper>())
216 .AddAttribute("ChannelSwitchDelay",
217 "Delay between two short frames transmitted on different frequencies.",
221 .AddAttribute(
222 "Antennas",
223 "The number of antennas on the device.",
224 UintegerValue(1),
226 MakeUintegerChecker<uint8_t>(1, 8))
227 .AddAttribute("MaxSupportedTxSpatialStreams",
228 "The maximum number of supported TX spatial streams."
229 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
230 UintegerValue(1),
233 MakeUintegerChecker<uint8_t>(1, 8))
234 .AddAttribute("MaxSupportedRxSpatialStreams",
235 "The maximum number of supported RX spatial streams."
236 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
237 UintegerValue(1),
240 MakeUintegerChecker<uint8_t>(1, 8))
241 .AddAttribute("ShortPlcpPreambleSupported",
242 "Whether or not short PHY preamble is supported."
243 "This parameter is only valuable for 802.11b STAs and APs."
244 "Note: 802.11g APs and STAs always support short PHY preamble.",
245 BooleanValue(false),
249 .AddAttribute("FrameCaptureModel",
250 "Ptr to an object that implements the frame capture model",
251 PointerValue(),
253 MakePointerChecker<FrameCaptureModel>())
254 .AddAttribute("PreambleDetectionModel",
255 "Ptr to an object that implements the preamble detection model",
256 PointerValue(),
258 MakePointerChecker<PreambleDetectionModel>())
259 .AddAttribute("PostReceptionErrorModel",
260 "An optional packet error model can be added to the receive "
261 "packet process after any propagation-based (SNR-based) error "
262 "models have been applied. Typically this is used to force "
263 "specific packet drops, for testing purposes.",
264 PointerValue(),
266 MakePointerChecker<ErrorModel>())
267 .AddAttribute("InterferenceHelper",
268 "Ptr to an object that implements the interference helper",
269 PointerValue(),
271 MakePointerChecker<InterferenceHelper>())
272 .AddAttribute("Sifs",
273 "The duration of the Short Interframe Space. "
274 "NOTE that the default value is overwritten by the value defined "
275 "by the standard; if you want to set this attribute, you have to "
276 "do it after that the PHY object is initialized.",
280 .AddAttribute("Slot",
281 "The duration of a slot. "
282 "NOTE that the default value is overwritten by the value defined "
283 "by the standard; if you want to set this attribute, you have to "
284 "do it after that the PHY object is initialized.",
288 .AddAttribute("Pifs",
289 "The duration of the PCF Interframe Space. "
290 "NOTE that the default value is overwritten by the value defined "
291 "by the standard; if you want to set this attribute, you have to "
292 "do it after that the PHY object is initialized.",
296 .AddAttribute("PowerDensityLimit",
297 "The mean equivalent isotropically radiated power density"
298 "limit (in dBm/MHz) set by regulators.",
299 DoubleValue(100.0), // set to a high value so as to have no effect
301 MakeDoubleChecker<double>())
302 .AddTraceSource("PhyTxBegin",
303 "Trace source indicating a packet "
304 "has begun transmitting over the channel medium",
306 "ns3::WifiPhy::PhyTxBeginTracedCallback")
307 .AddTraceSource("PhyTxPsduBegin",
308 "Trace source indicating a PSDU "
309 "has begun transmitting over the channel medium",
311 "ns3::WifiPhy::PsduTxBeginCallback")
312 .AddTraceSource("PhyTxEnd",
313 "Trace source indicating a packet "
314 "has been completely transmitted over the channel.",
316 "ns3::Packet::TracedCallback")
317 .AddTraceSource("PhyTxDrop",
318 "Trace source indicating a packet "
319 "has been dropped by the device during transmission",
321 "ns3::Packet::TracedCallback")
322 .AddTraceSource("PhyRxBegin",
323 "Trace source indicating a packet "
324 "has begun being received from the channel medium "
325 "by the device",
327 "ns3::WifiPhy::PhyRxBeginTracedCallback")
328 .AddTraceSource("PhyRxPayloadBegin",
329 "Trace source indicating the reception of the "
330 "payload of a PPDU has begun",
332 "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
333 .AddTraceSource("PhyRxEnd",
334 "Trace source indicating a packet "
335 "has been completely received from the channel medium "
336 "by the device",
338 "ns3::Packet::TracedCallback")
339 .AddTraceSource("PhyRxDrop",
340 "Trace source indicating a packet "
341 "has been dropped by the device during reception",
343 "ns3::Packet::TracedCallback")
344 .AddTraceSource("PhyRxPpduDrop",
345 "Trace source indicating a ppdu "
346 "has been dropped by the device during reception",
348 "ns3::WifiPhy::PhyRxPpduDropTracedCallback")
349 .AddTraceSource("MonitorSnifferRx",
350 "Trace source simulating a wifi device in monitor mode "
351 "sniffing all received frames",
353 "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
354 .AddTraceSource("MonitorSnifferTx",
355 "Trace source simulating the capability of a wifi device "
356 "in monitor mode to sniff all frames being transmitted",
358 "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
359 .AddTraceSource("SignalTransmission",
360 "Trace start of signal transmission",
362 "ns3::SpectrumWifiPhy::SignalTransmissionCallback");
363 return tid;
364}
365
367 : m_phyId(0),
368 m_txMpduReferenceNumber(0xffffffff),
369 m_rxMpduReferenceNumber(0xffffffff),
370 m_endPhyRxEvent(),
371 m_endTxEvent(),
372 m_currentEvent(nullptr),
373 m_previouslyRxPpduUid(UINT64_MAX),
374 m_standard(WIFI_STANDARD_UNSPECIFIED),
375 m_maxModClassSupported(WIFI_MOD_CLASS_UNKNOWN),
377 m_sifs(Seconds(0)),
378 m_slot(Seconds(0)),
379 m_pifs(Seconds(0)),
380 m_ackTxTime(Seconds(0)),
381 m_blockAckTxTime(Seconds(0)),
382 m_powerRestricted(false),
383 m_channelAccessRequested(false),
384 m_txSpatialStreams(1),
385 m_rxSpatialStreams(1),
386 m_wifiRadioEnergyModel(nullptr),
387 m_timeLastPreambleDetected(Seconds(0))
388{
389 NS_LOG_FUNCTION(this);
390 m_random = CreateObject<UniformRandomVariable>();
391 m_state = CreateObject<WifiPhyStateHelper>();
392}
393
395{
396 NS_LOG_FUNCTION(this);
397}
398
399void
401{
402 NS_LOG_FUNCTION(this);
403
404 // This method ensures that the local mobility model pointer holds
405 // a pointer to the Node's aggregated mobility model (if one exists)
406 // in the case that the user has not directly called SetMobility()
407 // on this WifiPhy during simulation setup. If the mobility model
408 // needs to be added or changed during simulation runtime, users must
409 // call SetMobility() on this object.
410
411 if (!m_mobility)
412 {
414 "Either install a MobilityModel on this object or ensure that this "
415 "object is part of a Node and NetDevice");
417 if (!m_mobility)
418 {
419 NS_LOG_WARN("Mobility not found, propagation models might not work properly");
420 }
421 }
422}
423
424void
426{
427 NS_LOG_FUNCTION(this);
428
429 m_device = nullptr;
430 m_mobility = nullptr;
431 m_frameCaptureModel = nullptr;
432 m_preambleDetectionModel = nullptr;
433 m_wifiRadioEnergyModel = nullptr;
435 if (m_interference)
436 {
437 m_interference->Dispose();
438 }
439 m_interference = nullptr;
440 m_random = nullptr;
441 m_state = nullptr;
442
443 Reset();
444
445 // this should be done after calling the Reset function
446 for (auto& phyEntity : m_phyEntities)
447 {
448 phyEntity.second = nullptr;
449 }
450 m_phyEntities.clear();
451}
452
453std::map<WifiModulationClass, Ptr<PhyEntity>>&
455{
456 static std::map<WifiModulationClass, Ptr<PhyEntity>> g_staticPhyEntities;
457 return g_staticPhyEntities;
458}
459
462{
463 return m_state;
464}
465
466void
468{
469 m_state->SetReceiveOkCallback(callback);
470}
471
472void
474{
475 m_state->SetReceiveErrorCallback(callback);
476}
477
478void
479WifiPhy::RegisterListener(const std::shared_ptr<WifiPhyListener>& listener)
480{
481 m_state->RegisterListener(listener);
482}
483
484void
485WifiPhy::UnregisterListener(const std::shared_ptr<WifiPhyListener>& listener)
486{
487 m_state->UnregisterListener(listener);
488}
489
490void
492{
494}
495
496void
498{
499 NS_LOG_FUNCTION(this << threshold);
500 m_rxSensitivityDbm = threshold;
501}
502
503double
505{
506 return m_rxSensitivityDbm;
507}
508
509void
511{
512 NS_LOG_FUNCTION(this << threshold);
513 m_ccaEdThresholdW = DbmToW(threshold);
514}
515
516double
518{
520}
521
522void
524{
525 NS_LOG_FUNCTION(this << threshold);
527}
528
529double
531{
533}
534
535void
536WifiPhy::SetRxNoiseFigure(double noiseFigureDb)
537{
538 NS_LOG_FUNCTION(this << noiseFigureDb);
539 if (m_interference)
540 {
541 m_interference->SetNoiseFigure(DbToRatio(noiseFigureDb));
542 }
543 m_noiseFigureDb = noiseFigureDb;
544}
545
546void
548{
549 NS_LOG_FUNCTION(this << start);
550 m_txPowerBaseDbm = start;
551}
552
553double
555{
556 return m_txPowerBaseDbm;
557}
558
559void
561{
562 NS_LOG_FUNCTION(this << end);
563 m_txPowerEndDbm = end;
564}
565
566double
568{
569 return m_txPowerEndDbm;
570}
571
572void
574{
575 NS_LOG_FUNCTION(this << +n);
576 m_nTxPower = n;
577}
578
579uint8_t
581{
582 return m_nTxPower;
583}
584
585void
587{
588 NS_LOG_FUNCTION(this << gain);
589 m_txGainDb = gain;
590}
591
592double
594{
595 return m_txGainDb;
596}
597
598void
600{
601 NS_LOG_FUNCTION(this << gain);
602 m_rxGainDb = gain;
603}
604
605double
607{
608 return m_rxGainDb;
609}
610
611void
613{
614 NS_LOG_FUNCTION(this << enable);
615 m_shortPreamble = enable;
616}
617
618bool
620{
621 return m_shortPreamble;
622}
623
624void
626{
627 m_device = device;
628}
629
632{
633 return m_device;
634}
635
636void
638{
639 m_mobility = mobility;
640}
641
644{
645 return m_mobility;
646}
647
648void
649WifiPhy::SetPhyId(uint8_t phyId)
650{
651 NS_LOG_FUNCTION(this << phyId);
652 m_phyId = phyId;
653}
654
655uint8_t
657{
658 return m_phyId;
659}
660
661void
663{
664 NS_LOG_FUNCTION(this << helper);
665 m_interference = helper;
666 m_interference->SetNoiseFigure(DbToRatio(m_noiseFigureDb));
667 m_interference->SetNumberOfReceiveAntennas(m_numberOfAntennas);
668}
669
670void
672{
673 NS_LOG_FUNCTION(this << model);
675 m_interference->SetErrorRateModel(model);
676}
677
678void
680{
681 NS_LOG_FUNCTION(this << em);
683}
684
685void
687{
688 m_frameCaptureModel = model;
689}
690
691void
693{
695}
696
697void
699{
700 m_wifiRadioEnergyModel = wifiRadioEnergyModel;
701}
702
703double
704WifiPhy::GetPowerDbm(uint8_t power) const
705{
708 double dbm;
709 if (m_nTxPower > 1)
710 {
712 }
713 else
714 {
716 "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
717 dbm = m_txPowerBaseDbm;
718 }
719 return dbm;
720}
721
722Time
724{
726}
727
728double
729WifiPhy::CalculateSnr(const WifiTxVector& txVector, double ber) const
730{
731 return m_interference->GetErrorRateModel()->CalculateSnr(txVector, ber);
732}
733
736{
737 const auto it = GetStaticPhyEntities().find(modulation);
739 "Unimplemented Wi-Fi modulation class " << modulation);
740 return it->second;
741}
742
745{
746 const auto it = m_phyEntities.find(modulation);
747 NS_ABORT_MSG_IF(it == m_phyEntities.cend(),
748 "Unsupported Wi-Fi modulation class " << modulation);
749 return it->second;
750}
751
754{
756}
757
760{
761 return GetPhyEntity(m_standard);
762}
763
766{
767 NS_ABORT_IF(!ppdu);
768 const auto modulation = ppdu->GetModulation();
769 if (modulation > m_phyEntities.rbegin()->first)
770 {
771 // unsupported modulation: start reception process with latest PHY entity
772 return GetLatestPhyEntity();
773 }
774 if (modulation < WIFI_MOD_CLASS_HT)
775 {
776 // for non-HT (duplicate), call the latest PHY entity since some extra processing can be
777 // done in PHYs implemented in HT and later (e.g. channel width selection for non-HT
778 // duplicates)
779 return GetLatestPhyEntity();
780 }
781 return GetPhyEntity(modulation);
782}
783
784void
786{
787 NS_ASSERT_MSG(!GetStaticPhyEntities().contains(modulation),
788 "The PHY entity has already been added. The setting should only be done once per "
789 "modulation class");
790 GetStaticPhyEntities()[modulation] = phyEntity;
791}
792
793void
795{
796 NS_LOG_FUNCTION(this << modulation);
797 NS_ABORT_MSG_IF(!GetStaticPhyEntities().contains(modulation),
798 "Cannot add an unimplemented PHY to supported list. Update the former first.");
799 NS_ASSERT_MSG(m_phyEntities.find(modulation) == m_phyEntities.end(),
800 "The PHY entity has already been added. The setting should only be done once per "
801 "modulation class");
802 phyEntity->SetOwner(this);
803 m_phyEntities[modulation] = phyEntity;
804}
805
806void
808{
809 m_sifs = sifs;
810}
811
812Time
814{
815 return m_sifs;
816}
817
818void
820{
821 m_slot = slot;
822}
823
824Time
826{
827 return m_slot;
828}
829
830void
832{
833 m_pifs = pifs;
834}
835
836Time
838{
839 return m_pifs;
840}
841
842Time
844{
845 return m_ackTxTime;
846}
847
848Time
850{
851 return m_blockAckTxTime;
852}
853
854void
856{
857 NS_LOG_FUNCTION(this);
858 AddPhyEntity(WIFI_MOD_CLASS_OFDM, Create<OfdmPhy>());
859
860 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
863 SetPifs(GetSifs() + GetSlot());
864 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
865 // of the PPDU causing the EIFS" of 802.11-2016
867}
868
869void
871{
872 NS_LOG_FUNCTION(this);
873 Ptr<DsssPhy> phyEntity = Create<DsssPhy>();
875 AddPhyEntity(WIFI_MOD_CLASS_DSSS, phyEntity); // when plain DSSS modes are used
876
877 // See Table 16-4 "HR/DSSS PHY characteristics" of 802.11-2016
880 SetPifs(GetSifs() + GetSlot());
881 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
882 // of the PPDU causing the EIFS" of 802.11-2016
884}
885
886void
888{
889 NS_LOG_FUNCTION(this);
890 // See Table 18-5 "ERP characteristics" of 802.11-2016
891 // Slot time defaults to the "long slot time" of 20 us in the standard
892 // according to mixed 802.11b/g deployments. Short slot time is enabled
893 // if the user sets the ShortSlotTimeSupported flag to true and when the BSS
894 // consists of only ERP STAs capable of supporting this option.
896 AddPhyEntity(WIFI_MOD_CLASS_ERP_OFDM, Create<ErpOfdmPhy>());
897}
898
899void
901{
902 NS_LOG_FUNCTION(this);
903 if (GetChannelWidth() == 10)
904 {
906
907 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
910 SetPifs(GetSifs() + GetSlot());
912 }
913 else if (GetChannelWidth() == 5)
914 {
916
917 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
920 SetPifs(GetSifs() + GetSlot());
922 }
923 else
924 {
925 NS_FATAL_ERROR("802.11p configured with a wrong channel width!");
926 }
927}
928
929void
931{
932 NS_LOG_FUNCTION(this);
934 {
936 }
937 else
938 {
940 }
942
943 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
944 // of the PPDU causing the EIFS" of 802.11-2016
946}
947
948void
950{
951 NS_LOG_FUNCTION(this);
953 AddPhyEntity(WIFI_MOD_CLASS_VHT, Create<VhtPhy>());
954}
955
956void
958{
959 NS_LOG_FUNCTION(this);
961 {
963 }
964 else
965 {
967 }
968 AddPhyEntity(WIFI_MOD_CLASS_HE, Create<HePhy>());
969}
970
971void
973{
974 NS_LOG_FUNCTION(this);
976 AddPhyEntity(WIFI_MOD_CLASS_EHT, Create<EhtPhy>());
977}
978
979void
981{
982 NS_LOG_FUNCTION(this << modClass);
983 m_maxModClassSupported = modClass;
984}
985
988{
990}
991
992void
994{
995 NS_LOG_FUNCTION(this << standard);
996
998 "Cannot change standard");
999
1000 m_standard = standard;
1001
1003 {
1005 }
1006
1008 {
1009 NS_LOG_DEBUG("Setting the operating channel first");
1011 // return because we are called back by SetOperatingChannel
1012 return;
1013 }
1014
1015 // this function is called when changing PHY band, hence we have to delete
1016 // the previous PHY entities
1017 m_phyEntities.clear();
1018
1019 switch (standard)
1020 {
1023 break;
1026 break;
1029 break;
1032 break;
1035 break;
1038 break;
1041 break;
1044 break;
1046 default:
1047 NS_ASSERT_MSG(false, "Unsupported standard");
1048 break;
1049 }
1050}
1051
1054{
1055 return m_band;
1056}
1057
1060{
1061 return m_standard;
1062}
1063
1066{
1067 return m_operatingChannel;
1068}
1069
1070uint16_t
1072{
1074}
1075
1076uint8_t
1078{
1080}
1081
1082uint16_t
1084{
1086}
1087
1088uint8_t
1090{
1092}
1093
1094void
1096{
1097 m_fixedPhyBand = enable;
1098}
1099
1100bool
1102{
1103 return m_fixedPhyBand;
1104}
1105
1106uint16_t
1107WifiPhy::GetTxBandwidth(WifiMode mode, uint16_t maxAllowedWidth) const
1108{
1109 auto modulation = mode.GetModulationClass();
1110 if (modulation == WIFI_MOD_CLASS_DSSS || modulation == WIFI_MOD_CLASS_HR_DSSS)
1111 {
1112 return 22;
1113 }
1114
1115 return std::min({GetChannelWidth(), GetMaximumChannelWidth(modulation), maxAllowedWidth});
1116}
1117
1118void
1120{
1121 NS_LOG_FUNCTION(this << channel);
1122 WifiPhy::ChannelTuple tuple(channel.GetNumber(),
1123 channel.GetWidth(),
1124 channel.GetPhyBand(),
1125 channel.GetPrimaryChannelIndex(20));
1126 SetOperatingChannel(tuple);
1127}
1128
1129void
1131{
1132 // the generic operator<< for tuples does not give a pretty result
1133 NS_LOG_FUNCTION(this << +std::get<0>(channelTuple) << std::get<1>(channelTuple)
1134 << static_cast<WifiPhyBand>(std::get<2>(channelTuple))
1135 << +std::get<3>(channelTuple));
1136
1137 m_channelSettings = channelTuple;
1138
1140 {
1141 NS_LOG_DEBUG("Channel information will be applied when a standard is configured");
1142 return;
1143 }
1144
1145 if (IsInitialized())
1146 {
1147 const auto delay = GetDelayUntilChannelSwitch();
1148 if (!delay.has_value())
1149 {
1150 // switching channel is not possible now
1151 return;
1152 }
1153 if (delay.value().IsStrictlyPositive())
1154 {
1155 // switching channel has been postponed
1156 void (WifiPhy::*fp)(const ChannelTuple&) = &WifiPhy::SetOperatingChannel;
1157 Simulator::Schedule(delay.value(), fp, this, channelTuple);
1158 return;
1159 }
1160 }
1161
1162 // channel can be switched now.
1164}
1165
1166std::optional<Time>
1168{
1169 if (!IsInitialized())
1170 {
1171 // this is not channel switch, this is initialization
1172 NS_LOG_DEBUG("Before initialization, nothing to do");
1173 return Seconds(0);
1174 }
1175
1177 std::optional<Time> delay;
1178 switch (m_state->GetState())
1179 {
1180 case WifiPhyState::RX:
1181 NS_LOG_DEBUG("drop packet because of channel switching while reception");
1183 delay = Seconds(0);
1184 break;
1185 case WifiPhyState::TX:
1186 NS_LOG_DEBUG("channel switching postponed until end of current transmission");
1187 delay = GetDelayUntilIdle();
1188 break;
1190 case WifiPhyState::IDLE:
1191 Reset();
1192 delay = Seconds(0);
1193 break;
1195 NS_LOG_DEBUG("channel switching ignored in sleep mode");
1196 break;
1197 default:
1198 NS_ASSERT(false);
1199 break;
1200 }
1201
1202 return delay;
1203}
1204
1205void
1207{
1208 NS_LOG_FUNCTION(this);
1209
1210 m_powerRestricted = false;
1212
1213 // Update unspecified parameters with default values
1214 {
1215 auto& [number, width, band, primary20] = m_channelSettings;
1216 if (band == WIFI_PHY_BAND_UNSPECIFIED)
1217 {
1219 }
1220 if (width == 0 && number == 0)
1221 {
1222 width = GetDefaultChannelWidth(m_standard, static_cast<WifiPhyBand>(band));
1223 }
1224 if (number == 0)
1225 {
1226 number =
1228 m_standard,
1229 static_cast<WifiPhyBand>(band));
1230 }
1231 }
1232
1233 // We need to call SetStandard if this is the first time we set a channel or we
1234 // are changing PHY band. Checking if the new PHY band is different than the
1235 // previous one covers both cases because initially the PHY band is unspecified
1236 bool changingPhyBand = (static_cast<WifiPhyBand>(std::get<2>(m_channelSettings)) != m_band);
1237
1238 NS_ABORT_MSG_IF(IsInitialized() && m_fixedPhyBand && changingPhyBand,
1239 "Trying to change PHY band while prohibited.");
1240
1241 m_band = static_cast<WifiPhyBand>(std::get<2>(m_channelSettings));
1242
1243 // check that the channel width is supported
1244 uint16_t chWidth = std::get<1>(m_channelSettings);
1245
1246 if (m_device)
1247 {
1248 if (auto htConfig = m_device->GetHtConfiguration();
1249 htConfig && !htConfig->Get40MHzOperationSupported() && chWidth > 20)
1250 {
1251 NS_ABORT_MSG("Attempting to set a " << chWidth
1252 << " MHz channel on"
1253 "a station only supporting 20 MHz operation");
1254 }
1255
1256 if (auto vhtConfig = m_device->GetVhtConfiguration();
1257 vhtConfig && !vhtConfig->Get160MHzOperationSupported() && chWidth > 80)
1258 {
1259 NS_ABORT_MSG("Attempting to set a " << chWidth
1260 << " MHz channel on"
1261 "a station supporting up to 80 MHz operation");
1262 }
1263 }
1264
1265 NS_LOG_DEBUG("switching channel");
1266 m_operatingChannel.Set(std::get<0>(m_channelSettings), 0, chWidth, m_standard, m_band);
1268
1269 if (changingPhyBand)
1270 {
1272 }
1273
1274 if (IsInitialized())
1275 {
1276 // notify channel switching
1277 m_state->SwitchToChannelSwitching(GetChannelSwitchDelay());
1278 /*
1279 * Needed here to be able to correctly sensed the medium for the first
1280 * time after the switching. The actual switching is not performed until
1281 * after m_channelSwitchDelay. Packets received during the switching
1282 * state are added to the event list and are employed later to figure
1283 * out the state of the medium after the switching.
1284 */
1285 }
1286}
1287
1288void
1290{
1291 NS_LOG_FUNCTION(this << +antennas);
1292 NS_ASSERT_MSG(antennas > 0 && antennas <= 8, "unsupported number of antennas");
1293 m_numberOfAntennas = antennas;
1294 if (m_interference)
1295 {
1296 m_interference->SetNumberOfReceiveAntennas(antennas);
1297 }
1298}
1299
1300uint8_t
1302{
1303 return m_numberOfAntennas;
1304}
1305
1306void
1308{
1309 NS_ASSERT(streams <= GetNumberOfAntennas());
1310 bool changed = (m_txSpatialStreams != streams);
1311 m_txSpatialStreams = streams;
1312 if (changed)
1313 {
1314 auto phyEntity = m_phyEntities.find(WIFI_MOD_CLASS_HT);
1315 if (phyEntity != m_phyEntities.end())
1316 {
1317 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity->second);
1318 if (htPhy)
1319 {
1320 htPhy->SetMaxSupportedNss(
1321 m_txSpatialStreams); // this is essential to have the right MCSs configured
1322 }
1323
1325 {
1327 }
1328 }
1329 }
1330}
1331
1332uint8_t
1334{
1335 return m_txSpatialStreams;
1336}
1337
1338void
1340{
1341 NS_ASSERT(streams <= GetNumberOfAntennas());
1342 bool changed = (m_rxSpatialStreams != streams);
1343 m_rxSpatialStreams = streams;
1344 if (changed && !m_capabilitiesChangedCallback.IsNull())
1345 {
1347 }
1348}
1349
1350uint8_t
1352{
1353 return m_rxSpatialStreams;
1354}
1355
1356std::list<uint8_t>
1358{
1359 std::list<uint8_t> list;
1360 for (const auto& phyEntity : m_phyEntities)
1361 {
1362 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity.second);
1363 if (htPhy)
1364 {
1365 list.emplace_back(htPhy->GetBssMembershipSelector());
1366 }
1367 }
1368 return list;
1369}
1370
1371void
1373{
1374 NS_LOG_FUNCTION(this);
1375 m_powerRestricted = false;
1377 switch (m_state->GetState())
1378 {
1379 case WifiPhyState::TX:
1380 NS_LOG_DEBUG("setting sleep mode postponed until end of current transmission");
1382 break;
1383 case WifiPhyState::RX:
1384 NS_LOG_DEBUG("setting sleep mode postponed until end of current reception");
1386 break;
1388 NS_LOG_DEBUG("setting sleep mode postponed until end of channel switching");
1390 break;
1392 case WifiPhyState::IDLE:
1393 NS_LOG_DEBUG("setting sleep mode");
1394 // The PHY object may be in CCA_BUSY state because it is receiving a preamble. Cancel
1395 // preamble events before switching to sleep state
1396 Reset();
1397 // It may happen that we request to switch to sleep at the same time the reception of
1398 // a PPDU ends. In such a case, WifiPhyStateHelper::GetState() does not return RX
1399 // (m_endRx equals now), we get here and set the state to SLEEP. However,
1400 // WifiPhyStateHelper::DoSwitchFromRx() may be called after this function (at the same
1401 // simulation time), thus hitting the assert that checks that the state is IDLE or
1402 // CCA_BUSY.
1404 break;
1406 NS_LOG_DEBUG("already in sleep mode");
1407 break;
1408 default:
1409 NS_ASSERT(false);
1410 break;
1411 }
1412}
1413
1414void
1416{
1417 NS_LOG_FUNCTION(this);
1418 m_powerRestricted = false;
1420 Reset();
1421 m_state->SwitchToOff();
1422}
1423
1424void
1426{
1427 NS_LOG_FUNCTION(this);
1428 switch (m_state->GetState())
1429 {
1430 case WifiPhyState::TX:
1431 case WifiPhyState::RX:
1432 case WifiPhyState::IDLE:
1435 NS_LOG_DEBUG("not in sleep mode, there is nothing to resume");
1436 break;
1437 }
1438 case WifiPhyState::SLEEP: {
1439 NS_LOG_DEBUG("resuming from sleep mode");
1440 m_state->SwitchFromSleep();
1442 break;
1443 }
1444 default: {
1445 NS_ASSERT(false);
1446 break;
1447 }
1448 }
1449}
1450
1451void
1453{
1454 NS_LOG_FUNCTION(this);
1455 switch (m_state->GetState())
1456 {
1457 case WifiPhyState::TX:
1458 case WifiPhyState::RX:
1459 case WifiPhyState::IDLE:
1462 case WifiPhyState::SLEEP: {
1463 NS_LOG_DEBUG("not in off mode, there is nothing to resume");
1464 break;
1465 }
1466 case WifiPhyState::OFF: {
1467 NS_LOG_DEBUG("resuming from off mode");
1468 m_state->SwitchFromOff();
1470 break;
1471 }
1472 default: {
1473 NS_ASSERT(false);
1474 break;
1475 }
1476 }
1477}
1478
1479Time
1481{
1482 return MicroSeconds(4);
1483}
1484
1485Time
1487{
1488 return MicroSeconds(4);
1489}
1490
1491Time
1493 const WifiTxVector& txVector,
1494 WifiPhyBand band,
1495 MpduType mpdutype,
1496 uint16_t staId)
1497{
1498 uint32_t totalAmpduSize;
1499 double totalAmpduNumSymbols;
1500 return GetPayloadDuration(size,
1501 txVector,
1502 band,
1503 mpdutype,
1504 false,
1505 totalAmpduSize,
1506 totalAmpduNumSymbols,
1507 staId);
1508}
1509
1510Time
1512 const WifiTxVector& txVector,
1513 WifiPhyBand band,
1514 MpduType mpdutype,
1515 bool incFlag,
1516 uint32_t& totalAmpduSize,
1517 double& totalAmpduNumSymbols,
1518 uint16_t staId)
1519{
1520 return GetStaticPhyEntity(txVector.GetModulationClass())
1521 ->GetPayloadDuration(size,
1522 txVector,
1523 band,
1524 mpdutype,
1525 incFlag,
1526 totalAmpduSize,
1527 totalAmpduNumSymbols,
1528 staId);
1529}
1530
1531Time
1533{
1534 return GetStaticPhyEntity(txVector.GetModulationClass())
1535 ->CalculatePhyPreambleAndHeaderDuration(txVector);
1536}
1537
1538Time
1540 const WifiTxVector& txVector,
1541 WifiPhyBand band,
1542 uint16_t staId)
1543{
1544 Time duration = CalculatePhyPreambleAndHeaderDuration(txVector) +
1545 GetPayloadDuration(size, txVector, band, NORMAL_MPDU, staId);
1546 NS_ASSERT(duration.IsStrictlyPositive());
1547 return duration;
1548}
1549
1550Time
1552 const WifiTxVector& txVector,
1553 WifiPhyBand band)
1554{
1555 return CalculateTxDuration(GetWifiConstPsduMap(psdu, txVector), txVector, band);
1556}
1557
1558Time
1560 const WifiTxVector& txVector,
1561 WifiPhyBand band)
1562{
1563 return GetStaticPhyEntity(txVector.GetModulationClass())
1564 ->CalculateTxDuration(psduMap, txVector, band);
1565}
1566
1569{
1570 return GetStaticPhyEntity(modulation)->GetMaxPsduSize();
1571}
1572
1573void
1575{
1576 if (!m_phyTxBeginTrace.IsEmpty())
1577 {
1578 for (const auto& psdu : psdus)
1579 {
1580 for (auto& mpdu : *PeekPointer(psdu.second))
1581 {
1582 m_phyTxBeginTrace(mpdu->GetProtocolDataUnit(), txPowerW);
1583 }
1584 }
1585 }
1586}
1587
1588void
1590{
1591 if (!m_phyTxEndTrace.IsEmpty())
1592 {
1593 for (const auto& psdu : psdus)
1594 {
1595 for (auto& mpdu : *PeekPointer(psdu.second))
1596 {
1597 m_phyTxEndTrace(mpdu->GetProtocolDataUnit());
1598 }
1599 }
1600 }
1601}
1602
1603void
1605{
1607 {
1608 for (auto& mpdu : *PeekPointer(psdu))
1609 {
1610 m_phyTxDropTrace(mpdu->GetProtocolDataUnit());
1611 }
1612 }
1613}
1614
1615void
1617{
1618 if (psdu && !m_phyRxBeginTrace.IsEmpty())
1619 {
1620 for (auto& mpdu : *PeekPointer(psdu))
1621 {
1622 m_phyRxBeginTrace(mpdu->GetProtocolDataUnit(), rxPowersW);
1623 }
1624 }
1625}
1626
1627void
1629{
1630 if (psdu && !m_phyRxEndTrace.IsEmpty())
1631 {
1632 for (auto& mpdu : *PeekPointer(psdu))
1633 {
1634 m_phyRxEndTrace(mpdu->GetProtocolDataUnit());
1635 }
1636 }
1637}
1638
1639void
1641{
1642 if (psdu && !m_phyRxDropTrace.IsEmpty())
1643 {
1644 for (auto& mpdu : *PeekPointer(psdu))
1645 {
1646 m_phyRxDropTrace(mpdu->GetProtocolDataUnit(), reason);
1647 }
1648 }
1649}
1650
1651void
1653{
1654 NotifyRxDrop(GetAddressedPsduInPpdu(ppdu), reason);
1655 m_phyRxPpduDropTrace(ppdu, reason);
1656}
1657
1658void
1660 uint16_t channelFreqMhz,
1661 WifiTxVector txVector,
1662 SignalNoiseDbm signalNoise,
1663 std::vector<bool> statusPerMpdu,
1664 uint16_t staId)
1665{
1666 MpduInfo aMpdu;
1667 if (psdu->IsAggregate())
1668 {
1669 // Expand A-MPDU
1670 NS_ASSERT_MSG(txVector.IsAggregation(),
1671 "TxVector with aggregate flag expected here according to PSDU");
1673 size_t nMpdus = psdu->GetNMpdus();
1674 NS_ASSERT_MSG(statusPerMpdu.size() == nMpdus, "Should have one reception status per MPDU");
1675 if (!m_phyMonitorSniffRxTrace.IsEmpty())
1676 {
1677 aMpdu.type = (psdu->IsSingle()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1678 for (size_t i = 0; i < nMpdus;)
1679 {
1680 if (statusPerMpdu.at(i)) // packet received without error, hand over to sniffer
1681 {
1682 m_phyMonitorSniffRxTrace(psdu->GetAmpduSubframe(i),
1683 channelFreqMhz,
1684 txVector,
1685 aMpdu,
1686 signalNoise,
1687 staId);
1688 }
1689 ++i;
1690 aMpdu.type =
1691 (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1692 }
1693 }
1694 }
1695 else
1696 {
1697 NS_ASSERT_MSG(statusPerMpdu.size() == 1,
1698 "Should have one reception status for normal MPDU");
1699 if (!m_phyMonitorSniffRxTrace.IsEmpty())
1700 {
1701 aMpdu.type = NORMAL_MPDU;
1702 m_phyMonitorSniffRxTrace(psdu->GetPacket(),
1703 channelFreqMhz,
1704 txVector,
1705 aMpdu,
1706 signalNoise,
1707 staId);
1708 }
1709 }
1710}
1711
1712void
1714 uint16_t channelFreqMhz,
1715 WifiTxVector txVector,
1716 uint16_t staId)
1717{
1718 MpduInfo aMpdu;
1719 if (psdu->IsAggregate())
1720 {
1721 // Expand A-MPDU
1722 NS_ASSERT_MSG(txVector.IsAggregation(),
1723 "TxVector with aggregate flag expected here according to PSDU");
1725 if (!m_phyMonitorSniffTxTrace.IsEmpty())
1726 {
1727 size_t nMpdus = psdu->GetNMpdus();
1728 aMpdu.type = (psdu->IsSingle()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1729 for (size_t i = 0; i < nMpdus;)
1730 {
1731 m_phyMonitorSniffTxTrace(psdu->GetAmpduSubframe(i),
1732 channelFreqMhz,
1733 txVector,
1734 aMpdu,
1735 staId);
1736 ++i;
1737 aMpdu.type =
1738 (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1739 }
1740 }
1741 }
1742 else
1743 {
1744 if (!m_phyMonitorSniffTxTrace.IsEmpty())
1745 {
1746 aMpdu.type = NORMAL_MPDU;
1747 m_phyMonitorSniffTxTrace(psdu->GetPacket(), channelFreqMhz, txVector, aMpdu, staId);
1748 }
1749 }
1750}
1751
1754{
1755 return GetStaticPhyEntity(txVector.GetModulationClass())->GetWifiConstPsduMap(psdu, txVector);
1756}
1757
1758void
1760{
1761 NS_LOG_FUNCTION(this << *psdu << txVector);
1762 Send(GetWifiConstPsduMap(psdu, txVector), txVector);
1763}
1764
1765void
1767{
1768 NS_LOG_FUNCTION(this << psdus << txVector);
1769 /* Transmission can happen if:
1770 * - we are syncing on a packet. It is the responsibility of the
1771 * MAC layer to avoid doing this but the PHY does nothing to
1772 * prevent it.
1773 * - we are idle
1774 */
1775 NS_ASSERT(!m_state->IsStateTx() && !m_state->IsStateSwitching());
1777
1778 if (!txVector.IsValid(m_band))
1779 {
1780 NS_FATAL_ERROR("TX-VECTOR is invalid!");
1781 }
1782
1783 uint8_t nss = 0;
1784 if (txVector.IsMu())
1785 {
1786 // We do not support mixed OFDMA and MU-MIMO
1787 if (txVector.IsDlMuMimo())
1788 {
1789 nss = txVector.GetNssTotal();
1790 }
1791 else
1792 {
1793 nss = txVector.GetNssMax();
1794 }
1795 }
1796 else
1797 {
1798 nss = txVector.GetNss();
1799 }
1800
1802 {
1803 NS_FATAL_ERROR("Unsupported number of spatial streams!");
1804 }
1805
1806 if (m_state->IsStateSleep())
1807 {
1808 NS_LOG_DEBUG("Dropping packet because in sleep mode");
1809 for (const auto& psdu : psdus)
1810 {
1811 NotifyTxDrop(psdu.second);
1812 }
1813 return;
1814 }
1815
1816 Time txDuration = CalculateTxDuration(psdus, txVector, GetPhyBand());
1817
1818 bool noEndPreambleDetectionEvent = true;
1819 for (const auto& [mc, entity] : m_phyEntities)
1820 {
1821 noEndPreambleDetectionEvent =
1822 noEndPreambleDetectionEvent && entity->NoEndPreambleDetectionEvents();
1823 }
1824 if (!noEndPreambleDetectionEvent && !m_currentEvent)
1825 {
1826 // PHY is in the initial few microseconds during which the
1827 // start of RX has occurred but the preamble detection period
1828 // has not elapsed
1830 }
1831 else if (!noEndPreambleDetectionEvent || m_currentEvent)
1832 {
1834 }
1835
1837 {
1838 NS_LOG_DEBUG("Transmitting with power restriction for " << txDuration.As(Time::NS));
1839 }
1840 else
1841 {
1842 NS_LOG_DEBUG("Transmitting without power restriction for " << txDuration.As(Time::NS));
1843 }
1844
1845 if (m_state->GetState() == WifiPhyState::OFF)
1846 {
1847 NS_LOG_DEBUG("Transmission canceled because device is OFF");
1848 return;
1849 }
1850
1851 Ptr<WifiPpdu> ppdu =
1852 GetPhyEntity(txVector.GetModulationClass())->BuildPpdu(psdus, txVector, txDuration);
1853 m_previouslyRxPpduUid = UINT64_MAX; // reset (after creation of PPDU) to use it only once
1854
1855 double txPowerW = DbmToW(GetTxPowerForTransmission(ppdu) + GetTxGain());
1856 NotifyTxBegin(psdus, txPowerW);
1857 if (!m_phyTxPsduBeginTrace.IsEmpty())
1858 {
1859 m_phyTxPsduBeginTrace(psdus, txVector, txPowerW);
1860 }
1861 for (const auto& psdu : psdus)
1862 {
1863 NotifyMonitorSniffTx(psdu.second, GetFrequency(), txVector, psdu.first);
1864 }
1865 m_state->SwitchToTx(txDuration, psdus, GetPowerDbm(txVector.GetTxPowerLevel()), txVector);
1866
1868 m_wifiRadioEnergyModel->GetMaximumTimeInState(WifiPhyState::TX) < txDuration)
1869 {
1870 ppdu->SetTruncatedTx();
1871 }
1872
1873 m_endTxEvent =
1874 Simulator::Schedule(txDuration, &WifiPhy::TxDone, this, psdus); // TODO: fix for MU
1875
1876 StartTx(ppdu);
1877 ppdu->ResetTxVector();
1878
1880 m_powerRestricted = false;
1881}
1882
1883void
1885{
1886 NS_LOG_FUNCTION(this << psdus);
1887 NotifyTxEnd(psdus);
1888 Reset();
1889 // we might have received signals during TX
1891}
1892
1893uint64_t
1895{
1896 return m_previouslyRxPpduUid;
1897}
1898
1899void
1901{
1904}
1905
1906void
1908{
1909 NS_LOG_FUNCTION(this);
1911 bool noEndPreambleDetectionEvent = true;
1912 for (const auto& [mc, entity] : m_phyEntities)
1913 {
1914 noEndPreambleDetectionEvent =
1915 noEndPreambleDetectionEvent && entity->NoEndPreambleDetectionEvents();
1916 }
1917 if (m_interference && (m_currentEvent || !noEndPreambleDetectionEvent))
1918 {
1920 }
1921 m_currentEvent = nullptr;
1922 for (auto& phyEntity : m_phyEntities)
1923 {
1924 phyEntity.second->CancelAllEvents();
1925 }
1928}
1929
1930void
1932 RxPowerWattPerChannelBand& rxPowersW,
1933 Time rxDuration)
1934{
1935 NS_LOG_FUNCTION(this << ppdu << rxDuration);
1936 WifiModulationClass modulation = ppdu->GetModulation();
1938 if (auto it = m_phyEntities.find(modulation);
1939 it != m_phyEntities.end() && modulation <= m_maxModClassSupported)
1940 {
1941 it->second->StartReceivePreamble(ppdu, rxPowersW, rxDuration);
1942 }
1943 else
1944 {
1945 // TODO find a fallback PHY for receiving the PPDU (e.g. 11a for 11ax due to preamble
1946 // structure)
1947 NS_LOG_DEBUG("Unsupported modulation received (" << modulation << "), consider as noise");
1948 m_interference->Add(ppdu, rxDuration, rxPowersW, GetCurrentFrequencyRange());
1950 }
1951}
1952
1953bool
1955{
1956 return m_endPhyRxEvent.IsPending();
1957}
1958
1959void
1961{
1962 NS_LOG_FUNCTION(this);
1964 {
1965 m_powerRestricted = false;
1966 }
1967}
1968
1969void
1971{
1972 NS_LOG_FUNCTION(this);
1974}
1975
1976bool
1978{
1979 for (const auto& phyEntity : m_phyEntities)
1980 {
1981 if (phyEntity.second->IsModeSupported(mode))
1982 {
1983 return true;
1984 }
1985 }
1986 return false;
1987}
1988
1991{
1992 // Start from oldest standards and move up (guaranteed by fact that WifModulationClass is
1993 // ordered)
1994 for (const auto& phyEntity : m_phyEntities)
1995 {
1996 for (const auto& mode : *(phyEntity.second))
1997 {
1998 return mode;
1999 }
2000 }
2001 NS_ASSERT_MSG(false, "Should have found at least one default mode");
2002 return WifiMode();
2003}
2004
2005bool
2006WifiPhy::IsMcsSupported(WifiModulationClass modulation, uint8_t mcs) const
2007{
2008 const auto phyEntity = m_phyEntities.find(modulation);
2009 if (phyEntity == m_phyEntities.end())
2010 {
2011 return false;
2012 }
2013 return phyEntity->second->IsMcsSupported(mcs);
2014}
2015
2016std::list<WifiMode>
2018{
2019 std::list<WifiMode> list;
2020 for (const auto& phyEntity : m_phyEntities)
2021 {
2022 if (!phyEntity.second->HandlesMcsModes()) // to exclude MCSs from search
2023 {
2024 for (const auto& mode : *(phyEntity.second))
2025 {
2026 list.emplace_back(mode);
2027 }
2028 }
2029 }
2030 return list;
2031}
2032
2033std::list<WifiMode>
2035{
2036 std::list<WifiMode> list;
2037 const auto phyEntity = m_phyEntities.find(modulation);
2038 if (phyEntity != m_phyEntities.end())
2039 {
2040 if (!phyEntity->second->HandlesMcsModes()) // to exclude MCSs from search
2041 {
2042 for (const auto& mode : *(phyEntity->second))
2043 {
2044 list.emplace_back(mode);
2045 }
2046 }
2047 }
2048 return list;
2049}
2050
2051uint16_t
2053{
2054 uint16_t numMcs = 0;
2055 for (const auto& phyEntity : m_phyEntities)
2056 {
2057 if (phyEntity.second->HandlesMcsModes()) // to exclude non-MCS modes from search
2058 {
2059 numMcs += phyEntity.second->GetNumModes();
2060 }
2061 }
2062 return numMcs;
2063}
2064
2065std::list<WifiMode>
2067{
2068 std::list<WifiMode> list;
2069 for (const auto& phyEntity : m_phyEntities)
2070 {
2071 if (phyEntity.second->HandlesMcsModes()) // to exclude non-MCS modes from search
2072 {
2073 for (const auto& mode : *(phyEntity.second))
2074 {
2075 list.emplace_back(mode);
2076 }
2077 }
2078 }
2079 return list;
2080}
2081
2082std::list<WifiMode>
2084{
2085 std::list<WifiMode> list;
2086 auto phyEntity = m_phyEntities.find(modulation);
2087 if (phyEntity != m_phyEntities.end())
2088 {
2089 if (phyEntity->second->HandlesMcsModes()) // to exclude non-MCS modes from search
2090 {
2091 for (const auto& mode : *(phyEntity->second))
2092 {
2093 list.emplace_back(mode);
2094 }
2095 }
2096 }
2097 return list;
2098}
2099
2101WifiPhy::GetMcs(WifiModulationClass modulation, uint8_t mcs) const
2102{
2103 NS_ASSERT_MSG(IsMcsSupported(modulation, mcs), "Unsupported MCS");
2104 return m_phyEntities.at(modulation)->GetMcs(mcs);
2105}
2106
2107bool
2109{
2110 return m_state->IsStateCcaBusy();
2111}
2112
2113bool
2115{
2116 return m_state->IsStateIdle();
2117}
2118
2119bool
2121{
2122 return m_state->IsStateRx();
2123}
2124
2125bool
2127{
2128 return m_state->IsStateTx();
2129}
2130
2131bool
2133{
2134 return m_state->IsStateSwitching();
2135}
2136
2137bool
2139{
2140 return m_state->IsStateSleep();
2141}
2142
2143bool
2145{
2146 return m_state->IsStateOff();
2147}
2148
2149Time
2151{
2152 return m_state->GetDelayUntilIdle();
2153}
2154
2155Time
2157{
2158 return m_state->GetLastRxStartTime();
2159}
2160
2161Time
2163{
2164 return m_state->GetLastRxEndTime();
2165}
2166
2167void
2169{
2170 NS_LOG_FUNCTION(this);
2171 GetLatestPhyEntity()->SwitchMaybeToCcaBusy(ppdu);
2172}
2173
2174void
2176{
2177 NS_LOG_FUNCTION(this << duration);
2178 GetLatestPhyEntity()->NotifyCcaBusy(ppdu, duration, WIFI_CHANLIST_PRIMARY);
2179}
2180
2181void
2183{
2184 NS_LOG_FUNCTION(this << reason);
2185 if (reason != OBSS_PD_CCA_RESET ||
2186 m_currentEvent) // Otherwise abort has already been called previously
2187 {
2188 if (reason == SIGNAL_DETECTION_ABORTED_BY_TX)
2189 {
2190 for (auto signalDetectEvent : m_currentPreambleEvents)
2191 {
2192 NotifyRxPpduDrop(signalDetectEvent.second->GetPpdu(),
2194 }
2195 }
2196 for (auto& phyEntity : m_phyEntities)
2197 {
2198 phyEntity.second->CancelAllEvents();
2199 }
2202 if (!m_currentEvent)
2203 {
2204 return;
2205 }
2206 NotifyRxPpduDrop(m_currentEvent->GetPpdu(), reason);
2207 if (reason == OBSS_PD_CCA_RESET)
2208 {
2209 m_state->SwitchFromRxAbort(GetChannelWidth());
2210 }
2211 if (reason == RECEPTION_ABORTED_BY_TX)
2212 {
2213 Reset();
2214 }
2215 else
2216 {
2217 for (auto it = m_currentPreambleEvents.begin(); it != m_currentPreambleEvents.end();
2218 ++it)
2219 {
2220 if (it->second == m_currentEvent)
2221 {
2222 it = m_currentPreambleEvents.erase(it);
2223 break;
2224 }
2225 }
2226 m_currentEvent = nullptr;
2227 }
2228 }
2229}
2230
2231void
2232WifiPhy::ResetCca(bool powerRestricted, double txPowerMaxSiso, double txPowerMaxMimo)
2233{
2234 NS_LOG_FUNCTION(this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2235 // This method might be called multiple times when receiving TB PPDUs with a BSS color
2236 // different than the one of the receiver. The first time this method is called, the call
2237 // to AbortCurrentReception sets m_currentEvent to 0. Therefore, we need to check whether
2238 // m_currentEvent is not 0 before executing the instructions below.
2239 if (m_currentEvent)
2240 {
2241 m_powerRestricted = powerRestricted;
2242 m_txPowerMaxSiso = txPowerMaxSiso;
2243 m_txPowerMaxMimo = txPowerMaxMimo;
2244 NS_ASSERT((m_currentEvent->GetEndTime() - Simulator::Now()).IsPositive());
2247 this);
2249 this,
2250 OBSS_PD_CCA_RESET); // finish processing field first
2251 }
2252}
2253
2254double
2256{
2257 NS_LOG_FUNCTION(this << m_powerRestricted << ppdu);
2258 const auto& txVector = ppdu->GetTxVector();
2259 // Get transmit power before antenna gain
2260 double txPowerDbm;
2261 if (!m_powerRestricted)
2262 {
2263 txPowerDbm = GetPowerDbm(txVector.GetTxPowerLevel());
2264 }
2265 else
2266 {
2267 if (txVector.GetNssMax() > 1 || txVector.GetNssTotal() > 1)
2268 {
2269 txPowerDbm = std::min(m_txPowerMaxMimo, GetPowerDbm(txVector.GetTxPowerLevel()));
2270 }
2271 else
2272 {
2273 txPowerDbm = std::min(m_txPowerMaxSiso, GetPowerDbm(txVector.GetTxPowerLevel()));
2274 }
2275 }
2276
2277 // Apply power density constraint on EIRP
2278 uint16_t channelWidth = ppdu->GetTxChannelWidth();
2279 double txPowerDbmPerMhz =
2280 (txPowerDbm + GetTxGain()) - RatioToDb(channelWidth); // account for antenna gain since EIRP
2281 NS_LOG_INFO("txPowerDbm=" << txPowerDbm << " with txPowerDbmPerMhz=" << txPowerDbmPerMhz
2282 << " over " << channelWidth << " MHz");
2283 txPowerDbm = std::min(txPowerDbmPerMhz, m_powerDensityLimit) + RatioToDb(channelWidth);
2284 txPowerDbm -= GetTxGain(); // remove antenna gain since will be added right afterwards
2285 NS_LOG_INFO("txPowerDbm=" << txPowerDbm
2286 << " after applying m_powerDensityLimit=" << m_powerDensityLimit);
2287 return txPowerDbm;
2288}
2289
2292{
2293 // TODO: wrapper. See if still needed
2294 return GetPhyEntityForPpdu(ppdu)->GetAddressedPsduInPpdu(ppdu);
2295}
2296
2297int64_t
2299{
2300 NS_LOG_FUNCTION(this << stream);
2301 int64_t currentStream = stream;
2302 m_random->SetStream(currentStream++);
2303 currentStream += m_interference->GetErrorRateModel()->AssignStreams(currentStream);
2304 return (currentStream - stream);
2305}
2306
2307std::ostream&
2308operator<<(std::ostream& os, RxSignalInfo rxSignalInfo)
2309{
2310 os << "SNR:" << RatioToDb(rxSignalInfo.snr) << " dB"
2311 << ", RSSI:" << rxSignalInfo.rssi << " dBm";
2312 return os;
2313}
2314
2315uint8_t
2316WifiPhy::GetPrimaryChannelNumber(uint16_t primaryChannelWidth) const
2317{
2318 return m_operatingChannel.GetPrimaryChannelNumber(primaryChannelWidth, m_standard);
2319}
2320
2323{
2324 uint32_t subcarrierSpacing = 0;
2325 switch (GetStandard())
2326 {
2332 subcarrierSpacing = 312500;
2333 break;
2335 if (GetChannelWidth() == 5)
2336 {
2337 subcarrierSpacing = 78125;
2338 }
2339 else
2340 {
2341 subcarrierSpacing = 156250;
2342 }
2343 break;
2346 subcarrierSpacing = 78125;
2347 break;
2348 default:
2349 NS_FATAL_ERROR("Standard unknown: " << GetStandard());
2350 break;
2351 }
2352 return subcarrierSpacing;
2353}
2354
2355} // namespace ns3
bool IsNull() const
Check for null implementation.
Definition: callback.h:571
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Hold variables of type enum.
Definition: enum.h:62
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:55
bool IsPending() const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:76
bool IsExpired() const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:69
Keep track of the current position and velocity of an object.
A base class which provides memory management and object aggregation.
Definition: object.h:89
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:522
bool IsInitialized() const
Check if the object has been initialized.
Definition: object.cc:251
AttributeValue implementation for Pointer.
Definition: pointer.h:48
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
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.
Definition: simulator.h:571
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:605
Hold variables of type string.
Definition: string.h:56
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:415
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
Definition: nstime.h:351
@ NS
nanosecond
Definition: nstime.h:119
bool IsEmpty() const
Checks if the Callbacks list is empty.
a unique identifier for an interface.
Definition: type-id.h:59
@ ATTR_GET
The attribute can be read.
Definition: type-id.h:64
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Hold an unsigned integer type.
Definition: uinteger.h:45
bool Get160MHzOperationSupported() const
represent a single transmission mode
Definition: wifi-mode.h:51
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:185
Ptr< VhtConfiguration > GetVhtConfiguration() const
Ptr< HtConfiguration > GetHtConfiguration() const
Ptr< Node > GetNode() const override
802.11 PHY layer model
Definition: wifi-phy.h:65
static TypeId GetTypeId()
Get the type ID.
Definition: wifi-phy.cc:69
void SetNumberOfAntennas(uint8_t antennas)
Definition: wifi-phy.cc:1289
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Definition: wifi-phy.h:1323
Time GetBlockAckTxTime() const
Return the estimated BlockAck TX time for this PHY.
Definition: wifi-phy.cc:849
double GetCcaEdThreshold() const
Return the CCA energy detection threshold (dBm).
Definition: wifi-phy.cc:517
double m_rxGainDb
Reception gain (dB)
Definition: wifi-phy.h:1584
bool IsStateTx() const
Definition: wifi-phy.cc:2126
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
Definition: wifi-phy.h:1608
WifiModulationClass GetMaxModulationClassSupported() const
Definition: wifi-phy.cc:987
bool IsStateIdle() const
Definition: wifi-phy.cc:2114
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
Definition: wifi-phy.cc:662
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
Definition: wifi-phy.h:1600
bool IsStateCcaBusy() const
Definition: wifi-phy.cc:2108
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.
Definition: wifi-phy.cc:1759
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Definition: wifi-phy.h:1322
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
Definition: wifi-phy.h:1612
void Configure80211ax()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard.
Definition: wifi-phy.cc:957
Time m_channelSwitchDelay
Time required to switch between channel.
Definition: wifi-phy.h:1605
void SetCcaEdThreshold(double threshold)
Sets the CCA energy detection threshold (dBm).
Definition: wifi-phy.cc:510
void NotifyCcaBusy(const Ptr< const WifiPpdu > ppdu, Time duration)
Notify PHY state helper to switch to CCA busy state,.
Definition: wifi-phy.cc:2175
WifiPhyOperatingChannel m_operatingChannel
Operating channel.
Definition: wifi-phy.h:1568
TracedCallback< Ptr< const Packet > > m_phyTxDropTrace
The trace source fired when the PHY layer drops a packet as it tries to transmit it.
Definition: wifi-phy.h:1470
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
Definition: wifi-phy.cc:671
bool m_channelAccessRequested
Flag if channels access has been requested (used for OBSS_PD SR)
Definition: wifi-phy.h:1595
static Time GetPayloadDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, MpduType mpdutype=NORMAL_MPDU, uint16_t staId=SU_STA_ID)
Definition: wifi-phy.cc:1492
Time GetSlot() const
Return the slot duration for this PHY.
Definition: wifi-phy.cc:825
uint32_t GetSubcarrierSpacing() const
Definition: wifi-phy.cc:2322
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1339
Ptr< const WifiPsdu > GetAddressedPsduInPpdu(Ptr< const WifiPpdu > ppdu) const
Get the PSDU addressed to that PHY in a PPDU (useful for MU PPDU).
Definition: wifi-phy.cc:2291
void Configure80211g()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
Definition: wifi-phy.cc:887
uint8_t GetPrimary20Index() const
Definition: wifi-phy.cc:1089
void NotifyTxEnd(WifiConstPsduMap psdus)
Public method used to fire a PhyTxEnd trace.
Definition: wifi-phy.cc:1589
uint16_t GetChannelWidth() const
Definition: wifi-phy.cc:1083
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...
Definition: wifi-phy.h:1335
uint8_t GetNumberOfAntennas() const
Definition: wifi-phy.cc:1301
Time m_slot
Slot duration.
Definition: wifi-phy.h:1572
double m_powerDensityLimit
the power density limit (dBm/MHz)
Definition: wifi-phy.h:1588
Time GetDelayUntilIdle()
Definition: wifi-phy.cc:2150
double GetRxSensitivity() const
Return the receive sensitivity threshold (dBm).
Definition: wifi-phy.cc:504
bool GetShortPhyPreambleSupported() const
Return whether short PHY preamble is supported.
Definition: wifi-phy.cc:619
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS) for this PHY.
Definition: wifi-phy.cc:807
std::list< uint8_t > GetBssMembershipSelectorList() const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1357
void Configure80211n()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
Definition: wifi-phy.cc:930
EventId m_endPhyRxEvent
the end of PHY receive event
Definition: wifi-phy.h:1330
double GetTxGain() const
Return the transmission gain (dB).
Definition: wifi-phy.cc:593
double m_txPowerBaseDbm
Minimum transmission power (dBm)
Definition: wifi-phy.h:1585
void Configure80211be()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11be standard.
Definition: wifi-phy.cc:972
void NotifyRxDrop(Ptr< const WifiPsdu > psdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:1640
bool IsStateRx() const
Definition: wifi-phy.cc:2120
bool IsMcsSupported(WifiModulationClass modulation, uint8_t mcs) const
Check if the given MCS of the given modulation class is supported by the PHY.
Definition: wifi-phy.cc:2006
Time GetSifs() const
Return the Short Interframe Space (SIFS) for this PHY.
Definition: wifi-phy.cc:813
uint16_t GetFrequency() const
Definition: wifi-phy.cc:1071
Ptr< MobilityModel > GetMobility() const
Return the mobility model this PHY is associated with.
Definition: wifi-phy.cc:643
uint16_t GetNMcs() const
Definition: wifi-phy.cc:2052
Time m_blockAckTxTime
estimated BlockAck TX time
Definition: wifi-phy.h:1575
uint8_t GetPrimaryChannelNumber(uint16_t primaryChannelWidth) const
Get channel number of the primary channel.
Definition: wifi-phy.cc:2316
void ResetCca(bool powerRestricted, double txPowerMaxSiso=0, double txPowerMaxMimo=0)
Reset PHY to IDLE, with some potential TX power restrictions for the next transmission.
Definition: wifi-phy.cc:2232
double m_txPowerMaxMimo
MIMO maximum transmit power due to OBSS PD SR power restriction (dBm)
Definition: wifi-phy.h:1594
void ResumeFromSleep()
Resume from sleep mode.
Definition: wifi-phy.cc:1425
static Time GetPreambleDetectionDuration()
Definition: wifi-phy.cc:1480
void Configure80211p()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11p standard.
Definition: wifi-phy.cc:900
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted.
Definition: wifi-phy.cc:2182
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
Definition: wifi-phy.h:1610
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition: wifi-phy.h:1502
void NotifyRxBegin(Ptr< const WifiPsdu > psdu, const RxPowerWattPerChannelBand &rxPowersW)
Public method used to fire a PhyRxBegin trace.
Definition: wifi-phy.cc:1616
Time GetChannelSwitchDelay() const
Definition: wifi-phy.cc:723
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1307
Time m_sifs
Short Interframe Space (SIFS) duration.
Definition: wifi-phy.h:1571
void SetReceiveErrorCallback(RxErrorCallback callback)
Definition: wifi-phy.cc:473
TracedCallback< Ptr< const WifiPpdu >, const WifiTxVector & > m_signalTransmissionCb
Signal Transmission callback.
Definition: wifi-phy.h:1361
bool IsStateOff() const
Definition: wifi-phy.cc:2144
uint8_t GetMaxSupportedRxSpatialStreams() const
Definition: wifi-phy.cc:1351
double GetTxPowerEnd() const
Return the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:567
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:993
void SetPostReceptionErrorModel(const Ptr< ErrorModel > em)
Attach a receive ErrorModel to the WifiPhy.
Definition: wifi-phy.cc:679
WifiMode GetMcs(WifiModulationClass modulation, uint8_t mcs) const
Get the WifiMode object corresponding to the given MCS of the given modulation class.
Definition: wifi-phy.cc:2101
uint8_t m_numberOfAntennas
Number of transmitters.
Definition: wifi-phy.h:1599
ChannelTuple m_channelSettings
Store operating channel settings until initialization.
Definition: wifi-phy.h:1567
TracedCallback< Ptr< const WifiPpdu >, WifiPhyRxfailureReason > m_phyRxPpduDropTrace
The trace source fired when the PHY layer drops a packet it has received.
Definition: wifi-phy.h:1514
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition: wifi-phy.cc:1539
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
Definition: wifi-phy.cc:1568
Ptr< WifiPhyStateHelper > GetState() const
Return the WifiPhyStateHelper of this PHY.
Definition: wifi-phy.cc:461
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.
Definition: wifi-phy.cc:1574
void EndReceiveInterBss()
For HE receptions only, check and possibly modify the transmit power restriction state at the end of ...
Definition: wifi-phy.cc:1960
void SetSleepMode()
Put in sleep mode.
Definition: wifi-phy.cc:1372
void SetShortPhyPreambleSupported(bool preamble)
Enable or disable short PHY preamble.
Definition: wifi-phy.cc:612
void SetNTxPower(uint8_t n)
Sets the number of transmission power levels available between the minimum level and the maximum leve...
Definition: wifi-phy.cc:573
WifiPhyBand m_band
WifiPhyBand.
Definition: wifi-phy.h:1566
void SetRxSensitivity(double threshold)
Sets the receive sensitivity threshold (dBm).
Definition: wifi-phy.cc:497
static const Ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
Definition: wifi-phy.cc:735
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.
Definition: wifi-phy.h:1553
double m_txPowerMaxSiso
SISO maximum transmit power due to OBSS PD SR power restriction (dBm)
Definition: wifi-phy.h:1592
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
Definition: wifi-phy.h:1358
void NotifyRxPpduDrop(Ptr< const WifiPpdu > ppdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxPpduDrop trace.
Definition: wifi-phy.cc:1652
virtual void StartTx(Ptr< const WifiPpdu > ppdu)=0
void SetMaxModulationClassSupported(WifiModulationClass modClass)
Set the maximum modulation class that has to be supported by this PHY object.
Definition: wifi-phy.cc:980
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...
Definition: wifi-phy.cc:794
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.
Definition: wifi-phy.h:1534
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
Definition: wifi-phy.h:1613
EventId m_endTxEvent
the end of transmit event
Definition: wifi-phy.h:1331
double GetRxGain() const
Return the reception gain (dB).
Definition: wifi-phy.cc:606
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.
Definition: wifi-phy.cc:1753
double m_rxSensitivityDbm
Receive sensitivity threshold in dBm.
Definition: wifi-phy.h:1577
void RegisterListener(const std::shared_ptr< WifiPhyListener > &listener)
Definition: wifi-phy.cc:479
static std::map< WifiModulationClass, Ptr< PhyEntity > > & GetStaticPhyEntities()
Definition: wifi-phy.cc:454
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition: wifi-phy.cc:819
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
Definition: wifi-phy.cc:1130
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:1053
void SetPreviouslyRxPpduUid(uint64_t uid)
Set the UID of the previously received PPDU.
Definition: wifi-phy.cc:1900
bool IsReceivingPhyHeader() const
Definition: wifi-phy.cc:1954
double m_ccaSensitivityThresholdW
Clear channel assessment (CCA) modulation and coding rate sensitivity threshold in watts.
Definition: wifi-phy.h:1580
Ptr< Event > m_currentEvent
Hold the current event.
Definition: wifi-phy.h:1333
Time GetLastRxStartTime() const
Return the start time of the last received packet.
Definition: wifi-phy.cc:2156
WifiMode GetDefaultMode() const
Get the default WifiMode supported by the PHY.
Definition: wifi-phy.cc:1990
void SetCcaSensitivityThreshold(double threshold)
Sets the CCA sensitivity threshold (dBm).
Definition: wifi-phy.cc:523
double m_ccaEdThresholdW
Clear channel assessment (CCA) energy detection (ED) threshold in watts.
Definition: wifi-phy.h:1578
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.
Definition: wifi-phy.cc:1713
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class.
Definition: wifi-phy.cc:744
uint8_t GetChannelNumber() const
Return current channel number.
Definition: wifi-phy.cc:1077
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
Definition: wifi-phy.h:1462
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
Definition: wifi-phy.h:1338
std::optional< Time > GetDelayUntilChannelSwitch()
Perform any actions necessary when user changes operating channel after initialization.
Definition: wifi-phy.cc:1167
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU.
Definition: wifi-phy.h:1327
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
Definition: wifi-phy.cc:698
TracedCallback< Ptr< const Packet >, double > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
Definition: wifi-phy.h:1447
virtual void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:625
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
Definition: wifi-phy.h:1611
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:560
Time GetPifs() const
Return the PCF Interframe Space (PIFS) for this PHY.
Definition: wifi-phy.cc:837
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
Definition: wifi-phy.cc:785
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
Definition: wifi-phy.cc:1628
void StartReceivePreamble(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Definition: wifi-phy.cc:1931
TracedCallback< WifiConstPsduMap, WifiTxVector, double > m_phyTxPsduBeginTrace
The trace source fired when a PSDU map begins the transmission process on the medium.
Definition: wifi-phy.h:1454
double m_txGainDb
Transmission gain (dB)
Definition: wifi-phy.h:1583
bool IsStateSleep() const
Definition: wifi-phy.cc:2138
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition: wifi-phy.cc:631
WifiStandard m_standard
WifiStandard.
Definition: wifi-phy.h:1564
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:704
uint8_t m_nTxPower
Number of available transmission power levels.
Definition: wifi-phy.h:1587
void DoDispose() override
Destructor implementation.
Definition: wifi-phy.cc:425
bool IsStateSwitching() const
Definition: wifi-phy.cc:2132
void SetPhyId(uint8_t phyId)
Set the index allocated to this PHY.
Definition: wifi-phy.cc:649
virtual void DoChannelSwitch()
Actually switch channel based on the stored channel settings.
Definition: wifi-phy.cc:1206
void SetOffMode()
Put in off mode.
Definition: wifi-phy.cc:1415
double m_noiseFigureDb
The noise figure in dB.
Definition: wifi-phy.h:1603
TracedCallback< Ptr< const Packet >, WifiPhyRxfailureReason > m_phyRxDropTrace
The trace source fired when the PHY layer drops a packet it has received.
Definition: wifi-phy.h:1509
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
Definition: wifi-phy.cc:692
uint8_t m_phyId
the index of the PHY in the vector of PHYs held by the WifiNetDevice
Definition: wifi-phy.h:1317
std::tuple< uint8_t, uint16_t, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying an operating channel.
Definition: wifi-phy.h:926
void SetPifs(Time pifs)
Set the PCF Interframe Space (PIFS) for this PHY.
Definition: wifi-phy.cc:831
void Configure80211b()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
Definition: wifi-phy.cc:870
static Time GetStartOfPacketDuration(const WifiTxVector &txVector)
Definition: wifi-phy.cc:1486
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...
Definition: wifi-phy.cc:1107
void SetRxGain(double gain)
Sets the reception gain (dB).
Definition: wifi-phy.cc:599
void SwitchMaybeToCcaBusy(const Ptr< const WifiPpdu > ppdu=nullptr)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
Definition: wifi-phy.cc:2168
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:637
void SetTxGain(double gain)
Sets the transmission gain (dB).
Definition: wifi-phy.cc:586
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
Definition: wifi-phy.h:1601
double m_txPowerEndDbm
Maximum transmission power (dBm)
Definition: wifi-phy.h:1586
double CalculateSnr(const WifiTxVector &txVector, double ber) const
Definition: wifi-phy.cc:729
void SetFixedPhyBand(bool enable)
Configure whether it is prohibited to change PHY band after initialization.
Definition: wifi-phy.cc:1095
~WifiPhy() override
Definition: wifi-phy.cc:394
void Configure80211ac()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard.
Definition: wifi-phy.cc:949
bool HasFixedPhyBand() const
Definition: wifi-phy.cc:1101
TracedCallback< Ptr< const Packet >, RxPowerWattPerChannelBand > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
Definition: wifi-phy.h:1478
Ptr< WifiNetDevice > m_device
Pointer to the device.
Definition: wifi-phy.h:1607
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
Definition: wifi-phy.h:1320
void DoInitialize() override
Initialize() implementation.
Definition: wifi-phy.cc:400
bool m_shortPreamble
Flag if short PHY preamble is supported.
Definition: wifi-phy.h:1598
uint8_t GetPhyId() const
Get the index allocated to this PHY.
Definition: wifi-phy.cc:656
Time m_pifs
PCF Interframe Space (PIFS) duration.
Definition: wifi-phy.h:1573
WifiModulationClass m_maxModClassSupported
max modulation class supported
Definition: wifi-phy.h:1565
void SetRxNoiseFigure(double noiseFigureDb)
Sets the RX loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
Definition: wifi-phy.cc:536
double GetTxPowerStart() const
Return the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:554
double GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
Definition: wifi-phy.cc:2255
WifiStandard GetStandard() const
Get the configured Wi-Fi standard.
Definition: wifi-phy.cc:1059
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition: wifi-phy.cc:491
void SetReceiveOkCallback(RxOkCallback callback)
Definition: wifi-phy.cc:467
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
Definition: wifi-phy.cc:686
void NotifyChannelAccessRequested()
Notify the PHY that an access to the channel was requested.
Definition: wifi-phy.cc:1970
void ResumeFromOff()
Resume from off mode.
Definition: wifi-phy.cc:1452
bool m_powerRestricted
Flag whether transmit power is restricted by OBSS PD SR.
Definition: wifi-phy.h:1590
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
Definition: wifi-phy.h:1616
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.
Definition: wifi-phy.cc:1659
Ptr< PhyEntity > GetPhyEntityForPpdu(const Ptr< const WifiPpdu > ppdu) const
Get the supported PHY entity to use for a received PPDU.
Definition: wifi-phy.cc:765
Time GetAckTxTime() const
Return the estimated Ack TX time for this PHY.
Definition: wifi-phy.cc:843
uint64_t GetPreviouslyRxPpduUid() const
Definition: wifi-phy.cc:1894
void Reset()
Reset data upon end of TX or RX.
Definition: wifi-phy.cc:1907
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
Definition: wifi-phy.h:1494
Time GetLastRxEndTime() const
Return the end time of the last received packet.
Definition: wifi-phy.cc:2162
uint8_t GetMaxSupportedTxSpatialStreams() const
Definition: wifi-phy.cc:1333
void Configure80211a()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
Definition: wifi-phy.cc:855
std::list< WifiMode > GetMcsList() const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
Definition: wifi-phy.cc:2066
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition: wifi-phy.cc:2017
void TxDone(const WifiConstPsduMap &psdus)
Callback function when a transmission is completed.
Definition: wifi-phy.cc:1884
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:1065
double GetCcaSensitivityThreshold() const
Return the CCA sensitivity threshold (dBm).
Definition: wifi-phy.cc:530
bool m_fixedPhyBand
True to prohibit changing PHY band after initialization.
Definition: wifi-phy.h:1569
Ptr< PhyEntity > GetLatestPhyEntity() const
Get the latest PHY entity supported by this PHY instance.
Definition: wifi-phy.cc:759
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:547
uint8_t GetNTxPower() const
Return the number of available transmission power levels.
Definition: wifi-phy.cc:580
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: wifi-phy.cc:2298
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition: wifi-phy.cc:1532
bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
Definition: wifi-phy.cc:1977
Time m_ackTxTime
estimated Ack TX time
Definition: wifi-phy.h:1574
void UnregisterListener(const std::shared_ptr< WifiPhyListener > &listener)
Definition: wifi-phy.cc:485
void NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
Definition: wifi-phy.cc:1604
Class that keeps track of all information about the current PHY operating channel.
bool IsSet() const
Return true if a valid channel has been set, false otherwise.
uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
void Set(uint8_t number, uint16_t frequency, uint16_t width, WifiStandard standard, WifiPhyBand band)
Set the channel according to the specified parameters if a unique frequency channel matches the speci...
uint8_t GetPrimaryChannelNumber(uint16_t primaryChannelWidth, WifiStandard standard) const
Get channel number of the primary channel.
uint16_t GetWidth() const
Return the width of the whole operating channel (in MHz).
static uint8_t GetDefaultChannelNumber(uint16_t width, WifiStandard standard, WifiPhyBand band)
Get the default channel number of the given width and for the given standard and band.
uint8_t GetNumber() const
Return the channel number identifying the whole operating channel.
uint16_t GetFrequency() const
Return the center frequency of the operating channel (in MHz).
void SwitchToSleep()
Switch to sleep mode.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
bool IsValid(WifiPhyBand band=WIFI_PHY_BAND_UNSPECIFIED) const
The standard disallows certain combinations of WifiMode, number of spatial streams,...
uint8_t GetNssTotal() const
WifiModulationClass GetModulationClass() const
Get the modulation class specified by this TXVECTOR.
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
uint8_t GetNssMax() const
uint8_t GetTxPowerLevel() const
bool IsAggregation() const
Checks whether the PSDU contains A-MPDU.
bool IsDlMuMimo() const
Return true if this TX vector is used for a downlink multi-user transmission using MU-MIMO.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:259
Ptr< const AttributeChecker > MakeTupleChecker(Ts... checkers)
Create a TupleChecker from AttributeCheckers associated with TupleValue elements.
Definition: tuple.h:540
Ptr< const AttributeAccessor > MakeTupleAccessor(T1 a1)
Create an AttributeAccessor for a class data member of type tuple, or a lone class get functor or set...
Definition: tuple.h:547
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition: abort.h:144
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:49
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition: abort.h:76
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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.
Definition: log.h:261
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1343
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
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.
Definition: wifi-phy-band.h:33
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
MpduType
The type of an MPDU.
@ WIFI_STANDARD_80211a
@ WIFI_STANDARD_80211p
@ WIFI_STANDARD_80211be
@ WIFI_STANDARD_80211n
@ WIFI_STANDARD_80211g
@ WIFI_STANDARD_80211ax
@ WIFI_STANDARD_UNSPECIFIED
@ WIFI_STANDARD_80211ac
@ WIFI_STANDARD_80211b
@ OBSS_PD_CCA_RESET
@ SIGNAL_DETECTION_ABORTED_BY_TX
@ RECEPTION_ABORTED_BY_TX
@ CHANNEL_SWITCHING
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
Definition: wifi-phy-band.h:39
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
Definition: wifi-phy-band.h:43
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
Definition: wifi-phy-band.h:35
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Definition: wifi-phy-band.h:37
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_UNKNOWN
Modulation class unknown or unspecified.
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_EHT
EHT (Clause 36)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_MOD_CLASS_DSSS
DSSS (Clause 15)
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
@ OFDM_PHY_10_MHZ
Definition: ofdm-phy.h:46
@ OFDM_PHY_5_MHZ
Definition: ofdm-phy.h:47
@ WIFI_CHANLIST_PRIMARY
@ LAST_MPDU_IN_AGGREGATE
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
@ FIRST_MPDU_IN_AGGREGATE
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate.
@ SINGLE_MPDU
The MPDU is a single MPDU.
@ MIDDLE_MPDU_IN_AGGREGATE
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition: boolean.cc:124
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:454
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition: wifi-utils.cc:54
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
@ SWITCHING
The PHY layer is switching to other channel.
@ TX
The PHY layer is sending a packet.
@ OFF
The PHY layer is switched off.
@ IDLE
The PHY layer is IDLE.
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
@ SLEEP
The PHY layer is sleeping.
@ RX
The PHY layer is receiving a packet.
uint16_t GetMaximumChannelWidth(WifiModulationClass modulation)
Get the maximum channel width in MHz allowed for the given modulation class.
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:48
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1407
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:42
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:189
std::map< WifiSpectrumBandInfo, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:77
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.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:81
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
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.
Definition: wifi-utils.cc:36
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition: nstime.h:1427
#define list
MpduInfo structure.
Definition: phy-entity.h:62
MpduType type
type of MPDU
Definition: phy-entity.h:63
uint32_t mpduRefNumber
MPDU ref number.
Definition: phy-entity.h:64
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:69
double rssi
RSSI in dBm.
Definition: phy-entity.h:71
double snr
SNR in linear scale.
Definition: phy-entity.h:70
SignalNoiseDbm structure.
Definition: phy-entity.h:55
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.