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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 * Sébastien Deronne <sebastien.deronne@gmail.com>
8 */
9
10#include "wifi-phy.h"
11
12#include "error-rate-model.h"
13#include "frame-capture-model.h"
14#include "interference-helper.h"
15#include "phy-entity.h"
17#include "wifi-net-device.h"
18#include "wifi-ppdu.h"
19#include "wifi-psdu.h"
21#include "wifi-utils.h"
22
23#include "ns3/channel.h"
24#include "ns3/dsss-phy.h"
25#include "ns3/eht-phy.h" //also includes OFDM, HT, VHT and HE
26#include "ns3/erp-ofdm-phy.h"
27#include "ns3/error-model.h"
28#include "ns3/ht-configuration.h"
29#include "ns3/log.h"
30#include "ns3/mobility-model.h"
31#include "ns3/pointer.h"
32#include "ns3/random-variable-stream.h"
33#include "ns3/simulator.h"
34#include "ns3/string.h"
35#include "ns3/vht-configuration.h"
36
37#include <algorithm>
38#include <numeric>
39
40#undef NS_LOG_APPEND_CONTEXT
41#define NS_LOG_APPEND_CONTEXT \
42 WIFI_PHY_NS_LOG_APPEND_CONTEXT( \
43 (m_device && (m_device->GetNPhys() > m_phyId) && m_device->GetPhy(m_phyId) \
44 ? m_device->GetPhy(m_phyId) \
45 : nullptr))
46
47namespace ns3
48{
49
51
52/****************************************************************
53 * The actual WifiPhy class
54 ****************************************************************/
55
57
58TypeId
60{
61 static TypeId tid =
62 TypeId("ns3::WifiPhy")
64 .SetGroupName("Wifi")
65 .AddAttribute("Channel",
66 "The channel attached to this PHY",
71 .AddAttribute(
72 "ChannelSettings",
73 "A vector of tuple {channel number, channel width (MHz), PHY band, primary20 "
74 "index} "
75 "describing the settings of the operating channel for each segment. "
76 "The primary20 index (only the value set for the first segment is used) "
77 "is the index of the primary 20 MHz channel within the operating channel "
78 "(0 indicates the 20 MHz subchannel with the lowest center frequency) and "
79 "is only valid if the width of the operating channel is a multiple of 20 MHz. "
80 "If the standard for this object has not been set yet, the value of this "
81 "attribute is saved and will be used to set the operating channel when the "
82 "standard is configured. If the PHY band is left unspecified, the default "
83 "band for the configured standard is used. If the channel width and the "
84 "channel number are both 0, the default channel width for the configured "
85 "standard and band are used. If the channel number is 0, the default "
86 "channel number for the configured standard, band and channel width is used. "
87 "Note that the channel width can be left unspecified (0) if the channel "
88 "number uniquely identify a frequency channel for the given standard and band.",
89 StringValue("{0, 0, BAND_UNSPECIFIED, 0}"),
91 static_cast<void (WifiPhy::*)(const ChannelSegments&)>(
94 .AddAttribute("Frequency",
95 "The center frequency (MHz) of the current operating channel.",
100 .AddAttribute("ChannelNumber",
101 "The channel number of the current operating channel.",
103 UintegerValue(0),
106 .AddAttribute(
107 "ChannelWidth",
108 "The width in MHz of the current operating channel (5, 10, 20, 22, 40, 80, 160 or "
109 "320). If 80+80MHz is used, this corresponds to the total channel width, hence 160 "
110 "MHz.",
112 UintegerValue(0),
115 .AddAttribute(
116 "Primary20MHzIndex",
117 "The index of the primary 20 MHz channel within the current operating channel "
118 "(0 indicates the 20 MHz subchannel with the lowest center frequency).",
119 UintegerValue(0),
122 .AddAttribute("FixedPhyBand",
123 "If set to true, changing PHY band is prohibited after initialization.",
124 BooleanValue(false),
127 .AddAttribute(
128 "MaxRadioBw",
129 "The maximum width supported by the radio. It is not possible to configure an "
130 "operating channel with a total width larger than this value. A value of 0 means "
131 "no restriction.",
132 TypeId::ATTR_GET | TypeId::ATTR_CONSTRUCT, // prevent setting after construction
133 DoubleValue(MHz_u{0}),
136 .AddAttribute(
137 "RxSensitivity",
138 "The energy of a received signal should be higher than "
139 "this threshold (dBm) for the PHY to detect the signal. "
140 "This threshold refers to a width of 20 MHz and will be "
141 "scaled to match the width of the received signal.",
142 DoubleValue(-101.0),
145 .AddAttribute(
146 "CcaEdThreshold",
147 "The energy of all received signals should be higher than "
148 "this threshold (dBm) in the primary channel to allow the PHY layer "
149 "to declare CCA BUSY state.",
150 DoubleValue(-62.0),
153 .AddAttribute("CcaSensitivity",
154 "The energy of a received wifi signal should be higher than "
155 "this threshold (dBm) in the primary channel to allow the PHY layer "
156 "to declare CCA BUSY state.",
157 DoubleValue(-82.0),
161 .AddAttribute("TxGain",
162 "Transmission gain (dB).",
163 DoubleValue(0.0),
166 .AddAttribute("RxGain",
167 "Reception gain (dB).",
168 DoubleValue(0.0),
171 .AddAttribute("TxPowerLevels",
172 "Number of transmission power levels available between "
173 "TxPowerStart and TxPowerEnd included.",
174 UintegerValue(1),
177 .AddAttribute("TxPowerEnd",
178 "Maximum available transmission level (dBm).",
179 DoubleValue(16.0206),
182 .AddAttribute("TxPowerStart",
183 "Minimum available transmission level (dBm).",
184 DoubleValue(16.0206),
187 .AddAttribute(
188 "RxNoiseFigure",
189 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
190 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
191 "\"the difference in decibels (dB) between"
192 " the noise output of the actual receiver to the noise output of an "
193 " ideal receiver with the same overall gain and bandwidth when the receivers "
194 " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
195 DoubleValue(7),
198 .AddAttribute("State",
199 "The state of the PHY layer.",
200 PointerValue(),
203 .AddAttribute("ChannelSwitchDelay",
204 "Delay between two short frames transmitted on different frequencies.",
205 TimeValue(MicroSeconds(250)),
208 .AddAttribute(
209 "Antennas",
210 "The number of antennas on the device.",
211 UintegerValue(1),
214 .AddAttribute("MaxSupportedTxSpatialStreams",
215 "The maximum number of supported TX spatial streams."
216 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
217 UintegerValue(1),
221 .AddAttribute("MaxSupportedRxSpatialStreams",
222 "The maximum number of supported RX spatial streams."
223 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
224 UintegerValue(1),
228 .AddAttribute("ShortPlcpPreambleSupported",
229 "Whether or not short PHY preamble is supported."
230 "This parameter is only valuable for 802.11b STAs and APs."
231 "Note: 802.11g APs and STAs always support short PHY preamble.",
232 BooleanValue(false),
236 .AddAttribute("FrameCaptureModel",
237 "Ptr to an object that implements the frame capture model",
238 PointerValue(),
241 .AddAttribute("PreambleDetectionModel",
242 "Ptr to an object that implements the preamble detection model",
243 PointerValue(),
246 .AddAttribute("PostReceptionErrorModel",
247 "An optional packet error model can be added to the receive "
248 "packet process after any propagation-based (SNR-based) error "
249 "models have been applied. Typically this is used to force "
250 "specific packet drops, for testing purposes.",
251 PointerValue(),
254 .AddAttribute("InterferenceHelper",
255 "Ptr to an object that implements the interference helper",
256 PointerValue(),
259 .AddAttribute("Sifs",
260 "The duration of the Short Interframe Space. "
261 "NOTE that the default value is overwritten by the value defined "
262 "by the standard; if you want to set this attribute, you have to "
263 "do it after that the PHY object is initialized.",
264 TimeValue(MicroSeconds(0)),
267 .AddAttribute("Slot",
268 "The duration of a slot. "
269 "NOTE that the default value is overwritten by the value defined "
270 "by the standard; if you want to set this attribute, you have to "
271 "do it after that the PHY object is initialized.",
272 TimeValue(MicroSeconds(0)),
275 .AddAttribute("Pifs",
276 "The duration of the PCF Interframe Space. "
277 "NOTE that the default value is overwritten by the value defined "
278 "by the standard; if you want to set this attribute, you have to "
279 "do it after that the PHY object is initialized.",
280 TimeValue(MicroSeconds(0)),
283 .AddAttribute("PowerDensityLimit",
284 "The mean equivalent isotropically radiated power density"
285 "limit (in dBm/MHz) set by regulators.",
286 DoubleValue(100.0), // set to a high value so as to have no effect
289 .AddAttribute("NotifyMacHdrRxEnd",
290 "Whether the PHY is capable of notifying the MAC about the end of "
291 "the reception of the MAC header of every MPDU.",
292 BooleanValue(false),
295 .AddTraceSource(
296 "PhyTxBegin",
297 "Trace source indicating a packet has begun transmitting over the medium; "
298 "the packet holds a single MPDU even if the MPDU is transmitted within an A-MPDU "
299 "(in which case this trace fires for each MPDU in the "
300 "A-MPDU).",
302 "ns3::WifiPhy::PhyTxBeginTracedCallback")
303 .AddTraceSource(
304 "PhyTxPsduBegin",
305 "Trace source indicating a PSDU has begun transmitting over the channel medium; "
306 "this trace returns a WifiConstPsduMap with a single element (in the case of SU "
307 "PPDU) "
308 "or multiple elements (in the case of MU PPDU)",
310 "ns3::WifiPhy::PsduTxBeginCallback")
311 .AddTraceSource("PhyTxEnd",
312 "Trace source indicating a packet "
313 "has been completely transmitted over the channel.",
315 "ns3::Packet::TracedCallback")
316 .AddTraceSource("PhyTxDrop",
317 "Trace source indicating a packet "
318 "has been dropped by the device during transmission",
320 "ns3::Packet::TracedCallback")
321 .AddTraceSource("PhyRxBegin",
322 "Trace source indicating a packet "
323 "has begun being received from the channel medium "
324 "by the device",
326 "ns3::WifiPhy::PhyRxBeginTracedCallback")
327 .AddTraceSource("PhyRxPayloadBegin",
328 "Trace source indicating the reception of the "
329 "payload of a PPDU has begun",
331 "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
332 .AddTraceSource("PhyRxMacHeaderEnd",
333 "Trace source indicating the MAC header of an MPDU has been "
334 "completely received.",
336 "ns3::WifiPhy::PhyRxMacHeaderEndTracedCallback")
337 .AddTraceSource("PhyRxEnd",
338 "Trace source indicating a packet "
339 "has been completely received from the channel medium "
340 "by the device",
342 "ns3::Packet::TracedCallback")
343 .AddTraceSource("PhyRxDrop",
344 "Trace source indicating a packet "
345 "has been dropped by the device during reception",
347 "ns3::WifiPhy::PhyRxDropTracedCallback")
348 .AddTraceSource("PhyRxPpduDrop",
349 "Trace source indicating a ppdu "
350 "has been dropped by the device during reception",
352 "ns3::WifiPhy::PhyRxPpduDropTracedCallback")
353 .AddTraceSource("MonitorSnifferRx",
354 "Trace source simulating a wifi device in monitor mode "
355 "sniffing all received frames",
357 "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
358 .AddTraceSource("MonitorSnifferTx",
359 "Trace source simulating the capability of a wifi device "
360 "in monitor mode to sniff all frames being transmitted",
362 "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
363 .AddTraceSource("SignalTransmission",
364 "Trace start of signal transmission",
366 "ns3::SpectrumWifiPhy::SignalTransmissionCallback");
367 return tid;
368}
369
370Ptr<const AttributeChecker>
387
413
415{
416 NS_LOG_FUNCTION(this);
417}
418
419void
421{
422 NS_LOG_FUNCTION(this);
423
424 // This method ensures that the local mobility model pointer holds
425 // a pointer to the Node's aggregated mobility model (if one exists)
426 // in the case that the user has not directly called SetMobility()
427 // on this WifiPhy during simulation setup. If the mobility model
428 // needs to be added or changed during simulation runtime, users must
429 // call SetMobility() on this object.
430
431 if (!m_mobility)
432 {
434 "Either install a MobilityModel on this object or ensure that this "
435 "object is part of a Node and NetDevice");
436 m_mobility = m_device->GetNode()->GetObject<MobilityModel>();
437 if (!m_mobility)
438 {
439 NS_LOG_WARN("Mobility not found, propagation models might not work properly");
440 }
441 }
442}
443
444void
446{
447 NS_LOG_FUNCTION(this);
448
449 m_device = nullptr;
450 m_mobility = nullptr;
451 m_frameCaptureModel = nullptr;
452 m_preambleDetectionModel = nullptr;
453 m_wifiRadioEnergyModel = nullptr;
455 if (m_interference)
456 {
457 m_interference->Dispose();
458 }
459 m_interference = nullptr;
460 m_random = nullptr;
461 m_state = nullptr;
462
463 Reset();
464
465 // this should be done after calling the Reset function
466 for (auto& phyEntity : m_phyEntities)
467 {
468 phyEntity.second = nullptr;
469 }
470 m_phyEntities.clear();
471}
472
473std::map<WifiModulationClass, std::shared_ptr<PhyEntity>>&
475{
476 static std::map<WifiModulationClass, std::shared_ptr<PhyEntity>> g_staticPhyEntities;
477 return g_staticPhyEntities;
478}
479
482{
483 return m_state;
484}
485
486void
488{
489 m_state->SetReceiveOkCallback(callback);
490}
491
492void
494{
495 m_state->SetReceiveErrorCallback(callback);
496}
497
498void
499WifiPhy::RegisterListener(const std::shared_ptr<WifiPhyListener>& listener)
500{
501 m_state->RegisterListener(listener);
502 if (IsInitialized())
503 {
504 // provide CCA busy information upon registering a PHY listener
505 SwitchMaybeToCcaBusy(nullptr);
506 }
507}
508
509void
510WifiPhy::UnregisterListener(const std::shared_ptr<WifiPhyListener>& listener)
511{
512 m_state->UnregisterListener(listener);
513}
514
515void
520
521void
523{
524 NS_LOG_FUNCTION(this << threshold);
525 m_rxSensitivity = threshold;
526}
527
528dBm_u
530{
531 return m_rxSensitivity;
532}
533
534void
536{
537 NS_LOG_FUNCTION(this << threshold);
538 m_ccaEdThreshold = threshold;
539}
540
541dBm_u
543{
544 return m_ccaEdThreshold;
545}
546
547void
549{
550 NS_LOG_FUNCTION(this << threshold);
551 m_ccaSensitivityThreshold = threshold;
552}
553
554dBm_u
559
560void
562{
563 NS_LOG_FUNCTION(this << noiseFigure);
564 if (m_interference)
565 {
566 m_interference->SetNoiseFigure(DbToRatio(noiseFigure));
567 }
568 m_noiseFigure = noiseFigure;
569}
570
571void
573{
574 NS_LOG_FUNCTION(this << start);
575 m_txPowerBase = start;
576}
577
578dBm_u
580{
581 return m_txPowerBase;
582}
583
584void
586{
587 NS_LOG_FUNCTION(this << end);
588 m_txPowerEnd = end;
589}
590
591dBm_u
593{
594 return m_txPowerEnd;
595}
596
597void
599{
600 NS_LOG_FUNCTION(this << +n);
601 m_nTxPower = n;
602}
603
604uint8_t
606{
607 return m_nTxPower;
608}
609
610void
612{
613 NS_LOG_FUNCTION(this << gain);
614 m_txGain = gain;
615}
616
617dB_u
619{
620 return m_txGain;
621}
622
623void
625{
626 NS_LOG_FUNCTION(this << gain);
627 m_rxGain = gain;
628}
629
630dB_u
632{
633 return m_rxGain;
634}
635
636void
638{
639 NS_LOG_FUNCTION(this << enable);
640 m_shortPreamble = enable;
641}
642
643bool
648
649void
651{
652 m_device = device;
653}
654
657{
658 return m_device;
659}
660
661void
663{
664 m_mobility = mobility;
665}
666
669{
670 return m_mobility;
671}
672
673void
674WifiPhy::SetPhyId(uint8_t phyId)
675{
676 NS_LOG_FUNCTION(this << phyId);
677 m_phyId = phyId;
678}
679
680uint8_t
682{
683 return m_phyId;
684}
685
686void
688{
689 NS_LOG_FUNCTION(this << helper);
690 m_interference = helper;
691 m_interference->SetNoiseFigure(DbToRatio(m_noiseFigure));
692 m_interference->SetNumberOfReceiveAntennas(m_numberOfAntennas);
693}
694
695void
697{
698 NS_LOG_FUNCTION(this << model);
700 m_interference->SetErrorRateModel(model);
701}
702
703void
709
710void
715
716void
721
722void
724{
725 m_wifiRadioEnergyModel = wifiRadioEnergyModel;
726}
727
728dBm_u
729WifiPhy::GetPower(uint8_t powerLevel) const
730{
733 dBm_u dbm;
734 if (m_nTxPower > 1)
735 {
736 dbm = m_txPowerBase + dB_u{powerLevel * (m_txPowerEnd - m_txPowerBase) / (m_nTxPower - 1)};
737 }
738 else
739 {
741 "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
742 dbm = m_txPowerBase;
743 }
744 return dbm;
745}
746
747Time
752
753double
754WifiPhy::CalculateSnr(const WifiTxVector& txVector, double ber) const
755{
756 return m_interference->GetErrorRateModel()->CalculateSnr(txVector, ber);
757}
758
759const std::shared_ptr<const PhyEntity>
761{
762 const auto it = GetStaticPhyEntities().find(modulation);
764 "Unimplemented Wi-Fi modulation class " << modulation);
765 return it->second;
766}
767
768std::shared_ptr<PhyEntity>
770{
771 const auto it = m_phyEntities.find(modulation);
772 NS_ABORT_MSG_IF(it == m_phyEntities.cend(),
773 "Unsupported Wi-Fi modulation class " << modulation);
774 return it->second;
775}
776
777std::shared_ptr<PhyEntity>
779{
781}
782
783std::shared_ptr<PhyEntity>
788
789std::shared_ptr<PhyEntity>
791{
792 NS_ABORT_IF(!ppdu);
793 const auto modulation = ppdu->GetModulation();
794 if (modulation > m_phyEntities.rbegin()->first)
795 {
796 // unsupported modulation: start reception process with latest PHY entity
797 return GetLatestPhyEntity();
798 }
799 if (modulation < WIFI_MOD_CLASS_HT)
800 {
801 // for non-HT (duplicate), call the latest PHY entity since some extra processing can be
802 // done in PHYs implemented in HT and later (e.g. channel width selection for non-HT
803 // duplicates)
804 return GetLatestPhyEntity();
805 }
806 return GetPhyEntity(modulation);
807}
808
809void
810WifiPhy::AddStaticPhyEntity(WifiModulationClass modulation, std::shared_ptr<PhyEntity> phyEntity)
811{
812 NS_ASSERT_MSG(!GetStaticPhyEntities().contains(modulation),
813 "The PHY entity has already been added. The setting should only be done once per "
814 "modulation class");
815 GetStaticPhyEntities()[modulation] = phyEntity;
816}
817
818void
819WifiPhy::AddPhyEntity(WifiModulationClass modulation, std::shared_ptr<PhyEntity> phyEntity)
820{
821 NS_LOG_FUNCTION(this << modulation);
822 NS_ABORT_MSG_IF(!GetStaticPhyEntities().contains(modulation),
823 "Cannot add an unimplemented PHY to supported list. Update the former first.");
824 NS_ASSERT_MSG(m_phyEntities.find(modulation) == m_phyEntities.end(),
825 "The PHY entity has already been added. The setting should only be done once per "
826 "modulation class");
827 phyEntity->SetOwner(this);
828 m_phyEntities[modulation] = phyEntity;
829}
830
831void
833{
834 m_sifs = sifs;
835}
836
837Time
839{
840 return m_sifs;
841}
842
843void
845{
846 m_slot = slot;
847}
848
849Time
851{
852 return m_slot;
853}
854
855void
857{
858 m_pifs = pifs;
859}
860
861Time
863{
864 return m_pifs;
865}
866
867void
869{
870 NS_LOG_FUNCTION(this);
871 AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared<OfdmPhy>());
872
873 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
876 SetPifs(GetSifs() + GetSlot());
877 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
878 // of the PPDU causing the EIFS" of 802.11-2016
879}
880
881void
883{
884 NS_LOG_FUNCTION(this);
885 std::shared_ptr<DsssPhy> phyEntity = std::make_shared<DsssPhy>();
887 AddPhyEntity(WIFI_MOD_CLASS_DSSS, phyEntity); // when plain DSSS modes are used
888
891 SetPifs(GetSifs() + GetSlot());
892 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
893 // of the PPDU causing the EIFS" of 802.11-2016
894}
895
896void
898{
899 NS_LOG_FUNCTION(this);
900 // See Table 18-5 "ERP characteristics" of 802.11-2016
901 // Slot time defaults to the "long slot time" of 20 us in the standard
902 // according to mixed 802.11b/g deployments. Short slot time is enabled
903 // if the user sets the ShortSlotTimeSupported flag to true and when the BSS
904 // consists of only ERP STAs capable of supporting this option.
906 AddPhyEntity(WIFI_MOD_CLASS_ERP_OFDM, std::make_shared<ErpOfdmPhy>());
907}
908
909void
911{
912 NS_LOG_FUNCTION(this);
913 if (GetChannelWidth() == MHz_u{10})
914 {
915 AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared<OfdmPhy>(OFDM_PHY_10_MHZ));
916
917 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
920 SetPifs(GetSifs() + GetSlot());
921 }
922 else if (GetChannelWidth() == MHz_u{5})
923 {
924 AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared<OfdmPhy>(OFDM_PHY_5_MHZ));
925
926 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
929 SetPifs(GetSifs() + GetSlot());
930 }
931 else
932 {
933 NS_FATAL_ERROR("802.11p configured with a wrong channel width!");
934 }
935}
936
937void
939{
940 NS_LOG_FUNCTION(this);
942 {
944 }
945 else
946 {
948 }
949 AddPhyEntity(WIFI_MOD_CLASS_HT, std::make_shared<HtPhy>(m_txSpatialStreams));
950}
951
952void
954{
955 NS_LOG_FUNCTION(this);
957 AddPhyEntity(WIFI_MOD_CLASS_VHT, std::make_shared<VhtPhy>());
958}
959
960void
962{
963 NS_LOG_FUNCTION(this);
965 {
967 }
968 else
969 {
971 }
972 AddPhyEntity(WIFI_MOD_CLASS_HE, std::make_shared<HePhy>());
973}
974
975void
977{
978 NS_LOG_FUNCTION(this);
980 AddPhyEntity(WIFI_MOD_CLASS_EHT, std::make_shared<EhtPhy>());
981}
982
983void
989
995
996void
998{
999 NS_LOG_FUNCTION(this << standard);
1000
1002 "Cannot change standard");
1003
1004 m_standard = standard;
1005
1007 {
1009 }
1010
1011 if (!m_operatingChannel.IsSet())
1012 {
1013 NS_LOG_DEBUG("Setting the operating channel first");
1015 // return because we are called back by SetOperatingChannel
1016 return;
1017 }
1018
1019 // this function is called when changing PHY band, hence we have to delete
1020 // the previous PHY entities
1021 m_phyEntities.clear();
1022
1023 switch (standard)
1024 {
1027 break;
1030 break;
1033 break;
1036 break;
1039 break;
1042 break;
1045 break;
1048 break;
1050 default:
1051 NS_ASSERT_MSG(false, "Unsupported standard");
1052 break;
1053 }
1054}
1055
1058{
1059 return m_band;
1060}
1061
1064{
1065 return m_standard;
1066}
1067
1070{
1071 return m_operatingChannel;
1072}
1073
1074MHz_u
1076{
1077 return m_operatingChannel.GetFrequency();
1078}
1079
1080uint8_t
1082{
1083 return m_operatingChannel.GetNumber();
1084}
1085
1086MHz_u
1088{
1089 return m_operatingChannel.GetTotalWidth();
1090}
1091
1092uint8_t
1094{
1095 return m_operatingChannel.GetPrimaryChannelIndex(MHz_u{20});
1096}
1097
1098void
1100{
1101 m_fixedPhyBand = enable;
1102}
1103
1104bool
1106{
1107 return m_fixedPhyBand;
1108}
1109
1110MHz_u
1111WifiPhy::GetTxBandwidth(WifiMode mode, MHz_u maxAllowedWidth) const
1112{
1113 auto modulation = mode.GetModulationClass();
1114 if (modulation == WIFI_MOD_CLASS_DSSS || modulation == WIFI_MOD_CLASS_HR_DSSS)
1115 {
1116 return MHz_u{22};
1117 }
1118
1119 return std::min({GetChannelWidth(), GetMaximumChannelWidth(modulation), maxAllowedWidth});
1120}
1121
1122void
1124{
1125 NS_LOG_FUNCTION(this << channel);
1127 for (std::size_t segmentId = 0; segmentId < channel.GetNSegments(); ++segmentId)
1128 {
1129 cfg.segments.emplace_back(channel.GetNumber(segmentId),
1130 channel.GetWidth(segmentId),
1131 channel.GetPhyBand(),
1132 channel.GetPrimaryChannelIndex(MHz_u{20}));
1133 }
1135}
1136
1137void
1139{
1140 SetOperatingChannel(WifiChannelConfig(channelSegments));
1141}
1142
1143void
1145{
1146 NS_LOG_FUNCTION(this << +channelCfg.front().number << channelCfg.front().width
1147 << channelCfg.front().band << +channelCfg.front().p20Index);
1148
1149 if (IsInitialized() && m_operatingChannel.IsSet() && (m_channelCfg == channelCfg))
1150 {
1151 NS_LOG_DEBUG("Already operating on requested channel");
1152 return;
1153 }
1154
1156 {
1157 NS_LOG_DEBUG("Channel information will be applied when a standard is configured");
1158 m_channelCfg = channelCfg;
1159 return;
1160 }
1161
1162 if (IsInitialized())
1163 {
1164 const auto delay = GetDelayUntilChannelSwitch();
1165 if (!delay.has_value())
1166 {
1167 // switching channel is not possible now
1168 return;
1169 }
1170 if (delay.value().IsStrictlyPositive())
1171 {
1172 // switching channel has been postponed
1173 Simulator::Schedule(delay.value(), [=, this] { SetOperatingChannel(channelCfg); });
1174 return;
1175 }
1176 }
1177
1178 m_channelCfg = channelCfg;
1179
1180 // channel can be switched now.
1182}
1183
1184std::optional<Time>
1186{
1187 if (!IsInitialized())
1188 {
1189 // this is not channel switch, this is initialization
1190 NS_LOG_DEBUG("Before initialization, nothing to do");
1191 return Seconds(0);
1192 }
1193
1194 std::optional<Time> delay;
1195 switch (m_state->GetState())
1196 {
1197 case WifiPhyState::RX:
1198 NS_LOG_DEBUG("drop packet because of channel switching while reception");
1200 delay = Seconds(0);
1201 break;
1202 case WifiPhyState::TX:
1203 NS_LOG_DEBUG("channel switching postponed until end of current transmission");
1204 delay = GetDelayUntilIdle();
1205 break;
1207 case WifiPhyState::IDLE:
1208 Reset();
1209 delay = Seconds(0);
1210 break;
1212 delay = Seconds(0);
1213 break;
1215 NS_LOG_DEBUG("channel switching ignored in sleep mode");
1216 break;
1217 default:
1218 NS_ASSERT(false);
1219 break;
1220 }
1221
1222 return delay;
1223}
1224
1225void
1227{
1228 std::optional<uint8_t> prevChannelNumber{};
1229 for (auto& [number, width, band, primary20] : channelCfg.segments)
1230 {
1231 if (band == WIFI_PHY_BAND_UNSPECIFIED)
1232 {
1233 band = GetDefaultPhyBand(standard);
1234 }
1235 if (width == MHz_u{0} && number == 0)
1236 {
1237 width = GetDefaultChannelWidth(standard, static_cast<WifiPhyBand>(band));
1238 }
1239 if (number == 0)
1240 {
1242 standard,
1243 band,
1244 prevChannelNumber);
1245 }
1246 prevChannelNumber = number;
1247 }
1248}
1249
1250void
1252{
1253 NS_LOG_FUNCTION(this);
1254
1255 m_powerRestricted = false;
1257
1258 // Update unspecified parameters with default values
1260
1261 // We need to call SetStandard if this is the first time we set a channel or we
1262 // are changing PHY band. Checking if the new PHY band is different than the
1263 // previous one covers both cases because initially the PHY band is unspecified
1264 const auto changingPhyBand = (m_channelCfg.front().band != m_band);
1265
1266 NS_ABORT_MSG_IF(IsInitialized() && m_fixedPhyBand && changingPhyBand,
1267 "Trying to change PHY band while prohibited.");
1268
1269 m_band = m_channelCfg.front().band;
1270
1271 NS_LOG_DEBUG("switching channel");
1272 std::vector<FrequencyChannelInfo> segments{};
1273 std::transform(m_channelCfg.segments.cbegin(),
1274 m_channelCfg.segments.cend(),
1275 std::back_inserter(segments),
1276 [this](const auto& segment) {
1277 return FrequencyChannelInfo{segment.number, MHz_u{0}, segment.width, m_band};
1278 });
1279 m_operatingChannel.Set(segments, m_standard);
1280 m_operatingChannel.SetPrimary20Index(m_channelCfg.front().p20Index);
1281
1282 // check that the channel width is supported
1283 if (const auto chWidth = GetChannelWidth();
1284 (m_maxRadioBw != MHz_u{0}) && (chWidth > m_maxRadioBw))
1285 {
1286 // throw an exception instead of using NS_ABORT_MSG for unit testing this code
1287 throw std::runtime_error("Attempting to set a " + std::to_string(chWidth) +
1288 " MHz channel on a station only supporting " +
1289 std::to_string(m_maxRadioBw) + " MHz operation");
1290 }
1291
1292 if (changingPhyBand)
1293 {
1294 ConfigureStandard(m_standard);
1295 }
1296
1297 FinalizeChannelSwitch();
1298
1299 if (IsInitialized())
1300 {
1301 // notify channel switching
1302 m_state->SwitchToChannelSwitching(GetChannelSwitchDelay());
1303 /*
1304 * Needed here to be able to correctly sensed the medium for the first
1305 * time after the switching. The actual switching is not performed until
1306 * after m_channelSwitchDelay. Packets received during the switching
1307 * state are added to the event list and are employed later to figure
1308 * out the state of the medium after the switching.
1309 */
1310 SwitchMaybeToCcaBusy(nullptr);
1311 }
1312}
1313
1314void
1316{
1317 NS_LOG_FUNCTION(this << +antennas);
1318 NS_ASSERT_MSG(antennas > 0 && antennas <= 8, "unsupported number of antennas");
1319 m_numberOfAntennas = antennas;
1320 if (m_interference)
1321 {
1322 m_interference->SetNumberOfReceiveAntennas(antennas);
1323 }
1324}
1325
1326uint8_t
1328{
1329 return m_numberOfAntennas;
1330}
1331
1332void
1334{
1335 NS_ASSERT(streams <= GetNumberOfAntennas());
1336 bool changed = (m_txSpatialStreams != streams);
1337 m_txSpatialStreams = streams;
1338 if (changed)
1339 {
1340 auto phyEntity = m_phyEntities.find(WIFI_MOD_CLASS_HT);
1341 if (phyEntity != m_phyEntities.end())
1343 std::shared_ptr<HtPhy> htPhy = std::dynamic_pointer_cast<HtPhy>(phyEntity->second);
1344 if (htPhy)
1345 {
1346 htPhy->SetMaxSupportedNss(
1347 m_txSpatialStreams); // this is essential to have the right MCSs configured
1348 }
1349
1350 if (!m_capabilitiesChangedCallback.IsNull())
1351 {
1353 }
1354 }
1355 }
1356}
1357
1358uint8_t
1363
1364void
1366{
1367 NS_ASSERT(streams <= GetNumberOfAntennas());
1368 bool changed = (m_rxSpatialStreams != streams);
1369 m_rxSpatialStreams = streams;
1370 if (changed && !m_capabilitiesChangedCallback.IsNull())
1371 {
1373 }
1374}
1375
1376uint8_t
1381
1382std::list<uint8_t>
1384{
1385 std::list<uint8_t> list;
1386 for (const auto& phyEntity : m_phyEntities)
1387 {
1388 std::shared_ptr<HtPhy> htPhy = std::dynamic_pointer_cast<HtPhy>(phyEntity.second);
1389 if (htPhy)
1390 {
1391 list.emplace_back(htPhy->GetBssMembershipSelector());
1392 }
1393 }
1394 return list;
1395}
1396
1397void
1398WifiPhy::SetSleepMode(bool forceSleepInRx)
1399{
1400 NS_LOG_FUNCTION(this);
1401 m_powerRestricted = false;
1403 switch (m_state->GetState())
1404 {
1405 case WifiPhyState::TX:
1406 NS_LOG_DEBUG("setting sleep mode postponed until end of current transmission");
1408 break;
1409 case WifiPhyState::RX:
1410 NS_LOG_DEBUG("setting sleep mode"
1411 << (forceSleepInRx ? "" : "postponed until end of current reception"));
1412 if (forceSleepInRx)
1413 {
1415 m_state->SwitchToSleep();
1416 }
1417 else
1418 {
1420 }
1421 break;
1423 NS_LOG_DEBUG("setting sleep mode postponed until end of channel switching");
1425 break;
1427 case WifiPhyState::IDLE:
1428 NS_LOG_DEBUG("setting sleep mode");
1429 // The PHY object may be in CCA_BUSY state because it is receiving a preamble. Cancel
1430 // preamble events before switching to sleep state
1431 Reset();
1432 m_state->SwitchToSleep();
1433 break;
1435 NS_LOG_DEBUG("already in sleep mode");
1436 break;
1437 default:
1438 NS_ASSERT(false);
1439 break;
1440 }
1441}
1442
1443void
1445{
1446 NS_LOG_FUNCTION(this);
1447 m_powerRestricted = false;
1449 Reset();
1450 m_state->SwitchToOff();
1451}
1452
1453void
1455{
1456 NS_LOG_FUNCTION(this);
1457 switch (m_state->GetState())
1458 {
1459 case WifiPhyState::TX:
1460 case WifiPhyState::RX:
1461 case WifiPhyState::IDLE:
1464 NS_LOG_DEBUG("not in sleep mode, there is nothing to resume");
1465 break;
1466 }
1467 case WifiPhyState::SLEEP: {
1468 NS_LOG_DEBUG("resuming from sleep mode");
1469 m_state->SwitchFromSleep();
1471 break;
1472 }
1473 default: {
1474 NS_ASSERT(false);
1475 break;
1476 }
1477 }
1478}
1479
1480void
1482{
1483 NS_LOG_FUNCTION(this);
1484 switch (m_state->GetState())
1485 {
1486 case WifiPhyState::TX:
1487 case WifiPhyState::RX:
1488 case WifiPhyState::IDLE:
1491 case WifiPhyState::SLEEP: {
1492 NS_LOG_DEBUG("not in off mode, there is nothing to resume");
1493 break;
1494 }
1495 case WifiPhyState::OFF: {
1496 NS_LOG_DEBUG("resuming from off mode");
1497 m_state->SwitchFromOff();
1499 break;
1500 }
1501 default: {
1502 NS_ASSERT(false);
1503 break;
1504 }
1505 }
1506}
1507
1508Time
1513
1514Time
1516{
1517 return MicroSeconds(4);
1518}
1519
1520Time
1522 const WifiTxVector& txVector,
1523 WifiPhyBand band,
1524 MpduType mpdutype,
1525 uint16_t staId)
1526{
1527 uint32_t totalAmpduSize;
1528 double totalAmpduNumSymbols;
1529 return GetPayloadDuration(size,
1530 txVector,
1531 band,
1532 mpdutype,
1533 false,
1534 totalAmpduSize,
1535 totalAmpduNumSymbols,
1536 staId);
1537}
1538
1539Time
1541 const WifiTxVector& txVector,
1542 WifiPhyBand band,
1543 MpduType mpdutype,
1544 bool incFlag,
1545 uint32_t& totalAmpduSize,
1546 double& totalAmpduNumSymbols,
1547 uint16_t staId)
1548{
1549 return GetStaticPhyEntity(txVector.GetModulationClass())
1550 ->GetPayloadDuration(size,
1551 txVector,
1552 band,
1553 mpdutype,
1554 incFlag,
1555 totalAmpduSize,
1556 totalAmpduNumSymbols,
1557 staId);
1558}
1559
1560Time
1562{
1563 return GetStaticPhyEntity(txVector.GetModulationClass())
1564 ->CalculatePhyPreambleAndHeaderDuration(txVector);
1565}
1566
1567Time
1569 const WifiTxVector& txVector,
1570 WifiPhyBand band,
1571 uint16_t staId)
1572{
1573 NS_ASSERT(txVector.IsValid(band));
1574 Time duration = CalculatePhyPreambleAndHeaderDuration(txVector) +
1575 GetPayloadDuration(size, txVector, band, NORMAL_MPDU, staId);
1576 NS_ASSERT(duration.IsStrictlyPositive());
1577 return duration;
1578}
1579
1580Time
1582 const WifiTxVector& txVector,
1583 WifiPhyBand band)
1584{
1585 return CalculateTxDuration(GetWifiConstPsduMap(psdu, txVector), txVector, band);
1586}
1587
1588Time
1590 const WifiTxVector& txVector,
1591 WifiPhyBand band)
1592{
1593 NS_ASSERT(txVector.IsValid(band));
1594 return GetStaticPhyEntity(txVector.GetModulationClass())
1595 ->CalculateTxDuration(psduMap, txVector, band);
1596}
1597
1600{
1601 return GetStaticPhyEntity(modulation)->GetMaxPsduSize();
1602}
1603
1604void
1606{
1607 if (!m_phyTxBeginTrace.IsEmpty())
1608 {
1609 for (const auto& psdu : psdus)
1610 {
1611 for (auto& mpdu : *PeekPointer(psdu.second))
1612 {
1613 m_phyTxBeginTrace(mpdu->GetProtocolDataUnit(), txPower);
1614 }
1615 }
1616 }
1617}
1618
1619void
1621{
1622 if (!m_phyTxEndTrace.IsEmpty())
1623 {
1624 for (const auto& psdu : psdus)
1625 {
1626 for (auto& mpdu : *PeekPointer(psdu.second))
1627 {
1628 m_phyTxEndTrace(mpdu->GetProtocolDataUnit());
1629 }
1630 }
1631 }
1632}
1633
1634void
1636{
1637 if (!m_phyTxDropTrace.IsEmpty())
1638 {
1639 for (auto& mpdu : *PeekPointer(psdu))
1640 {
1641 m_phyTxDropTrace(mpdu->GetProtocolDataUnit());
1642 }
1643 }
1644}
1645
1646void
1648{
1649 if (psdu && !m_phyRxBeginTrace.IsEmpty())
1650 {
1651 for (auto& mpdu : *PeekPointer(psdu))
1652 {
1653 m_phyRxBeginTrace(mpdu->GetProtocolDataUnit(), rxPowersW);
1654 }
1655 }
1656}
1657
1658void
1660{
1661 if (psdu && !m_phyRxEndTrace.IsEmpty())
1662 {
1663 for (auto& mpdu : *PeekPointer(psdu))
1664 {
1665 m_phyRxEndTrace(mpdu->GetProtocolDataUnit());
1666 }
1667 }
1668}
1669
1670void
1672{
1673 if (psdu && !m_phyRxDropTrace.IsEmpty())
1674 {
1675 for (auto& mpdu : *PeekPointer(psdu))
1676 {
1677 m_phyRxDropTrace(mpdu->GetProtocolDataUnit(), reason);
1678 }
1679 }
1680}
1681
1682void
1688
1689void
1691 MHz_u channelFreq,
1692 const WifiTxVector& txVector,
1693 SignalNoiseDbm signalNoise,
1694 const std::vector<bool>& statusPerMpdu,
1695 uint16_t staId)
1696{
1697 MpduInfo aMpdu;
1698 if (psdu->IsAggregate())
1699 {
1700 // Expand A-MPDU
1701 NS_ASSERT_MSG(txVector.IsAggregation(),
1702 "TxVector with aggregate flag expected here according to PSDU");
1704 size_t nMpdus = psdu->GetNMpdus();
1705 NS_ASSERT_MSG(statusPerMpdu.size() == nMpdus, "Should have one reception status per MPDU");
1706 if (!m_phyMonitorSniffRxTrace.IsEmpty())
1707 {
1708 aMpdu.type = (psdu->IsSingle()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1709 for (size_t i = 0; i < nMpdus;)
1710 {
1711 if (statusPerMpdu.at(i)) // packet received without error, hand over to sniffer
1712 {
1713 m_phyMonitorSniffRxTrace(psdu->GetAmpduSubframe(i),
1714 static_cast<uint16_t>(channelFreq),
1715 txVector,
1716 aMpdu,
1717 signalNoise,
1718 staId);
1719 }
1720 ++i;
1721 aMpdu.type =
1722 (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1723 }
1724 }
1725 }
1726 else
1727 {
1728 NS_ASSERT_MSG(statusPerMpdu.size() == 1,
1729 "Should have one reception status for normal MPDU");
1730 if (!m_phyMonitorSniffRxTrace.IsEmpty())
1731 {
1732 aMpdu.type = NORMAL_MPDU;
1733 m_phyMonitorSniffRxTrace(psdu->GetPacket(),
1734 static_cast<uint16_t>(channelFreq),
1735 txVector,
1736 aMpdu,
1737 signalNoise,
1738 staId);
1739 }
1740 }
1741}
1742
1743void
1745 MHz_u channelFreq,
1746 const WifiTxVector& txVector,
1747 uint16_t staId)
1748{
1749 MpduInfo aMpdu;
1750 if (psdu->IsAggregate())
1751 {
1752 // Expand A-MPDU
1753 NS_ASSERT_MSG(txVector.IsAggregation(),
1754 "TxVector with aggregate flag expected here according to PSDU");
1756 if (!m_phyMonitorSniffTxTrace.IsEmpty())
1757 {
1758 size_t nMpdus = psdu->GetNMpdus();
1759 aMpdu.type = (psdu->IsSingle()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1760 for (size_t i = 0; i < nMpdus;)
1761 {
1762 m_phyMonitorSniffTxTrace(psdu->GetAmpduSubframe(i),
1763 channelFreq,
1764 txVector,
1765 aMpdu,
1766 staId);
1767 ++i;
1768 aMpdu.type =
1769 (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1770 }
1771 }
1772 }
1773 else
1774 {
1775 if (!m_phyMonitorSniffTxTrace.IsEmpty())
1776 {
1777 aMpdu.type = NORMAL_MPDU;
1778 m_phyMonitorSniffTxTrace(psdu->GetPacket(), channelFreq, txVector, aMpdu, staId);
1779 }
1780 }
1781}
1782
1783std::optional<Time>
1785{
1786 for (const auto& [modClass, phyEntity] : m_phyEntities)
1787 {
1788 if (auto remTime = phyEntity->GetTimeToPreambleDetectionEnd())
1789 {
1790 return remTime;
1791 }
1792 }
1793 return std::nullopt;
1794}
1795
1796std::optional<Time>
1797WifiPhy::GetTimeToMacHdrEnd(uint16_t staId) const
1798{
1799 for (auto& [modClass, phyEntity] : m_phyEntities)
1800 {
1801 if (auto remTime = phyEntity->GetTimeToMacHdrEnd(staId))
1802 {
1803 return remTime;
1804 }
1805 }
1806 return std::nullopt;
1807}
1808
1811{
1812 return GetStaticPhyEntity(txVector.GetModulationClass())->GetWifiConstPsduMap(psdu, txVector);
1813}
1814
1815void
1817{
1818 NS_LOG_FUNCTION(this << *psdu << txVector);
1819 Send(GetWifiConstPsduMap(psdu, txVector), txVector);
1820}
1821
1822void
1823WifiPhy::Send(const WifiConstPsduMap& psdus, const WifiTxVector& txVector)
1824{
1825 NS_LOG_FUNCTION(this << psdus << txVector);
1826 /* Transmission can happen if:
1827 * - we are syncing on a packet. It is the responsibility of the
1828 * MAC layer to avoid doing this but the PHY does nothing to
1829 * prevent it.
1830 * - we are idle
1831 */
1832 NS_ASSERT(!m_state->IsStateTx() && !m_state->IsStateSwitching());
1833 NS_ASSERT(m_endTxEvent.IsExpired());
1834
1835 if (!txVector.IsValid(m_band))
1836 {
1837 NS_FATAL_ERROR("TX-VECTOR is invalid!");
1838 }
1839
1840 uint8_t nss = 0;
1841 if (txVector.IsMu())
1842 {
1843 // We do not support mixed OFDMA and MU-MIMO
1844 if (txVector.IsDlMuMimo())
1845 {
1846 nss = txVector.GetNssTotal();
1847 }
1848 else
1849 {
1850 nss = txVector.GetNssMax();
1851 }
1852 }
1853 else
1854 {
1855 nss = txVector.GetNss();
1856 }
1857
1859 {
1860 NS_FATAL_ERROR("Unsupported number of spatial streams!");
1861 }
1862
1863 if (m_state->IsStateSleep())
1864 {
1865 NS_LOG_DEBUG("Dropping packet because in sleep mode");
1866 for (const auto& psdu : psdus)
1867 {
1868 NotifyTxDrop(psdu.second);
1869 }
1870 return;
1871 }
1872
1873 const auto txDuration = CalculateTxDuration(psdus, txVector, GetPhyBand());
1874
1875 if (const auto timeToPreambleDetectionEnd = GetTimeToPreambleDetectionEnd();
1876 timeToPreambleDetectionEnd && !m_currentEvent)
1877 {
1878 // PHY is in the initial few microseconds during which the
1879 // start of RX has occurred but the preamble detection period
1880 // has not elapsed
1882 }
1883 else if (timeToPreambleDetectionEnd || m_currentEvent)
1884 {
1886 }
1887
1889 {
1890 NS_LOG_DEBUG("Transmitting with power restriction for " << txDuration.As(Time::NS));
1891 }
1892 else
1893 {
1894 NS_LOG_DEBUG("Transmitting without power restriction for " << txDuration.As(Time::NS));
1895 }
1896
1897 if (m_state->GetState() == WifiPhyState::OFF)
1898 {
1899 NS_LOG_DEBUG("Transmission canceled because device is OFF");
1900 return;
1901 }
1902
1903 auto ppdu = GetPhyEntity(txVector.GetModulationClass())->BuildPpdu(psdus, txVector, txDuration);
1904 m_previouslyRxPpduUid = UINT64_MAX; // reset (after creation of PPDU) to use it only once
1905
1906 const auto txPower = DbmToW(GetTxPowerForTransmission(ppdu) + GetTxGain());
1907 NotifyTxBegin(psdus, txPower);
1908 if (!m_phyTxPsduBeginTrace.IsEmpty())
1909 {
1910 m_phyTxPsduBeginTrace(psdus, txVector, txPower);
1911 }
1912 for (const auto& psdu : psdus)
1913 {
1914 NotifyMonitorSniffTx(psdu.second, GetFrequency(), txVector, psdu.first);
1915 }
1916 m_state->SwitchToTx(txDuration, psdus, GetPower(txVector.GetTxPowerLevel()), txVector);
1917
1919 m_wifiRadioEnergyModel->GetMaximumTimeInState(WifiPhyState::TX) < txDuration)
1920 {
1921 ppdu->SetTruncatedTx();
1922 }
1923
1924 m_endTxEvent =
1925 Simulator::Schedule(txDuration, &WifiPhy::TxDone, this, psdus); // TODO: fix for MU
1926
1927 StartTx(ppdu);
1928 ppdu->ResetTxVector();
1929
1931 m_powerRestricted = false;
1932}
1933
1934void
1936{
1937 NS_LOG_FUNCTION(this << psdus);
1938 NotifyTxEnd(psdus);
1939 Reset();
1940 // we might have received signals during TX
1942}
1943
1944uint64_t
1949
1950void
1956
1957void
1959{
1960 NS_LOG_FUNCTION(this);
1963 {
1965 }
1966 m_currentEvent = nullptr;
1967 for (auto& phyEntity : m_phyEntities)
1968 {
1969 phyEntity.second->CancelAllEvents();
1970 }
1971 m_endPhyRxEvent.Cancel();
1972 m_endTxEvent.Cancel();
1973}
1974
1975void
1977 RxPowerWattPerChannelBand& rxPowersW,
1978 Time rxDuration)
1979{
1980 NS_LOG_FUNCTION(this << ppdu << rxDuration);
1981 WifiModulationClass modulation = ppdu->GetModulation();
1983 if (auto it = m_phyEntities.find(modulation);
1984 it != m_phyEntities.end() && modulation <= m_maxModClassSupported)
1985 {
1986 it->second->StartReceivePreamble(ppdu, rxPowersW, rxDuration);
1987 }
1988 else
1989 {
1990 // TODO find a fallback PHY for receiving the PPDU (e.g. 11a for 11ax due to preamble
1991 // structure)
1992 NS_LOG_DEBUG("Unsupported modulation received (" << modulation << "), consider as noise");
1993 m_interference->Add(ppdu, rxDuration, rxPowersW, GetCurrentFrequencyRange());
1995 }
1996}
1997
1998std::optional<std::reference_wrapper<const WifiTxVector>>
2000{
2001 if (m_endPhyRxEvent.IsPending())
2002 {
2003 NS_ASSERT_MSG(m_currentEvent, "No current event while receiving PHY header");
2004 return std::cref(m_currentEvent->GetPpdu()->GetTxVector());
2005 }
2006 return std::nullopt;
2007}
2008
2009void
2011{
2012 NS_LOG_FUNCTION(this);
2014 {
2015 m_powerRestricted = false;
2016 }
2017}
2018
2019void
2025
2026bool
2028{
2029 for (const auto& phyEntity : m_phyEntities)
2030 {
2031 if (phyEntity.second->IsModeSupported(mode))
2032 {
2033 return true;
2034 }
2035 }
2036 return false;
2037}
2038
2041{
2042 // Start from oldest standards and move up (guaranteed by fact that WifModulationClass is
2043 // ordered)
2044 for (const auto& phyEntity : m_phyEntities)
2045 {
2046 for (const auto& mode : *(phyEntity.second))
2047 {
2048 return mode;
2049 }
2050 }
2051 NS_ASSERT_MSG(false, "Should have found at least one default mode");
2052 return WifiMode();
2053}
2054
2055bool
2056WifiPhy::IsMcsSupported(WifiModulationClass modulation, uint8_t mcs) const
2057{
2058 const auto phyEntity = m_phyEntities.find(modulation);
2059 if (phyEntity == m_phyEntities.end())
2060 {
2061 return false;
2062 }
2063 return phyEntity->second->IsMcsSupported(mcs);
2064}
2065
2066std::list<WifiMode>
2068{
2069 std::list<WifiMode> list;
2070 for (const auto& phyEntity : m_phyEntities)
2071 {
2072 if (!phyEntity.second->HandlesMcsModes()) // to exclude MCSs from search
2073 {
2074 for (const auto& mode : *(phyEntity.second))
2075 {
2076 list.emplace_back(mode);
2077 }
2078 }
2079 }
2080 return list;
2081}
2082
2083std::list<WifiMode>
2085{
2086 std::list<WifiMode> list;
2087 const auto phyEntity = m_phyEntities.find(modulation);
2088 if (phyEntity != m_phyEntities.end())
2089 {
2090 if (!phyEntity->second->HandlesMcsModes()) // to exclude MCSs from search
2091 {
2092 for (const auto& mode : *(phyEntity->second))
2093 {
2094 list.emplace_back(mode);
2095 }
2096 }
2097 }
2098 return list;
2099}
2100
2101uint16_t
2103{
2104 uint16_t numMcs = 0;
2105 for (const auto& phyEntity : m_phyEntities)
2106 {
2107 if (phyEntity.second->HandlesMcsModes()) // to exclude non-MCS modes from search
2108 {
2109 numMcs += phyEntity.second->GetNumModes();
2110 }
2111 }
2112 return numMcs;
2113}
2114
2115std::list<WifiMode>
2117{
2118 std::list<WifiMode> list;
2119 for (const auto& phyEntity : m_phyEntities)
2120 {
2121 if (phyEntity.second->HandlesMcsModes()) // to exclude non-MCS modes from search
2122 {
2123 for (const auto& mode : *(phyEntity.second))
2124 {
2125 list.emplace_back(mode);
2126 }
2127 }
2128 }
2129 return list;
2130}
2131
2132std::list<WifiMode>
2134{
2135 std::list<WifiMode> list;
2136 auto phyEntity = m_phyEntities.find(modulation);
2137 if (phyEntity != m_phyEntities.end())
2138 {
2139 if (phyEntity->second->HandlesMcsModes()) // to exclude non-MCS modes from search
2140 {
2141 for (const auto& mode : *(phyEntity->second))
2142 {
2143 list.emplace_back(mode);
2144 }
2145 }
2146 }
2147 return list;
2148}
2149
2151WifiPhy::GetMcs(WifiModulationClass modulation, uint8_t mcs) const
2152{
2153 NS_ASSERT_MSG(IsMcsSupported(modulation, mcs), "Unsupported MCS");
2154 return m_phyEntities.at(modulation)->GetMcs(mcs);
2155}
2156
2157bool
2159{
2160 return m_state->IsStateCcaBusy();
2161}
2162
2163bool
2165{
2166 return m_state->IsStateIdle();
2167}
2168
2169bool
2171{
2172 return m_state->IsStateRx();
2173}
2174
2175bool
2177{
2178 return m_state->IsStateTx();
2179}
2180
2181bool
2183{
2184 return m_state->IsStateSwitching();
2185}
2186
2187bool
2189{
2190 return m_state->IsStateSleep();
2191}
2192
2193bool
2195{
2196 return m_state->IsStateOff();
2197}
2198
2199Time
2201{
2202 return m_state->GetDelayUntilIdle();
2203}
2204
2205Time
2207{
2208 return m_state->GetLastRxStartTime();
2209}
2210
2211Time
2213{
2214 return m_state->GetLastRxEndTime();
2215}
2216
2217void
2219{
2220 NS_LOG_FUNCTION(this);
2221 GetLatestPhyEntity()->SwitchMaybeToCcaBusy(ppdu);
2222}
2223
2224void
2226{
2227 NS_LOG_FUNCTION(this << duration);
2228 GetLatestPhyEntity()->NotifyCcaBusy(ppdu, duration, WIFI_CHANLIST_PRIMARY);
2229}
2230
2231void
2233{
2234 NS_LOG_FUNCTION(this << reason);
2235 if (reason != OBSS_PD_CCA_RESET ||
2236 m_currentEvent) // Otherwise abort has already been called previously
2237 {
2238 if (reason == SIGNAL_DETECTION_ABORTED_BY_TX)
2239 {
2240 for (auto signalDetectEvent : m_currentPreambleEvents)
2241 {
2242 NotifyRxPpduDrop(signalDetectEvent.second->GetPpdu(),
2244 }
2245 }
2246 for (auto& phyEntity : m_phyEntities)
2247 {
2248 phyEntity.second->CancelAllEvents();
2249 }
2250 m_endPhyRxEvent.Cancel();
2252 if (!m_currentEvent)
2253 {
2254 return;
2255 }
2256 NotifyRxPpduDrop(m_currentEvent->GetPpdu(), reason);
2257 if (reason == OBSS_PD_CCA_RESET)
2258 {
2259 m_state->SwitchFromRxAbort(GetChannelWidth());
2260 }
2261 if (reason == RECEPTION_ABORTED_BY_TX)
2262 {
2263 Reset();
2264 }
2265 else
2266 {
2267 for (auto it = m_currentPreambleEvents.begin(); it != m_currentPreambleEvents.end();
2268 ++it)
2269 {
2270 if (it->second == m_currentEvent)
2271 {
2272 it = m_currentPreambleEvents.erase(it);
2273 break;
2274 }
2275 }
2276 m_currentEvent = nullptr;
2277 }
2278 }
2279}
2280
2281void
2282WifiPhy::ResetCca(bool powerRestricted, dBm_u txPowerMaxSiso, dBm_u txPowerMaxMimo)
2283{
2284 NS_LOG_FUNCTION(this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2285 // This method might be called multiple times when receiving TB PPDUs with a BSS color
2286 // different than the one of the receiver. The first time this method is called, the call
2287 // to AbortCurrentReception sets m_currentEvent to 0. Therefore, we need to check whether
2288 // m_currentEvent is not 0 before executing the instructions below.
2289 if (m_currentEvent)
2290 {
2291 m_powerRestricted = powerRestricted;
2292 m_txPowerMaxSiso = txPowerMaxSiso;
2293 m_txPowerMaxMimo = txPowerMaxMimo;
2294 NS_ASSERT((m_currentEvent->GetEndTime() - Simulator::Now()).IsPositive());
2297 this);
2299 this,
2300 OBSS_PD_CCA_RESET); // finish processing field first
2301 }
2302}
2303
2304dBm_u
2306{
2307 NS_LOG_FUNCTION(this << m_powerRestricted << ppdu);
2308 const auto& txVector = ppdu->GetTxVector();
2309 // Get transmit power before antenna gain
2310 dBm_u txPower;
2311 if (!m_powerRestricted)
2312 {
2313 txPower = GetPower(txVector.GetTxPowerLevel());
2314 }
2315 else
2316 {
2317 if (txVector.GetNssMax() > 1 || txVector.GetNssTotal() > 1)
2318 {
2319 txPower = std::min(m_txPowerMaxMimo, GetPower(txVector.GetTxPowerLevel()));
2320 }
2321 else
2322 {
2323 txPower = std::min(m_txPowerMaxSiso, GetPower(txVector.GetTxPowerLevel()));
2324 }
2325 }
2326
2327 // Apply power density constraint on EIRP
2328 const auto channelWidth = ppdu->GetTxChannelWidth();
2329 dBm_per_MHz_u txPowerDbmPerMhz =
2330 (txPower + GetTxGain()) - RatioToDb(channelWidth); // account for antenna gain since EIRP
2331 NS_LOG_INFO("txPower=" << txPower << "dBm with txPowerDbmPerMhz=" << txPowerDbmPerMhz
2332 << " over " << channelWidth << " MHz");
2333 txPower = std::min(txPowerDbmPerMhz, m_powerDensityLimit) + RatioToDb(channelWidth);
2334 txPower -= GetTxGain(); // remove antenna gain since will be added right afterwards
2335 NS_LOG_INFO("txPower=" << txPower
2336 << "dBm after applying m_powerDensityLimit=" << m_powerDensityLimit);
2337 return txPower;
2338}
2339
2342{
2343 // TODO: wrapper. See if still needed
2344 return GetPhyEntityForPpdu(ppdu)->GetAddressedPsduInPpdu(ppdu);
2345}
2346
2347int64_t
2349{
2350 NS_LOG_FUNCTION(this << stream);
2351 int64_t currentStream = stream;
2352 m_random->SetStream(currentStream++);
2353 currentStream += m_interference->GetErrorRateModel()->AssignStreams(currentStream);
2354 return (currentStream - stream);
2355}
2356
2357std::ostream&
2358operator<<(std::ostream& os, RxSignalInfo rxSignalInfo)
2359{
2360 os << "SNR:" << RatioToDb(rxSignalInfo.snr) << " dB"
2361 << ", RSSI:" << rxSignalInfo.rssi << " dBm";
2362 return os;
2363}
2364
2365uint8_t
2366WifiPhy::GetPrimaryChannelNumber(MHz_u primaryChannelWidth) const
2367{
2368 return m_operatingChannel.GetPrimaryChannelNumber(primaryChannelWidth, m_standard);
2369}
2370
2371Hz_u
2373{
2374 Hz_u subcarrierSpacing{0};
2375 switch (GetStandard())
2376 {
2382 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING;
2383 break;
2385 if (GetChannelWidth() == MHz_u{5})
2386 {
2387 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING / 4;
2388 }
2389 else
2390 {
2391 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING / 2;
2392 }
2393 break;
2396 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING_HE;
2397 break;
2398 default:
2399 NS_FATAL_ERROR("Standard unknown: " << GetStandard());
2400 break;
2401 }
2402 return subcarrierSpacing;
2403}
2404
2405} // namespace ns3
AttributeValue implementation for Boolean.
Definition boolean.h:26
Callback template class.
Definition callback.h:422
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
Hold variables of type enum.
Definition enum.h:52
Keep track of the current position and velocity of an object.
Object()
Constructor.
Definition object.cc:96
bool IsInitialized() const
Check if the object has been initialized.
Definition object.cc:240
AttributeValue implementation for Pointer.
Definition pointer.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:561
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition simulator.h:595
Hold variables of type string.
Definition string.h:45
Simulation virtual time values and global simulation resolution.
Definition nstime.h:96
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
Definition nstime.h:342
@ NS
nanosecond
Definition nstime.h:110
a unique identifier for an interface.
Definition type-id.h:49
@ ATTR_GET
The attribute can be read.
Definition type-id.h:54
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
Definition type-id.h:56
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
represent a single transmission mode
Definition wifi-mode.h:38
WifiModulationClass GetModulationClass() const
Definition wifi-mode.cc:172
static TypeId GetTypeId()
Get the type ID.
Definition wifi-phy.cc:59
void SetNumberOfAntennas(uint8_t antennas)
Definition wifi-phy.cc:1315
WifiChannelConfig m_channelCfg
Store operating channel config until initialization.
Definition wifi-phy.h:1651
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Definition wifi-phy.h:1390
void AddPhyEntity(WifiModulationClass modulation, std::shared_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:819
static void SetUnspecifiedChannelParams(WifiChannelConfig &channelCfg, WifiStandard standard)
The ChannelSettings attribute allows users to leave some parameters (e.g., the channel width) unspeci...
Definition wifi-phy.cc:1226
bool IsStateTx() const
Definition wifi-phy.cc:2176
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
Definition wifi-phy.h:1689
dBm_u m_ccaEdThreshold
Clear channel assessment (CCA) energy detection (ED) threshold.
Definition wifi-phy.h:1660
dBm_u GetTxPowerStart() const
Return the minimum available transmission power level.
Definition wifi-phy.cc:579
WifiModulationClass GetMaxModulationClassSupported() const
Definition wifi-phy.cc:991
bool IsStateIdle() const
Definition wifi-phy.cc:2164
void SetRxGain(dB_u gain)
Sets the reception gain.
Definition wifi-phy.cc:624
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
Definition wifi-phy.cc:687
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
Definition wifi-phy.h:1679
bool IsStateCcaBusy() const
Definition wifi-phy.cc:2158
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:1816
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Definition wifi-phy.h:1389
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
Definition wifi-phy.h:1693
void SetRxNoiseFigure(dB_u noiseFigure)
Sets the RX loss in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
Definition wifi-phy.cc:561
void Configure80211ax()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard.
Definition wifi-phy.cc:961
void SetRxSensitivity(dBm_u threshold)
Sets the receive sensitivity threshold.
Definition wifi-phy.cc:522
Time m_channelSwitchDelay
Time required to switch between channel.
Definition wifi-phy.h:1684
dB_u GetTxGain() const
Return the transmission gain.
Definition wifi-phy.cc:618
void SetTxPowerEnd(dBm_u end)
Sets the maximum available transmission power level.
Definition wifi-phy.cc:585
std::map< WifiModulationClass, std::shared_ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
Definition wifi-phy.h:1425
dBm_per_MHz_u m_powerDensityLimit
the power density limit
Definition wifi-phy.h:1669
void NotifyCcaBusy(const Ptr< const WifiPpdu > ppdu, Time duration)
Notify PHY state helper to switch to CCA busy state,.
Definition wifi-phy.cc:2225
void NotifyMonitorSniffTx(Ptr< const WifiPsdu > psdu, MHz_u channelFreq, const 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:1744
WifiPhyOperatingChannel m_operatingChannel
Operating channel.
Definition wifi-phy.h:1652
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:1543
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
Definition wifi-phy.cc:696
bool m_channelAccessRequested
Flag if channels access has been requested (used for OBSS_PD SR)
Definition wifi-phy.h:1674
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:1521
Time GetSlot() const
Return the slot duration for this PHY.
Definition wifi-phy.cc:850
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
Definition wifi-phy.cc:1365
static std::map< WifiModulationClass, std::shared_ptr< PhyEntity > > & GetStaticPhyEntities()
Definition wifi-phy.cc:474
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:2341
std::shared_ptr< PhyEntity > GetLatestPhyEntity() const
Get the latest PHY entity supported by this PHY instance.
Definition wifi-phy.cc:784
void Configure80211g()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
Definition wifi-phy.cc:897
uint8_t GetPrimary20Index() const
Definition wifi-phy.cc:1093
dBm_u m_rxSensitivity
Receive sensitivity threshold.
Definition wifi-phy.h:1659
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:1402
uint8_t GetNumberOfAntennas() const
Definition wifi-phy.cc:1327
Time m_slot
Slot duration.
Definition wifi-phy.h:1656
dBm_u GetRxSensitivity() const
Return the receive sensitivity threshold.
Definition wifi-phy.cc:529
Time GetDelayUntilIdle()
Definition wifi-phy.cc:2200
MHz_u m_maxRadioBw
Maximum radio bandwidth.
Definition wifi-phy.h:1686
bool GetShortPhyPreambleSupported() const
Return whether short PHY preamble is supported.
Definition wifi-phy.cc:644
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS) for this PHY.
Definition wifi-phy.cc:832
std::list< uint8_t > GetBssMembershipSelectorList() const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition wifi-phy.cc:1383
std::shared_ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class.
Definition wifi-phy.cc:769
void Configure80211n()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
Definition wifi-phy.cc:938
EventId m_endPhyRxEvent
the end of PHY receive event
Definition wifi-phy.h:1397
dBm_u m_ccaSensitivityThreshold
Clear channel assessment (CCA) modulation and coding rate sensitivity threshold.
Definition wifi-phy.h:1661
void Configure80211be()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11be standard.
Definition wifi-phy.cc:976
void NotifyRxDrop(Ptr< const WifiPsdu > psdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxDrop trace.
Definition wifi-phy.cc:1671
bool IsStateRx() const
Definition wifi-phy.cc:2170
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:2056
Time GetSifs() const
Return the Short Interframe Space (SIFS) for this PHY.
Definition wifi-phy.cc:838
dBm_u m_txPowerMaxMimo
MIMO maximum transmit power due to OBSS PD SR power restriction.
Definition wifi-phy.h:1673
bool m_notifyRxMacHeaderEnd
whether the PHY is capable of notifying MAC header RX end
Definition wifi-phy.h:1696
Hz_u GetSubcarrierSpacing() const
Definition wifi-phy.cc:2372
MHz_u GetFrequency() const
Definition wifi-phy.cc:1075
Ptr< MobilityModel > GetMobility() const
Return the mobility model this PHY is associated with.
Definition wifi-phy.cc:668
uint16_t GetNMcs() const
Definition wifi-phy.cc:2102
void SetSleepMode(bool forceSleepWhileInRx=false)
Put in sleep mode.
Definition wifi-phy.cc:1398
void ResumeFromSleep()
Resume from sleep mode.
Definition wifi-phy.cc:1454
void SetTxPowerStart(dBm_u start)
Sets the minimum available transmission power level.
Definition wifi-phy.cc:572
static Time GetPreambleDetectionDuration()
Definition wifi-phy.cc:1509
void Configure80211p()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11p standard.
Definition wifi-phy.cc:910
dBm_u m_txPowerEnd
Maximum transmission power.
Definition wifi-phy.h:1667
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted.
Definition wifi-phy.cc:2232
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
Definition wifi-phy.h:1691
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition wifi-phy.h:1586
void NotifyRxBegin(Ptr< const WifiPsdu > psdu, const RxPowerWattPerChannelBand &rxPowersW)
Public method used to fire a PhyRxBegin trace.
Definition wifi-phy.cc:1647
Time GetChannelSwitchDelay() const
Definition wifi-phy.cc:748
void SetTxGain(dB_u gain)
Sets the transmission gain.
Definition wifi-phy.cc:611
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
Definition wifi-phy.cc:1333
void NotifyTxBegin(const WifiConstPsduMap &psdus, Watt_u txPower)
Public method used to fire a PhyTxBegin trace.
Definition wifi-phy.cc:1605
Time m_sifs
Short Interframe Space (SIFS) duration.
Definition wifi-phy.h:1655
void SetReceiveErrorCallback(RxErrorCallback callback)
Definition wifi-phy.cc:493
TracedCallback< Ptr< const WifiPpdu >, const WifiTxVector & > m_signalTransmissionCb
Signal Transmission callback.
Definition wifi-phy.h:1428
void NotifyMonitorSniffRx(Ptr< const WifiPsdu > psdu, MHz_u channelFreq, const WifiTxVector &txVector, SignalNoiseDbm signalNoise, const 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:1690
dBm_u GetTxPowerEnd() const
Return the maximum available transmission power level.
Definition wifi-phy.cc:592
bool IsStateOff() const
Definition wifi-phy.cc:2194
uint8_t GetMaxSupportedRxSpatialStreams() const
Definition wifi-phy.cc:1377
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition wifi-phy.cc:997
void SetPostReceptionErrorModel(const Ptr< ErrorModel > em)
Attach a receive ErrorModel to the WifiPhy.
Definition wifi-phy.cc:704
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:2151
uint8_t m_numberOfAntennas
Number of transmitters.
Definition wifi-phy.h:1678
uint32_t m_txMpduReferenceNumber
A-MPDU reference number to identify all transmitted subframes belonging to the same received A-MPDU.
Definition wifi-phy.h:1392
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:1598
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition wifi-phy.cc:1568
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
Definition wifi-phy.cc:1599
dBm_u GetCcaEdThreshold() const
Return the CCA energy detection threshold.
Definition wifi-phy.cc:542
Ptr< WifiPhyStateHelper > GetState() const
Return the WifiPhyStateHelper of this PHY.
Definition wifi-phy.cc:481
dBm_u m_txPowerBase
Minimum transmission power.
Definition wifi-phy.h:1666
virtual Ptr< Channel > GetChannel() const =0
Return the Channel this WifiPhy is connected to.
void NotifyTxEnd(const WifiConstPsduMap &psdus)
Public method used to fire a PhyTxEnd trace.
Definition wifi-phy.cc:1620
void EndReceiveInterBss()
For HE receptions only, check and possibly modify the transmit power restriction state at the end of ...
Definition wifi-phy.cc:2010
void SetShortPhyPreambleSupported(bool preamble)
Enable or disable short PHY preamble.
Definition wifi-phy.cc:637
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:598
void SetCcaSensitivityThreshold(dBm_u threshold)
Sets the CCA sensitivity threshold.
Definition wifi-phy.cc:548
WifiPhyBand m_band
WifiPhyBand.
Definition wifi-phy.h:1650
static void AddStaticPhyEntity(WifiModulationClass modulation, std::shared_ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
Definition wifi-phy.cc:810
dBm_u m_txPowerMaxSiso
SISO maximum transmit power due to OBSS PD SR power restriction.
Definition wifi-phy.h:1672
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:1637
virtual std::optional< Time > GetTimeToMacHdrEnd(uint16_t staId) const
Get the remaining time to the end of the MAC header reception of the next MPDU being received from th...
Definition wifi-phy.cc:1797
MHz_u GetTxBandwidth(WifiMode mode, MHz_u maxAllowedBandWidth=MHz_u{ std::numeric_limits< double >::max()}) const
Get the bandwidth for a transmission occurring on the current operating channel and using the given W...
Definition wifi-phy.cc:1111
void NotifyRxPpduDrop(Ptr< const WifiPpdu > ppdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxPpduDrop trace.
Definition wifi-phy.cc:1683
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:984
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:1618
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
Definition wifi-phy.h:1694
EventId m_endTxEvent
the end of transmit event
Definition wifi-phy.h:1398
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:1810
std::list< WifiChannelConfig::TupleWithoutUnits > ChannelSegments
segments identifying an operating channel
Definition wifi-phy.h:952
void RegisterListener(const std::shared_ptr< WifiPhyListener > &listener)
Definition wifi-phy.cc:499
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition wifi-phy.cc:844
std::shared_ptr< PhyEntity > GetPhyEntityForPpdu(const Ptr< const WifiPpdu > ppdu) const
Get the supported PHY entity to use for a received PPDU.
Definition wifi-phy.cc:790
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition wifi-phy.cc:1057
void SetPreviouslyRxPpduUid(uint64_t uid)
Set the UID of the previously received PPDU.
Definition wifi-phy.cc:1951
Ptr< Event > m_currentEvent
Hold the current event.
Definition wifi-phy.h:1400
Time GetLastRxStartTime() const
Return the start time of the last received packet.
Definition wifi-phy.cc:2206
WifiMode GetDefaultMode() const
Get the default WifiMode supported by the PHY.
Definition wifi-phy.cc:2040
uint8_t GetChannelNumber() const
Return current channel number.
Definition wifi-phy.cc:1081
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
Definition wifi-phy.h:1535
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
Definition wifi-phy.h:1405
std::optional< Time > GetDelayUntilChannelSwitch()
Perform any actions necessary when user changes operating channel after initialization.
Definition wifi-phy.cc:1185
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU.
Definition wifi-phy.h:1394
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
Definition wifi-phy.cc:723
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:1520
virtual void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition wifi-phy.cc:650
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
Definition wifi-phy.h:1692
virtual std::optional< std::reference_wrapper< const WifiTxVector > > GetInfoIfRxingPhyHeader() const
Definition wifi-phy.cc:1999
Time GetPifs() const
Return the PCF Interframe Space (PIFS) for this PHY.
Definition wifi-phy.cc:862
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
Definition wifi-phy.cc:1659
void StartReceivePreamble(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Definition wifi-phy.cc:1976
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:1527
dB_u m_txGain
Transmission gain.
Definition wifi-phy.h:1664
MHz_u GetChannelWidth() const
Definition wifi-phy.cc:1087
bool IsStateSleep() const
Definition wifi-phy.cc:2188
void SetOperatingChannel(const WifiPhyOperatingChannel &channel)
If the standard for this object has not been set yet, store the channel settings corresponding to the...
Definition wifi-phy.cc:1123
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition wifi-phy.cc:656
WifiStandard m_standard
WifiStandard.
Definition wifi-phy.h:1648
uint8_t m_nTxPower
Number of available transmission power levels.
Definition wifi-phy.h:1668
void DoDispose() override
Destructor implementation.
Definition wifi-phy.cc:445
void ResetCca(bool powerRestricted, dBm_u txPowerMaxSiso=dBm_u{0}, dBm_u txPowerMaxMimo=dBm_u{0})
Reset PHY to IDLE, with some potential TX power restrictions for the next transmission.
Definition wifi-phy.cc:2282
dB_u GetRxGain() const
Return the reception gain.
Definition wifi-phy.cc:631
bool IsStateSwitching() const
Definition wifi-phy.cc:2182
void SetPhyId(uint8_t phyId)
Set the index allocated to this PHY.
Definition wifi-phy.cc:674
virtual void DoChannelSwitch()
Actually switch channel based on the stored channel settings.
Definition wifi-phy.cc:1251
void SetOffMode()
Put in off mode.
Definition wifi-phy.cc:1444
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:1593
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
Definition wifi-phy.cc:717
uint8_t m_phyId
the index of the PHY in the vector of PHYs held by the WifiNetDevice
Definition wifi-phy.h:1384
void SetPifs(Time pifs)
Set the PCF Interframe Space (PIFS) for this PHY.
Definition wifi-phy.cc:856
void Configure80211b()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
Definition wifi-phy.cc:882
static const std::shared_ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
Definition wifi-phy.cc:760
void SetCcaEdThreshold(dBm_u threshold)
Sets the CCA energy detection threshold.
Definition wifi-phy.cc:535
dB_u m_noiseFigure
The noise figure.
Definition wifi-phy.h:1682
static Time GetStartOfPacketDuration(const WifiTxVector &txVector)
Definition wifi-phy.cc:1515
virtual FrequencyRange GetCurrentFrequencyRange() const =0
Get the frequency range of the current RF interface.
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:2218
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition wifi-phy.cc:662
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
Definition wifi-phy.h:1680
dB_u m_rxGain
Reception gain.
Definition wifi-phy.h:1665
double CalculateSnr(const WifiTxVector &txVector, double ber) const
Definition wifi-phy.cc:754
TupleValue< UintegerValue, UintegerValue, EnumValue< WifiPhyBand >, UintegerValue > ChannelTupleValue
AttributeValue type of a ChannelTuple object.
Definition wifi-phy.h:955
void SetFixedPhyBand(bool enable)
Configure whether it is prohibited to change PHY band after initialization.
Definition wifi-phy.cc:1099
~WifiPhy() override
Definition wifi-phy.cc:414
void Configure80211ac()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard.
Definition wifi-phy.cc:953
bool HasFixedPhyBand() const
Definition wifi-phy.cc:1105
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:1551
Ptr< WifiNetDevice > m_device
Pointer to the device.
Definition wifi-phy.h:1688
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
Definition wifi-phy.h:1387
void DoInitialize() override
Initialize() implementation.
Definition wifi-phy.cc:420
bool m_shortPreamble
Flag if short PHY preamble is supported.
Definition wifi-phy.h:1677
uint8_t GetPhyId() const
Get the index allocated to this PHY.
Definition wifi-phy.cc:681
Time m_pifs
PCF Interframe Space (PIFS) duration.
Definition wifi-phy.h:1657
WifiModulationClass m_maxModClassSupported
max modulation class supported
Definition wifi-phy.h:1649
WifiStandard GetStandard() const
Get the configured Wi-Fi standard.
Definition wifi-phy.cc:1063
static Ptr< const AttributeChecker > GetChannelSegmentsChecker()
Get a checker for the ChannelSettings attribute, which can be used to deserialize a ChannelSegments o...
Definition wifi-phy.cc:371
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition wifi-phy.cc:516
void SetReceiveOkCallback(RxOkCallback callback)
Definition wifi-phy.cc:487
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
Definition wifi-phy.cc:711
void NotifyChannelAccessRequested()
Notify the PHY that an access to the channel was requested.
Definition wifi-phy.cc:2020
dBm_u GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
Definition wifi-phy.cc:2305
void ResumeFromOff()
Resume from off mode.
Definition wifi-phy.cc:1481
bool m_powerRestricted
Flag whether transmit power is restricted by OBSS PD SR.
Definition wifi-phy.h:1671
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
Definition wifi-phy.h:1698
uint64_t GetPreviouslyRxPpduUid() const
Definition wifi-phy.cc:1945
void Reset()
Reset data upon end of TX or RX.
Definition wifi-phy.cc:1958
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
Definition wifi-phy.h:1567
Time GetLastRxEndTime() const
Return the end time of the last received packet.
Definition wifi-phy.cc:2212
TracedCallback< const WifiMacHeader &, const WifiTxVector &, Time > m_phyRxMacHeaderEndTrace
The trace source fired when the reception of a MAC header ends.
Definition wifi-phy.h:1578
Time m_timeLastPreambleDetected
Record the time the last preamble was detected.
Definition wifi-phy.h:1695
uint8_t GetMaxSupportedTxSpatialStreams() const
Definition wifi-phy.cc:1359
void Configure80211a()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
Definition wifi-phy.cc:868
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:2116
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition wifi-phy.cc:2067
void TxDone(const WifiConstPsduMap &psdus)
Callback function when a transmission is completed.
Definition wifi-phy.cc:1935
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Definition wifi-phy.cc:1069
virtual std::optional< Time > GetTimeToPreambleDetectionEnd() const
Get the remaining time to preamble detection period to elapse, if preamble detection is ongoing.
Definition wifi-phy.cc:1784
uint8_t GetPrimaryChannelNumber(MHz_u primaryChannelWidth) const
Get channel number of the primary channel.
Definition wifi-phy.cc:2366
dBm_u GetPower(uint8_t powerLevel) const
Get the power of the given power level.
Definition wifi-phy.cc:729
bool m_fixedPhyBand
True to prohibit changing PHY band after initialization.
Definition wifi-phy.h:1653
uint8_t GetNTxPower() const
Return the number of available transmission power levels.
Definition wifi-phy.cc:605
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:2348
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition wifi-phy.cc:1561
bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
Definition wifi-phy.cc:2027
void UnregisterListener(const std::shared_ptr< WifiPhyListener > &listener)
Definition wifi-phy.cc:510
dBm_u GetCcaSensitivityThreshold() const
Return the CCA sensitivity threshold.
Definition wifi-phy.cc:555
void NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
Definition wifi-phy.cc:1635
Class that keeps track of all information about the current PHY operating channel.
static uint8_t GetDefaultChannelNumber(MHz_u width, WifiStandard standard, WifiPhyBand band, std::optional< uint8_t > previousChannelNumber=std::nullopt)
Get the default channel number for a given segment of the given width and for the given standard and ...
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.
static void Send(Ptr< NetDevice > dev, int level, std::string emuMode)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#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:75
Ptr< AttributeChecker > MakeAttributeContainerChecker()
Make uninitialized AttributeContainerChecker using explicit types.
Ptr< const AttributeAccessor > MakeAttributeContainerAccessor(T1 a1)
Make AttributeContainerAccessor using explicit types.
Ptr< const AttributeChecker > MakeBooleanChecker()
Definition boolean.cc:114
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition boolean.h:70
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition double.h:32
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition pointer.h:249
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:270
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition nstime.h:1457
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1477
Ptr< const AttributeChecker > MakeTupleChecker(Ts... checkers)
Create a TupleChecker from AttributeCheckers associated with TupleValue elements.
Definition tuple.h:532
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
Definition abort.h:133
#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.
Definition abort.h:97
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition abort.h:65
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#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:250
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1393
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1369
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.
Definition wifi-types.h:53
@ 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.
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_UNKNOWN
Modulation class unknown or unspecified.
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_EHT
EHT (Clause 36)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_MOD_CLASS_DSSS
DSSS (Clause 15)
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
@ OFDM_PHY_10_MHZ
Definition ofdm-phy.h:35
@ OFDM_PHY_5_MHZ
Definition ofdm-phy.h:36
@ WIFI_CHANLIST_PRIMARY
@ LAST_MPDU_IN_AGGREGATE
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
Definition wifi-types.h:65
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
Definition wifi-types.h:55
@ FIRST_MPDU_IN_AGGREGATE
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate.
Definition wifi-types.h:60
@ SINGLE_MPDU
The MPDU is a single MPDU.
Definition wifi-types.h:57
@ MIDDLE_MPDU_IN_AGGREGATE
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate.
Definition wifi-types.h:63
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const Time DSSS_SIFS_TIME
aSIFSTime duration for DSSS (Table 16-4 "HR/DSSS PHY characteristics" of 802.11-2020)
U * PeekPointer(const Ptr< U > &p)
Definition ptr.h:448
Callback< void, Ptr< const WifiPsdu > > RxErrorCallback
Callback if PSDU unsuccessfully received.
std::map< WifiSpectrumBandInfo, Watt_u > RxPowerWattPerChannelBand
A map of the received power for each band.
@ 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.
const Time DSSS_SLOT_TIME
aSlotTime duration for DSSS (Table 16-4 "HR/DSSS PHY characteristics" of 802.11-2020)
const Time OFDM_SIFS_TIME_10MHZ
aSIFSTime value for OFDM (10 MHz channel spacing) (Table 17-21 "OFDM PHY characteristics" of 802....
dB_u RatioToDb(double ratio)
Convert from ratio to dB.
Definition wifi-utils.cc:45
const Time OFDM_SLOT_TIME_20MHZ
aSlotTime duration for OFDM (20 MHz channel spacing) (Table 17-21 "OFDM PHY characteristics" of 802....
double Hz_u
Hz weak type.
Definition wifi-units.h:30
double MHz_u
MHz weak type.
Definition wifi-units.h:31
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:179
MHz_u GetDefaultChannelWidth(WifiStandard standard, WifiPhyBand band)
Get the default channel width for the given PHY standard and band.
const Time OFDM_SIFS_TIME_5MHZ
aSIFSTime value for OFDM (5 MHz channel spacing) (Table 17-21 "OFDM PHY characteristics" of 802....
MHz_u GetMaximumChannelWidth(WifiModulationClass modulation)
Get the maximum channel width allowed for the given modulation class.
double dBm_u
dBm weak type
Definition wifi-units.h:27
double DbToRatio(dB_u val)
Convert from dB to ratio.
Definition wifi-utils.cc:26
const Time OFDM_SLOT_TIME_5MHZ
aSlotTime duration for OFDM (5 MHz channel spacing) (Table 17-21 "OFDM PHY characteristics" of 802....
static constexpr uint32_t SUBCARRIER_FREQUENCY_SPACING
Subcarrier frequency spacing in Hz (Table 19-6 "Timing-related constants" of 802.11-2020)
Watt_u DbmToW(dBm_u val)
Convert from dBm to Watts.
Definition wifi-utils.cc:32
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.
Callback< void, Ptr< const WifiPsdu >, RxSignalInfo, const WifiTxVector &, const std::vector< bool > & > RxOkCallback
Callback if PSDU successfully received (i.e.
static constexpr uint32_t SUBCARRIER_FREQUENCY_SPACING_HE
Subcarrier frequency spacing for the HE modulated fields in Hz (Table 27-12 "Timing-relatedconstants"...
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:38
const Time OFDM_SIFS_TIME_20MHZ
aSIFSTime value for OFDM (20 MHz channel spacing) (Table 17-21 "OFDM PHY characteristics" of 802....
double Watt_u
Watt weak type.
Definition wifi-units.h:25
double dBm_per_MHz_u
dBm/MHz weak type
Definition wifi-units.h:38
const Time OFDM_SLOT_TIME_10MHZ
aSlotTime duration for OFDM (10 MHz channel spacing) (Table 17-21 "OFDM PHY characteristics" of 802....
double dB_u
dB weak type
Definition wifi-units.h:28
#define list
std::ostream & operator<<(std::ostream &os, const PairObject &obj)
Stream insertion operator.
Declaration of:
MpduInfo structure.
Definition wifi-types.h:77
MpduType type
type of MPDU
Definition wifi-types.h:78
uint32_t mpduRefNumber
MPDU ref number.
Definition wifi-types.h:79
RxSignalInfo structure containing info on the received signal.
Definition wifi-types.h:84
double snr
SNR in linear scale.
Definition wifi-types.h:85
dBm_u rssi
RSSI.
Definition wifi-types.h:86
SignalNoiseDbm structure.
Definition wifi-types.h:70
uint8_t p20Index
primary20 index
Definition wifi-types.h:127
uint8_t number
channel number
Definition wifi-types.h:124
WifiPhyBand band
PHY band.
Definition wifi-types.h:126
Struct defining the configuration of a wifi channel, which can be made of one or multiple channel seg...
Definition wifi-types.h:94
std::vector< Segment > segments
channel config
Definition wifi-types.h:167
const Segment & front() const
Definition wifi-types.h:216
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.