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