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
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 if (IsInitialized())
540 {
542 }
543}
544
545dBm_u
547{
548 return m_ccaEdThreshold;
549}
550
551void
553{
554 NS_LOG_FUNCTION(this << threshold);
555 m_ccaSensitivityThreshold = threshold;
556}
557
558dBm_u
563
564void
566{
567 NS_LOG_FUNCTION(this << noiseFigure);
568 if (m_interference)
569 {
570 m_interference->SetNoiseFigure(DbToRatio(noiseFigure));
571 }
572 m_noiseFigure = noiseFigure;
573}
574
575void
577{
578 NS_LOG_FUNCTION(this << start);
579 m_txPowerBase = start;
580}
581
582dBm_u
584{
585 return m_txPowerBase;
586}
587
588void
590{
591 NS_LOG_FUNCTION(this << end);
592 m_txPowerEnd = end;
593}
594
595dBm_u
597{
598 return m_txPowerEnd;
599}
600
601void
603{
604 NS_LOG_FUNCTION(this << +n);
606}
607
608uint8_t
610{
611 return m_nTxPowerLevels;
612}
613
614void
616{
617 NS_LOG_FUNCTION(this << gain);
618 m_txGain = gain;
619}
620
621dB_u
623{
624 return m_txGain;
625}
626
627void
629{
630 NS_LOG_FUNCTION(this << gain);
631 m_rxGain = gain;
632}
633
634dB_u
636{
637 return m_rxGain;
638}
639
640void
642{
643 NS_LOG_FUNCTION(this << enable);
644 m_shortPreamble = enable;
645}
646
647bool
652
653void
655{
656 m_device = device;
657}
658
661{
662 return m_device;
663}
664
665void
667{
668 m_mobility = mobility;
669}
670
673{
674 return m_mobility;
675}
676
677void
678WifiPhy::SetPhyId(uint8_t phyId)
679{
680 NS_LOG_FUNCTION(this << phyId);
681 m_phyId = phyId;
682}
683
684uint8_t
686{
687 return m_phyId;
688}
689
690void
692{
693 NS_LOG_FUNCTION(this << helper);
694 m_interference = helper;
695 m_interference->SetNoiseFigure(DbToRatio(m_noiseFigure));
696 m_interference->SetNumberOfReceiveAntennas(m_numberOfAntennas);
697}
698
699void
701{
702 NS_LOG_FUNCTION(this << model);
704 m_interference->SetErrorRateModel(model);
705}
706
707void
713
714void
719
720void
725
726void
728{
729 m_wifiRadioEnergyModel = wifiRadioEnergyModel;
730}
731
732dBm_u
733WifiPhy::GetPower(uint8_t powerLevel) const
734{
735 NS_ASSERT_MSG((powerLevel >= WIFI_MIN_TX_PWR_LEVEL) &&
736 (powerLevel < (WIFI_MIN_TX_PWR_LEVEL + m_nTxPowerLevels)),
737 "Invalid TX power level");
741 auto power{m_txPowerBase};
742 if (m_nTxPowerLevels > 1)
743 {
744 power += dB_u{(powerLevel - WIFI_MIN_TX_PWR_LEVEL) * (m_txPowerEnd - m_txPowerBase) /
745 (m_nTxPowerLevels - 1)};
746 }
747 return power;
748}
749
750Time
755
756double
757WifiPhy::CalculateSnr(const WifiTxVector& txVector, double ber) const
758{
759 return m_interference->GetErrorRateModel()->CalculateSnr(txVector, ber);
760}
761
762const std::shared_ptr<const PhyEntity>
764{
765 const auto it = GetStaticPhyEntities().find(modulation);
767 "Unimplemented Wi-Fi modulation class " << modulation);
768 return it->second;
769}
770
771std::shared_ptr<PhyEntity>
773{
774 const auto it = m_phyEntities.find(modulation);
775 NS_ABORT_MSG_IF(it == m_phyEntities.cend(),
776 "Unsupported Wi-Fi modulation class " << modulation);
777 return it->second;
778}
779
780std::shared_ptr<PhyEntity>
782{
784}
785
786std::shared_ptr<PhyEntity>
791
792std::shared_ptr<PhyEntity>
794{
795 NS_ABORT_IF(!ppdu);
796 const auto modulation = ppdu->GetModulation();
797 if (modulation > m_phyEntities.rbegin()->first)
798 {
799 // unsupported modulation: start reception process with latest PHY entity
800 return GetLatestPhyEntity();
801 }
802 if (modulation < WIFI_MOD_CLASS_HT)
803 {
804 // for non-HT (duplicate), call the latest PHY entity since some extra processing can be
805 // done in PHYs implemented in HT and later (e.g. channel width selection for non-HT
806 // duplicates)
807 return GetLatestPhyEntity();
808 }
809 return GetPhyEntity(modulation);
810}
811
812void
813WifiPhy::AddStaticPhyEntity(WifiModulationClass modulation, std::shared_ptr<PhyEntity> phyEntity)
814{
815 NS_ASSERT_MSG(!GetStaticPhyEntities().contains(modulation),
816 "The PHY entity has already been added. The setting should only be done once per "
817 "modulation class");
818 GetStaticPhyEntities()[modulation] = phyEntity;
819}
820
821void
822WifiPhy::AddPhyEntity(WifiModulationClass modulation, std::shared_ptr<PhyEntity> phyEntity)
823{
824 NS_LOG_FUNCTION(this << modulation);
825 NS_ABORT_MSG_IF(!GetStaticPhyEntities().contains(modulation),
826 "Cannot add an unimplemented PHY to supported list. Update the former first.");
827 NS_ASSERT_MSG(m_phyEntities.find(modulation) == m_phyEntities.end(),
828 "The PHY entity has already been added. The setting should only be done once per "
829 "modulation class");
830 phyEntity->SetOwner(this);
831 m_phyEntities[modulation] = phyEntity;
832}
833
834void
836{
837 m_sifs = sifs;
838}
839
840Time
842{
843 return m_sifs;
844}
845
846void
848{
849 m_slot = slot;
850}
851
852Time
854{
855 return m_slot;
856}
857
858void
860{
861 m_pifs = pifs;
862}
863
864Time
866{
867 return m_pifs;
868}
869
870void
872{
873 NS_LOG_FUNCTION(this);
874 AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared<OfdmPhy>());
875
876 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
879 SetPifs(GetSifs() + GetSlot());
880 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
881 // of the PPDU causing the EIFS" of 802.11-2016
882}
883
884void
886{
887 NS_LOG_FUNCTION(this);
888 std::shared_ptr<DsssPhy> phyEntity = std::make_shared<DsssPhy>();
890 AddPhyEntity(WIFI_MOD_CLASS_DSSS, phyEntity); // when plain DSSS modes are used
891
894 SetPifs(GetSifs() + GetSlot());
895 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
896 // of the PPDU causing the EIFS" of 802.11-2016
897}
898
899void
901{
902 NS_LOG_FUNCTION(this);
903 // See Table 18-5 "ERP characteristics" of 802.11-2016
904 // Slot time defaults to the "long slot time" of 20 us in the standard
905 // according to mixed 802.11b/g deployments. Short slot time is enabled
906 // if the user sets the ShortSlotTimeSupported flag to true and when the BSS
907 // consists of only ERP STAs capable of supporting this option.
909 AddPhyEntity(WIFI_MOD_CLASS_ERP_OFDM, std::make_shared<ErpOfdmPhy>());
910}
911
912void
914{
915 NS_LOG_FUNCTION(this);
916 if (GetChannelWidth() == MHz_u{10})
917 {
918 AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared<OfdmPhy>(OFDM_PHY_10_MHZ));
919
920 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
923 SetPifs(GetSifs() + GetSlot());
924 }
925 else if (GetChannelWidth() == MHz_u{5})
926 {
927 AddPhyEntity(WIFI_MOD_CLASS_OFDM, std::make_shared<OfdmPhy>(OFDM_PHY_5_MHZ));
928
929 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
932 SetPifs(GetSifs() + GetSlot());
933 }
934 else
935 {
936 NS_FATAL_ERROR("802.11p configured with a wrong channel width!");
937 }
938}
939
940void
942{
943 NS_LOG_FUNCTION(this);
945 {
947 }
948 else
949 {
951 }
952 AddPhyEntity(WIFI_MOD_CLASS_HT, std::make_shared<HtPhy>(m_txSpatialStreams));
953}
954
955void
957{
958 NS_LOG_FUNCTION(this);
960 AddPhyEntity(WIFI_MOD_CLASS_VHT, std::make_shared<VhtPhy>());
961}
962
963void
965{
966 NS_LOG_FUNCTION(this);
968 {
970 }
971 else
972 {
974 }
975 AddPhyEntity(WIFI_MOD_CLASS_HE, std::make_shared<HePhy>());
976}
977
978void
980{
981 NS_LOG_FUNCTION(this);
983 AddPhyEntity(WIFI_MOD_CLASS_EHT, std::make_shared<EhtPhy>());
984}
985
986void
992
998
999void
1001{
1002 NS_LOG_FUNCTION(this << standard);
1003
1005 "Cannot change standard");
1006
1007 m_standard = standard;
1008
1010 {
1012 }
1013
1014 if (!m_operatingChannel.IsSet())
1015 {
1016 NS_LOG_DEBUG("Setting the operating channel first");
1018 // return because we are called back by SetOperatingChannel
1019 return;
1020 }
1021
1022 // this function is called when changing PHY band, hence we have to delete
1023 // the previous PHY entities
1024 m_phyEntities.clear();
1025
1026 switch (standard)
1027 {
1030 break;
1033 break;
1036 break;
1039 break;
1042 break;
1045 break;
1048 break;
1051 break;
1053 default:
1054 NS_ASSERT_MSG(false, "Unsupported standard");
1055 break;
1056 }
1057}
1058
1061{
1062 return m_band;
1063}
1064
1067{
1068 return m_standard;
1069}
1070
1073{
1074 return m_operatingChannel;
1075}
1076
1077MHz_u
1079{
1080 return m_operatingChannel.GetFrequency();
1081}
1082
1083uint8_t
1085{
1086 return m_operatingChannel.GetNumber();
1087}
1088
1089MHz_u
1091{
1092 return m_operatingChannel.GetTotalWidth();
1093}
1094
1095uint8_t
1097{
1098 return m_operatingChannel.GetPrimaryChannelIndex(MHz_u{20});
1099}
1100
1101void
1103{
1104 m_fixedPhyBand = enable;
1105}
1106
1107bool
1109{
1110 return m_fixedPhyBand;
1111}
1112
1113MHz_u
1114WifiPhy::GetTxBandwidth(WifiMode mode, MHz_u maxAllowedWidth) const
1115{
1116 auto modulation = mode.GetModulationClass();
1117 if (modulation == WIFI_MOD_CLASS_DSSS || modulation == WIFI_MOD_CLASS_HR_DSSS)
1118 {
1119 return MHz_u{22};
1120 }
1121
1122 return std::min({GetChannelWidth(), GetMaximumChannelWidth(modulation), maxAllowedWidth});
1123}
1124
1125void
1127{
1128 NS_LOG_FUNCTION(this << channel);
1130 for (std::size_t segmentId = 0; segmentId < channel.GetNSegments(); ++segmentId)
1131 {
1132 cfg.segments.emplace_back(channel.GetNumber(segmentId),
1133 channel.GetWidth(segmentId),
1134 channel.GetPhyBand(),
1135 channel.GetPrimaryChannelIndex(MHz_u{20}));
1136 }
1138}
1139
1140void
1142{
1143 SetOperatingChannel(WifiChannelConfig(channelSegments));
1144}
1145
1146void
1148{
1149 NS_LOG_FUNCTION(this << +channelCfg.front().number << channelCfg.front().width
1150 << channelCfg.front().band << +channelCfg.front().p20Index);
1151
1152 if (IsInitialized() && m_operatingChannel.IsSet() && (m_channelCfg == channelCfg))
1153 {
1154 NS_LOG_DEBUG("Already operating on requested channel");
1155 return;
1156 }
1157
1159 {
1160 NS_LOG_DEBUG("Channel information will be applied when a standard is configured");
1161 m_channelCfg = channelCfg;
1162 return;
1163 }
1164
1165 if (IsInitialized())
1166 {
1167 const auto delay = GetDelayUntilChannelSwitch();
1168 if (!delay.has_value())
1169 {
1170 // switching channel is not possible now
1171 return;
1172 }
1173 if (delay.value().IsStrictlyPositive())
1174 {
1175 // switching channel has been postponed
1176 Simulator::Schedule(delay.value(), [=, this] { SetOperatingChannel(channelCfg); });
1177 return;
1178 }
1179 }
1180
1181 m_channelCfg = channelCfg;
1182
1183 // channel can be switched now.
1185}
1186
1187std::optional<Time>
1189{
1190 if (!IsInitialized())
1191 {
1192 // this is not channel switch, this is initialization
1193 NS_LOG_DEBUG("Before initialization, nothing to do");
1194 return Seconds(0);
1195 }
1196
1197 std::optional<Time> delay;
1198 switch (m_state->GetState())
1199 {
1200 case WifiPhyState::RX:
1201 NS_LOG_DEBUG("drop packet because of channel switching while reception");
1203 delay = Seconds(0);
1204 break;
1205 case WifiPhyState::TX:
1206 NS_LOG_DEBUG("channel switching postponed until end of current transmission");
1207 delay = GetDelayUntilIdle();
1208 break;
1210 case WifiPhyState::IDLE:
1211 Reset();
1212 delay = Seconds(0);
1213 break;
1215 delay = Seconds(0);
1216 break;
1218 NS_LOG_DEBUG("channel switching ignored in sleep mode");
1219 break;
1220 default:
1221 NS_ASSERT(false);
1222 break;
1223 }
1224
1225 return delay;
1226}
1227
1228void
1230{
1231 std::optional<uint8_t> prevChannelNumber{};
1232 for (auto& [number, width, band, primary20] : channelCfg.segments)
1233 {
1234 if (band == WIFI_PHY_BAND_UNSPECIFIED)
1235 {
1236 band = GetDefaultPhyBand(standard);
1237 }
1238 if (width == MHz_u{0} && number == 0)
1239 {
1240 width = GetDefaultChannelWidth(standard, static_cast<WifiPhyBand>(band));
1241 }
1242 if (number == 0)
1243 {
1245 standard,
1246 band,
1247 prevChannelNumber);
1248 }
1249 prevChannelNumber = number;
1250 }
1251}
1252
1253void
1255{
1256 NS_LOG_FUNCTION(this);
1257
1258 m_powerRestricted = false;
1260
1261 // Update unspecified parameters with default values
1263
1264 // We need to call SetStandard if this is the first time we set a channel or we
1265 // are changing PHY band. Checking if the new PHY band is different than the
1266 // previous one covers both cases because initially the PHY band is unspecified
1267 const auto changingPhyBand = (m_channelCfg.front().band != m_band);
1268
1269 NS_ABORT_MSG_IF(IsInitialized() && m_fixedPhyBand && changingPhyBand,
1270 "Trying to change PHY band while prohibited.");
1271
1272 m_band = m_channelCfg.front().band;
1273
1274 NS_LOG_DEBUG("switching channel");
1275 std::vector<FrequencyChannelInfo> segments{};
1276 std::transform(m_channelCfg.segments.cbegin(),
1277 m_channelCfg.segments.cend(),
1278 std::back_inserter(segments),
1279 [this](const auto& segment) {
1280 return FrequencyChannelInfo{segment.number, MHz_u{0}, segment.width, m_band};
1281 });
1282 m_operatingChannel.Set(segments, m_standard);
1283 m_operatingChannel.SetPrimary20Index(m_channelCfg.front().p20Index);
1284
1285 // check that the channel width is supported
1286 if (const auto chWidth = GetChannelWidth();
1287 (m_maxRadioBw != MHz_u{0}) && (chWidth > m_maxRadioBw))
1288 {
1289 // throw an exception instead of using NS_ABORT_MSG for unit testing this code
1290 throw std::runtime_error("Attempting to set a " + std::to_string(chWidth) +
1291 " MHz channel on a station only supporting " +
1292 std::to_string(m_maxRadioBw) + " MHz operation");
1293 }
1294
1295 if (changingPhyBand)
1296 {
1297 ConfigureStandard(m_standard);
1298 }
1299
1300 FinalizeChannelSwitch();
1301
1302 if (IsInitialized())
1303 {
1304 // notify channel switching
1305 m_state->SwitchToChannelSwitching(GetChannelSwitchDelay());
1306 /*
1307 * Needed here to be able to correctly sensed the medium for the first
1308 * time after the switching. The actual switching is not performed until
1309 * after m_channelSwitchDelay. Packets received during the switching
1310 * state are added to the event list and are employed later to figure
1311 * out the state of the medium after the switching.
1312 */
1313 Simulator::Schedule(GetChannelSwitchDelay(), [=, this]() {
1314 NS_LOG_DEBUG("Channel switching completed: update CCA indication");
1315 SwitchMaybeToCcaBusy();
1316 });
1317 }
1318}
1319
1320void
1322{
1323 NS_LOG_FUNCTION(this << +antennas);
1324 NS_ASSERT_MSG(antennas > 0 && antennas <= 8, "unsupported number of antennas");
1325 m_numberOfAntennas = antennas;
1326 if (m_interference)
1327 {
1328 m_interference->SetNumberOfReceiveAntennas(antennas);
1329 }
1330}
1331
1332uint8_t
1334{
1335 return m_numberOfAntennas;
1336}
1337
1338void
1340{
1341 NS_ASSERT(streams <= GetNumberOfAntennas());
1342 bool changed = (m_txSpatialStreams != streams);
1343 m_txSpatialStreams = streams;
1344 if (changed)
1345 {
1346 auto phyEntity = m_phyEntities.find(WIFI_MOD_CLASS_HT);
1347 if (phyEntity != m_phyEntities.end())
1348 {
1349 std::shared_ptr<HtPhy> htPhy = std::dynamic_pointer_cast<HtPhy>(phyEntity->second);
1350 if (htPhy)
1351 {
1352 htPhy->SetMaxSupportedNss(
1353 m_txSpatialStreams); // this is essential to have the right MCSs configured
1354 }
1355
1356 if (!m_capabilitiesChangedCallback.IsNull())
1357 {
1359 }
1360 }
1361 }
1362}
1363
1364uint8_t
1369
1370void
1372{
1373 NS_ASSERT(streams <= GetNumberOfAntennas());
1374 bool changed = (m_rxSpatialStreams != streams);
1375 m_rxSpatialStreams = streams;
1376 if (changed && !m_capabilitiesChangedCallback.IsNull())
1377 {
1379 }
1380}
1381
1382uint8_t
1387
1388std::list<uint8_t>
1390{
1391 std::list<uint8_t> list;
1392 for (const auto& phyEntity : m_phyEntities)
1393 {
1394 std::shared_ptr<HtPhy> htPhy = std::dynamic_pointer_cast<HtPhy>(phyEntity.second);
1395 if (htPhy)
1396 {
1397 list.emplace_back(htPhy->GetBssMembershipSelector());
1398 }
1399 }
1400 return list;
1401}
1402
1403void
1404WifiPhy::SetSleepMode(bool forceSleepInRx)
1405{
1406 NS_LOG_FUNCTION(this);
1407 m_powerRestricted = false;
1409 switch (m_state->GetState())
1410 {
1411 case WifiPhyState::TX:
1412 NS_LOG_DEBUG("setting sleep mode postponed until end of current transmission");
1414 break;
1415 case WifiPhyState::RX:
1416 NS_LOG_DEBUG("setting sleep mode"
1417 << (forceSleepInRx ? "" : "postponed until end of current reception"));
1418 if (forceSleepInRx)
1419 {
1421 m_state->SwitchToSleep();
1422 }
1423 else
1424 {
1426 }
1427 break;
1429 NS_LOG_DEBUG("setting sleep mode postponed until end of channel switching");
1431 break;
1433 case WifiPhyState::IDLE:
1434 NS_LOG_DEBUG("setting sleep mode");
1435 // The PHY object may be in CCA_BUSY state because it is receiving a preamble. Cancel
1436 // preamble events before switching to sleep state
1437 Reset();
1438 m_state->SwitchToSleep();
1439 break;
1441 NS_LOG_DEBUG("already in sleep mode");
1442 break;
1443 default:
1444 NS_ASSERT(false);
1445 break;
1446 }
1447}
1448
1449void
1451{
1452 NS_LOG_FUNCTION(this);
1453 m_powerRestricted = false;
1455 Reset();
1456 m_state->SwitchToOff();
1457}
1458
1459void
1461{
1462 NS_LOG_FUNCTION(this);
1463 switch (m_state->GetState())
1464 {
1465 case WifiPhyState::TX:
1466 case WifiPhyState::RX:
1467 case WifiPhyState::IDLE:
1470 NS_LOG_DEBUG("not in sleep mode, there is nothing to resume");
1471 break;
1472 }
1473 case WifiPhyState::SLEEP: {
1474 NS_LOG_DEBUG("resuming from sleep mode");
1475 m_state->SwitchFromSleep();
1477 break;
1478 }
1479 default: {
1480 NS_ASSERT(false);
1481 break;
1482 }
1483 }
1484}
1485
1486void
1488{
1489 NS_LOG_FUNCTION(this);
1490 switch (m_state->GetState())
1491 {
1492 case WifiPhyState::TX:
1493 case WifiPhyState::RX:
1494 case WifiPhyState::IDLE:
1497 case WifiPhyState::SLEEP: {
1498 NS_LOG_DEBUG("not in off mode, there is nothing to resume");
1499 break;
1500 }
1501 case WifiPhyState::OFF: {
1502 NS_LOG_DEBUG("resuming from off mode");
1503 m_state->SwitchFromOff();
1505 break;
1506 }
1507 default: {
1508 NS_ASSERT(false);
1509 break;
1510 }
1511 }
1512}
1513
1514Time
1519
1520Time
1522{
1523 return MicroSeconds(4);
1524}
1525
1526Time
1528 const WifiTxVector& txVector,
1529 WifiPhyBand band,
1530 MpduType mpdutype,
1531 uint16_t staId)
1532{
1533 uint32_t totalAmpduSize;
1534 double totalAmpduNumSymbols;
1535 return GetPayloadDuration(size,
1536 txVector,
1537 band,
1538 mpdutype,
1539 false,
1540 totalAmpduSize,
1541 totalAmpduNumSymbols,
1542 staId);
1543}
1544
1545Time
1547 const WifiTxVector& txVector,
1548 WifiPhyBand band,
1549 MpduType mpdutype,
1550 bool incFlag,
1551 uint32_t& totalAmpduSize,
1552 double& totalAmpduNumSymbols,
1553 uint16_t staId)
1554{
1555 return GetStaticPhyEntity(txVector.GetModulationClass())
1556 ->GetPayloadDuration(size,
1557 txVector,
1558 band,
1559 mpdutype,
1560 incFlag,
1561 totalAmpduSize,
1562 totalAmpduNumSymbols,
1563 staId);
1564}
1565
1566Time
1568{
1569 return GetStaticPhyEntity(txVector.GetModulationClass())
1570 ->CalculatePhyPreambleAndHeaderDuration(txVector);
1571}
1572
1573Time
1575 const WifiTxVector& txVector,
1576 WifiPhyBand band,
1577 uint16_t staId)
1578{
1579 NS_ASSERT(txVector.IsValid(band));
1580 Time duration = CalculatePhyPreambleAndHeaderDuration(txVector) +
1581 GetPayloadDuration(size, txVector, band, NORMAL_MPDU, staId);
1582 NS_ASSERT(duration.IsStrictlyPositive());
1583 return duration;
1584}
1585
1586Time
1588 const WifiTxVector& txVector,
1589 WifiPhyBand band)
1590{
1591 return CalculateTxDuration(GetWifiConstPsduMap(psdu, txVector), txVector, band);
1592}
1593
1594Time
1596 const WifiTxVector& txVector,
1597 WifiPhyBand band)
1598{
1599 NS_ASSERT(txVector.IsValid(band));
1600 return GetStaticPhyEntity(txVector.GetModulationClass())
1601 ->CalculateTxDuration(psduMap, txVector, band);
1602}
1603
1606{
1607 return GetStaticPhyEntity(modulation)->GetMaxPsduSize();
1608}
1609
1610void
1612{
1613 if (!m_phyTxBeginTrace.IsEmpty())
1614 {
1615 for (const auto& psdu : psdus)
1616 {
1617 for (auto& mpdu : *PeekPointer(psdu.second))
1618 {
1619 m_phyTxBeginTrace(mpdu->GetProtocolDataUnit(), txPower);
1620 }
1621 }
1622 }
1623}
1624
1625void
1627{
1628 if (!m_phyTxEndTrace.IsEmpty())
1629 {
1630 for (const auto& psdu : psdus)
1631 {
1632 for (auto& mpdu : *PeekPointer(psdu.second))
1633 {
1634 m_phyTxEndTrace(mpdu->GetProtocolDataUnit());
1635 }
1636 }
1637 }
1638}
1639
1640void
1642{
1643 if (!m_phyTxDropTrace.IsEmpty())
1644 {
1645 for (auto& mpdu : *PeekPointer(psdu))
1646 {
1647 m_phyTxDropTrace(mpdu->GetProtocolDataUnit());
1648 }
1649 }
1650}
1651
1652void
1654{
1655 if (psdu && !m_phyRxBeginTrace.IsEmpty())
1656 {
1657 for (auto& mpdu : *PeekPointer(psdu))
1658 {
1659 m_phyRxBeginTrace(mpdu->GetProtocolDataUnit(), rxPowersW);
1660 }
1661 }
1662}
1663
1664void
1666{
1667 if (psdu && !m_phyRxEndTrace.IsEmpty())
1668 {
1669 for (auto& mpdu : *PeekPointer(psdu))
1670 {
1671 m_phyRxEndTrace(mpdu->GetProtocolDataUnit());
1672 }
1673 }
1674}
1675
1676void
1678{
1679 if (psdu && !m_phyRxDropTrace.IsEmpty())
1680 {
1681 for (auto& mpdu : *PeekPointer(psdu))
1682 {
1683 m_phyRxDropTrace(mpdu->GetProtocolDataUnit(), reason);
1684 }
1685 }
1686}
1687
1688void
1694
1695void
1697 MHz_u channelFreq,
1698 const WifiTxVector& txVector,
1699 SignalNoiseDbm signalNoise,
1700 const std::vector<bool>& statusPerMpdu,
1701 uint16_t staId)
1702{
1703 MpduInfo aMpdu;
1704 if (psdu->IsAggregate())
1705 {
1706 // Expand A-MPDU
1707 NS_ASSERT_MSG(txVector.IsAggregation(),
1708 "TxVector with aggregate flag expected here according to PSDU");
1710 size_t nMpdus = psdu->GetNMpdus();
1711 NS_ASSERT_MSG(statusPerMpdu.size() == nMpdus, "Should have one reception status per MPDU");
1712 if (!m_phyMonitorSniffRxTrace.IsEmpty())
1713 {
1714 aMpdu.type = (psdu->IsSingle()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1715 for (size_t i = 0; i < nMpdus;)
1716 {
1717 if (statusPerMpdu.at(i)) // packet received without error, hand over to sniffer
1718 {
1719 m_phyMonitorSniffRxTrace(psdu->GetAmpduSubframe(i),
1720 static_cast<uint16_t>(channelFreq),
1721 txVector,
1722 aMpdu,
1723 signalNoise,
1724 staId);
1725 }
1726 ++i;
1727 aMpdu.type =
1728 (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1729 }
1730 }
1731 }
1732 else
1733 {
1734 NS_ASSERT_MSG(statusPerMpdu.size() == 1,
1735 "Should have one reception status for normal MPDU");
1736 if (!m_phyMonitorSniffRxTrace.IsEmpty())
1737 {
1738 aMpdu.type = NORMAL_MPDU;
1739 m_phyMonitorSniffRxTrace(psdu->GetPacket(),
1740 static_cast<uint16_t>(channelFreq),
1741 txVector,
1742 aMpdu,
1743 signalNoise,
1744 staId);
1745 }
1746 }
1747}
1748
1749void
1751 MHz_u channelFreq,
1752 const WifiTxVector& txVector,
1753 uint16_t staId)
1754{
1755 MpduInfo aMpdu;
1756 if (psdu->IsAggregate())
1757 {
1758 // Expand A-MPDU
1759 NS_ASSERT_MSG(txVector.IsAggregation(),
1760 "TxVector with aggregate flag expected here according to PSDU");
1762 if (!m_phyMonitorSniffTxTrace.IsEmpty())
1763 {
1764 size_t nMpdus = psdu->GetNMpdus();
1765 aMpdu.type = (psdu->IsSingle()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1766 for (size_t i = 0; i < nMpdus;)
1767 {
1768 m_phyMonitorSniffTxTrace(psdu->GetAmpduSubframe(i),
1769 channelFreq,
1770 txVector,
1771 aMpdu,
1772 staId);
1773 ++i;
1774 aMpdu.type =
1775 (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1776 }
1777 }
1778 }
1779 else
1780 {
1781 if (!m_phyMonitorSniffTxTrace.IsEmpty())
1782 {
1783 aMpdu.type = NORMAL_MPDU;
1784 m_phyMonitorSniffTxTrace(psdu->GetPacket(), channelFreq, txVector, aMpdu, staId);
1785 }
1786 }
1787}
1788
1789std::optional<Time>
1791{
1792 for (const auto& [modClass, phyEntity] : m_phyEntities)
1793 {
1794 if (auto remTime = phyEntity->GetTimeToPreambleDetectionEnd())
1795 {
1796 return remTime;
1797 }
1798 }
1799 return std::nullopt;
1800}
1801
1802std::optional<Time>
1803WifiPhy::GetTimeToMacHdrEnd(uint16_t staId) const
1804{
1805 for (auto& [modClass, phyEntity] : m_phyEntities)
1806 {
1807 if (auto remTime = phyEntity->GetTimeToMacHdrEnd(staId))
1808 {
1809 return remTime;
1810 }
1811 }
1812 return std::nullopt;
1813}
1814
1817{
1818 return GetStaticPhyEntity(txVector.GetModulationClass())->GetWifiConstPsduMap(psdu, txVector);
1819}
1820
1821void
1823{
1824 NS_LOG_FUNCTION(this << *psdu << txVector);
1825 Send(GetWifiConstPsduMap(psdu, txVector), txVector);
1826}
1827
1828void
1829WifiPhy::Send(const WifiConstPsduMap& psdus, const WifiTxVector& txVector)
1830{
1831 NS_LOG_FUNCTION(this << psdus << txVector);
1832 /* Transmission can happen if:
1833 * - we are syncing on a packet. It is the responsibility of the
1834 * MAC layer to avoid doing this but the PHY does nothing to
1835 * prevent it.
1836 * - we are idle
1837 */
1838 NS_ASSERT(!m_state->IsStateTx() && !m_state->IsStateSwitching());
1839 NS_ASSERT(m_endTxEvent.IsExpired());
1840
1841 if (!txVector.IsValid(m_band))
1842 {
1843 NS_FATAL_ERROR("TX-VECTOR is invalid!");
1844 }
1845
1846 uint8_t nss = 0;
1847 if (txVector.IsMu())
1848 {
1849 // We do not support mixed OFDMA and MU-MIMO
1850 if (txVector.IsDlMuMimo())
1851 {
1852 nss = txVector.GetNssTotal();
1853 }
1854 else
1855 {
1856 nss = txVector.GetNssMax();
1857 }
1858 }
1859 else
1860 {
1861 nss = txVector.GetNss();
1862 }
1863
1865 {
1866 NS_FATAL_ERROR("Unsupported number of spatial streams!");
1867 }
1868
1869 if (m_state->IsStateSleep())
1870 {
1871 NS_LOG_DEBUG("Dropping packet because in sleep mode");
1872 for (const auto& psdu : psdus)
1873 {
1874 NotifyTxDrop(psdu.second);
1875 }
1876 return;
1877 }
1878
1879 const auto txDuration = CalculateTxDuration(psdus, txVector, GetPhyBand());
1880
1881 if (const auto timeToPreambleDetectionEnd = GetTimeToPreambleDetectionEnd();
1882 timeToPreambleDetectionEnd && !m_currentEvent)
1883 {
1884 // PHY is in the initial few microseconds during which the
1885 // start of RX has occurred but the preamble detection period
1886 // has not elapsed
1888 }
1889 else if (timeToPreambleDetectionEnd || m_currentEvent)
1890 {
1892 }
1893
1895 {
1896 NS_LOG_DEBUG("Transmitting with power restriction for " << txDuration.As(Time::NS));
1897 }
1898 else
1899 {
1900 NS_LOG_DEBUG("Transmitting without power restriction for " << txDuration.As(Time::NS));
1901 }
1902
1903 if (m_state->GetState() == WifiPhyState::OFF)
1904 {
1905 NS_LOG_DEBUG("Transmission canceled because device is OFF");
1906 return;
1907 }
1908
1909 auto ppdu = GetPhyEntity(txVector.GetModulationClass())->BuildPpdu(psdus, txVector, txDuration);
1910 m_previouslyRxPpduUid = UINT64_MAX; // reset (after creation of PPDU) to use it only once
1911
1912 const auto txPower = DbmToW(GetTxPowerForTransmission(ppdu) + GetTxGain());
1913 NotifyTxBegin(psdus, txPower);
1914 if (!m_phyTxPsduBeginTrace.IsEmpty())
1915 {
1916 m_phyTxPsduBeginTrace(psdus, txVector, txPower);
1917 }
1918 for (const auto& psdu : psdus)
1919 {
1920 NotifyMonitorSniffTx(psdu.second, GetFrequency(), txVector, psdu.first);
1921 }
1922 m_state->SwitchToTx(txDuration, psdus, GetPower(txVector.GetTxPowerLevel()), txVector);
1923
1925 m_wifiRadioEnergyModel->GetMaximumTimeInState(WifiPhyState::TX) < txDuration)
1926 {
1927 ppdu->SetTruncatedTx();
1928 }
1929
1930 m_endTxEvent =
1931 Simulator::Schedule(txDuration, &WifiPhy::TxDone, this, psdus); // TODO: fix for MU
1932
1933 StartTx(ppdu);
1934 ppdu->ResetTxVector();
1935
1937 m_powerRestricted = false;
1938}
1939
1940void
1942{
1943 NS_LOG_FUNCTION(this << psdus);
1944 NotifyTxEnd(psdus);
1945 Reset();
1946 // we might have received signals during TX
1948}
1949
1950uint64_t
1955
1956void
1962
1963void
1965{
1966 NS_LOG_FUNCTION(this);
1969 {
1971 }
1972 m_currentEvent = nullptr;
1973 for (auto& phyEntity : m_phyEntities)
1974 {
1975 phyEntity.second->CancelAllEvents();
1976 }
1977 m_endPhyRxEvent.Cancel();
1978 m_endTxEvent.Cancel();
1979}
1980
1981void
1983 RxPowerWattPerChannelBand& rxPowersW,
1984 Time rxDuration)
1985{
1986 NS_LOG_FUNCTION(this << ppdu << rxDuration);
1987 WifiModulationClass modulation = ppdu->GetModulation();
1989 if (auto it = m_phyEntities.find(modulation);
1990 it != m_phyEntities.end() && modulation <= m_maxModClassSupported)
1991 {
1992 it->second->StartReceivePreamble(ppdu, rxPowersW, rxDuration);
1993 }
1994 else
1995 {
1996 // TODO find a fallback PHY for receiving the PPDU (e.g. 11a for 11ax due to preamble
1997 // structure)
1998 NS_LOG_DEBUG("Unsupported modulation received (" << modulation << "), consider as noise");
1999 m_interference->Add(ppdu, rxDuration, rxPowersW, GetCurrentFrequencyRange());
2001 }
2002}
2003
2004std::optional<std::reference_wrapper<const WifiTxVector>>
2006{
2007 if (m_endPhyRxEvent.IsPending())
2008 {
2009 NS_ASSERT_MSG(m_currentEvent, "No current event while receiving PHY header");
2010 return std::cref(m_currentEvent->GetPpdu()->GetTxVector());
2011 }
2012 return std::nullopt;
2013}
2014
2015void
2017{
2018 NS_LOG_FUNCTION(this);
2020 {
2021 m_powerRestricted = false;
2022 }
2023}
2024
2025void
2031
2032bool
2034{
2035 for (const auto& phyEntity : m_phyEntities)
2036 {
2037 if (phyEntity.second->IsModeSupported(mode))
2038 {
2039 return true;
2040 }
2041 }
2042 return false;
2043}
2044
2047{
2048 // Start from oldest standards and move up (guaranteed by fact that WifModulationClass is
2049 // ordered)
2050 for (const auto& phyEntity : m_phyEntities)
2051 {
2052 for (const auto& mode : *(phyEntity.second))
2053 {
2054 return mode;
2055 }
2056 }
2057 NS_ASSERT_MSG(false, "Should have found at least one default mode");
2058 return WifiMode();
2059}
2060
2061bool
2062WifiPhy::IsMcsSupported(WifiModulationClass modulation, uint8_t mcs) const
2063{
2064 const auto phyEntity = m_phyEntities.find(modulation);
2065 if (phyEntity == m_phyEntities.end())
2066 {
2067 return false;
2068 }
2069 return phyEntity->second->IsMcsSupported(mcs);
2070}
2071
2072std::list<WifiMode>
2074{
2075 std::list<WifiMode> list;
2076 for (const auto& phyEntity : m_phyEntities)
2077 {
2078 if (!phyEntity.second->HandlesMcsModes()) // to exclude MCSs from search
2079 {
2080 for (const auto& mode : *(phyEntity.second))
2081 {
2082 list.emplace_back(mode);
2083 }
2084 }
2085 }
2086 return list;
2087}
2088
2089std::list<WifiMode>
2091{
2092 std::list<WifiMode> list;
2093 const auto phyEntity = m_phyEntities.find(modulation);
2094 if (phyEntity != m_phyEntities.end())
2095 {
2096 if (!phyEntity->second->HandlesMcsModes()) // to exclude MCSs from search
2097 {
2098 for (const auto& mode : *(phyEntity->second))
2099 {
2100 list.emplace_back(mode);
2101 }
2102 }
2103 }
2104 return list;
2105}
2106
2107uint16_t
2109{
2110 uint16_t numMcs = 0;
2111 for (const auto& phyEntity : m_phyEntities)
2112 {
2113 if (phyEntity.second->HandlesMcsModes()) // to exclude non-MCS modes from search
2114 {
2115 numMcs += phyEntity.second->GetNumModes();
2116 }
2117 }
2118 return numMcs;
2119}
2120
2121std::list<WifiMode>
2123{
2124 std::list<WifiMode> list;
2125 for (const auto& phyEntity : m_phyEntities)
2126 {
2127 if (phyEntity.second->HandlesMcsModes()) // to exclude non-MCS modes from search
2128 {
2129 for (const auto& mode : *(phyEntity.second))
2130 {
2131 list.emplace_back(mode);
2132 }
2133 }
2134 }
2135 return list;
2136}
2137
2138std::list<WifiMode>
2140{
2141 std::list<WifiMode> list;
2142 auto phyEntity = m_phyEntities.find(modulation);
2143 if (phyEntity != m_phyEntities.end())
2144 {
2145 if (phyEntity->second->HandlesMcsModes()) // to exclude non-MCS modes from search
2146 {
2147 for (const auto& mode : *(phyEntity->second))
2148 {
2149 list.emplace_back(mode);
2150 }
2151 }
2152 }
2153 return list;
2154}
2155
2157WifiPhy::GetMcs(WifiModulationClass modulation, uint8_t mcs) const
2158{
2159 NS_ASSERT_MSG(IsMcsSupported(modulation, mcs), "Unsupported MCS");
2160 return m_phyEntities.at(modulation)->GetMcs(mcs);
2161}
2162
2163bool
2165{
2166 return m_state->IsStateCcaBusy();
2167}
2168
2169bool
2171{
2172 return m_state->IsStateIdle();
2173}
2174
2175bool
2177{
2178 return m_state->IsStateRx();
2179}
2180
2181bool
2183{
2184 return m_state->IsStateTx();
2185}
2186
2187bool
2189{
2190 return m_state->IsStateSwitching();
2191}
2192
2193bool
2195{
2196 return m_state->IsStateSleep();
2197}
2198
2199bool
2201{
2202 return m_state->IsStateOff();
2203}
2204
2205Time
2207{
2208 return m_state->GetDelayUntilIdle();
2209}
2210
2211Time
2213{
2214 return m_state->GetLastRxStartTime();
2215}
2216
2217Time
2219{
2220 return m_state->GetLastRxEndTime();
2221}
2222
2223void
2225{
2226 NS_LOG_FUNCTION(this);
2227 if (!IsStateIdle() && !IsStateCcaBusy())
2228 {
2229 return;
2230 }
2231 GetLatestPhyEntity()->SwitchMaybeToCcaBusy(ppdu);
2232}
2233
2234void
2236{
2237 NS_LOG_FUNCTION(this << duration);
2238 GetLatestPhyEntity()->NotifyCcaBusy(ppdu, duration, WIFI_CHANLIST_PRIMARY);
2239}
2240
2241void
2243{
2244 NS_LOG_FUNCTION(this << reason);
2245 if (reason != OBSS_PD_CCA_RESET ||
2246 m_currentEvent) // Otherwise abort has already been called previously
2247 {
2248 if (reason == SIGNAL_DETECTION_ABORTED_BY_TX)
2249 {
2250 for (auto signalDetectEvent : m_currentPreambleEvents)
2251 {
2252 NotifyRxPpduDrop(signalDetectEvent.second->GetPpdu(),
2254 }
2255 }
2256 for (auto& phyEntity : m_phyEntities)
2257 {
2258 phyEntity.second->CancelAllEvents();
2259 }
2260 m_endPhyRxEvent.Cancel();
2262 if (!m_currentEvent)
2263 {
2264 return;
2265 }
2266 NotifyRxPpduDrop(m_currentEvent->GetPpdu(), reason);
2267 if (reason == OBSS_PD_CCA_RESET)
2268 {
2269 m_state->SwitchFromRxAbort(GetChannelWidth());
2270 }
2271 if (reason == RECEPTION_ABORTED_BY_TX)
2272 {
2273 Reset();
2274 }
2275 else
2276 {
2277 for (auto it = m_currentPreambleEvents.begin(); it != m_currentPreambleEvents.end();
2278 ++it)
2279 {
2280 if (it->second == m_currentEvent)
2281 {
2282 it = m_currentPreambleEvents.erase(it);
2283 break;
2284 }
2285 }
2286 m_currentEvent = nullptr;
2287 }
2288 }
2289}
2290
2291void
2292WifiPhy::ResetCca(bool powerRestricted, dBm_u txPowerMaxSiso, dBm_u txPowerMaxMimo)
2293{
2294 NS_LOG_FUNCTION(this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2295 // This method might be called multiple times when receiving TB PPDUs with a BSS color
2296 // different than the one of the receiver. The first time this method is called, the call
2297 // to AbortCurrentReception sets m_currentEvent to 0. Therefore, we need to check whether
2298 // m_currentEvent is not 0 before executing the instructions below.
2299 if (m_currentEvent)
2300 {
2301 m_powerRestricted = powerRestricted;
2302 m_txPowerMaxSiso = txPowerMaxSiso;
2303 m_txPowerMaxMimo = txPowerMaxMimo;
2304 NS_ASSERT((m_currentEvent->GetEndTime() - Simulator::Now()).IsPositive());
2307 this);
2309 this,
2310 OBSS_PD_CCA_RESET); // finish processing field first
2311 }
2312}
2313
2314dBm_u
2316{
2317 NS_LOG_FUNCTION(this << m_powerRestricted << ppdu);
2318 const auto& txVector = ppdu->GetTxVector();
2319 // Get transmit power before antenna gain
2320 dBm_u txPower;
2321 if (!m_powerRestricted)
2322 {
2323 txPower = GetPower(txVector.GetTxPowerLevel());
2324 }
2325 else
2326 {
2327 if (txVector.GetNssMax() > 1 || txVector.GetNssTotal() > 1)
2328 {
2329 txPower = std::min(m_txPowerMaxMimo, GetPower(txVector.GetTxPowerLevel()));
2330 }
2331 else
2332 {
2333 txPower = std::min(m_txPowerMaxSiso, GetPower(txVector.GetTxPowerLevel()));
2334 }
2335 }
2336
2337 // Apply power density constraint on EIRP
2338 const auto channelWidth = ppdu->GetTxChannelWidth();
2339 dBm_per_MHz_u txPowerDbmPerMhz =
2340 (txPower + GetTxGain()) - RatioToDb(channelWidth); // account for antenna gain since EIRP
2341 NS_LOG_INFO("txPower=" << txPower << "dBm with txPowerDbmPerMhz=" << txPowerDbmPerMhz
2342 << " over " << channelWidth << " MHz");
2343 txPower = std::min(txPowerDbmPerMhz, m_powerDensityLimit) + RatioToDb(channelWidth);
2344 txPower -= GetTxGain(); // remove antenna gain since will be added right afterwards
2345 NS_LOG_INFO("txPower=" << txPower
2346 << "dBm after applying m_powerDensityLimit=" << m_powerDensityLimit);
2347 return txPower;
2348}
2349
2352{
2353 // TODO: wrapper. See if still needed
2354 return GetPhyEntityForPpdu(ppdu)->GetAddressedPsduInPpdu(ppdu);
2355}
2356
2357int64_t
2359{
2360 NS_LOG_FUNCTION(this << stream);
2361 int64_t currentStream = stream;
2362 m_random->SetStream(currentStream++);
2363 currentStream += m_interference->GetErrorRateModel()->AssignStreams(currentStream);
2364 return (currentStream - stream);
2365}
2366
2367std::ostream&
2368operator<<(std::ostream& os, RxSignalInfo rxSignalInfo)
2369{
2370 os << "SNR:" << RatioToDb(rxSignalInfo.snr) << " dB"
2371 << ", RSSI:" << rxSignalInfo.rssi << " dBm";
2372 return os;
2373}
2374
2375uint8_t
2376WifiPhy::GetPrimaryChannelNumber(MHz_u primaryChannelWidth) const
2377{
2378 return m_operatingChannel.GetPrimaryChannelNumber(primaryChannelWidth, m_standard);
2379}
2380
2381Hz_u
2383{
2384 Hz_u subcarrierSpacing{0};
2385 switch (GetStandard())
2386 {
2392 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING;
2393 break;
2395 if (GetChannelWidth() == MHz_u{5})
2396 {
2397 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING / 4;
2398 }
2399 else
2400 {
2401 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING / 2;
2402 }
2403 break;
2406 subcarrierSpacing = SUBCARRIER_FREQUENCY_SPACING_HE;
2407 break;
2408 default:
2409 NS_FATAL_ERROR("Standard unknown: " << GetStandard());
2410 break;
2411 }
2412 return subcarrierSpacing;
2413}
2414
2415} // namespace ns3
AttributeValue implementation for Boolean.
Definition boolean.h:26
Callback template class.
Definition callback.h:428
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()
Caller graph was not generated because of its size.
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:70
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:580
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:614
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:1483
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:1321
WifiChannelConfig m_channelCfg
Store operating channel config until initialization.
Definition wifi-phy.h:1656
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Definition wifi-phy.h:1395
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:822
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:1229
bool IsStateTx() const
Definition wifi-phy.cc:2182
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
Definition wifi-phy.h:1694
dBm_u m_ccaEdThreshold
Clear channel assessment (CCA) energy detection (ED) threshold.
Definition wifi-phy.h:1665
dBm_u GetTxPowerStart() const
Return the minimum available transmission power level.
Definition wifi-phy.cc:583
WifiModulationClass GetMaxModulationClassSupported() const
Definition wifi-phy.cc:994
bool IsStateIdle() const
Definition wifi-phy.cc:2170
void SetRxGain(dB_u gain)
Sets the reception gain.
Definition wifi-phy.cc:628
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
Definition wifi-phy.cc:691
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
Definition wifi-phy.h:1684
bool IsStateCcaBusy() const
Definition wifi-phy.cc:2164
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:1822
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Definition wifi-phy.h:1394
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
Definition wifi-phy.h:1698
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:565
void Configure80211ax()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard.
Definition wifi-phy.cc:964
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:1689
dB_u GetTxGain() const
Return the transmission gain.
Definition wifi-phy.cc:622
void SetTxPowerEnd(dBm_u end)
Sets the maximum available transmission power level.
Definition wifi-phy.cc:589
std::map< WifiModulationClass, std::shared_ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
Definition wifi-phy.h:1430
dBm_per_MHz_u m_powerDensityLimit
the power density limit
Definition wifi-phy.h:1674
void NotifyCcaBusy(const Ptr< const WifiPpdu > ppdu, Time duration)
Notify PHY state helper to switch to CCA busy state,.
Definition wifi-phy.cc:2235
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:1750
WifiPhyOperatingChannel m_operatingChannel
Operating channel.
Definition wifi-phy.h:1657
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:1548
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
Definition wifi-phy.cc:700
bool m_channelAccessRequested
Flag if channels access has been requested (used for OBSS_PD SR).
Definition wifi-phy.h:1679
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:1527
Time GetSlot() const
Return the slot duration for this PHY.
Definition wifi-phy.cc:853
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
Definition wifi-phy.cc:1371
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:2351
std::shared_ptr< PhyEntity > GetLatestPhyEntity() const
Get the latest PHY entity supported by this PHY instance.
Definition wifi-phy.cc:787
void Configure80211g()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
Definition wifi-phy.cc:900
uint8_t GetPrimary20Index() const
Definition wifi-phy.cc:1096
dBm_u m_rxSensitivity
Receive sensitivity threshold.
Definition wifi-phy.h:1664
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:1407
uint8_t GetNumberOfAntennas() const
Definition wifi-phy.cc:1333
Time m_slot
Slot duration.
Definition wifi-phy.h:1661
dBm_u GetRxSensitivity() const
Return the receive sensitivity threshold.
Definition wifi-phy.cc:529
Time GetDelayUntilIdle()
Definition wifi-phy.cc:2206
MHz_u m_maxRadioBw
Maximum radio bandwidth.
Definition wifi-phy.h:1691
bool GetShortPhyPreambleSupported() const
Return whether short PHY preamble is supported.
Definition wifi-phy.cc:648
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS) for this PHY.
Definition wifi-phy.cc:835
std::list< uint8_t > GetBssMembershipSelectorList() const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition wifi-phy.cc:1389
std::shared_ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class.
Definition wifi-phy.cc:772
void Configure80211n()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
Definition wifi-phy.cc:941
EventId m_endPhyRxEvent
the end of PHY receive event
Definition wifi-phy.h:1402
dBm_u m_ccaSensitivityThreshold
Clear channel assessment (CCA) modulation and coding rate sensitivity threshold.
Definition wifi-phy.h:1666
void Configure80211be()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11be standard.
Definition wifi-phy.cc:979
void NotifyRxDrop(Ptr< const WifiPsdu > psdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxDrop trace.
Definition wifi-phy.cc:1677
bool IsStateRx() const
Definition wifi-phy.cc:2176
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:2062
Time GetSifs() const
Return the Short Interframe Space (SIFS) for this PHY.
Definition wifi-phy.cc:841
dBm_u m_txPowerMaxMimo
MIMO maximum transmit power due to OBSS PD SR power restriction.
Definition wifi-phy.h:1678
bool m_notifyRxMacHeaderEnd
whether the PHY is capable of notifying MAC header RX end
Definition wifi-phy.h:1701
Hz_u GetSubcarrierSpacing() const
Definition wifi-phy.cc:2382
MHz_u GetFrequency() const
Definition wifi-phy.cc:1078
Ptr< MobilityModel > GetMobility() const
Return the mobility model this PHY is associated with.
Definition wifi-phy.cc:672
uint16_t GetNMcs() const
Definition wifi-phy.cc:2108
void SetSleepMode(bool forceSleepWhileInRx=false)
Put in sleep mode.
Definition wifi-phy.cc:1404
void ResumeFromSleep()
Resume from sleep mode.
Definition wifi-phy.cc:1460
void SetTxPowerStart(dBm_u start)
Sets the minimum available transmission power level.
Definition wifi-phy.cc:576
static Time GetPreambleDetectionDuration()
Definition wifi-phy.cc:1515
void Configure80211p()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11p standard.
Definition wifi-phy.cc:913
dBm_u m_txPowerEnd
Maximum transmission power.
Definition wifi-phy.h:1672
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted.
Definition wifi-phy.cc:2242
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
Definition wifi-phy.h:1696
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition wifi-phy.h:1591
void NotifyRxBegin(Ptr< const WifiPsdu > psdu, const RxPowerWattPerChannelBand &rxPowersW)
Public method used to fire a PhyRxBegin trace.
Definition wifi-phy.cc:1653
Time GetChannelSwitchDelay() const
Definition wifi-phy.cc:751
void SetTxGain(dB_u gain)
Sets the transmission gain.
Definition wifi-phy.cc:615
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
Definition wifi-phy.cc:1339
void NotifyTxBegin(const WifiConstPsduMap &psdus, Watt_u txPower)
Public method used to fire a PhyTxBegin trace.
Definition wifi-phy.cc:1611
Time m_sifs
Short Interframe Space (SIFS) duration.
Definition wifi-phy.h:1660
void SetReceiveErrorCallback(RxErrorCallback callback)
Definition wifi-phy.cc:493
TracedCallback< Ptr< const WifiPpdu >, const WifiTxVector & > m_signalTransmissionCb
Signal Transmission callback.
Definition wifi-phy.h:1433
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:1696
dBm_u GetTxPowerEnd() const
Return the maximum available transmission power level.
Definition wifi-phy.cc:596
bool IsStateOff() const
Definition wifi-phy.cc:2200
uint8_t GetMaxSupportedRxSpatialStreams() const
Definition wifi-phy.cc:1383
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition wifi-phy.cc:1000
void SetPostReceptionErrorModel(const Ptr< ErrorModel > em)
Attach a receive ErrorModel to the WifiPhy.
Definition wifi-phy.cc:708
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:2157
uint8_t m_numberOfAntennas
Number of transmitters.
Definition wifi-phy.h:1683
uint32_t m_txMpduReferenceNumber
A-MPDU reference number to identify all transmitted subframes belonging to the same received A-MPDU.
Definition wifi-phy.h:1397
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:1603
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition wifi-phy.cc:1574
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
Definition wifi-phy.cc:1605
dBm_u GetCcaEdThreshold() const
Return the CCA energy detection threshold.
Definition wifi-phy.cc:546
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:1671
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:1626
void EndReceiveInterBss()
For HE receptions only, check and possibly modify the transmit power restriction state at the end of ...
Definition wifi-phy.cc:2016
void SetShortPhyPreambleSupported(bool preamble)
Enable or disable short PHY preamble.
Definition wifi-phy.cc:641
void SetCcaSensitivityThreshold(dBm_u threshold)
Sets the CCA sensitivity threshold.
Definition wifi-phy.cc:552
WifiPhyBand m_band
WifiPhyBand.
Definition wifi-phy.h:1655
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:813
dBm_u m_txPowerMaxSiso
SISO maximum transmit power due to OBSS PD SR power restriction.
Definition wifi-phy.h:1677
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:1642
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:1803
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:1114
void NotifyRxPpduDrop(Ptr< const WifiPpdu > ppdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxPpduDrop trace.
Definition wifi-phy.cc:1689
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:987
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:1623
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
Definition wifi-phy.h:1699
EventId m_endTxEvent
the end of transmit event
Definition wifi-phy.h:1403
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:1816
std::list< WifiChannelConfig::TupleWithoutUnits > ChannelSegments
segments identifying an operating channel
Definition wifi-phy.h:957
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:847
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:793
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
Definition wifi-phy.cc:1060
void SetPreviouslyRxPpduUid(uint64_t uid)
Set the UID of the previously received PPDU.
Definition wifi-phy.cc:1957
Ptr< Event > m_currentEvent
Hold the current event.
Definition wifi-phy.h:1405
Time GetLastRxStartTime() const
Return the start time of the last received packet.
Definition wifi-phy.cc:2212
WifiMode GetDefaultMode() const
Get the default WifiMode supported by the PHY.
Definition wifi-phy.cc:2046
uint8_t GetChannelNumber() const
Return current channel number.
Definition wifi-phy.cc:1084
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
Definition wifi-phy.h:1540
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
Definition wifi-phy.h:1410
std::optional< Time > GetDelayUntilChannelSwitch()
Perform any actions necessary when user changes operating channel after initialization.
Definition wifi-phy.cc:1188
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU.
Definition wifi-phy.h:1399
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
Definition wifi-phy.cc:727
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:1525
virtual void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition wifi-phy.cc:654
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
Definition wifi-phy.h:1697
virtual std::optional< std::reference_wrapper< const WifiTxVector > > GetInfoIfRxingPhyHeader() const
Definition wifi-phy.cc:2005
Time GetPifs() const
Return the PCF Interframe Space (PIFS) for this PHY.
Definition wifi-phy.cc:865
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
Definition wifi-phy.cc:1665
void StartReceivePreamble(Ptr< const WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Definition wifi-phy.cc:1982
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:1532
dB_u m_txGain
Transmission gain.
Definition wifi-phy.h:1669
MHz_u GetChannelWidth() const
Definition wifi-phy.cc:1090
bool IsStateSleep() const
Definition wifi-phy.cc:2194
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:1126
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
Definition wifi-phy.cc:660
WifiStandard m_standard
WifiStandard.
Definition wifi-phy.h:1653
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:2292
dB_u GetRxGain() const
Return the reception gain.
Definition wifi-phy.cc:635
bool IsStateSwitching() const
Definition wifi-phy.cc:2188
void SetPhyId(uint8_t phyId)
Set the index allocated to this PHY.
Definition wifi-phy.cc:678
virtual void DoChannelSwitch()
Actually switch channel based on the stored channel settings.
Definition wifi-phy.cc:1254
void SetOffMode()
Put in off mode.
Definition wifi-phy.cc:1450
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:1598
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
Definition wifi-phy.cc:721
uint8_t m_phyId
the index of the PHY in the vector of PHYs held by the WifiNetDevice
Definition wifi-phy.h:1389
void SetPifs(Time pifs)
Set the PCF Interframe Space (PIFS) for this PHY.
Definition wifi-phy.cc:859
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:602
void Configure80211b()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
Definition wifi-phy.cc:885
static const std::shared_ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
Definition wifi-phy.cc:763
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:1687
static Time GetStartOfPacketDuration(const WifiTxVector &txVector)
Definition wifi-phy.cc:1521
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:2224
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition wifi-phy.cc:666
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
Definition wifi-phy.h:1685
dB_u m_rxGain
Reception gain.
Definition wifi-phy.h:1670
double CalculateSnr(const WifiTxVector &txVector, double ber) const
Definition wifi-phy.cc:757
TupleValue< UintegerValue, UintegerValue, EnumValue< WifiPhyBand >, UintegerValue > ChannelTupleValue
AttributeValue type of a ChannelTuple object.
Definition wifi-phy.h:960
void SetFixedPhyBand(bool enable)
Configure whether it is prohibited to change PHY band after initialization.
Definition wifi-phy.cc:1102
~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:956
bool HasFixedPhyBand() const
Definition wifi-phy.cc:1108
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:1556
Ptr< WifiNetDevice > m_device
Pointer to the device.
Definition wifi-phy.h:1693
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
Definition wifi-phy.h:1392
void DoInitialize() override
Initialize() implementation.
Definition wifi-phy.cc:420
bool m_shortPreamble
Flag if short PHY preamble is supported.
Definition wifi-phy.h:1682
uint8_t GetPhyId() const
Get the index allocated to this PHY.
Definition wifi-phy.cc:685
Time m_pifs
PCF Interframe Space (PIFS) duration.
Definition wifi-phy.h:1662
WifiModulationClass m_maxModClassSupported
max modulation class supported
Definition wifi-phy.h:1654
uint8_t GetNTxPowerLevels() const
Return the number of available transmission power levels.
Definition wifi-phy.cc:609
WifiStandard GetStandard() const
Get the configured Wi-Fi standard.
Definition wifi-phy.cc:1066
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:715
void NotifyChannelAccessRequested()
Notify the PHY that an access to the channel was requested.
Definition wifi-phy.cc:2026
dBm_u GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
Definition wifi-phy.cc:2315
void ResumeFromOff()
Resume from off mode.
Definition wifi-phy.cc:1487
bool m_powerRestricted
Flag whether transmit power is restricted by OBSS PD SR.
Definition wifi-phy.h:1676
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
Definition wifi-phy.h:1703
uint64_t GetPreviouslyRxPpduUid() const
Definition wifi-phy.cc:1951
void Reset()
Reset data upon end of TX or RX.
Definition wifi-phy.cc:1964
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
Definition wifi-phy.h:1572
Time GetLastRxEndTime() const
Return the end time of the last received packet.
Definition wifi-phy.cc:2218
TracedCallback< const WifiMacHeader &, const WifiTxVector &, Time > m_phyRxMacHeaderEndTrace
The trace source fired when the reception of a MAC header ends.
Definition wifi-phy.h:1583
Time m_timeLastPreambleDetected
Record the time the last preamble was detected.
Definition wifi-phy.h:1700
uint8_t GetMaxSupportedTxSpatialStreams() const
Definition wifi-phy.cc:1365
void Configure80211a()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
Definition wifi-phy.cc:871
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:2122
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition wifi-phy.cc:2073
void TxDone(const WifiConstPsduMap &psdus)
Callback function when a transmission is completed.
Definition wifi-phy.cc:1941
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
Definition wifi-phy.cc:1072
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:1790
uint8_t GetPrimaryChannelNumber(MHz_u primaryChannelWidth) const
Get channel number of the primary channel.
Definition wifi-phy.cc:2376
dBm_u GetPower(uint8_t powerLevel) const
Get the power of the given power level.
Definition wifi-phy.cc:733
bool m_fixedPhyBand
True to prohibit changing PHY band after initialization.
Definition wifi-phy.h:1658
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:2358
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition wifi-phy.cc:1567
bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
Definition wifi-phy.cc:2033
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:559
uint8_t m_nTxPowerLevels
Number of available transmission power levels.
Definition wifi-phy.h:1673
void NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
Definition wifi-phy.cc:1641
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:250
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Definition pointer.h:273
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:1484
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1504
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:194
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:260
#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:253
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:267
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:627
#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:1415
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1381
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:463
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:181
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.