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"
16#include "wifi-net-device.h"
17#include "wifi-ppdu.h"
18#include "wifi-psdu.h"
20#include "wifi-utils.h"
21
22#include "ns3/attribute-container.h"
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/tuple.h"
36#include "ns3/vht-configuration.h"
37
38#include <algorithm>
39#include <numeric>
40
41#undef NS_LOG_APPEND_CONTEXT
42#define NS_LOG_APPEND_CONTEXT \
43 WIFI_PHY_NS_LOG_APPEND_CONTEXT( \
44 (m_device && (m_device->GetNPhys() > m_phyId) && m_device->GetPhy(m_phyId) \
45 ? m_device->GetPhy(m_phyId) \
46 : nullptr))
47
48namespace ns3
49{
50
52
53/****************************************************************
54 * The actual WifiPhy class
55 ****************************************************************/
56
58
59TypeId
61{
62 static TypeId tid =
63 TypeId("ns3::WifiPhy")
65 .SetGroupName("Wifi")
66 .AddAttribute("Channel",
67 "The channel attached to this PHY",
72 .AddAttribute(
73 "ChannelSettings",
74 "A vector of tuple {channel number, channel width (MHz), PHY band, primary20 "
75 "index} "
76 "describing the settings of the operating channel for each segment. "
77 "The primary20 index (only the value set for the first segment is used) "
78 "is the index of the primary 20 MHz channel within the operating channel "
79 "(0 indicates the 20 MHz subchannel with the lowest center frequency) and "
80 "is only valid if the width of the operating channel is a multiple of 20 MHz. "
81 "If the standard for this object has not been set yet, the value of this "
82 "attribute is saved and will be used to set the operating channel when the "
83 "standard is configured. If the PHY band is left unspecified, the default "
84 "band for the configured standard is used. If the channel width and the "
85 "channel number are both 0, the default channel width for the configured "
86 "standard and band are used. If the channel number is 0, the default "
87 "channel number for the configured standard, band and channel width is used. "
88 "Note that the channel width can be left unspecified (0) if the channel "
89 "number uniquely identify a frequency channel for the given standard and band.",
90 StringValue("{0, 0, BAND_UNSPECIFIED, 0}"),
93 ';'>(static_cast<void (WifiPhy::*)(const ChannelSegments&)>(
104 "BAND_2_4GHZ",
106 "BAND_5GHZ",
108 "BAND_6GHZ",
110 "BAND_UNSPECIFIED"),
112 .AddAttribute("Frequency",
113 "The center frequency (MHz) of the current operating channel.",
115 UintegerValue(0),
118 .AddAttribute("ChannelNumber",
119 "The channel number of the current operating channel.",
121 UintegerValue(0),
124 .AddAttribute(
125 "ChannelWidth",
126 "The width in MHz of the current operating channel (5, 10, 20, 22, 40, 80 or 160). "
127 "If 80+80MHz is used, this corresponds to the total channel width, hence 160 MHz.",
129 UintegerValue(0),
132 .AddAttribute(
133 "Primary20MHzIndex",
134 "The index of the primary 20 MHz channel within the current operating channel "
135 "(0 indicates the 20 MHz subchannel with the lowest center frequency).",
136 UintegerValue(0),
139 .AddAttribute("FixedPhyBand",
140 "If set to true, changing PHY band is prohibited after initialization.",
141 BooleanValue(false),
144 .AddAttribute(
145 "MaxRadioBw",
146 "The maximum width supported by the radio. It is not possible to configure an "
147 "operating channel with a total width larger than this value. A value of 0 means "
148 "no restriction.",
149 TypeId::ATTR_GET | TypeId::ATTR_CONSTRUCT, // prevent setting after construction
150 DoubleValue(MHz_u{0}),
153 .AddAttribute(
154 "RxSensitivity",
155 "The energy of a received signal should be higher than "
156 "this threshold (dBm) for the PHY to detect the signal. "
157 "This threshold refers to a width of 20 MHz and will be "
158 "scaled to match the width of the received signal.",
159 DoubleValue(-101.0),
162 .AddAttribute(
163 "CcaEdThreshold",
164 "The energy of all received signals should be higher than "
165 "this threshold (dBm) in the primary channel to allow the PHY layer "
166 "to declare CCA BUSY state.",
167 DoubleValue(-62.0),
170 .AddAttribute("CcaSensitivity",
171 "The energy of a received wifi signal should be higher than "
172 "this threshold (dBm) in the primary channel to allow the PHY layer "
173 "to declare CCA BUSY state.",
174 DoubleValue(-82.0),
178 .AddAttribute("TxGain",
179 "Transmission gain (dB).",
180 DoubleValue(0.0),
183 .AddAttribute("RxGain",
184 "Reception gain (dB).",
185 DoubleValue(0.0),
188 .AddAttribute("TxPowerLevels",
189 "Number of transmission power levels available between "
190 "TxPowerStart and TxPowerEnd included.",
191 UintegerValue(1),
194 .AddAttribute("TxPowerEnd",
195 "Maximum available transmission level (dBm).",
196 DoubleValue(16.0206),
199 .AddAttribute("TxPowerStart",
200 "Minimum available transmission level (dBm).",
201 DoubleValue(16.0206),
204 .AddAttribute(
205 "RxNoiseFigure",
206 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
207 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
208 "\"the difference in decibels (dB) between"
209 " the noise output of the actual receiver to the noise output of an "
210 " ideal receiver with the same overall gain and bandwidth when the receivers "
211 " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
212 DoubleValue(7),
215 .AddAttribute("State",
216 "The state of the PHY layer.",
217 PointerValue(),
220 .AddAttribute("ChannelSwitchDelay",
221 "Delay between two short frames transmitted on different frequencies.",
225 .AddAttribute(
226 "Antennas",
227 "The number of antennas on the device.",
228 UintegerValue(1),
231 .AddAttribute("MaxSupportedTxSpatialStreams",
232 "The maximum number of supported TX spatial streams."
233 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
234 UintegerValue(1),
238 .AddAttribute("MaxSupportedRxSpatialStreams",
239 "The maximum number of supported RX spatial streams."
240 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
241 UintegerValue(1),
245 .AddAttribute("ShortPlcpPreambleSupported",
246 "Whether or not short PHY preamble is supported."
247 "This parameter is only valuable for 802.11b STAs and APs."
248 "Note: 802.11g APs and STAs always support short PHY preamble.",
249 BooleanValue(false),
253 .AddAttribute("FrameCaptureModel",
254 "Ptr to an object that implements the frame capture model",
255 PointerValue(),
258 .AddAttribute("PreambleDetectionModel",
259 "Ptr to an object that implements the preamble detection model",
260 PointerValue(),
263 .AddAttribute("PostReceptionErrorModel",
264 "An optional packet error model can be added to the receive "
265 "packet process after any propagation-based (SNR-based) error "
266 "models have been applied. Typically this is used to force "
267 "specific packet drops, for testing purposes.",
268 PointerValue(),
271 .AddAttribute("InterferenceHelper",
272 "Ptr to an object that implements the interference helper",
273 PointerValue(),
276 .AddAttribute("Sifs",
277 "The duration of the Short Interframe Space. "
278 "NOTE that the default value is overwritten by the value defined "
279 "by the standard; if you want to set this attribute, you have to "
280 "do it after that the PHY object is initialized.",
284 .AddAttribute("Slot",
285 "The duration of a slot. "
286 "NOTE that the default value is overwritten by the value defined "
287 "by the standard; if you want to set this attribute, you have to "
288 "do it after that the PHY object is initialized.",
292 .AddAttribute("Pifs",
293 "The duration of the PCF Interframe Space. "
294 "NOTE that the default value is overwritten by the value defined "
295 "by the standard; if you want to set this attribute, you have to "
296 "do it after that the PHY object is initialized.",
300 .AddAttribute("PowerDensityLimit",
301 "The mean equivalent isotropically radiated power density"
302 "limit (in dBm/MHz) set by regulators.",
303 DoubleValue(100.0), // set to a high value so as to have no effect
306 .AddAttribute("NotifyMacHdrRxEnd",
307 "Whether the PHY is capable of notifying the MAC about the end of "
308 "the reception of the MAC header of every MPDU.",
309 BooleanValue(false),
312 .AddTraceSource(
313 "PhyTxBegin",
314 "Trace source indicating a packet has begun transmitting over the medium; "
315 "the packet holds a single MPDU even if the MPDU is transmitted within an A-MPDU "
316 "(in which case this trace fires for each MPDU in the "
317 "A-MPDU).",
319 "ns3::WifiPhy::PhyTxBeginTracedCallback")
320 .AddTraceSource(
321 "PhyTxPsduBegin",
322 "Trace source indicating a PSDU has begun transmitting over the channel medium; "
323 "this trace returns a WifiConstPsduMap with a single element (in the case of SU "
324 "PPDU) "
325 "or multiple elements (in the case of MU PPDU)",
327 "ns3::WifiPhy::PsduTxBeginCallback")
328 .AddTraceSource("PhyTxEnd",
329 "Trace source indicating a packet "
330 "has been completely transmitted over the channel.",
332 "ns3::Packet::TracedCallback")
333 .AddTraceSource("PhyTxDrop",
334 "Trace source indicating a packet "
335 "has been dropped by the device during transmission",
337 "ns3::Packet::TracedCallback")
338 .AddTraceSource("PhyRxBegin",
339 "Trace source indicating a packet "
340 "has begun being received from the channel medium "
341 "by the device",
343 "ns3::WifiPhy::PhyRxBeginTracedCallback")
344 .AddTraceSource("PhyRxPayloadBegin",
345 "Trace source indicating the reception of the "
346 "payload of a PPDU has begun",
348 "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
349 .AddTraceSource("PhyRxMacHeaderEnd",
350 "Trace source indicating the MAC header of an MPDU has been "
351 "completely received.",
353 "ns3::WifiPhy::PhyRxMacHeaderEndTracedCallback")
354 .AddTraceSource("PhyRxEnd",
355 "Trace source indicating a packet "
356 "has been completely received from the channel medium "
357 "by the device",
359 "ns3::Packet::TracedCallback")
360 .AddTraceSource("PhyRxDrop",
361 "Trace source indicating a packet "
362 "has been dropped by the device during reception",
364 "ns3::WifiPhy::PhyRxDropTracedCallback")
365 .AddTraceSource("PhyRxPpduDrop",
366 "Trace source indicating a ppdu "
367 "has been dropped by the device during reception",
369 "ns3::WifiPhy::PhyRxPpduDropTracedCallback")
370 .AddTraceSource("MonitorSnifferRx",
371 "Trace source simulating a wifi device in monitor mode "
372 "sniffing all received frames",
374 "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
375 .AddTraceSource("MonitorSnifferTx",
376 "Trace source simulating the capability of a wifi device "
377 "in monitor mode to sniff all frames being transmitted",
379 "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
380 .AddTraceSource("SignalTransmission",
381 "Trace start of signal transmission",
383 "ns3::SpectrumWifiPhy::SignalTransmissionCallback");
384 return tid;
385}
386
388 : m_phyId(0),
389 m_txMpduReferenceNumber(0xffffffff),
390 m_rxMpduReferenceNumber(0xffffffff),
391 m_endPhyRxEvent(),
392 m_endTxEvent(),
393 m_currentEvent(nullptr),
394 m_previouslyRxPpduUid(UINT64_MAX),
395 m_standard(WIFI_STANDARD_UNSPECIFIED),
396 m_maxModClassSupported(WIFI_MOD_CLASS_UNKNOWN),
398 m_sifs(),
399 m_slot(),
400 m_pifs(),
401 m_powerRestricted(false),
402 m_channelAccessRequested(false),
403 m_txSpatialStreams(1),
404 m_rxSpatialStreams(1),
405 m_wifiRadioEnergyModel(nullptr),
406 m_timeLastPreambleDetected()
407{
408 NS_LOG_FUNCTION(this);
411}
412
414{
415 NS_LOG_FUNCTION(this);
416}
417
418void
420{
421 NS_LOG_FUNCTION(this);
422
423 // This method ensures that the local mobility model pointer holds
424 // a pointer to the Node's aggregated mobility model (if one exists)
425 // in the case that the user has not directly called SetMobility()
426 // on this WifiPhy during simulation setup. If the mobility model
427 // needs to be added or changed during simulation runtime, users must
428 // call SetMobility() on this object.
429
430 if (!m_mobility)
431 {
433 "Either install a MobilityModel on this object or ensure that this "
434 "object is part of a Node and NetDevice");
435 m_mobility = m_device->GetNode()->GetObject<MobilityModel>();
436 if (!m_mobility)
437 {
438 NS_LOG_WARN("Mobility not found, propagation models might not work properly");
439 }
440 }
441}
442
443void
445{
446 NS_LOG_FUNCTION(this);
447
448 m_device = nullptr;
449 m_mobility = nullptr;
450 m_frameCaptureModel = nullptr;
451 m_preambleDetectionModel = nullptr;
452 m_wifiRadioEnergyModel = nullptr;
454 if (m_interference)
455 {
456 m_interference->Dispose();
457 }
458 m_interference = nullptr;
459 m_random = nullptr;
460 m_state = nullptr;
461
462 Reset();
463
464 // this should be done after calling the Reset function
465 for (auto& phyEntity : m_phyEntities)
466 {
467 phyEntity.second = nullptr;
468 }
469 m_phyEntities.clear();
470}
471
472std::map<WifiModulationClass, Ptr<PhyEntity>>&
474{
475 static std::map<WifiModulationClass, Ptr<PhyEntity>> g_staticPhyEntities;
476 return g_staticPhyEntities;
477}
478
481{
482 return m_state;
483}
484
485void
487{
488 m_state->SetReceiveOkCallback(callback);
489}
490
491void
493{
494 m_state->SetReceiveErrorCallback(callback);
495}
496
497void
498WifiPhy::RegisterListener(const std::shared_ptr<WifiPhyListener>& listener)
499{
500 m_state->RegisterListener(listener);
501 if (IsInitialized())
502 {
503 // provide CCA busy information upon registering a PHY listener
504 SwitchMaybeToCcaBusy(nullptr);
505 }
506}
507
508void
509WifiPhy::UnregisterListener(const std::shared_ptr<WifiPhyListener>& listener)
510{
511 m_state->UnregisterListener(listener);
512}
513
514void
519
520void
522{
523 NS_LOG_FUNCTION(this << threshold);
524 m_rxSensitivity = threshold;
525}
526
527dBm_u
529{
530 return m_rxSensitivity;
531}
532
533void
535{
536 NS_LOG_FUNCTION(this << threshold);
537 m_ccaEdThreshold = threshold;
538}
539
540dBm_u
542{
543 return m_ccaEdThreshold;
544}
545
546void
548{
549 NS_LOG_FUNCTION(this << threshold);
550 m_ccaSensitivityThreshold = threshold;
551}
552
553dBm_u
558
559void
561{
562 NS_LOG_FUNCTION(this << noiseFigure);
563 if (m_interference)
564 {
565 m_interference->SetNoiseFigure(DbToRatio(noiseFigure));
566 }
567 m_noiseFigure = noiseFigure;
568}
569
570void
572{
573 NS_LOG_FUNCTION(this << start);
574 m_txPowerBase = start;
575}
576
577dBm_u
579{
580 return m_txPowerBase;
581}
582
583void
585{
586 NS_LOG_FUNCTION(this << end);
587 m_txPowerEnd = end;
588}
589
590dBm_u
592{
593 return m_txPowerEnd;
594}
595
596void
598{
599 NS_LOG_FUNCTION(this << +n);
600 m_nTxPower = n;
601}
602
603uint8_t
605{
606 return m_nTxPower;
607}
608
609void
611{
612 NS_LOG_FUNCTION(this << gain);
613 m_txGain = gain;
614}
615
616dB_u
618{
619 return m_txGain;
620}
621
622void
624{
625 NS_LOG_FUNCTION(this << gain);
626 m_rxGain = gain;
627}
628
629dB_u
631{
632 return m_rxGain;
633}
634
635void
637{
638 NS_LOG_FUNCTION(this << enable);
639 m_shortPreamble = enable;
640}
641
642bool
647
648void
650{
651 m_device = device;
652}
653
656{
657 return m_device;
658}
659
660void
662{
663 m_mobility = mobility;
664}
665
668{
669 return m_mobility;
670}
671
672void
673WifiPhy::SetPhyId(uint8_t phyId)
674{
675 NS_LOG_FUNCTION(this << phyId);
676 m_phyId = phyId;
677}
678
679uint8_t
681{
682 return m_phyId;
683}
684
685void
687{
688 NS_LOG_FUNCTION(this << helper);
689 m_interference = helper;
690 m_interference->SetNoiseFigure(DbToRatio(m_noiseFigure));
691 m_interference->SetNumberOfReceiveAntennas(m_numberOfAntennas);
692}
693
694void
696{
697 NS_LOG_FUNCTION(this << model);
699 m_interference->SetErrorRateModel(model);
700}
701
702void
708
709void
714
715void
720
721void
723{
724 m_wifiRadioEnergyModel = wifiRadioEnergyModel;
725}
726
727dBm_u
728WifiPhy::GetPower(uint8_t powerLevel) const
729{
732 dBm_u dbm;
733 if (m_nTxPower > 1)
734 {
735 dbm = m_txPowerBase + dB_u{powerLevel * (m_txPowerEnd - m_txPowerBase) / (m_nTxPower - 1)};
736 }
737 else
738 {
740 "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
741 dbm = m_txPowerBase;
742 }
743 return dbm;
744}
745
746Time
751
752double
753WifiPhy::CalculateSnr(const WifiTxVector& txVector, double ber) const
754{
755 return m_interference->GetErrorRateModel()->CalculateSnr(txVector, ber);
756}
757
760{
761 const auto it = GetStaticPhyEntities().find(modulation);
763 "Unimplemented Wi-Fi modulation class " << modulation);
764 return it->second;
765}
766
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
778{
780}
781
787
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
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
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);
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 Ptr<DsssPhy> phyEntity = Create<DsssPhy>();
886 AddPhyEntity(WIFI_MOD_CLASS_DSSS, phyEntity); // when plain DSSS modes are used
887
888 // See Table 16-4 "HR/DSSS PHY characteristics" of 802.11-2016
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.
907}
908
909void
911{
912 NS_LOG_FUNCTION(this);
913 if (GetChannelWidth() == MHz_u{10})
914 {
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 {
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
951
952void
959
960void
962{
963 NS_LOG_FUNCTION(this);
965 {
967 }
968 else
969 {
971 }
973}
974
975void
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
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{
1078}
1079
1080uint8_t
1082{
1084}
1085
1086MHz_u
1091
1092uint8_t
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);
1126 ChannelSegments segments{};
1127 for (std::size_t segmentId = 0; segmentId < channel.GetNSegments(); ++segmentId)
1128 {
1129 segments.emplace_back(channel.GetNumber(segmentId),
1130 channel.GetWidth(segmentId),
1131 channel.GetPhyBand(),
1132 channel.GetPrimaryChannelIndex(MHz_u{20}));
1133 }
1134 SetOperatingChannel(segments);
1135}
1136
1137void
1142
1143void
1145{
1146 NS_LOG_FUNCTION(this << +std::get<0>(channelSegments.front())
1147 << std::get<1>(channelSegments.front())
1148 << static_cast<WifiPhyBand>(std::get<2>(channelSegments.front()))
1149 << +std::get<3>(channelSegments.front()));
1150
1151 m_channelSettings = channelSegments;
1152
1154 {
1155 NS_LOG_DEBUG("Channel information will be applied when a standard is configured");
1156 return;
1157 }
1158
1159 if (IsInitialized())
1160 {
1161 const auto delay = GetDelayUntilChannelSwitch();
1162 if (!delay.has_value())
1163 {
1164 // switching channel is not possible now
1165 return;
1166 }
1167 if (delay.value().IsStrictlyPositive())
1168 {
1169 // switching channel has been postponed
1171 Simulator::Schedule(delay.value(), fp, this, channelSegments);
1172 return;
1173 }
1174 }
1175
1176 // channel can be switched now.
1178}
1179
1180std::optional<Time>
1182{
1183 if (!IsInitialized())
1184 {
1185 // this is not channel switch, this is initialization
1186 NS_LOG_DEBUG("Before initialization, nothing to do");
1187 return Seconds(0);
1188 }
1189
1190 std::optional<Time> delay;
1191 switch (m_state->GetState())
1192 {
1193 case WifiPhyState::RX:
1194 NS_LOG_DEBUG("drop packet because of channel switching while reception");
1196 delay = Seconds(0);
1197 break;
1198 case WifiPhyState::TX:
1199 NS_LOG_DEBUG("channel switching postponed until end of current transmission");
1200 delay = GetDelayUntilIdle();
1201 break;
1203 case WifiPhyState::IDLE:
1204 Reset();
1205 delay = Seconds(0);
1206 break;
1208 delay = Seconds(0);
1209 break;
1211 NS_LOG_DEBUG("channel switching ignored in sleep mode");
1212 break;
1213 default:
1214 NS_ASSERT(false);
1215 break;
1216 }
1217
1218 return delay;
1219}
1220
1221void
1223{
1224 NS_LOG_FUNCTION(this);
1225
1226 m_powerRestricted = false;
1228
1229 // Update unspecified parameters with default values
1230 std::optional<uint8_t> prevChannelNumber{};
1231 for (auto& [number, width, band, primary20] : m_channelSettings)
1232 {
1233 if (band == WIFI_PHY_BAND_UNSPECIFIED)
1234 {
1236 }
1237 if (width == MHz_u{0} && number == 0)
1238 {
1239 width = GetDefaultChannelWidth(m_standard, static_cast<WifiPhyBand>(band));
1240 }
1241 if (number == 0)
1242 {
1243 number =
1245 m_standard,
1246 static_cast<WifiPhyBand>(band),
1247 prevChannelNumber);
1248 }
1249 prevChannelNumber = number;
1250 }
1251
1252 // We need to call SetStandard if this is the first time we set a channel or we
1253 // are changing PHY band. Checking if the new PHY band is different than the
1254 // previous one covers both cases because initially the PHY band is unspecified
1255 bool changingPhyBand =
1256 (static_cast<WifiPhyBand>(std::get<2>(m_channelSettings.front())) != m_band);
1257
1258 NS_ABORT_MSG_IF(IsInitialized() && m_fixedPhyBand && changingPhyBand,
1259 "Trying to change PHY band while prohibited.");
1260
1261 m_band = static_cast<WifiPhyBand>(std::get<2>(m_channelSettings.front()));
1262
1263 NS_LOG_DEBUG("switching channel");
1264 std::vector<FrequencyChannelInfo> segments{};
1265 std::transform(m_channelSettings.cbegin(),
1266 m_channelSettings.cend(),
1267 std::back_inserter(segments),
1268 [this](const auto& channelTuple) {
1269 return FrequencyChannelInfo{std::get<0>(channelTuple),
1270 MHz_u{0},
1271 std::get<1>(channelTuple),
1272 m_band};
1273 });
1274 m_operatingChannel.Set(segments, m_standard);
1275 m_operatingChannel.SetPrimary20Index(std::get<3>(m_channelSettings.front()));
1276
1277 // check that the channel width is supported
1278 if (const auto chWidth = GetChannelWidth();
1279 (m_maxRadioBw != MHz_u{0}) && (chWidth > m_maxRadioBw))
1280 {
1281 // throw an exception instead of using NS_ABORT_MSG for unit testing this code
1282 throw std::runtime_error("Attempting to set a " + std::to_string(chWidth) +
1283 " MHz channel on a station only supporting " +
1284 std::to_string(m_maxRadioBw) + " MHz operation");
1285 }
1286
1287 if (changingPhyBand)
1288 {
1289 ConfigureStandard(m_standard);
1290 }
1291
1292 FinalizeChannelSwitch();
1293
1294 if (IsInitialized())
1295 {
1296 // notify channel switching
1297 m_state->SwitchToChannelSwitching(GetChannelSwitchDelay());
1299 * Needed here to be able to correctly sensed the medium for the first
1300 * time after the switching. The actual switching is not performed until
1301 * after m_channelSwitchDelay. Packets received during the switching
1302 * state are added to the event list and are employed later to figure
1303 * out the state of the medium after the switching.
1304 */
1305 SwitchMaybeToCcaBusy(nullptr);
1306 }
1307}
1308
1309void
1310WifiPhy::SetNumberOfAntennas(uint8_t antennas)
1311{
1312 NS_LOG_FUNCTION(this << +antennas);
1313 NS_ASSERT_MSG(antennas > 0 && antennas <= 8, "unsupported number of antennas");
1314 m_numberOfAntennas = antennas;
1315 if (m_interference)
1316 {
1317 m_interference->SetNumberOfReceiveAntennas(antennas);
1318 }
1319}
1320
1321uint8_t
1322WifiPhy::GetNumberOfAntennas() const
1323{
1324 return m_numberOfAntennas;
1325}
1326
1327void
1328WifiPhy::SetMaxSupportedTxSpatialStreams(uint8_t streams)
1329{
1330 NS_ASSERT(streams <= GetNumberOfAntennas());
1331 bool changed = (m_txSpatialStreams != streams);
1332 m_txSpatialStreams = streams;
1333 if (changed)
1334 {
1335 auto phyEntity = m_phyEntities.find(WIFI_MOD_CLASS_HT);
1336 if (phyEntity != m_phyEntities.end())
1337 {
1338 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity->second);
1339 if (htPhy)
1340 {
1341 htPhy->SetMaxSupportedNss(
1342 m_txSpatialStreams); // this is essential to have the right MCSs configured
1343 }
1344
1345 if (!m_capabilitiesChangedCallback.IsNull())
1346 {
1347 m_capabilitiesChangedCallback();
1348 }
1349 }
1350 }
1351}
1352
1353uint8_t
1354WifiPhy::GetMaxSupportedTxSpatialStreams() const
1355{
1356 return m_txSpatialStreams;
1357}
1358
1359void
1360WifiPhy::SetMaxSupportedRxSpatialStreams(uint8_t streams)
1361{
1362 NS_ASSERT(streams <= GetNumberOfAntennas());
1363 bool changed = (m_rxSpatialStreams != streams);
1364 m_rxSpatialStreams = streams;
1365 if (changed && !m_capabilitiesChangedCallback.IsNull())
1366 {
1367 m_capabilitiesChangedCallback();
1368 }
1369}
1370
1371uint8_t
1372WifiPhy::GetMaxSupportedRxSpatialStreams() const
1373{
1374 return m_rxSpatialStreams;
1375}
1376
1377std::list<uint8_t>
1378WifiPhy::GetBssMembershipSelectorList() const
1379{
1380 std::list<uint8_t> list;
1381 for (const auto& phyEntity : m_phyEntities)
1382 {
1383 Ptr<HtPhy> htPhy = DynamicCast<HtPhy>(phyEntity.second);
1384 if (htPhy)
1385 {
1386 list.emplace_back(htPhy->GetBssMembershipSelector());
1387 }
1388 }
1389 return list;
1390}
1391
1392void
1393WifiPhy::SetSleepMode(bool forceSleepInRx)
1394{
1395 NS_LOG_FUNCTION(this);
1396 m_powerRestricted = false;
1397 m_channelAccessRequested = false;
1398 switch (m_state->GetState())
1399 {
1400 case WifiPhyState::TX:
1401 NS_LOG_DEBUG("setting sleep mode postponed until end of current transmission");
1402 Simulator::Schedule(GetDelayUntilIdle(), &WifiPhy::SetSleepMode, this, forceSleepInRx);
1403 break;
1404 case WifiPhyState::RX:
1405 NS_LOG_DEBUG("setting sleep mode"
1406 << (forceSleepInRx ? "" : "postponed until end of current reception"));
1407 if (forceSleepInRx)
1408 {
1409 AbortCurrentReception(WifiPhyRxfailureReason::SLEEPING);
1410 m_state->SwitchToSleep();
1411 }
1412 else
1413 {
1414 Simulator::Schedule(GetDelayUntilIdle(), &WifiPhy::SetSleepMode, this, forceSleepInRx);
1415 }
1416 break;
1417 case WifiPhyState::SWITCHING:
1418 NS_LOG_DEBUG("setting sleep mode postponed until end of channel switching");
1419 Simulator::Schedule(GetDelayUntilIdle(), &WifiPhy::SetSleepMode, this, forceSleepInRx);
1420 break;
1421 case WifiPhyState::CCA_BUSY:
1422 case WifiPhyState::IDLE:
1423 NS_LOG_DEBUG("setting sleep mode");
1424 // The PHY object may be in CCA_BUSY state because it is receiving a preamble. Cancel
1425 // preamble events before switching to sleep state
1426 Reset();
1427 m_state->SwitchToSleep();
1428 break;
1429 case WifiPhyState::SLEEP:
1430 NS_LOG_DEBUG("already in sleep mode");
1431 break;
1432 default:
1433 NS_ASSERT(false);
1434 break;
1435 }
1436}
1437
1438void
1439WifiPhy::SetOffMode()
1440{
1441 NS_LOG_FUNCTION(this);
1442 m_powerRestricted = false;
1443 m_channelAccessRequested = false;
1444 Reset();
1445 m_state->SwitchToOff();
1446}
1447
1448void
1449WifiPhy::ResumeFromSleep()
1450{
1451 NS_LOG_FUNCTION(this);
1452 switch (m_state->GetState())
1453 {
1454 case WifiPhyState::TX:
1455 case WifiPhyState::RX:
1456 case WifiPhyState::IDLE:
1457 case WifiPhyState::CCA_BUSY:
1458 case WifiPhyState::SWITCHING: {
1459 NS_LOG_DEBUG("not in sleep mode, there is nothing to resume");
1460 break;
1461 }
1462 case WifiPhyState::SLEEP: {
1463 NS_LOG_DEBUG("resuming from sleep mode");
1464 m_state->SwitchFromSleep();
1465 SwitchMaybeToCcaBusy();
1466 break;
1467 }
1468 default: {
1469 NS_ASSERT(false);
1470 break;
1471 }
1472 }
1473}
1474
1475void
1476WifiPhy::ResumeFromOff()
1477{
1478 NS_LOG_FUNCTION(this);
1479 switch (m_state->GetState())
1480 {
1481 case WifiPhyState::TX:
1482 case WifiPhyState::RX:
1483 case WifiPhyState::IDLE:
1484 case WifiPhyState::CCA_BUSY:
1485 case WifiPhyState::SWITCHING:
1486 case WifiPhyState::SLEEP: {
1487 NS_LOG_DEBUG("not in off mode, there is nothing to resume");
1488 break;
1489 }
1490 case WifiPhyState::OFF: {
1491 NS_LOG_DEBUG("resuming from off mode");
1492 m_state->SwitchFromOff();
1493 SwitchMaybeToCcaBusy();
1494 break;
1495 }
1496 default: {
1497 NS_ASSERT(false);
1498 break;
1499 }
1500 }
1501}
1502
1503Time
1504WifiPhy::GetPreambleDetectionDuration()
1505{
1506 return MicroSeconds(4);
1507}
1508
1509Time
1510WifiPhy::GetStartOfPacketDuration(const WifiTxVector& txVector)
1511{
1512 return MicroSeconds(4);
1513}
1514
1515Time
1516WifiPhy::GetPayloadDuration(uint32_t size,
1517 const WifiTxVector& txVector,
1518 WifiPhyBand band,
1519 MpduType mpdutype,
1520 uint16_t staId)
1521{
1522 uint32_t totalAmpduSize;
1523 double totalAmpduNumSymbols;
1524 return GetPayloadDuration(size,
1525 txVector,
1526 band,
1527 mpdutype,
1528 false,
1529 totalAmpduSize,
1530 totalAmpduNumSymbols,
1531 staId);
1532}
1533
1534Time
1535WifiPhy::GetPayloadDuration(uint32_t size,
1536 const WifiTxVector& txVector,
1537 WifiPhyBand band,
1538 MpduType mpdutype,
1539 bool incFlag,
1540 uint32_t& totalAmpduSize,
1541 double& totalAmpduNumSymbols,
1542 uint16_t staId)
1543{
1544 return GetStaticPhyEntity(txVector.GetModulationClass())
1545 ->GetPayloadDuration(size,
1546 txVector,
1547 band,
1548 mpdutype,
1549 incFlag,
1550 totalAmpduSize,
1551 totalAmpduNumSymbols,
1552 staId);
1553}
1554
1555Time
1556WifiPhy::CalculatePhyPreambleAndHeaderDuration(const WifiTxVector& txVector)
1557{
1558 return GetStaticPhyEntity(txVector.GetModulationClass())
1559 ->CalculatePhyPreambleAndHeaderDuration(txVector);
1560}
1561
1562Time
1563WifiPhy::CalculateTxDuration(uint32_t size,
1564 const WifiTxVector& txVector,
1565 WifiPhyBand band,
1566 uint16_t staId)
1567{
1568 Time duration = CalculatePhyPreambleAndHeaderDuration(txVector) +
1569 GetPayloadDuration(size, txVector, band, NORMAL_MPDU, staId);
1570 NS_ASSERT(duration.IsStrictlyPositive());
1571 return duration;
1572}
1573
1574Time
1575WifiPhy::CalculateTxDuration(Ptr<const WifiPsdu> psdu,
1576 const WifiTxVector& txVector,
1577 WifiPhyBand band)
1578{
1579 return CalculateTxDuration(GetWifiConstPsduMap(psdu, txVector), txVector, band);
1580}
1581
1582Time
1583WifiPhy::CalculateTxDuration(const WifiConstPsduMap& psduMap,
1584 const WifiTxVector& txVector,
1585 WifiPhyBand band)
1586{
1587 return GetStaticPhyEntity(txVector.GetModulationClass())
1588 ->CalculateTxDuration(psduMap, txVector, band);
1589}
1590
1592WifiPhy::GetMaxPsduSize(WifiModulationClass modulation)
1593{
1594 return GetStaticPhyEntity(modulation)->GetMaxPsduSize();
1595}
1596
1597void
1598WifiPhy::NotifyTxBegin(const WifiConstPsduMap& psdus, Watt_u txPower)
1599{
1600 if (!m_phyTxBeginTrace.IsEmpty())
1601 {
1602 for (const auto& psdu : psdus)
1603 {
1604 for (auto& mpdu : *PeekPointer(psdu.second))
1605 {
1606 m_phyTxBeginTrace(mpdu->GetProtocolDataUnit(), txPower);
1607 }
1608 }
1609 }
1610}
1611
1612void
1613WifiPhy::NotifyTxEnd(const WifiConstPsduMap& psdus)
1614{
1615 if (!m_phyTxEndTrace.IsEmpty())
1616 {
1617 for (const auto& psdu : psdus)
1618 {
1619 for (auto& mpdu : *PeekPointer(psdu.second))
1620 {
1621 m_phyTxEndTrace(mpdu->GetProtocolDataUnit());
1622 }
1623 }
1624 }
1625}
1626
1627void
1628WifiPhy::NotifyTxDrop(Ptr<const WifiPsdu> psdu)
1629{
1630 if (!m_phyTxDropTrace.IsEmpty())
1631 {
1632 for (auto& mpdu : *PeekPointer(psdu))
1633 {
1634 m_phyTxDropTrace(mpdu->GetProtocolDataUnit());
1635 }
1636 }
1637}
1638
1639void
1640WifiPhy::NotifyRxBegin(Ptr<const WifiPsdu> psdu, const RxPowerWattPerChannelBand& rxPowersW)
1641{
1642 if (psdu && !m_phyRxBeginTrace.IsEmpty())
1643 {
1644 for (auto& mpdu : *PeekPointer(psdu))
1645 {
1646 m_phyRxBeginTrace(mpdu->GetProtocolDataUnit(), rxPowersW);
1647 }
1648 }
1649}
1650
1651void
1652WifiPhy::NotifyRxEnd(Ptr<const WifiPsdu> psdu)
1653{
1654 if (psdu && !m_phyRxEndTrace.IsEmpty())
1655 {
1656 for (auto& mpdu : *PeekPointer(psdu))
1657 {
1658 m_phyRxEndTrace(mpdu->GetProtocolDataUnit());
1659 }
1660 }
1661}
1662
1663void
1664WifiPhy::NotifyRxDrop(Ptr<const WifiPsdu> psdu, WifiPhyRxfailureReason reason)
1665{
1666 if (psdu && !m_phyRxDropTrace.IsEmpty())
1667 {
1668 for (auto& mpdu : *PeekPointer(psdu))
1669 {
1670 m_phyRxDropTrace(mpdu->GetProtocolDataUnit(), reason);
1671 }
1672 }
1673}
1674
1675void
1676WifiPhy::NotifyRxPpduDrop(Ptr<const WifiPpdu> ppdu, WifiPhyRxfailureReason reason)
1677{
1678 NotifyRxDrop(GetAddressedPsduInPpdu(ppdu), reason);
1679 m_phyRxPpduDropTrace(ppdu, reason);
1680}
1681
1682void
1683WifiPhy::NotifyMonitorSniffRx(Ptr<const WifiPsdu> psdu,
1684 MHz_u channelFreq,
1685 const WifiTxVector& txVector,
1686 SignalNoiseDbm signalNoise,
1687 const std::vector<bool>& statusPerMpdu,
1688 uint16_t staId)
1689{
1690 MpduInfo aMpdu;
1691 if (psdu->IsAggregate())
1692 {
1693 // Expand A-MPDU
1694 NS_ASSERT_MSG(txVector.IsAggregation(),
1695 "TxVector with aggregate flag expected here according to PSDU");
1696 aMpdu.mpduRefNumber = ++m_rxMpduReferenceNumber;
1697 size_t nMpdus = psdu->GetNMpdus();
1698 NS_ASSERT_MSG(statusPerMpdu.size() == nMpdus, "Should have one reception status per MPDU");
1699 if (!m_phyMonitorSniffRxTrace.IsEmpty())
1700 {
1701 aMpdu.type = (psdu->IsSingle()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1702 for (size_t i = 0; i < nMpdus;)
1703 {
1704 if (statusPerMpdu.at(i)) // packet received without error, hand over to sniffer
1705 {
1706 m_phyMonitorSniffRxTrace(psdu->GetAmpduSubframe(i),
1707 static_cast<uint16_t>(channelFreq),
1708 txVector,
1709 aMpdu,
1710 signalNoise,
1711 staId);
1712 }
1713 ++i;
1714 aMpdu.type =
1715 (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1716 }
1717 }
1718 }
1719 else
1720 {
1721 NS_ASSERT_MSG(statusPerMpdu.size() == 1,
1722 "Should have one reception status for normal MPDU");
1723 if (!m_phyMonitorSniffRxTrace.IsEmpty())
1724 {
1725 aMpdu.type = NORMAL_MPDU;
1726 m_phyMonitorSniffRxTrace(psdu->GetPacket(),
1727 static_cast<uint16_t>(channelFreq),
1728 txVector,
1729 aMpdu,
1730 signalNoise,
1731 staId);
1732 }
1733 }
1734}
1735
1736void
1737WifiPhy::NotifyMonitorSniffTx(Ptr<const WifiPsdu> psdu,
1738 MHz_u channelFreq,
1739 const WifiTxVector& txVector,
1740 uint16_t staId)
1741{
1742 MpduInfo aMpdu;
1743 if (psdu->IsAggregate())
1744 {
1745 // Expand A-MPDU
1746 NS_ASSERT_MSG(txVector.IsAggregation(),
1747 "TxVector with aggregate flag expected here according to PSDU");
1748 aMpdu.mpduRefNumber = ++m_rxMpduReferenceNumber;
1749 if (!m_phyMonitorSniffTxTrace.IsEmpty())
1750 {
1751 size_t nMpdus = psdu->GetNMpdus();
1752 aMpdu.type = (psdu->IsSingle()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1753 for (size_t i = 0; i < nMpdus;)
1754 {
1755 m_phyMonitorSniffTxTrace(psdu->GetAmpduSubframe(i),
1756 channelFreq,
1757 txVector,
1758 aMpdu,
1759 staId);
1760 ++i;
1761 aMpdu.type =
1762 (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1763 }
1764 }
1765 }
1766 else
1767 {
1768 if (!m_phyMonitorSniffTxTrace.IsEmpty())
1769 {
1770 aMpdu.type = NORMAL_MPDU;
1771 m_phyMonitorSniffTxTrace(psdu->GetPacket(), channelFreq, txVector, aMpdu, staId);
1772 }
1773 }
1774}
1775
1776std::optional<Time>
1777WifiPhy::GetTimeToPreambleDetectionEnd() const
1778{
1779 for (const auto& [modClass, phyEntity] : m_phyEntities)
1780 {
1781 if (auto remTime = phyEntity->GetTimeToPreambleDetectionEnd())
1782 {
1783 return remTime;
1784 }
1785 }
1786 return std::nullopt;
1787}
1788
1789std::optional<Time>
1790WifiPhy::GetTimeToMacHdrEnd(uint16_t staId) const
1791{
1792 for (auto& [modClass, phyEntity] : m_phyEntities)
1793 {
1794 if (auto remTime = phyEntity->GetTimeToMacHdrEnd(staId))
1795 {
1796 return remTime;
1797 }
1798 }
1799 return std::nullopt;
1800}
1801
1803WifiPhy::GetWifiConstPsduMap(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector)
1804{
1805 return GetStaticPhyEntity(txVector.GetModulationClass())->GetWifiConstPsduMap(psdu, txVector);
1806}
1807
1808void
1809WifiPhy::Send(Ptr<const WifiPsdu> psdu, const WifiTxVector& txVector)
1810{
1811 NS_LOG_FUNCTION(this << *psdu << txVector);
1812 Send(GetWifiConstPsduMap(psdu, txVector), txVector);
1813}
1814
1815void
1816WifiPhy::Send(const WifiConstPsduMap& psdus, const WifiTxVector& txVector)
1817{
1818 NS_LOG_FUNCTION(this << psdus << txVector);
1819 /* Transmission can happen if:
1820 * - we are syncing on a packet. It is the responsibility of the
1821 * MAC layer to avoid doing this but the PHY does nothing to
1822 * prevent it.
1823 * - we are idle
1824 */
1825 NS_ASSERT(!m_state->IsStateTx() && !m_state->IsStateSwitching());
1826 NS_ASSERT(m_endTxEvent.IsExpired());
1827
1828 if (!txVector.IsValid(m_band))
1829 {
1830 NS_FATAL_ERROR("TX-VECTOR is invalid!");
1831 }
1832
1833 uint8_t nss = 0;
1834 if (txVector.IsMu())
1835 {
1836 // We do not support mixed OFDMA and MU-MIMO
1837 if (txVector.IsDlMuMimo())
1838 {
1839 nss = txVector.GetNssTotal();
1840 }
1841 else
1842 {
1843 nss = txVector.GetNssMax();
1844 }
1845 }
1846 else
1847 {
1848 nss = txVector.GetNss();
1849 }
1850
1851 if (nss > GetMaxSupportedTxSpatialStreams())
1852 {
1853 NS_FATAL_ERROR("Unsupported number of spatial streams!");
1854 }
1855
1856 if (m_state->IsStateSleep())
1857 {
1858 NS_LOG_DEBUG("Dropping packet because in sleep mode");
1859 for (const auto& psdu : psdus)
1860 {
1861 NotifyTxDrop(psdu.second);
1862 }
1863 return;
1864 }
1865
1866 const auto txDuration = CalculateTxDuration(psdus, txVector, GetPhyBand());
1867
1868 if (const auto timeToPreambleDetectionEnd = GetTimeToPreambleDetectionEnd();
1869 timeToPreambleDetectionEnd && !m_currentEvent)
1870 {
1871 // PHY is in the initial few microseconds during which the
1872 // start of RX has occurred but the preamble detection period
1873 // has not elapsed
1874 AbortCurrentReception(SIGNAL_DETECTION_ABORTED_BY_TX);
1875 }
1876 else if (timeToPreambleDetectionEnd || m_currentEvent)
1877 {
1878 AbortCurrentReception(RECEPTION_ABORTED_BY_TX);
1879 }
1880
1881 if (m_powerRestricted)
1882 {
1883 NS_LOG_DEBUG("Transmitting with power restriction for " << txDuration.As(Time::NS));
1884 }
1885 else
1886 {
1887 NS_LOG_DEBUG("Transmitting without power restriction for " << txDuration.As(Time::NS));
1888 }
1889
1890 if (m_state->GetState() == WifiPhyState::OFF)
1891 {
1892 NS_LOG_DEBUG("Transmission canceled because device is OFF");
1893 return;
1894 }
1895
1896 auto ppdu = GetPhyEntity(txVector.GetModulationClass())->BuildPpdu(psdus, txVector, txDuration);
1897 m_previouslyRxPpduUid = UINT64_MAX; // reset (after creation of PPDU) to use it only once
1898
1899 const auto txPower = DbmToW(GetTxPowerForTransmission(ppdu) + GetTxGain());
1900 NotifyTxBegin(psdus, txPower);
1901 if (!m_phyTxPsduBeginTrace.IsEmpty())
1902 {
1903 m_phyTxPsduBeginTrace(psdus, txVector, txPower);
1904 }
1905 for (const auto& psdu : psdus)
1906 {
1907 NotifyMonitorSniffTx(psdu.second, GetFrequency(), txVector, psdu.first);
1908 }
1909 m_state->SwitchToTx(txDuration, psdus, GetPower(txVector.GetTxPowerLevel()), txVector);
1910
1911 if (m_wifiRadioEnergyModel &&
1912 m_wifiRadioEnergyModel->GetMaximumTimeInState(WifiPhyState::TX) < txDuration)
1913 {
1914 ppdu->SetTruncatedTx();
1915 }
1916
1917 m_endTxEvent =
1918 Simulator::Schedule(txDuration, &WifiPhy::TxDone, this, psdus); // TODO: fix for MU
1919
1920 StartTx(ppdu);
1921 ppdu->ResetTxVector();
1922
1923 m_channelAccessRequested = false;
1924 m_powerRestricted = false;
1925}
1926
1927void
1928WifiPhy::TxDone(const WifiConstPsduMap& psdus)
1929{
1930 NS_LOG_FUNCTION(this << psdus);
1931 NotifyTxEnd(psdus);
1932 Reset();
1933 // we might have received signals during TX
1934 SwitchMaybeToCcaBusy();
1935}
1936
1937uint64_t
1938WifiPhy::GetPreviouslyRxPpduUid() const
1939{
1940 return m_previouslyRxPpduUid;
1941}
1942
1943void
1944WifiPhy::SetPreviouslyRxPpduUid(uint64_t uid)
1945{
1946 NS_ASSERT(m_standard >= WIFI_STANDARD_80211be);
1947 m_previouslyRxPpduUid = uid;
1948}
1949
1950void
1951WifiPhy::Reset()
1952{
1953 NS_LOG_FUNCTION(this);
1954 m_currentPreambleEvents.clear();
1955 if (m_interference && (m_currentEvent || GetTimeToPreambleDetectionEnd()))
1956 {
1957 m_interference->NotifyRxEnd(Simulator::Now(), GetCurrentFrequencyRange());
1958 }
1959 m_currentEvent = nullptr;
1960 for (auto& phyEntity : m_phyEntities)
1961 {
1962 phyEntity.second->CancelAllEvents();
1963 }
1964 m_endPhyRxEvent.Cancel();
1965 m_endTxEvent.Cancel();
1966}
1967
1968void
1969WifiPhy::StartReceivePreamble(Ptr<const WifiPpdu> ppdu,
1970 RxPowerWattPerChannelBand& rxPowersW,
1971 Time rxDuration)
1972{
1973 NS_LOG_FUNCTION(this << ppdu << rxDuration);
1974 WifiModulationClass modulation = ppdu->GetModulation();
1975 NS_ASSERT(m_maxModClassSupported != WIFI_MOD_CLASS_UNKNOWN);
1976 if (auto it = m_phyEntities.find(modulation);
1977 it != m_phyEntities.end() && modulation <= m_maxModClassSupported)
1978 {
1979 it->second->StartReceivePreamble(ppdu, rxPowersW, rxDuration);
1980 }
1981 else
1982 {
1983 // TODO find a fallback PHY for receiving the PPDU (e.g. 11a for 11ax due to preamble
1984 // structure)
1985 NS_LOG_DEBUG("Unsupported modulation received (" << modulation << "), consider as noise");
1986 m_interference->Add(ppdu, rxDuration, rxPowersW, GetCurrentFrequencyRange());
1987 SwitchMaybeToCcaBusy();
1988 }
1989}
1990
1991std::optional<std::reference_wrapper<const WifiTxVector>>
1992WifiPhy::GetInfoIfRxingPhyHeader() const
1993{
1994 if (m_endPhyRxEvent.IsPending())
1995 {
1996 NS_ASSERT_MSG(m_currentEvent, "No current event while receiving PHY header");
1997 return std::cref(m_currentEvent->GetPpdu()->GetTxVector());
1998 }
1999 return std::nullopt;
2000}
2001
2002void
2003WifiPhy::EndReceiveInterBss()
2004{
2005 NS_LOG_FUNCTION(this);
2006 if (!m_channelAccessRequested)
2007 {
2008 m_powerRestricted = false;
2009 }
2010}
2011
2012void
2013WifiPhy::NotifyChannelAccessRequested()
2014{
2015 NS_LOG_FUNCTION(this);
2016 m_channelAccessRequested = true;
2017}
2018
2019bool
2020WifiPhy::IsModeSupported(WifiMode mode) const
2021{
2022 for (const auto& phyEntity : m_phyEntities)
2023 {
2024 if (phyEntity.second->IsModeSupported(mode))
2025 {
2026 return true;
2027 }
2028 }
2029 return false;
2030}
2031
2033WifiPhy::GetDefaultMode() const
2034{
2035 // Start from oldest standards and move up (guaranteed by fact that WifModulationClass is
2036 // ordered)
2037 for (const auto& phyEntity : m_phyEntities)
2038 {
2039 for (const auto& mode : *(phyEntity.second))
2040 {
2041 return mode;
2042 }
2043 }
2044 NS_ASSERT_MSG(false, "Should have found at least one default mode");
2045 return WifiMode();
2046}
2047
2048bool
2049WifiPhy::IsMcsSupported(WifiModulationClass modulation, uint8_t mcs) const
2050{
2051 const auto phyEntity = m_phyEntities.find(modulation);
2052 if (phyEntity == m_phyEntities.end())
2053 {
2054 return false;
2055 }
2056 return phyEntity->second->IsMcsSupported(mcs);
2057}
2058
2059std::list<WifiMode>
2060WifiPhy::GetModeList() const
2061{
2062 std::list<WifiMode> list;
2063 for (const auto& phyEntity : m_phyEntities)
2064 {
2065 if (!phyEntity.second->HandlesMcsModes()) // to exclude MCSs from search
2066 {
2067 for (const auto& mode : *(phyEntity.second))
2068 {
2069 list.emplace_back(mode);
2070 }
2071 }
2072 }
2073 return list;
2074}
2075
2076std::list<WifiMode>
2077WifiPhy::GetModeList(WifiModulationClass modulation) const
2078{
2079 std::list<WifiMode> list;
2080 const auto phyEntity = m_phyEntities.find(modulation);
2081 if (phyEntity != m_phyEntities.end())
2082 {
2083 if (!phyEntity->second->HandlesMcsModes()) // to exclude MCSs from search
2084 {
2085 for (const auto& mode : *(phyEntity->second))
2086 {
2087 list.emplace_back(mode);
2088 }
2089 }
2090 }
2091 return list;
2092}
2093
2094uint16_t
2095WifiPhy::GetNMcs() const
2096{
2097 uint16_t numMcs = 0;
2098 for (const auto& phyEntity : m_phyEntities)
2099 {
2100 if (phyEntity.second->HandlesMcsModes()) // to exclude non-MCS modes from search
2101 {
2102 numMcs += phyEntity.second->GetNumModes();
2103 }
2104 }
2105 return numMcs;
2106}
2107
2108std::list<WifiMode>
2109WifiPhy::GetMcsList() const
2110{
2111 std::list<WifiMode> list;
2112 for (const auto& phyEntity : m_phyEntities)
2113 {
2114 if (phyEntity.second->HandlesMcsModes()) // to exclude non-MCS modes from search
2115 {
2116 for (const auto& mode : *(phyEntity.second))
2117 {
2118 list.emplace_back(mode);
2119 }
2120 }
2121 }
2122 return list;
2123}
2124
2125std::list<WifiMode>
2126WifiPhy::GetMcsList(WifiModulationClass modulation) const
2127{
2128 std::list<WifiMode> list;
2129 auto phyEntity = m_phyEntities.find(modulation);
2130 if (phyEntity != m_phyEntities.end())
2131 {
2132 if (phyEntity->second->HandlesMcsModes()) // to exclude non-MCS modes from search
2133 {
2134 for (const auto& mode : *(phyEntity->second))
2135 {
2136 list.emplace_back(mode);
2137 }
2138 }
2139 }
2140 return list;
2141}
2142
2144WifiPhy::GetMcs(WifiModulationClass modulation, uint8_t mcs) const
2145{
2146 NS_ASSERT_MSG(IsMcsSupported(modulation, mcs), "Unsupported MCS");
2147 return m_phyEntities.at(modulation)->GetMcs(mcs);
2148}
2149
2150bool
2151WifiPhy::IsStateCcaBusy() const
2152{
2153 return m_state->IsStateCcaBusy();
2154}
2155
2156bool
2157WifiPhy::IsStateIdle() const
2158{
2159 return m_state->IsStateIdle();
2160}
2161
2162bool
2163WifiPhy::IsStateRx() const
2164{
2165 return m_state->IsStateRx();
2166}
2167
2168bool
2169WifiPhy::IsStateTx() const
2170{
2171 return m_state->IsStateTx();
2172}
2173
2174bool
2175WifiPhy::IsStateSwitching() const
2176{
2177 return m_state->IsStateSwitching();
2178}
2179
2180bool
2181WifiPhy::IsStateSleep() const
2182{
2183 return m_state->IsStateSleep();
2184}
2185
2186bool
2187WifiPhy::IsStateOff() const
2188{
2189 return m_state->IsStateOff();
2190}
2191
2192Time
2193WifiPhy::GetDelayUntilIdle()
2194{
2195 return m_state->GetDelayUntilIdle();
2196}
2197
2198Time
2199WifiPhy::GetLastRxStartTime() const
2200{
2201 return m_state->GetLastRxStartTime();
2202}
2203
2204Time
2205WifiPhy::GetLastRxEndTime() const
2206{
2207 return m_state->GetLastRxEndTime();
2208}
2209
2210void
2211WifiPhy::SwitchMaybeToCcaBusy(const Ptr<const WifiPpdu> ppdu /* = nullptr */)
2212{
2213 NS_LOG_FUNCTION(this);
2214 GetLatestPhyEntity()->SwitchMaybeToCcaBusy(ppdu);
2215}
2216
2217void
2218WifiPhy::NotifyCcaBusy(const Ptr<const WifiPpdu> ppdu, Time duration)
2219{
2220 NS_LOG_FUNCTION(this << duration);
2221 GetLatestPhyEntity()->NotifyCcaBusy(ppdu, duration, WIFI_CHANLIST_PRIMARY);
2222}
2223
2224void
2225WifiPhy::AbortCurrentReception(WifiPhyRxfailureReason reason)
2226{
2227 NS_LOG_FUNCTION(this << reason);
2228 if (reason != OBSS_PD_CCA_RESET ||
2229 m_currentEvent) // Otherwise abort has already been called previously
2230 {
2231 if (reason == SIGNAL_DETECTION_ABORTED_BY_TX)
2232 {
2233 for (auto signalDetectEvent : m_currentPreambleEvents)
2234 {
2235 NotifyRxPpduDrop(signalDetectEvent.second->GetPpdu(),
2237 }
2238 }
2239 for (auto& phyEntity : m_phyEntities)
2240 {
2241 phyEntity.second->CancelAllEvents();
2242 }
2243 m_endPhyRxEvent.Cancel();
2244 m_interference->NotifyRxEnd(Simulator::Now(), GetCurrentFrequencyRange());
2245 if (!m_currentEvent)
2246 {
2247 return;
2248 }
2249 NotifyRxPpduDrop(m_currentEvent->GetPpdu(), reason);
2250 if (reason == OBSS_PD_CCA_RESET)
2251 {
2252 m_state->SwitchFromRxAbort(GetChannelWidth());
2253 }
2254 if (reason == RECEPTION_ABORTED_BY_TX)
2255 {
2256 Reset();
2257 }
2258 else
2259 {
2260 for (auto it = m_currentPreambleEvents.begin(); it != m_currentPreambleEvents.end();
2261 ++it)
2262 {
2263 if (it->second == m_currentEvent)
2264 {
2265 it = m_currentPreambleEvents.erase(it);
2266 break;
2267 }
2268 }
2269 m_currentEvent = nullptr;
2270 }
2271 }
2272}
2273
2274void
2275WifiPhy::ResetCca(bool powerRestricted, dBm_u txPowerMaxSiso, dBm_u txPowerMaxMimo)
2276{
2277 NS_LOG_FUNCTION(this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2278 // This method might be called multiple times when receiving TB PPDUs with a BSS color
2279 // different than the one of the receiver. The first time this method is called, the call
2280 // to AbortCurrentReception sets m_currentEvent to 0. Therefore, we need to check whether
2281 // m_currentEvent is not 0 before executing the instructions below.
2282 if (m_currentEvent)
2283 {
2284 m_powerRestricted = powerRestricted;
2285 m_txPowerMaxSiso = txPowerMaxSiso;
2286 m_txPowerMaxMimo = txPowerMaxMimo;
2287 NS_ASSERT((m_currentEvent->GetEndTime() - Simulator::Now()).IsPositive());
2288 Simulator::Schedule(m_currentEvent->GetEndTime() - Simulator::Now(),
2289 &WifiPhy::EndReceiveInterBss,
2290 this);
2291 Simulator::ScheduleNow(&WifiPhy::AbortCurrentReception,
2292 this,
2293 OBSS_PD_CCA_RESET); // finish processing field first
2294 }
2295}
2296
2297dBm_u
2298WifiPhy::GetTxPowerForTransmission(Ptr<const WifiPpdu> ppdu) const
2299{
2300 NS_LOG_FUNCTION(this << m_powerRestricted << ppdu);
2301 const auto& txVector = ppdu->GetTxVector();
2302 // Get transmit power before antenna gain
2303 dBm_u txPower;
2304 if (!m_powerRestricted)
2305 {
2306 txPower = GetPower(txVector.GetTxPowerLevel());
2307 }
2308 else
2309 {
2310 if (txVector.GetNssMax() > 1 || txVector.GetNssTotal() > 1)
2311 {
2312 txPower = std::min(m_txPowerMaxMimo, GetPower(txVector.GetTxPowerLevel()));
2313 }
2314 else
2315 {
2316 txPower = std::min(m_txPowerMaxSiso, GetPower(txVector.GetTxPowerLevel()));
2317 }
2318 }
2319
2320 // Apply power density constraint on EIRP
2321 const auto channelWidth = ppdu->GetTxChannelWidth();
2322 dBm_per_MHz_u txPowerDbmPerMhz =
2323 (txPower + GetTxGain()) - RatioToDb(channelWidth); // account for antenna gain since EIRP
2324 NS_LOG_INFO("txPower=" << txPower << "dBm with txPowerDbmPerMhz=" << txPowerDbmPerMhz
2325 << " over " << channelWidth << " MHz");
2326 txPower = std::min(txPowerDbmPerMhz, m_powerDensityLimit) + RatioToDb(channelWidth);
2327 txPower -= GetTxGain(); // remove antenna gain since will be added right afterwards
2328 NS_LOG_INFO("txPower=" << txPower
2329 << "dBm after applying m_powerDensityLimit=" << m_powerDensityLimit);
2330 return txPower;
2331}
2332
2334WifiPhy::GetAddressedPsduInPpdu(Ptr<const WifiPpdu> ppdu) const
2335{
2336 // TODO: wrapper. See if still needed
2337 return GetPhyEntityForPpdu(ppdu)->GetAddressedPsduInPpdu(ppdu);
2338}
2339
2340int64_t
2341WifiPhy::AssignStreams(int64_t stream)
2342{
2343 NS_LOG_FUNCTION(this << stream);
2344 int64_t currentStream = stream;
2345 m_random->SetStream(currentStream++);
2346 currentStream += m_interference->GetErrorRateModel()->AssignStreams(currentStream);
2347 return (currentStream - stream);
2348}
2349
2350std::ostream&
2351operator<<(std::ostream& os, RxSignalInfo rxSignalInfo)
2352{
2353 os << "SNR:" << RatioToDb(rxSignalInfo.snr) << " dB"
2354 << ", RSSI:" << rxSignalInfo.rssi << " dBm";
2355 return os;
2356}
2357
2358uint8_t
2359WifiPhy::GetPrimaryChannelNumber(MHz_u primaryChannelWidth) const
2360{
2361 return m_operatingChannel.GetPrimaryChannelNumber(primaryChannelWidth, m_standard);
2362}
2363
2364Hz_u
2365WifiPhy::GetSubcarrierSpacing() const
2366{
2367 Hz_u subcarrierSpacing{0};
2368 switch (GetStandard())
2369 {
2375 subcarrierSpacing = Hz_u{312500};
2376 break;
2378 if (GetChannelWidth() == MHz_u{5})
2379 {
2380 subcarrierSpacing = Hz_u{78125};
2381 }
2382 else
2383 {
2384 subcarrierSpacing = Hz_u{156250};
2385 }
2386 break;
2389 subcarrierSpacing = Hz_u{78125};
2390 break;
2391 default:
2392 NS_FATAL_ERROR("Standard unknown: " << GetStandard());
2393 break;
2394 }
2395 return subcarrierSpacing;
2396}
2397
2398} // namespace ns3
AttributeValue implementation for Boolean.
Definition boolean.h:26
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.
A base class which provides memory management and object aggregation.
Definition object.h:78
bool IsInitialized() const
Check if the object has been initialized.
Definition object.cc:240
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:561
Hold variables of type string.
Definition string.h:45
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
bool IsStrictlyPositive() const
Exactly equivalent to t > 0.
Definition nstime.h:340
AttributeValue implementation for Time.
Definition nstime.h:1432
AttributeValue implementation for Tuple.
Definition tuple.h:67
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:40
WifiModulationClass GetModulationClass() const
Definition wifi-mode.cc:172
802.11 PHY layer model
Definition wifi-phy.h:55
static TypeId GetTypeId()
Get the type ID.
Definition wifi-phy.cc:60
void SetNumberOfAntennas(uint8_t antennas)
Definition wifi-phy.cc:1310
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Definition wifi-phy.h:1346
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
Definition wifi-phy.h:1645
dBm_u m_ccaEdThreshold
Clear channel assessment (CCA) energy detection (ED) threshold.
Definition wifi-phy.h:1616
dBm_u GetTxPowerStart() const
Return the minimum available transmission power level.
Definition wifi-phy.cc:578
WifiModulationClass GetMaxModulationClassSupported() const
Definition wifi-phy.cc:991
void SetRxGain(dB_u gain)
Sets the reception gain.
Definition wifi-phy.cc:623
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
Definition wifi-phy.cc:686
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
Definition wifi-phy.h:1635
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Definition wifi-phy.h:1345
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
Definition wifi-phy.h:1649
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:560
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:521
Time m_channelSwitchDelay
Time required to switch between channel.
Definition wifi-phy.h:1640
dB_u GetTxGain() const
Return the transmission gain.
Definition wifi-phy.cc:617
void SetTxPowerEnd(dBm_u end)
Sets the maximum available transmission power level.
Definition wifi-phy.cc:584
dBm_per_MHz_u m_powerDensityLimit
the power density limit
Definition wifi-phy.h:1625
WifiPhyOperatingChannel m_operatingChannel
Operating channel.
Definition wifi-phy.h:1608
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:1499
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
Definition wifi-phy.cc:695
bool m_channelAccessRequested
Flag if channels access has been requested (used for OBSS_PD SR)
Definition wifi-phy.h:1630
Time GetSlot() const
Return the slot duration for this PHY.
Definition wifi-phy.cc:849
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
Definition wifi-phy.cc:1360
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:1615
uint8_t GetNumberOfAntennas() const
Definition wifi-phy.cc:1322
Time m_slot
Slot duration.
Definition wifi-phy.h:1612
dBm_u GetRxSensitivity() const
Return the receive sensitivity threshold.
Definition wifi-phy.cc:528
Time GetDelayUntilIdle()
Definition wifi-phy.cc:2193
MHz_u m_maxRadioBw
Maximum radio bandwidth.
Definition wifi-phy.h:1642
bool GetShortPhyPreambleSupported() const
Return whether short PHY preamble is supported.
Definition wifi-phy.cc:643
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS) for this PHY.
Definition wifi-phy.cc:831
void Configure80211n()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
Definition wifi-phy.cc:938
dBm_u m_ccaSensitivityThreshold
Clear channel assessment (CCA) modulation and coding rate sensitivity threshold.
Definition wifi-phy.h:1617
void Configure80211be()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11be standard.
Definition wifi-phy.cc:976
Time GetSifs() const
Return the Short Interframe Space (SIFS) for this PHY.
Definition wifi-phy.cc:837
bool m_notifyRxMacHeaderEnd
whether the PHY is capable of notifying MAC header RX end
Definition wifi-phy.h:1652
std::tuple< uint8_t, MHz_u, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying a segment of an operating channel.
Definition wifi-phy.h:937
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:667
void SetTxPowerStart(dBm_u start)
Sets the minimum available transmission power level.
Definition wifi-phy.cc:571
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:1623
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted.
Definition wifi-phy.cc:2225
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
Definition wifi-phy.h:1647
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition wifi-phy.h:1542
Time GetChannelSwitchDelay() const
Definition wifi-phy.cc:747
void SetTxGain(dB_u gain)
Sets the transmission gain.
Definition wifi-phy.cc:610
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
Definition wifi-phy.cc:1328
Time m_sifs
Short Interframe Space (SIFS) duration.
Definition wifi-phy.h:1611
void SetReceiveErrorCallback(RxErrorCallback callback)
Definition wifi-phy.cc:492
TracedCallback< Ptr< const WifiPpdu >, const WifiTxVector & > m_signalTransmissionCb
Signal Transmission callback.
Definition wifi-phy.h:1384
dBm_u GetTxPowerEnd() const
Return the maximum available transmission power level.
Definition wifi-phy.cc:591
uint8_t GetMaxSupportedRxSpatialStreams() const
Definition wifi-phy.cc:1372
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:703
uint8_t m_numberOfAntennas
Number of transmitters.
Definition wifi-phy.h:1634
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:1554
dBm_u GetCcaEdThreshold() const
Return the CCA energy detection threshold.
Definition wifi-phy.cc:541
Ptr< WifiPhyStateHelper > GetState() const
Return the WifiPhyStateHelper of this PHY.
Definition wifi-phy.cc:480
dBm_u m_txPowerBase
Minimum transmission power.
Definition wifi-phy.h:1622
virtual Ptr< Channel > GetChannel() const =0
Return the Channel this WifiPhy is connected to.
void SetShortPhyPreambleSupported(bool preamble)
Enable or disable short PHY preamble.
Definition wifi-phy.cc:636
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:597
void SetCcaSensitivityThreshold(dBm_u threshold)
Sets the CCA sensitivity threshold.
Definition wifi-phy.cc:547
WifiPhyBand m_band
WifiPhyBand.
Definition wifi-phy.h:1606
static const Ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
Definition wifi-phy.cc:759
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:1593
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
Definition wifi-phy.h:1381
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 SetMaxModulationClassSupported(WifiModulationClass modClass)
Set the maximum modulation class that has to be supported by this PHY object.
Definition wifi-phy.cc:984
void AddPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of supported PHY entities for the given modulation class for the WifiPh...
Definition wifi-phy.cc:818
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:1574
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
Definition wifi-phy.h:1650
void RegisterListener(const std::shared_ptr< WifiPhyListener > &listener)
Definition wifi-phy.cc:498
static std::map< WifiModulationClass, Ptr< PhyEntity > > & GetStaticPhyEntities()
Definition wifi-phy.cc:473
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition wifi-phy.cc:843
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition wifi-phy.cc:1057
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class.
Definition wifi-phy.cc:768
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:1491
std::optional< Time > GetDelayUntilChannelSwitch()
Perform any actions necessary when user changes operating channel after initialization.
Definition wifi-phy.cc:1181
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
Definition wifi-phy.cc:722
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:1476
virtual void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition wifi-phy.cc:649
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
Definition wifi-phy.h:1648
Time GetPifs() const
Return the PCF Interframe Space (PIFS) for this PHY.
Definition wifi-phy.cc:861
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
Definition wifi-phy.cc:809
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:1483
std::vector< ChannelTuple > ChannelSegments
segments identifying an operating channel
Definition wifi-phy.h:943
dB_u m_txGain
Transmission gain.
Definition wifi-phy.h:1620
MHz_u GetChannelWidth() const
Definition wifi-phy.cc:1087
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:655
WifiStandard m_standard
WifiStandard.
Definition wifi-phy.h:1604
uint8_t m_nTxPower
Number of available transmission power levels.
Definition wifi-phy.h:1624
void DoDispose() override
Destructor implementation.
Definition wifi-phy.cc:444
dB_u GetRxGain() const
Return the reception gain.
Definition wifi-phy.cc:630
void SetPhyId(uint8_t phyId)
Set the index allocated to this PHY.
Definition wifi-phy.cc:673
virtual void DoChannelSwitch()
Actually switch channel based on the stored channel settings.
Definition wifi-phy.cc:1222
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:1549
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
Definition wifi-phy.cc:716
uint8_t m_phyId
the index of the PHY in the vector of PHYs held by the WifiNetDevice
Definition wifi-phy.h:1340
void SetPifs(Time pifs)
Set the PCF Interframe Space (PIFS) for this PHY.
Definition wifi-phy.cc:855
void Configure80211b()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
Definition wifi-phy.cc:881
void SetCcaEdThreshold(dBm_u threshold)
Sets the CCA energy detection threshold.
Definition wifi-phy.cc:534
dB_u m_noiseFigure
The noise figure.
Definition wifi-phy.h:1638
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:2211
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition wifi-phy.cc:661
dB_u m_rxGain
Reception gain.
Definition wifi-phy.h:1621
double CalculateSnr(const WifiTxVector &txVector, double ber) const
Definition wifi-phy.cc:753
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:413
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:1507
Ptr< WifiNetDevice > m_device
Pointer to the device.
Definition wifi-phy.h:1644
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
Definition wifi-phy.h:1343
void DoInitialize() override
Initialize() implementation.
Definition wifi-phy.cc:419
bool m_shortPreamble
Flag if short PHY preamble is supported.
Definition wifi-phy.h:1633
uint8_t GetPhyId() const
Get the index allocated to this PHY.
Definition wifi-phy.cc:680
Time m_pifs
PCF Interframe Space (PIFS) duration.
Definition wifi-phy.h:1613
WifiModulationClass m_maxModClassSupported
max modulation class supported
Definition wifi-phy.h:1605
WifiStandard GetStandard() const
Get the configured Wi-Fi standard.
Definition wifi-phy.cc:1063
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition wifi-phy.cc:515
void SetReceiveOkCallback(RxOkCallback callback)
Definition wifi-phy.cc:486
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
Definition wifi-phy.cc:710
bool m_powerRestricted
Flag whether transmit power is restricted by OBSS PD SR.
Definition wifi-phy.h:1627
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
Definition wifi-phy.h:1654
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
void Reset()
Reset data upon end of TX or RX.
Definition wifi-phy.cc:1951
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
Definition wifi-phy.h:1523
TracedCallback< const WifiMacHeader &, const WifiTxVector &, Time > m_phyRxMacHeaderEndTrace
The trace source fired when the reception of a MAC header ends.
Definition wifi-phy.h:1534
uint8_t GetMaxSupportedTxSpatialStreams() const
Definition wifi-phy.cc:1354
void Configure80211a()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
Definition wifi-phy.cc:867
ChannelSegments m_channelSettings
Store operating channel settings until initialization.
Definition wifi-phy.h:1607
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Definition wifi-phy.cc:1069
dBm_u GetPower(uint8_t powerLevel) const
Get the power of the given power level.
Definition wifi-phy.cc:728
bool m_fixedPhyBand
True to prohibit changing PHY band after initialization.
Definition wifi-phy.h:1609
Ptr< PhyEntity > GetLatestPhyEntity() const
Get the latest PHY entity supported by this PHY instance.
Definition wifi-phy.cc:783
uint8_t GetNTxPower() const
Return the number of available transmission power levels.
Definition wifi-phy.cc:604
void UnregisterListener(const std::shared_ptr< WifiPhyListener > &listener)
Definition wifi-phy.cc:509
dBm_u GetCcaSensitivityThreshold() const
Return the CCA sensitivity threshold.
Definition wifi-phy.cc:554
Class that keeps track of all information about the current PHY operating channel.
MHz_u GetTotalWidth() const
Return the width of the whole operating channel.
bool IsSet() const
Return true if a valid channel has been set, false otherwise.
uint8_t GetNumber(std::size_t segment=0) const
Return the channel number for a given frequency segment.
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 ...
uint8_t GetPrimaryChannelIndex(MHz_u primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
MHz_u GetFrequency(std::size_t segment=0) const
Return the center frequency for a given frequency segment.
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:113
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:248
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:269
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:1433
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1453
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
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1369
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1345
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:47
@ 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:59
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
Definition wifi-types.h:49
@ 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:54
@ SINGLE_MPDU
The MPDU is a single MPDU.
Definition wifi-types.h:51
@ 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:57
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition ptr.h:443
@ SWITCHING
The PHY layer is switching to other channel.
@ TX
The PHY layer is sending a packet.
@ 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.
dB_u RatioToDb(double ratio)
Convert from ratio to dB.
Definition wifi-utils.cc:47
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.
std::map< WifiSpectrumBandInfo, Watt_u > RxPowerWattPerChannelBand
A map of the received power for each band.
Definition phy-entity.h:45
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:28
Watt_u DbmToW(dBm_u val)
Convert from dBm to Watts.
Definition wifi-utils.cc:34
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.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition wifi-ppdu.h:38
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.
MpduInfo structure.
Definition wifi-types.h:71
MpduType type
type of MPDU
Definition wifi-types.h:72
uint32_t mpduRefNumber
MPDU ref number.
Definition wifi-types.h:73
RxSignalInfo structure containing info on the received signal.
Definition wifi-types.h:78
double snr
SNR in linear scale.
Definition wifi-types.h:79
dBm_u rssi
RSSI.
Definition wifi-types.h:80
SignalNoiseDbm structure.
Definition wifi-types.h:64
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.