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.",
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.",
267 .AddAttribute("Slot",
268 "The duration of a slot. "
269 "NOTE that the default value is overwritten by the value defined "
270 "by the standard; if you want to set this attribute, you have to "
271 "do it after that the PHY object is initialized.",
275 .AddAttribute("Pifs",
276 "The duration of the PCF Interframe Space. "
277 "NOTE that the default value is overwritten by the value defined "
278 "by the standard; if you want to set this attribute, you have to "
279 "do it after that the PHY object is initialized.",
283 .AddAttribute("PowerDensityLimit",
284 "The mean equivalent isotropically radiated power density"
285 "limit (in dBm/MHz) set by regulators.",
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
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);
602}
603
604uint8_t
606{
607 return m_nTxPowerLevels;
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{
731 NS_ASSERT_MSG((powerLevel >= WIFI_MIN_TX_PWR_LEVEL) &&
732 (powerLevel < (WIFI_MIN_TX_PWR_LEVEL + m_nTxPowerLevels)),
733 "Invalid TX power level");
737 auto power{m_txPowerBase};
738 if (m_nTxPowerLevels > 1)
739 {
740 power += dB_u{(powerLevel - WIFI_MIN_TX_PWR_LEVEL) * (m_txPowerEnd - m_txPowerBase) /
741 (m_nTxPowerLevels - 1)};
742 }
743 return power;
744}
745
746Time
751
752double
753WifiPhy::CalculateSnr(const WifiTxVector& txVector, double ber) const
754{
755 return m_interference->GetErrorRateModel()->CalculateSnr(txVector, ber);
756}
757
758const std::shared_ptr<const PhyEntity>
760{
761 const auto it = GetStaticPhyEntities().find(modulation);
763 "Unimplemented Wi-Fi modulation class " << modulation);
764 return it->second;
765}
766
767std::shared_ptr<PhyEntity>
769{
770 const auto it = m_phyEntities.find(modulation);
771 NS_ABORT_MSG_IF(it == m_phyEntities.cend(),
772 "Unsupported Wi-Fi modulation class " << modulation);
773 return it->second;
774}
775
776std::shared_ptr<PhyEntity>
778{
780}
781
782std::shared_ptr<PhyEntity>
787
788std::shared_ptr<PhyEntity>
790{
791 NS_ABORT_IF(!ppdu);
792 const auto modulation = ppdu->GetModulation();
793 if (modulation > m_phyEntities.rbegin()->first)
794 {
795 // unsupported modulation: start reception process with latest PHY entity
796 return GetLatestPhyEntity();
797 }
798 if (modulation < WIFI_MOD_CLASS_HT)
799 {
800 // for non-HT (duplicate), call the latest PHY entity since some extra processing can be
801 // done in PHYs implemented in HT and later (e.g. channel width selection for non-HT
802 // duplicates)
803 return GetLatestPhyEntity();
804 }
805 return GetPhyEntity(modulation);
806}
807
808void
809WifiPhy::AddStaticPhyEntity(WifiModulationClass modulation, std::shared_ptr<PhyEntity> phyEntity)
810{
811 NS_ASSERT_MSG(!GetStaticPhyEntities().contains(modulation),
812 "The PHY entity has already been added. The setting should only be done once per "
813 "modulation class");
814 GetStaticPhyEntities()[modulation] = phyEntity;
815}
816
817void
818WifiPhy::AddPhyEntity(WifiModulationClass modulation, std::shared_ptr<PhyEntity> phyEntity)
819{
820 NS_LOG_FUNCTION(this << modulation);
821 NS_ABORT_MSG_IF(!GetStaticPhyEntities().contains(modulation),
822 "Cannot add an unimplemented PHY to supported list. Update the former first.");
823 NS_ASSERT_MSG(m_phyEntities.find(modulation) == m_phyEntities.end(),
824 "The PHY entity has already been added. The setting should only be done once per "
825 "modulation class");
826 phyEntity->SetOwner(this);
827 m_phyEntities[modulation] = phyEntity;
828}
829
830void
832{
833 m_sifs = sifs;
834}
835
836Time
838{
839 return m_sifs;
840}
841
842void
844{
845 m_slot = slot;
846}
847
848Time
850{
851 return m_slot;
852}
853
854void
856{
857 m_pifs = pifs;
858}
859
860Time
862{
863 return m_pifs;
864}
865
866void
868{
869 NS_LOG_FUNCTION(this);
870 AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared<OfdmPhy>());
871
872 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
875 SetPifs(GetSifs() + GetSlot());
876 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
877 // of the PPDU causing the EIFS" of 802.11-2016
878}
879
880void
882{
883 NS_LOG_FUNCTION(this);
884 std::shared_ptr<DsssPhy> phyEntity = std::make_shared<DsssPhy>();
886 AddPhyEntity(WIFI_MOD_CLASS_DSSS, phyEntity); // when plain DSSS modes are used
887
890 SetPifs(GetSifs() + GetSlot());
891 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
892 // of the PPDU causing the EIFS" of 802.11-2016
893}
894
895void
897{
898 NS_LOG_FUNCTION(this);
899 // See Table 18-5 "ERP characteristics" of 802.11-2016
900 // Slot time defaults to the "long slot time" of 20 us in the standard
901 // according to mixed 802.11b/g deployments. Short slot time is enabled
902 // if the user sets the ShortSlotTimeSupported flag to true and when the BSS
903 // consists of only ERP STAs capable of supporting this option.
905 AddPhyEntity(WIFI_MOD_CLASS_ERP_OFDM, std::make_shared<ErpOfdmPhy>());
906}
907
908void
910{
911 NS_LOG_FUNCTION(this);
912 if (GetChannelWidth() == MHz_u{10})
913 {
914 AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared<OfdmPhy>(OFDM_PHY_10_MHZ));
915
916 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
919 SetPifs(GetSifs() + GetSlot());
920 }
921 else if (GetChannelWidth() == MHz_u{5})
922 {
923 AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared<OfdmPhy>(OFDM_PHY_5_MHZ));
924
925 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
928 SetPifs(GetSifs() + GetSlot());
929 }
930 else
931 {
932 NS_FATAL_ERROR("802.11p configured with a wrong channel width!");
933 }
934}
935
936void
938{
939 NS_LOG_FUNCTION(this);
941 {
943 }
944 else
945 {
947 }
948 AddPhyEntity(WIFI_MOD_CLASS_HT, std::make_shared<HtPhy>(m_txSpatialStreams));
949}
950
951void
953{
954 NS_LOG_FUNCTION(this);
956 AddPhyEntity(WIFI_MOD_CLASS_VHT, std::make_shared<VhtPhy>());
957}
958
959void
961{
962 NS_LOG_FUNCTION(this);
964 {
966 }
967 else
968 {
970 }
971 AddPhyEntity(WIFI_MOD_CLASS_HE, std::make_shared<HePhy>());
972}
973
974void
976{
977 NS_LOG_FUNCTION(this);
979 AddPhyEntity(WIFI_MOD_CLASS_EHT, std::make_shared<EhtPhy>());
980}
981
982void
988
994
995void
997{
998 NS_LOG_FUNCTION(this << standard);
999
1001 "Cannot change standard");
1002
1003 m_standard = standard;
1004
1006 {
1008 }
1009
1010 if (!m_operatingChannel.IsSet())
1011 {
1012 NS_LOG_DEBUG("Setting the operating channel first");
1014 // return because we are called back by SetOperatingChannel
1015 return;
1016 }
1017
1018 // this function is called when changing PHY band, hence we have to delete
1019 // the previous PHY entities
1020 m_phyEntities.clear();
1021
1022 switch (standard)
1023 {
1026 break;
1029 break;
1032 break;
1035 break;
1038 break;
1041 break;
1044 break;
1047 break;
1049 default:
1050 NS_ASSERT_MSG(false, "Unsupported standard");
1051 break;
1052 }
1053}
1054
1057{
1058 return m_band;
1059}
1060
1063{
1064 return m_standard;
1065}
1066
1069{
1070 return m_operatingChannel;
1071}
1072
1073MHz_u
1075{
1076 return m_operatingChannel.GetFrequency();
1077}
1078
1079uint8_t
1081{
1082 return m_operatingChannel.GetNumber();
1083}
1084
1085MHz_u
1087{
1088 return m_operatingChannel.GetTotalWidth();
1089}
1090
1091uint8_t
1093{
1094 return m_operatingChannel.GetPrimaryChannelIndex(MHz_u{20});
1095}
1096
1097void
1099{
1100 m_fixedPhyBand = enable;
1101}
1102
1103bool
1105{
1106 return m_fixedPhyBand;
1107}
1108
1109MHz_u
1110WifiPhy::GetTxBandwidth(WifiMode mode, MHz_u maxAllowedWidth) const
1111{
1112 auto modulation = mode.GetModulationClass();
1113 if (modulation == WIFI_MOD_CLASS_DSSS || modulation == WIFI_MOD_CLASS_HR_DSSS)
1114 {
1115 return MHz_u{22};
1116 }
1117
1118 return std::min({GetChannelWidth(), GetMaximumChannelWidth(modulation), maxAllowedWidth});
1119}
1120
1121void
1123{
1124 NS_LOG_FUNCTION(this << channel);
1126 for (std::size_t segmentId = 0; segmentId < channel.GetNSegments(); ++segmentId)
1127 {
1128 cfg.segments.emplace_back(channel.GetNumber(segmentId),
1129 channel.GetWidth(segmentId),
1130 channel.GetPhyBand(),
1131 channel.GetPrimaryChannelIndex(MHz_u{20}));
1132 }
1134}
1135
1136void
1138{
1139 SetOperatingChannel(WifiChannelConfig(channelSegments));
1140}
1141
1142void
1144{
1145 NS_LOG_FUNCTION(this << +channelCfg.front().number << channelCfg.front().width
1146 << channelCfg.front().band << +channelCfg.front().p20Index);
1147
1148 if (IsInitialized() && m_operatingChannel.IsSet() && (m_channelCfg == channelCfg))
1149 {
1150 NS_LOG_DEBUG("Already operating on requested channel");
1151 return;
1152 }
1153
1155 {
1156 NS_LOG_DEBUG("Channel information will be applied when a standard is configured");
1157 m_channelCfg = channelCfg;
1158 return;
1159 }
1160
1161 if (IsInitialized())
1162 {
1163 const auto delay = GetDelayUntilChannelSwitch();
1164 if (!delay.has_value())
1165 {
1166 // switching channel is not possible now
1167 return;
1168 }
1169 if (delay.value().IsStrictlyPositive())
1170 {
1171 // switching channel has been postponed
1172 Simulator::Schedule(delay.value(), [=, this] { SetOperatingChannel(channelCfg); });
1173 return;
1174 }
1175 }
1176
1177 m_channelCfg = channelCfg;
1178
1179 // channel can be switched now.
1181}
1182
1183std::optional<Time>
1185{
1186 if (!IsInitialized())
1187 {
1188 // this is not channel switch, this is initialization
1189 NS_LOG_DEBUG("Before initialization, nothing to do");
1190 return Seconds(0);
1191 }
1192
1193 std::optional<Time> delay;
1194 switch (m_state->GetState())
1195 {
1196 case WifiPhyState::RX:
1197 NS_LOG_DEBUG("drop packet because of channel switching while reception");
1199 delay = Seconds(0);
1200 break;
1201 case WifiPhyState::TX:
1202 NS_LOG_DEBUG("channel switching postponed until end of current transmission");
1203 delay = GetDelayUntilIdle();
1204 break;
1206 case WifiPhyState::IDLE:
1207 Reset();
1208 delay = Seconds(0);
1209 break;
1211 delay = Seconds(0);
1212 break;
1214 NS_LOG_DEBUG("channel switching ignored in sleep mode");
1215 break;
1216 default:
1217 NS_ASSERT(false);
1218 break;
1219 }
1220
1221 return delay;
1222}
1223
1224void
1226{
1227 std::optional<uint8_t> prevChannelNumber{};
1228 for (auto& [number, width, band, primary20] : channelCfg.segments)
1229 {
1230 if (band == WIFI_PHY_BAND_UNSPECIFIED)
1231 {
1232 band = GetDefaultPhyBand(standard);
1233 }
1234 if (width == MHz_u{0} && number == 0)
1235 {
1236 width = GetDefaultChannelWidth(standard, static_cast<WifiPhyBand>(band));
1237 }
1238 if (number == 0)
1239 {
1241 standard,
1242 band,
1243 prevChannelNumber);
1244 }
1245 prevChannelNumber = number;
1246 }
1247}
1248
1249void
1251{
1252 NS_LOG_FUNCTION(this);
1253
1254 m_powerRestricted = false;
1256
1257 // Update unspecified parameters with default values
1259
1260 // We need to call SetStandard if this is the first time we set a channel or we
1261 // are changing PHY band. Checking if the new PHY band is different than the
1262 // previous one covers both cases because initially the PHY band is unspecified
1263 const auto changingPhyBand = (m_channelCfg.front().band != m_band);
1264
1265 NS_ABORT_MSG_IF(IsInitialized() && m_fixedPhyBand && changingPhyBand,
1266 "Trying to change PHY band while prohibited.");
1267
1268 m_band = m_channelCfg.front().band;
1269
1270 NS_LOG_DEBUG("switching channel");
1271 std::vector<FrequencyChannelInfo> segments{};
1272 std::transform(m_channelCfg.segments.cbegin(),
1273 m_channelCfg.segments.cend(),
1274 std::back_inserter(segments),
1275 [this](const auto& segment) {
1276 return FrequencyChannelInfo{segment.number, MHz_u{0}, segment.width, m_band};
1277 });
1278 m_operatingChannel.Set(segments, m_standard);
1279 m_operatingChannel.SetPrimary20Index(m_channelCfg.front().p20Index);
1280
1281 // check that the channel width is supported
1282 if (const auto chWidth = GetChannelWidth();
1283 (m_maxRadioBw != MHz_u{0}) && (chWidth > m_maxRadioBw))
1284 {
1285 // throw an exception instead of using NS_ABORT_MSG for unit testing this code
1286 throw std::runtime_error("Attempting to set a " + std::to_string(chWidth) +
1287 " MHz channel on a station only supporting " +
1288 std::to_string(m_maxRadioBw) + " MHz operation");
1289 }
1290
1291 if (changingPhyBand)
1292 {
1293 ConfigureStandard(m_standard);
1294 }
1295
1296 FinalizeChannelSwitch();
1297
1298 if (IsInitialized())
1299 {
1300 // notify channel switching
1301 m_state->SwitchToChannelSwitching(GetChannelSwitchDelay());
1302 /*
1303 * Needed here to be able to correctly sensed the medium for the first
1304 * time after the switching. The actual switching is not performed until
1305 * after m_channelSwitchDelay. Packets received during the switching
1306 * state are added to the event list and are employed later to figure
1307 * out the state of the medium after the switching.
1308 */
1309 SwitchMaybeToCcaBusy(nullptr);
1310 }
1311}
1312
1313void
1315{
1316 NS_LOG_FUNCTION(this << +antennas);
1317 NS_ASSERT_MSG(antennas > 0 && antennas <= 8, "unsupported number of antennas");
1318 m_numberOfAntennas = antennas;
1319 if (m_interference)
1320 {
1321 m_interference->SetNumberOfReceiveAntennas(antennas);
1322 }
1323}
1324
1325uint8_t
1327{
1328 return m_numberOfAntennas;
1329}
1330
1331void
1333{
1334 NS_ASSERT(streams <= GetNumberOfAntennas());
1335 bool changed = (m_txSpatialStreams != streams);
1336 m_txSpatialStreams = streams;
1337 if (changed)
1338 {
1339 auto phyEntity = m_phyEntities.find(WIFI_MOD_CLASS_HT);
1340 if (phyEntity != m_phyEntities.end())
1341 {
1342 std::shared_ptr<HtPhy> htPhy = std::dynamic_pointer_cast<HtPhy>(phyEntity->second);
1343 if (htPhy)
1344 {
1345 htPhy->SetMaxSupportedNss(
1346 m_txSpatialStreams); // this is essential to have the right MCSs configured
1347 }
1348
1349 if (!m_capabilitiesChangedCallback.IsNull())
1350 {
1351 m_capabilitiesChangedCallback();
1352 }
1353 }
1354 }
1355}
1356
1357uint8_t
1362
1363void
1365{
1366 NS_ASSERT(streams <= GetNumberOfAntennas());
1367 bool changed = (m_rxSpatialStreams != streams);
1368 m_rxSpatialStreams = streams;
1369 if (changed && !m_capabilitiesChangedCallback.IsNull())
1370 {
1372 }
1373}
1374
1375uint8_t
1380
1381std::list<uint8_t>
1383{
1384 std::list<uint8_t> list;
1385 for (const auto& phyEntity : m_phyEntities)
1386 {
1387 std::shared_ptr<HtPhy> htPhy = std::dynamic_pointer_cast<HtPhy>(phyEntity.second);
1388 if (htPhy)
1389 {
1390 list.emplace_back(htPhy->GetBssMembershipSelector());
1391 }
1392 }
1393 return list;
1394}
1395
1396void
1397WifiPhy::SetSleepMode(bool forceSleepInRx)
1398{
1399 NS_LOG_FUNCTION(this);
1400 m_powerRestricted = false;
1402 switch (m_state->GetState())
1403 {
1404 case WifiPhyState::TX:
1405 NS_LOG_DEBUG("setting sleep mode postponed until end of current transmission");
1407 break;
1408 case WifiPhyState::RX:
1409 NS_LOG_DEBUG("setting sleep mode"
1410 << (forceSleepInRx ? "" : "postponed until end of current reception"));
1411 if (forceSleepInRx)
1412 {
1414 m_state->SwitchToSleep();
1415 }
1416 else
1417 {
1419 }
1420 break;
1422 NS_LOG_DEBUG("setting sleep mode postponed until end of channel switching");
1424 break;
1426 case WifiPhyState::IDLE:
1427 NS_LOG_DEBUG("setting sleep mode");
1428 // The PHY object may be in CCA_BUSY state because it is receiving a preamble. Cancel
1429 // preamble events before switching to sleep state
1430 Reset();
1431 m_state->SwitchToSleep();
1432 break;
1434 NS_LOG_DEBUG("already in sleep mode");
1435 break;
1436 default:
1437 NS_ASSERT(false);
1438 break;
1439 }
1440}
1441
1442void
1444{
1445 NS_LOG_FUNCTION(this);
1446 m_powerRestricted = false;
1448 Reset();
1449 m_state->SwitchToOff();
1450}
1451
1452void
1454{
1455 NS_LOG_FUNCTION(this);
1456 switch (m_state->GetState())
1457 {
1458 case WifiPhyState::TX:
1459 case WifiPhyState::RX:
1460 case WifiPhyState::IDLE:
1463 NS_LOG_DEBUG("not in sleep mode, there is nothing to resume");
1464 break;
1465 }
1466 case WifiPhyState::SLEEP: {
1467 NS_LOG_DEBUG("resuming from sleep mode");
1468 m_state->SwitchFromSleep();
1470 break;
1471 }
1472 default: {
1473 NS_ASSERT(false);
1474 break;
1475 }
1476 }
1477}
1478
1479void
1481{
1482 NS_LOG_FUNCTION(this);
1483 switch (m_state->GetState())
1484 {
1485 case WifiPhyState::TX:
1486 case WifiPhyState::RX:
1487 case WifiPhyState::IDLE:
1490 case WifiPhyState::SLEEP: {
1491 NS_LOG_DEBUG("not in off mode, there is nothing to resume");
1492 break;
1493 }
1494 case WifiPhyState::OFF: {
1495 NS_LOG_DEBUG("resuming from off mode");
1496 m_state->SwitchFromOff();
1498 break;
1499 }
1500 default: {
1501 NS_ASSERT(false);
1502 break;
1503 }
1504 }
1505}
1506
1507Time
1512
1513Time
1515{
1516 return MicroSeconds(4);
1517}
1518
1519Time
1521 const WifiTxVector& txVector,
1522 WifiPhyBand band,
1523 MpduType mpdutype,
1524 uint16_t staId)
1525{
1526 uint32_t totalAmpduSize;
1527 double totalAmpduNumSymbols;
1528 return GetPayloadDuration(size,
1529 txVector,
1530 band,
1531 mpdutype,
1532 false,
1533 totalAmpduSize,
1534 totalAmpduNumSymbols,
1535 staId);
1536}
1537
1538Time
1540 const WifiTxVector& txVector,
1541 WifiPhyBand band,
1542 MpduType mpdutype,
1543 bool incFlag,
1544 uint32_t& totalAmpduSize,
1545 double& totalAmpduNumSymbols,
1546 uint16_t staId)
1547{
1548 return GetStaticPhyEntity(txVector.GetModulationClass())
1549 ->GetPayloadDuration(size,
1550 txVector,
1551 band,
1552 mpdutype,
1553 incFlag,
1554 totalAmpduSize,
1555 totalAmpduNumSymbols,
1556 staId);
1557}
1558
1559Time
1561{
1562 return GetStaticPhyEntity(txVector.GetModulationClass())
1563 ->CalculatePhyPreambleAndHeaderDuration(txVector);
1564}
1565
1566Time
1568 const WifiTxVector& txVector,
1569 WifiPhyBand band,
1570 uint16_t staId)
1571{
1572 NS_ASSERT(txVector.IsValid(band));
1573 Time duration = CalculatePhyPreambleAndHeaderDuration(txVector) +
1574 GetPayloadDuration(size, txVector, band, NORMAL_MPDU, staId);
1575 NS_ASSERT(duration.IsStrictlyPositive());
1576 return duration;
1577}
1578
1579Time
1581 const WifiTxVector& txVector,
1582 WifiPhyBand band)
1583{
1584 return CalculateTxDuration(GetWifiConstPsduMap(psdu, txVector), txVector, band);
1585}
1586
1587Time
1589 const WifiTxVector& txVector,
1590 WifiPhyBand band)
1591{
1592 NS_ASSERT(txVector.IsValid(band));
1593 return GetStaticPhyEntity(txVector.GetModulationClass())
1594 ->CalculateTxDuration(psduMap, txVector, band);
1595}
1596
1599{
1600 return GetStaticPhyEntity(modulation)->GetMaxPsduSize();
1601}
1602
1603void
1605{
1606 if (!m_phyTxBeginTrace.IsEmpty())
1607 {
1608 for (const auto& psdu : psdus)
1609 {
1610 for (auto& mpdu : *PeekPointer(psdu.second))
1611 {
1612 m_phyTxBeginTrace(mpdu->GetProtocolDataUnit(), txPower);
1613 }
1614 }
1615 }
1616}
1617
1618void
1620{
1621 if (!m_phyTxEndTrace.IsEmpty())
1622 {
1623 for (const auto& psdu : psdus)
1624 {
1625 for (auto& mpdu : *PeekPointer(psdu.second))
1626 {
1627 m_phyTxEndTrace(mpdu->GetProtocolDataUnit());
1628 }
1629 }
1630 }
1631}
1632
1633void
1635{
1636 if (!m_phyTxDropTrace.IsEmpty())
1637 {
1638 for (auto& mpdu : *PeekPointer(psdu))
1639 {
1640 m_phyTxDropTrace(mpdu->GetProtocolDataUnit());
1641 }
1642 }
1643}
1644
1645void
1647{
1648 if (psdu && !m_phyRxBeginTrace.IsEmpty())
1649 {
1650 for (auto& mpdu : *PeekPointer(psdu))
1651 {
1652 m_phyRxBeginTrace(mpdu->GetProtocolDataUnit(), rxPowersW);
1653 }
1654 }
1655}
1656
1657void
1659{
1660 if (psdu && !m_phyRxEndTrace.IsEmpty())
1661 {
1662 for (auto& mpdu : *PeekPointer(psdu))
1663 {
1664 m_phyRxEndTrace(mpdu->GetProtocolDataUnit());
1665 }
1666 }
1667}
1668
1669void
1671{
1672 if (psdu && !m_phyRxDropTrace.IsEmpty())
1673 {
1674 for (auto& mpdu : *PeekPointer(psdu))
1675 {
1676 m_phyRxDropTrace(mpdu->GetProtocolDataUnit(), reason);
1677 }
1678 }
1679}
1680
1681void
1687
1688void
1690 MHz_u channelFreq,
1691 const WifiTxVector& txVector,
1692 SignalNoiseDbm signalNoise,
1693 const std::vector<bool>& statusPerMpdu,
1694 uint16_t staId)
1695{
1696 MpduInfo aMpdu;
1697 if (psdu->IsAggregate())
1698 {
1699 // Expand A-MPDU
1700 NS_ASSERT_MSG(txVector.IsAggregation(),
1701 "TxVector with aggregate flag expected here according to PSDU");
1703 size_t nMpdus = psdu->GetNMpdus();
1704 NS_ASSERT_MSG(statusPerMpdu.size() == nMpdus, "Should have one reception status per MPDU");
1705 if (!m_phyMonitorSniffRxTrace.IsEmpty())
1706 {
1707 aMpdu.type = (psdu->IsSingle()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1708 for (size_t i = 0; i < nMpdus;)
1709 {
1710 if (statusPerMpdu.at(i)) // packet received without error, hand over to sniffer
1711 {
1712 m_phyMonitorSniffRxTrace(psdu->GetAmpduSubframe(i),
1713 static_cast<uint16_t>(channelFreq),
1714 txVector,
1715 aMpdu,
1716 signalNoise,
1717 staId);
1718 }
1719 ++i;
1720 aMpdu.type =
1721 (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1722 }
1723 }
1724 }
1725 else
1726 {
1727 NS_ASSERT_MSG(statusPerMpdu.size() == 1,
1728 "Should have one reception status for normal MPDU");
1729 if (!m_phyMonitorSniffRxTrace.IsEmpty())
1730 {
1731 aMpdu.type = NORMAL_MPDU;
1732 m_phyMonitorSniffRxTrace(psdu->GetPacket(),
1733 static_cast<uint16_t>(channelFreq),
1734 txVector,
1735 aMpdu,
1736 signalNoise,
1737 staId);
1738 }
1739 }
1740}
1741
1742void
1744 MHz_u channelFreq,
1745 const WifiTxVector& txVector,
1746 uint16_t staId)
1747{
1748 MpduInfo aMpdu;
1749 if (psdu->IsAggregate())
1750 {
1751 // Expand A-MPDU
1752 NS_ASSERT_MSG(txVector.IsAggregation(),
1753 "TxVector with aggregate flag expected here according to PSDU");
1755 if (!m_phyMonitorSniffTxTrace.IsEmpty())
1756 {
1757 size_t nMpdus = psdu->GetNMpdus();
1758 aMpdu.type = (psdu->IsSingle()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1759 for (size_t i = 0; i < nMpdus;)
1760 {
1761 m_phyMonitorSniffTxTrace(psdu->GetAmpduSubframe(i),
1762 channelFreq,
1763 txVector,
1764 aMpdu,
1765 staId);
1766 ++i;
1767 aMpdu.type =
1768 (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1769 }
1770 }
1771 }
1772 else
1773 {
1774 if (!m_phyMonitorSniffTxTrace.IsEmpty())
1775 {
1776 aMpdu.type = NORMAL_MPDU;
1777 m_phyMonitorSniffTxTrace(psdu->GetPacket(), channelFreq, txVector, aMpdu, staId);
1778 }
1779 }
1780}
1781
1782std::optional<Time>
1784{
1785 for (const auto& [modClass, phyEntity] : m_phyEntities)
1786 {
1787 if (auto remTime = phyEntity->GetTimeToPreambleDetectionEnd())
1788 {
1789 return remTime;
1790 }
1791 }
1792 return std::nullopt;
1793}
1794
1795std::optional<Time>
1796WifiPhy::GetTimeToMacHdrEnd(uint16_t staId) const
1797{
1798 for (auto& [modClass, phyEntity] : m_phyEntities)
1799 {
1800 if (auto remTime = phyEntity->GetTimeToMacHdrEnd(staId))
1801 {
1802 return remTime;
1803 }
1804 }
1805 return std::nullopt;
1806}
1807
1810{
1811 return GetStaticPhyEntity(txVector.GetModulationClass())->GetWifiConstPsduMap(psdu, txVector);
1812}
1813
1814void
1816{
1817 NS_LOG_FUNCTION(this << *psdu << txVector);
1818 Send(GetWifiConstPsduMap(psdu, txVector), txVector);
1819}
1820
1821void
1822WifiPhy::Send(const WifiConstPsduMap& psdus, const WifiTxVector& txVector)
1823{
1824 NS_LOG_FUNCTION(this << psdus << txVector);
1825 /* Transmission can happen if:
1826 * - we are syncing on a packet. It is the responsibility of the
1827 * MAC layer to avoid doing this but the PHY does nothing to
1828 * prevent it.
1829 * - we are idle
1830 */
1831 NS_ASSERT(!m_state->IsStateTx() && !m_state->IsStateSwitching());
1832 NS_ASSERT(m_endTxEvent.IsExpired());
1833
1834 if (!txVector.IsValid(m_band))
1835 {
1836 NS_FATAL_ERROR("TX-VECTOR is invalid!");
1837 }
1838
1839 uint8_t nss = 0;
1840 if (txVector.IsMu())
1841 {
1842 // We do not support mixed OFDMA and MU-MIMO
1843 if (txVector.IsDlMuMimo())
1844 {
1845 nss = txVector.GetNssTotal();
1846 }
1847 else
1848 {
1849 nss = txVector.GetNssMax();
1850 }
1851 }
1852 else
1853 {
1854 nss = txVector.GetNss();
1855 }
1856
1858 {
1859 NS_FATAL_ERROR("Unsupported number of spatial streams!");
1860 }
1861
1862 if (m_state->IsStateSleep())
1863 {
1864 NS_LOG_DEBUG("Dropping packet because in sleep mode");
1865 for (const auto& psdu : psdus)
1866 {
1867 NotifyTxDrop(psdu.second);
1868 }
1869 return;
1870 }
1871
1872 const auto txDuration = CalculateTxDuration(psdus, txVector, GetPhyBand());
1873
1874 if (const auto timeToPreambleDetectionEnd = GetTimeToPreambleDetectionEnd();
1875 timeToPreambleDetectionEnd && !m_currentEvent)
1876 {
1877 // PHY is in the initial few microseconds during which the
1878 // start of RX has occurred but the preamble detection period
1879 // has not elapsed
1881 }
1882 else if (timeToPreambleDetectionEnd || m_currentEvent)
1883 {
1885 }
1886
1888 {
1889 NS_LOG_DEBUG("Transmitting with power restriction for " << txDuration.As(Time::NS));
1890 }
1891 else
1892 {
1893 NS_LOG_DEBUG("Transmitting without power restriction for " << txDuration.As(Time::NS));
1894 }
1895
1896 if (m_state->GetState() == WifiPhyState::OFF)
1897 {
1898 NS_LOG_DEBUG("Transmission canceled because device is OFF");
1899 return;
1900 }
1901
1902 auto ppdu = GetPhyEntity(txVector.GetModulationClass())->BuildPpdu(psdus, txVector, txDuration);
1903 m_previouslyRxPpduUid = UINT64_MAX; // reset (after creation of PPDU) to use it only once
1904
1905 const auto txPower = DbmToW(GetTxPowerForTransmission(ppdu) + GetTxGain());
1906 NotifyTxBegin(psdus, txPower);
1907 if (!m_phyTxPsduBeginTrace.IsEmpty())
1908 {
1909 m_phyTxPsduBeginTrace(psdus, txVector, txPower);
1910 }
1911 for (const auto& psdu : psdus)
1912 {
1913 NotifyMonitorSniffTx(psdu.second, GetFrequency(), txVector, psdu.first);
1914 }
1915 m_state->SwitchToTx(txDuration, psdus, GetPower(txVector.GetTxPowerLevel()), txVector);
1916
1918 m_wifiRadioEnergyModel->GetMaximumTimeInState(WifiPhyState::TX) < txDuration)
1919 {
1920 ppdu->SetTruncatedTx();
1921 }
1922
1923 m_endTxEvent =
1924 Simulator::Schedule(txDuration, &WifiPhy::TxDone, this, psdus); // TODO: fix for MU
1925
1926 StartTx(ppdu);
1927 ppdu->ResetTxVector();
1928
1930 m_powerRestricted = false;
1931}
1932
1933void
1935{
1936 NS_LOG_FUNCTION(this << psdus);
1937 NotifyTxEnd(psdus);
1938 Reset();
1939 // we might have received signals during TX
1941}
1942
1943uint64_t
1948
1949void
1955
1956void
1958{
1959 NS_LOG_FUNCTION(this);
1962 {
1964 }
1965 m_currentEvent = nullptr;
1966 for (auto& phyEntity : m_phyEntities)
1967 {
1968 phyEntity.second->CancelAllEvents();
1969 }
1970 m_endPhyRxEvent.Cancel();
1971 m_endTxEvent.Cancel();
1972}
1973
1974void
1976 RxPowerWattPerChannelBand& rxPowersW,
1977 Time rxDuration)
1978{
1979 NS_LOG_FUNCTION(this << ppdu << rxDuration);
1980 WifiModulationClass modulation = ppdu->GetModulation();
1982 if (auto it = m_phyEntities.find(modulation);
1983 it != m_phyEntities.end() && modulation <= m_maxModClassSupported)
1984 {
1985 it->second->StartReceivePreamble(ppdu, rxPowersW, rxDuration);
1986 }
1987 else
1988 {
1989 // TODO find a fallback PHY for receiving the PPDU (e.g. 11a for 11ax due to preamble
1990 // structure)
1991 NS_LOG_DEBUG("Unsupported modulation received (" << modulation << "), consider as noise");
1992 m_interference->Add(ppdu, rxDuration, rxPowersW, GetCurrentFrequencyRange());
1994 }
1995}
1996
1997std::optional<std::reference_wrapper<const WifiTxVector>>
1999{
2000 if (m_endPhyRxEvent.IsPending())
2001 {
2002 NS_ASSERT_MSG(m_currentEvent, "No current event while receiving PHY header");
2003 return std::cref(m_currentEvent->GetPpdu()->GetTxVector());
2004 }
2005 return std::nullopt;
2006}
2007
2008void
2010{
2011 NS_LOG_FUNCTION(this);
2013 {
2014 m_powerRestricted = false;
2015 }
2016}
2017
2018void
2024
2025bool
2027{
2028 for (const auto& phyEntity : m_phyEntities)
2029 {
2030 if (phyEntity.second->IsModeSupported(mode))
2031 {
2032 return true;
2033 }
2034 }
2035 return false;
2036}
2037
2040{
2041 // Start from oldest standards and move up (guaranteed by fact that WifModulationClass is
2042 // ordered)
2043 for (const auto& phyEntity : m_phyEntities)
2044 {
2045 for (const auto& mode : *(phyEntity.second))
2046 {
2047 return mode;
2048 }
2049 }
2050 NS_ASSERT_MSG(false, "Should have found at least one default mode");
2051 return WifiMode();
2052}
2053
2054bool
2055WifiPhy::IsMcsSupported(WifiModulationClass modulation, uint8_t mcs) const
2056{
2057 const auto phyEntity = m_phyEntities.find(modulation);
2058 if (phyEntity == m_phyEntities.end())
2059 {
2060 return false;
2061 }
2062 return phyEntity->second->IsMcsSupported(mcs);
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 MCSs 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 const auto phyEntity = m_phyEntities.find(modulation);
2087 if (phyEntity != m_phyEntities.end())
2088 {
2089 if (!phyEntity->second->HandlesMcsModes()) // to exclude MCSs from search
2090 {
2091 for (const auto& mode : *(phyEntity->second))
2092 {
2093 list.emplace_back(mode);
2094 }
2095 }
2096 }
2097 return list;
2098}
2099
2100uint16_t
2102{
2103 uint16_t numMcs = 0;
2104 for (const auto& phyEntity : m_phyEntities)
2105 {
2106 if (phyEntity.second->HandlesMcsModes()) // to exclude non-MCS modes from search
2107 {
2108 numMcs += phyEntity.second->GetNumModes();
2109 }
2110 }
2111 return numMcs;
2112}
2113
2114std::list<WifiMode>
2116{
2117 std::list<WifiMode> list;
2118 for (const auto& phyEntity : m_phyEntities)
2119 {
2120 if (phyEntity.second->HandlesMcsModes()) // to exclude non-MCS modes from search
2121 {
2122 for (const auto& mode : *(phyEntity.second))
2123 {
2124 list.emplace_back(mode);
2125 }
2126 }
2127 }
2128 return list;
2129}
2130
2131std::list<WifiMode>
2133{
2134 std::list<WifiMode> list;
2135 auto phyEntity = m_phyEntities.find(modulation);
2136 if (phyEntity != m_phyEntities.end())
2137 {
2138 if (phyEntity->second->HandlesMcsModes()) // to exclude non-MCS modes from search
2139 {
2140 for (const auto& mode : *(phyEntity->second))
2141 {
2142 list.emplace_back(mode);
2143 }
2144 }
2145 }
2146 return list;
2147}
2148
2150WifiPhy::GetMcs(WifiModulationClass modulation, uint8_t mcs) const
2151{
2152 NS_ASSERT_MSG(IsMcsSupported(modulation, mcs), "Unsupported MCS");
2153 return m_phyEntities.at(modulation)->GetMcs(mcs);
2154}
2155
2156bool
2158{
2159 return m_state->IsStateCcaBusy();
2160}
2161
2162bool
2164{
2165 return m_state->IsStateIdle();
2166}
2167
2168bool
2170{
2171 return m_state->IsStateRx();
2172}
2173
2174bool
2176{
2177 return m_state->IsStateTx();
2178}
2179
2180bool
2182{
2183 return m_state->IsStateSwitching();
2184}
2185
2186bool
2188{
2189 return m_state->IsStateSleep();
2190}
2191
2192bool
2194{
2195 return m_state->IsStateOff();
2196}
2197
2198Time
2200{
2201 return m_state->GetDelayUntilIdle();
2202}
2203
2204Time
2206{
2207 return m_state->GetLastRxStartTime();
2208}
2209
2210Time
2212{
2213 return m_state->GetLastRxEndTime();
2214}
2215
2216void
2218{
2219 NS_LOG_FUNCTION(this);
2220 GetLatestPhyEntity()->SwitchMaybeToCcaBusy(ppdu);
2221}
2222
2223void
2225{
2226 NS_LOG_FUNCTION(this << duration);
2227 GetLatestPhyEntity()->NotifyCcaBusy(ppdu, duration, WIFI_CHANLIST_PRIMARY);
2228}
2229
2230void
2232{
2233 NS_LOG_FUNCTION(this << reason);
2234 if (reason != OBSS_PD_CCA_RESET ||
2235 m_currentEvent) // Otherwise abort has already been called previously
2236 {
2237 if (reason == SIGNAL_DETECTION_ABORTED_BY_TX)
2238 {
2239 for (auto signalDetectEvent : m_currentPreambleEvents)
2240 {
2241 NotifyRxPpduDrop(signalDetectEvent.second->GetPpdu(),
2243 }
2244 }
2245 for (auto& phyEntity : m_phyEntities)
2246 {
2247 phyEntity.second->CancelAllEvents();
2248 }
2249 m_endPhyRxEvent.Cancel();
2251 if (!m_currentEvent)
2252 {
2253 return;
2254 }
2255 NotifyRxPpduDrop(m_currentEvent->GetPpdu(), reason);
2256 if (reason == OBSS_PD_CCA_RESET)
2257 {
2258 m_state->SwitchFromRxAbort(GetChannelWidth());
2259 }
2260 if (reason == RECEPTION_ABORTED_BY_TX)
2261 {
2262 Reset();
2263 }
2264 else
2265 {
2266 for (auto it = m_currentPreambleEvents.begin(); it != m_currentPreambleEvents.end();
2267 ++it)
2268 {
2269 if (it->second == m_currentEvent)
2270 {
2271 it = m_currentPreambleEvents.erase(it);
2272 break;
2273 }
2274 }
2275 m_currentEvent = nullptr;
2276 }
2277 }
2278}
2279
2280void
2281WifiPhy::ResetCca(bool powerRestricted, dBm_u txPowerMaxSiso, dBm_u txPowerMaxMimo)
2282{
2283 NS_LOG_FUNCTION(this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2284 // This method might be called multiple times when receiving TB PPDUs with a BSS color
2285 // different than the one of the receiver. The first time this method is called, the call
2286 // to AbortCurrentReception sets m_currentEvent to 0. Therefore, we need to check whether
2287 // m_currentEvent is not 0 before executing the instructions below.
2288 if (m_currentEvent)
2289 {
2290 m_powerRestricted = powerRestricted;
2291 m_txPowerMaxSiso = txPowerMaxSiso;
2292 m_txPowerMaxMimo = txPowerMaxMimo;
2293 NS_ASSERT((m_currentEvent->GetEndTime() - Simulator::Now()).IsPositive());
2296 this);
2298 this,
2299 OBSS_PD_CCA_RESET); // finish processing field first
2300 }
2301}
2302
2303dBm_u
2305{
2306 NS_LOG_FUNCTION(this << m_powerRestricted << ppdu);
2307 const auto& txVector = ppdu->GetTxVector();
2308 // Get transmit power before antenna gain
2309 dBm_u txPower;
2310 if (!m_powerRestricted)
2311 {
2312 txPower = GetPower(txVector.GetTxPowerLevel());
2313 }
2314 else
2315 {
2316 if (txVector.GetNssMax() > 1 || txVector.GetNssTotal() > 1)
2317 {
2318 txPower = std::min(m_txPowerMaxMimo, GetPower(txVector.GetTxPowerLevel()));
2319 }
2320 else
2321 {
2322 txPower = std::min(m_txPowerMaxSiso, GetPower(txVector.GetTxPowerLevel()));
2323 }
2324 }
2325
2326 // Apply power density constraint on EIRP
2327 const auto channelWidth = ppdu->GetTxChannelWidth();
2328 dBm_per_MHz_u txPowerDbmPerMhz =
2329 (txPower + GetTxGain()) - RatioToDb(channelWidth); // account for antenna gain since EIRP
2330 NS_LOG_INFO("txPower=" << txPower << "dBm with txPowerDbmPerMhz=" << txPowerDbmPerMhz
2331 << " over " << channelWidth << " MHz");
2332 txPower = std::min(txPowerDbmPerMhz, m_powerDensityLimit) + RatioToDb(channelWidth);
2333 txPower -= GetTxGain(); // remove antenna gain since will be added right afterwards
2334 NS_LOG_INFO("txPower=" << txPower
2335 << "dBm after applying m_powerDensityLimit=" << m_powerDensityLimit);
2336 return txPower;
2337}
2338
2341{
2342 // TODO: wrapper. See if still needed
2343 return GetPhyEntityForPpdu(ppdu)->GetAddressedPsduInPpdu(ppdu);
2344}
2345
2346int64_t
2348{
2349 NS_LOG_FUNCTION(this << stream);
2350 int64_t currentStream = stream;
2351 m_random->SetStream(currentStream++);
2352 currentStream += m_interference->GetErrorRateModel()->AssignStreams(currentStream);
2353 return (currentStream - stream);
2354}
2355
2356std::ostream&
2357operator<<(std::ostream& os, RxSignalInfo rxSignalInfo)
2358{
2359 os << "SNR:" << RatioToDb(rxSignalInfo.snr) << " dB"
2360 << ", RSSI:" << rxSignalInfo.rssi << " dBm";
2361 return os;
2362}
2363
2364uint8_t
2365WifiPhy::GetPrimaryChannelNumber(MHz_u primaryChannelWidth) const
2366{
2367 return m_operatingChannel.GetPrimaryChannelNumber(primaryChannelWidth, m_standard);
2368}
2369
2370Hz_u
2372{
2373 Hz_u subcarrierSpacing{0};
2374 switch (GetStandard())
2375 {
2381 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING;
2382 break;
2384 if (GetChannelWidth() == MHz_u{5})
2385 {
2386 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING / 4;
2387 }
2388 else
2389 {
2390 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING / 2;
2391 }
2392 break;
2395 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING_HE;
2396 break;
2397 default:
2398 NS_FATAL_ERROR("Standard unknown: " << GetStandard());
2399 break;
2400 }
2401 return subcarrierSpacing;
2402}
2403
2404} // 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
AttributeValue implementation for Time.
Definition nstime.h:1456
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:1314
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:818
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:1225
bool IsStateTx() const
Definition wifi-phy.cc:2175
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:990
bool IsStateIdle() const
Definition wifi-phy.cc:2163
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:2157
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:1815
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:960
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:2224
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:1743
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:1520
Time GetSlot() const
Return the slot duration for this PHY.
Definition wifi-phy.cc:849
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
Definition wifi-phy.cc:1364
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:2340
std::shared_ptr< PhyEntity > GetLatestPhyEntity() const
Get the latest PHY entity supported by this PHY instance.
Definition wifi-phy.cc:783
void Configure80211g()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
Definition wifi-phy.cc:896
uint8_t GetPrimary20Index() const
Definition wifi-phy.cc:1092
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:1326
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:2199
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:831
std::list< uint8_t > GetBssMembershipSelectorList() const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition wifi-phy.cc:1382
std::shared_ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class.
Definition wifi-phy.cc:768
void Configure80211n()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
Definition wifi-phy.cc:937
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:975
void NotifyRxDrop(Ptr< const WifiPsdu > psdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxDrop trace.
Definition wifi-phy.cc:1670
bool IsStateRx() const
Definition wifi-phy.cc:2169
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:2055
Time GetSifs() const
Return the Short Interframe Space (SIFS) for this PHY.
Definition wifi-phy.cc:837
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:2371
MHz_u GetFrequency() const
Definition wifi-phy.cc:1074
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:2101
void SetSleepMode(bool forceSleepWhileInRx=false)
Put in sleep mode.
Definition wifi-phy.cc:1397
void ResumeFromSleep()
Resume from sleep mode.
Definition wifi-phy.cc:1453
void SetTxPowerStart(dBm_u start)
Sets the minimum available transmission power level.
Definition wifi-phy.cc:572
static Time GetPreambleDetectionDuration()
Definition wifi-phy.cc:1508
void Configure80211p()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11p standard.
Definition wifi-phy.cc:909
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:2231
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:1646
Time GetChannelSwitchDelay() const
Definition wifi-phy.cc:747
void SetTxGain(dB_u gain)
Sets the transmission gain.
Definition wifi-phy.cc:611
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
Definition wifi-phy.cc:1332
void NotifyTxBegin(const WifiConstPsduMap &psdus, Watt_u txPower)
Public method used to fire a PhyTxBegin trace.
Definition wifi-phy.cc:1604
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:1689
dBm_u GetTxPowerEnd() const
Return the maximum available transmission power level.
Definition wifi-phy.cc:592
bool IsStateOff() const
Definition wifi-phy.cc:2193
uint8_t GetMaxSupportedRxSpatialStreams() const
Definition wifi-phy.cc:1376
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition wifi-phy.cc:996
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:2150
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:1567
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
Definition wifi-phy.cc:1598
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:1619
void EndReceiveInterBss()
For HE receptions only, check and possibly modify the transmit power restriction state at the end of ...
Definition wifi-phy.cc:2009
void SetShortPhyPreambleSupported(bool preamble)
Enable or disable short PHY preamble.
Definition wifi-phy.cc:637
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:809
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:1796
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:1110
void NotifyRxPpduDrop(Ptr< const WifiPpdu > ppdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxPpduDrop trace.
Definition wifi-phy.cc:1682
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:983
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:1809
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:843
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:789
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition wifi-phy.cc:1056
void SetPreviouslyRxPpduUid(uint64_t uid)
Set the UID of the previously received PPDU.
Definition wifi-phy.cc:1950
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:2205
WifiMode GetDefaultMode() const
Get the default WifiMode supported by the PHY.
Definition wifi-phy.cc:2039
uint8_t GetChannelNumber() const
Return current channel number.
Definition wifi-phy.cc:1080
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:1184
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:1998
Time GetPifs() const
Return the PCF Interframe Space (PIFS) for this PHY.
Definition wifi-phy.cc:861
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
Definition wifi-phy.cc:1658
void StartReceivePreamble(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Definition wifi-phy.cc:1975
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:1086
bool IsStateSleep() const
Definition wifi-phy.cc:2187
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:1122
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
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:2281
dB_u GetRxGain() const
Return the reception gain.
Definition wifi-phy.cc:631
bool IsStateSwitching() const
Definition wifi-phy.cc:2181
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:1250
void SetOffMode()
Put in off mode.
Definition wifi-phy.cc:1443
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:855
void SetNTxPowerLevels(uint8_t numLevels)
Sets the number of transmission power levels available between the minimum level and the maximum leve...
Definition wifi-phy.cc:598
void Configure80211b()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
Definition wifi-phy.cc:881
static const std::shared_ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
Definition wifi-phy.cc:759
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:1514
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:2217
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:753
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:1098
~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:952
bool HasFixedPhyBand() const
Definition wifi-phy.cc:1104
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
uint8_t GetNTxPowerLevels() const
Return the number of available transmission power levels.
Definition wifi-phy.cc:605
WifiStandard GetStandard() const
Get the configured Wi-Fi standard.
Definition wifi-phy.cc:1062
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:2019
dBm_u GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
Definition wifi-phy.cc:2304
void ResumeFromOff()
Resume from off mode.
Definition wifi-phy.cc:1480
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:1944
void Reset()
Reset data upon end of TX or RX.
Definition wifi-phy.cc:1957
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:2211
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:1358
void Configure80211a()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
Definition wifi-phy.cc:867
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:2115
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition wifi-phy.cc:2066
void TxDone(const WifiConstPsduMap &psdus)
Callback function when a transmission is completed.
Definition wifi-phy.cc:1934
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Definition wifi-phy.cc:1068
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:1783
uint8_t GetPrimaryChannelNumber(MHz_u primaryChannelWidth) const
Get channel number of the primary channel.
Definition wifi-phy.cc:2365
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
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:2347
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition wifi-phy.cc:1560
bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
Definition wifi-phy.cc:2026
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
uint8_t m_nTxPowerLevels
Number of available transmission power levels.
Definition wifi-phy.h:1668
void NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
Definition wifi-phy.cc:1634
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....
static constexpr uint8_t WIFI_MIN_TX_PWR_LEVEL
minimum TX power level value
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.