A Discrete-Event Network Simulator
API
wifi-phy.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2005,2006 INRIA
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 * S├ębastien Deronne <sebastien.deronne@gmail.com>
20 */
21
22#include <algorithm>
23#include "ns3/simulator.h"
24#include "ns3/log.h"
25#include "ns3/pointer.h"
26#include "ns3/string.h"
27#include "ns3/tuple.h"
28#include "ns3/mobility-model.h"
29#include "ns3/random-variable-stream.h"
30#include "ns3/error-model.h"
31#include "wifi-net-device.h"
32#include "wifi-phy.h"
33#include "wifi-utils.h"
34#include "frame-capture-model.h"
37#include "error-rate-model.h"
38#include "wifi-net-device.h"
39#include "wifi-psdu.h"
40#include "wifi-ppdu.h"
41#include "ns3/dsss-phy.h"
42#include "ns3/erp-ofdm-phy.h"
43#include "ns3/he-phy.h" //includes OFDM, HT, and VHT
44
45namespace ns3 {
46
47NS_LOG_COMPONENT_DEFINE ("WifiPhy");
48
49/****************************************************************
50 * The actual WifiPhy class
51 ****************************************************************/
52
54
55TypeId
57{
58 static TypeId tid = TypeId ("ns3::WifiPhy")
59 .SetParent<Object> ()
60 .SetGroupName ("Wifi")
61 .AddAttribute ("ChannelSettings",
62 "Tuple {channel number, channel width (MHz), PHY band, primary20 index} "
63 "describing the settings of the operating channel. The primary20 index is "
64 "the index of the primary 20 MHz channel within the operating channel "
65 "(0 indicates the 20 MHz subchannel with the lowest center frequency) and "
66 "is only valid if the width of the operating channel is a multiple of 20 MHz. "
67 "If the standard for this object has not been set yet, the value of this "
68 "attribute is saved and will be used to set the operating channel when the "
69 "standard is configured. If the PHY band is left unspecified, the default "
70 "band for the configured standard is used. If the channel width and the "
71 "channel number are both 0, the default channel width for the configured "
72 "standard and band are used. If the channel number is 0, the default "
73 "channel number for the configured standard, band and channel width is used."
74 "Note that the channel width can be left unspecified (0) if the channel "
75 "number uniquely identify a frequency channel for the given standard and band. ",
76 StringValue ("{0, 0, BAND_UNSPECIFIED, 0}"),
77 MakeTupleAccessor <UintegerValue, UintegerValue, EnumValue, UintegerValue> ((void (WifiPhy::*) (const ChannelTuple&))(&WifiPhy::SetOperatingChannel)),
78 MakeTupleChecker<UintegerValue, UintegerValue, EnumValue, UintegerValue>
79 (MakeUintegerChecker<uint8_t> (0, 233),
80 MakeUintegerChecker<uint16_t> (0, 160),
84 WifiPhyBand::WIFI_PHY_BAND_UNSPECIFIED, "BAND_UNSPECIFIED"),
85 MakeUintegerChecker<uint8_t> (0, 7)))
86 .AddAttribute ("Frequency",
87 "The center frequency (MHz) of the current operating channel.",
88 UintegerValue (0),
90 MakeUintegerChecker<uint16_t> ())
91 .AddAttribute ("ChannelNumber",
92 "The channel number of the current operating channel.",
93 UintegerValue (0),
95 MakeUintegerChecker<uint8_t> (0, 233))
96 .AddAttribute ("ChannelWidth",
97 "The width in MHz of the current operating channel (5, 10, 20, 22, 40, 80 or 160).",
98 UintegerValue (0),
100 MakeUintegerChecker<uint16_t> (5, 160))
101 .AddAttribute ("Primary20MHzIndex",
102 "The index of the primary 20 MHz channel within the current operating channel "
103 "(0 indicates the 20 MHz subchannel with the lowest center frequency).",
104 UintegerValue (0),
106 MakeUintegerChecker<uint8_t> (0, 7))
107 .AddAttribute ("RxSensitivity",
108 "The energy of a received signal should be higher than "
109 "this threshold (dBm) for the PHY to detect the signal. "
110 "This threshold refers to a width of 20 MHz and will be "
111 "scaled to match the width of the received signal.",
112 DoubleValue (-101.0),
115 MakeDoubleChecker<double> ())
116 .AddAttribute ("CcaEdThreshold",
117 "The energy of a non Wi-Fi received signal should be higher than "
118 "this threshold (dBm) to allow the PHY layer to declare CCA BUSY state. "
119 "This check is performed on the 20 MHz primary channel only.",
120 DoubleValue (-62.0),
123 MakeDoubleChecker<double> ())
124 .AddAttribute ("TxGain",
125 "Transmission gain (dB).",
126 DoubleValue (0.0),
129 MakeDoubleChecker<double> ())
130 .AddAttribute ("RxGain",
131 "Reception gain (dB).",
132 DoubleValue (0.0),
135 MakeDoubleChecker<double> ())
136 .AddAttribute ("TxPowerLevels",
137 "Number of transmission power levels available between "
138 "TxPowerStart and TxPowerEnd included.",
139 UintegerValue (1),
141 MakeUintegerChecker<uint8_t> ())
142 .AddAttribute ("TxPowerEnd",
143 "Maximum available transmission level (dBm).",
144 DoubleValue (16.0206),
147 MakeDoubleChecker<double> ())
148 .AddAttribute ("TxPowerStart",
149 "Minimum available transmission level (dBm).",
150 DoubleValue (16.0206),
153 MakeDoubleChecker<double> ())
154 .AddAttribute ("RxNoiseFigure",
155 "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
156 " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
157 "\"the difference in decibels (dB) between"
158 " the noise output of the actual receiver to the noise output of an "
159 " ideal receiver with the same overall gain and bandwidth when the receivers "
160 " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
161 DoubleValue (7),
163 MakeDoubleChecker<double> ())
164 .AddAttribute ("State",
165 "The state of the PHY layer.",
166 PointerValue (),
168 MakePointerChecker<WifiPhyStateHelper> ())
169 .AddAttribute ("ChannelSwitchDelay",
170 "Delay between two short frames transmitted on different frequencies.",
171 TimeValue (MicroSeconds (250)),
174 .AddAttribute ("Antennas",
175 "The number of antennas on the device.",
176 UintegerValue (1),
179 MakeUintegerChecker<uint8_t> (1, 8))
180 .AddAttribute ("MaxSupportedTxSpatialStreams",
181 "The maximum number of supported TX spatial streams."
182 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
183 UintegerValue (1),
186 MakeUintegerChecker<uint8_t> (1, 8))
187 .AddAttribute ("MaxSupportedRxSpatialStreams",
188 "The maximum number of supported RX spatial streams."
189 "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
190 UintegerValue (1),
193 MakeUintegerChecker<uint8_t> (1, 8))
194 .AddAttribute ("ShortPlcpPreambleSupported",
195 "Whether or not short PHY preamble is supported."
196 "This parameter is only valuable for 802.11b STAs and APs."
197 "Note: 802.11g APs and STAs always support short PHY preamble.",
198 BooleanValue (false),
202 .AddAttribute ("FrameCaptureModel",
203 "Ptr to an object that implements the frame capture model",
204 PointerValue (),
206 MakePointerChecker <FrameCaptureModel> ())
207 .AddAttribute ("PreambleDetectionModel",
208 "Ptr to an object that implements the preamble detection model",
209 PointerValue (),
211 MakePointerChecker <PreambleDetectionModel> ())
212 .AddAttribute ("PostReceptionErrorModel",
213 "An optional packet error model can be added to the receive "
214 "packet process after any propagation-based (SNR-based) error "
215 "models have been applied. Typically this is used to force "
216 "specific packet drops, for testing purposes.",
217 PointerValue (),
219 MakePointerChecker<ErrorModel> ())
220 .AddAttribute ("Sifs",
221 "The duration of the Short Interframe Space. "
222 "NOTE that the default value is overwritten by the value defined "
223 "by the standard; if you want to set this attribute, you have to "
224 "do it after that the PHY object is initialized.",
228 .AddAttribute ("Slot",
229 "The duration of a slot. "
230 "NOTE that the default value is overwritten by the value defined "
231 "by the standard; if you want to set this attribute, you have to "
232 "do it after that the PHY object is initialized.",
236 .AddAttribute ("Pifs",
237 "The duration of the PCF Interframe Space. "
238 "NOTE that the default value is overwritten by the value defined "
239 "by the standard; if you want to set this attribute, you have to "
240 "do it after that the PHY object is initialized.",
244 .AddAttribute ("PowerDensityLimit",
245 "The mean equivalent isotropically radiated power density"
246 "limit (in dBm/MHz) set by regulators.",
247 DoubleValue (100.0), //set to a high value so as to have no effect
249 MakeDoubleChecker<double> ())
250 .AddTraceSource ("PhyTxBegin",
251 "Trace source indicating a packet "
252 "has begun transmitting over the channel medium",
254 "ns3::WifiPhy::PhyTxBeginTracedCallback")
255 .AddTraceSource ("PhyTxPsduBegin",
256 "Trace source indicating a PSDU "
257 "has begun transmitting over the channel medium",
259 "ns3::WifiPhy::PsduTxBeginCallback")
260 .AddTraceSource ("PhyTxEnd",
261 "Trace source indicating a packet "
262 "has been completely transmitted over the channel.",
264 "ns3::Packet::TracedCallback")
265 .AddTraceSource ("PhyTxDrop",
266 "Trace source indicating a packet "
267 "has been dropped by the device during transmission",
269 "ns3::Packet::TracedCallback")
270 .AddTraceSource ("PhyRxBegin",
271 "Trace source indicating a packet "
272 "has begun being received from the channel medium "
273 "by the device",
275 "ns3::WifiPhy::PhyRxBeginTracedCallback")
276 .AddTraceSource ("PhyRxPayloadBegin",
277 "Trace source indicating the reception of the "
278 "payload of a PPDU has begun",
280 "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
281 .AddTraceSource ("PhyRxEnd",
282 "Trace source indicating a packet "
283 "has been completely received from the channel medium "
284 "by the device",
286 "ns3::Packet::TracedCallback")
287 .AddTraceSource ("PhyRxDrop",
288 "Trace source indicating a packet "
289 "has been dropped by the device during reception",
291 "ns3::Packet::TracedCallback")
292 .AddTraceSource ("MonitorSnifferRx",
293 "Trace source simulating a wifi device in monitor mode "
294 "sniffing all received frames",
296 "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
297 .AddTraceSource ("MonitorSnifferTx",
298 "Trace source simulating the capability of a wifi device "
299 "in monitor mode to sniff all frames being transmitted",
301 "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
302 ;
303 return tid;
304}
305
307 : m_txMpduReferenceNumber (0xffffffff),
308 m_rxMpduReferenceNumber (0xffffffff),
309 m_endPhyRxEvent (),
310 m_endTxEvent (),
311 m_currentEvent (0),
312 m_previouslyRxPpduUid (UINT64_MAX),
313 m_standard (WIFI_STANDARD_UNSPECIFIED),
315 m_initialFrequency (0),
316 m_initialChannelNumber (0),
317 m_initialChannelWidth (0),
318 m_initialPrimary20Index (0),
319 m_sifs (Seconds (0)),
320 m_slot (Seconds (0)),
321 m_pifs (Seconds (0)),
322 m_ackTxTime (Seconds (0)),
323 m_blockAckTxTime (Seconds (0)),
324 m_powerRestricted (false),
325 m_channelAccessRequested (false),
326 m_txSpatialStreams (0),
327 m_rxSpatialStreams (0),
328 m_wifiRadioEnergyModel (0),
329 m_timeLastPreambleDetected (Seconds (0))
330{
331 NS_LOG_FUNCTION (this);
332 m_random = CreateObject<UniformRandomVariable> ();
333 m_state = CreateObject<WifiPhyStateHelper> ();
334}
335
337{
338 NS_LOG_FUNCTION (this);
339}
340
341void
343{
344 NS_LOG_FUNCTION (this);
347 for (auto & phyEntity : m_phyEntities)
348 {
349 phyEntity.second->CancelAllEvents ();
350 }
351 m_device = 0;
352 m_mobility = 0;
358 m_random = 0;
359 m_state = 0;
360 m_currentEvent = 0;
361 for (auto & preambleEvent : m_currentPreambleEvents)
362 {
363 preambleEvent.second = 0;
364 }
366
367 for (auto & phyEntity : m_phyEntities)
368 {
369 phyEntity.second = 0;
370 }
371 m_phyEntities.clear ();
372}
373
374std::map<WifiModulationClass, Ptr<PhyEntity> > &
376{
377 static std::map<WifiModulationClass, Ptr<PhyEntity> > g_staticPhyEntities;
378 return g_staticPhyEntities;
379}
380
383{
384 return m_state;
385}
386
387void
389{
390 m_state->SetReceiveOkCallback (callback);
391}
392
393void
395{
396 m_state->SetReceiveErrorCallback (callback);
397}
398
399void
401{
402 m_state->RegisterListener (listener);
403}
404
405void
407{
408 m_state->UnregisterListener (listener);
409}
410
411void
413{
415}
416
417void
419{
420 NS_LOG_FUNCTION (this << threshold);
421 m_rxSensitivityW = DbmToW (threshold);
422}
423
424double
426{
427 return WToDbm (m_rxSensitivityW);
428}
429
430void
432{
433 NS_LOG_FUNCTION (this << threshold);
434 m_ccaEdThresholdW = DbmToW (threshold);
435}
436
437double
439{
440 return WToDbm (m_ccaEdThresholdW);
441}
442
443void
444WifiPhy::SetRxNoiseFigure (double noiseFigureDb)
445{
446 NS_LOG_FUNCTION (this << noiseFigureDb);
447 m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
449}
450
451void
453{
454 NS_LOG_FUNCTION (this << start);
456}
457
458double
460{
461 return m_txPowerBaseDbm;
462}
463
464void
466{
467 NS_LOG_FUNCTION (this << end);
468 m_txPowerEndDbm = end;
469}
470
471double
473{
474 return m_txPowerEndDbm;
475}
476
477void
479{
480 NS_LOG_FUNCTION (this << +n);
481 m_nTxPower = n;
482}
483
484uint8_t
486{
487 return m_nTxPower;
488}
489
490void
492{
493 NS_LOG_FUNCTION (this << gain);
494 m_txGainDb = gain;
495}
496
497double
499{
500 return m_txGainDb;
501}
502
503void
505{
506 NS_LOG_FUNCTION (this << gain);
507 m_rxGainDb = gain;
508}
509
510double
512{
513 return m_rxGainDb;
514}
515
516void
518{
519 NS_LOG_FUNCTION (this << enable);
520 m_shortPreamble = enable;
521}
522
523bool
525{
526 return m_shortPreamble;
527}
528
529void
531{
532 m_device = device;
533}
534
537{
538 return m_device;
539}
540
541void
543{
545}
546
549{
550 if (m_mobility != 0)
551 {
552 return m_mobility;
553 }
554 else
555 {
556 return m_device->GetNode ()->GetObject<MobilityModel> ();
557 }
558}
559
560void
562{
565}
566
567void
569{
570 NS_LOG_FUNCTION (this << em);
572}
573
574void
576{
577 m_frameCaptureModel = model;
578}
579
580void
582{
584}
585
586void
588{
589 m_wifiRadioEnergyModel = wifiRadioEnergyModel;
590}
591
592double
593WifiPhy::GetPowerDbm (uint8_t power) const
594{
596 NS_ASSERT (m_nTxPower > 0);
597 double dbm;
598 if (m_nTxPower > 1)
599 {
601 }
602 else
603 {
604 NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
605 dbm = m_txPowerBaseDbm;
606 }
607 return dbm;
608}
609
610Time
612{
614}
615
616double
617WifiPhy::CalculateSnr (const WifiTxVector& txVector, double ber) const
618{
619 return m_interference.GetErrorRateModel ()->CalculateSnr (txVector, ber);
620}
621
624{
625 const auto it = GetStaticPhyEntities ().find (modulation);
626 NS_ABORT_MSG_IF (it == GetStaticPhyEntities ().end (), "Unimplemented Wi-Fi modulation class");
627 return it->second;
628}
629
632{
633 const auto it = m_phyEntities.find (modulation);
634 NS_ABORT_MSG_IF (it == m_phyEntities.end (), "Unsupported Wi-Fi modulation class " << modulation);
635 return it->second;
636}
637
638void
640{
641 NS_LOG_FUNCTION (modulation);
642 NS_ASSERT_MSG (GetStaticPhyEntities ().find (modulation) == GetStaticPhyEntities ().end (), "The PHY entity has already been added. The setting should only be done once per modulation class");
643 GetStaticPhyEntities ()[modulation] = phyEntity;
644}
645
646void
648{
649 NS_LOG_FUNCTION (this << modulation);
650 NS_ABORT_MSG_IF (GetStaticPhyEntities ().find (modulation) == GetStaticPhyEntities ().end (), "Cannot add an unimplemented PHY to supported list. Update the former first.");
651 NS_ASSERT_MSG (m_phyEntities.find (modulation) == m_phyEntities.end (), "The PHY entity has already been added. The setting should only be done once per modulation class");
652 phyEntity->SetOwner (this);
653 m_phyEntities[modulation] = phyEntity;
654}
655
656void
658{
659 m_sifs = sifs;
660}
661
662Time
664{
665 return m_sifs;
666}
667
668void
670{
671 m_slot = slot;
672}
673
674Time
676{
677 return m_slot;
678}
679
680void
682{
683 m_pifs = pifs;
684}
685
686Time
688{
689 return m_pifs;
690}
691
692Time
694{
695 return m_ackTxTime;
696}
697
698Time
700{
701 return m_blockAckTxTime;
702}
703
704void
706{
707 NS_LOG_FUNCTION (this);
708 AddPhyEntity (WIFI_MOD_CLASS_OFDM, Create<OfdmPhy> ());
709
710 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
711 SetSifs (MicroSeconds (16));
712 SetSlot (MicroSeconds (9));
713 SetPifs (GetSifs () + GetSlot ());
714 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
715 // of the PPDU causing the EIFS" of 802.11-2016
717}
718
719void
721{
722 NS_LOG_FUNCTION (this);
723 Ptr<DsssPhy> phyEntity = Create<DsssPhy> ();
725 AddPhyEntity (WIFI_MOD_CLASS_DSSS, phyEntity); //when plain DSSS modes are used
726
727 // See Table 16-4 "HR/DSSS PHY characteristics" of 802.11-2016
728 SetSifs (MicroSeconds (10));
729 SetSlot (MicroSeconds (20));
730 SetPifs (GetSifs () + GetSlot ());
731 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
732 // of the PPDU causing the EIFS" of 802.11-2016
734}
735
736void
738{
739 NS_LOG_FUNCTION (this);
740 // See Table 18-5 "ERP characteristics" of 802.11-2016
741 // Slot time defaults to the "long slot time" of 20 us in the standard
742 // according to mixed 802.11b/g deployments. Short slot time is enabled
743 // if the user sets the ShortSlotTimeSupported flag to true and when the BSS
744 // consists of only ERP STAs capable of supporting this option.
746 AddPhyEntity (WIFI_MOD_CLASS_ERP_OFDM, Create<ErpOfdmPhy> ());
747}
748
749void
751{
752 NS_LOG_FUNCTION (this);
753 if (GetChannelWidth () == 10)
754 {
756
757 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
758 SetSifs (MicroSeconds (32));
759 SetSlot (MicroSeconds (13));
760 SetPifs (GetSifs () + GetSlot ());
762 }
763 else if (GetChannelWidth () == 5)
764 {
766
767 // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
768 SetSifs (MicroSeconds (64));
769 SetSlot (MicroSeconds (21));
770 SetPifs (GetSifs () + GetSlot ());
772 }
773 else
774 {
775 NS_FATAL_ERROR ("802.11p configured with a wrong channel width!");
776 }
777}
778
779void
781{
782 NS_LOG_FUNCTION (this);
784 {
786 }
787 else
788 {
790 }
792
793 // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
794 // of the PPDU causing the EIFS" of 802.11-2016
796}
797
798void
800{
801 NS_LOG_FUNCTION (this);
803 AddPhyEntity (WIFI_MOD_CLASS_VHT, Create<VhtPhy> ());
804}
805
806void
808{
809 NS_LOG_FUNCTION (this);
811 {
813 }
814 else
815 {
817 }
818 AddPhyEntity (WIFI_MOD_CLASS_HE, Create<HePhy> ());
819}
820
821void
823{
824 NS_LOG_FUNCTION (this << standard << band);
825 m_standard = standard;
826 m_band = band;
827
829 {
830 // set a default channel if the user did not specify anything
831 if (m_initialChannelWidth == 0)
832 {
833 // set a default channel width
835 }
836
838 }
839 else
840 {
843 }
845
846 switch (standard)
847 {
850 break;
853 break;
856 break;
859 break;
862 break;
865 break;
868 break;
870 default:
871 NS_ASSERT_MSG (false, "Unsupported standard");
872 break;
873 }
874}
875
876void
878{
879 NS_LOG_FUNCTION (this << standard);
880
882 "Cannot change standard");
883
884 m_standard = standard;
885
887 {
888 NS_LOG_DEBUG ("Setting the operating channel first");
890 // return because we are called back by SetOperatingChannel
891 return;
892 }
893
894 // this function is called when changing PHY band, hence we have to delete
895 // the previous PHY entities
896 m_phyEntities.clear ();
897
898 switch (standard)
899 {
902 break;
905 break;
908 break;
911 break;
914 break;
917 break;
920 break;
922 default:
923 NS_ASSERT_MSG (false, "Unsupported standard");
924 break;
925 }
926}
927
930{
931 return m_band;
932}
933
934
937{
938 return m_standard;
939}
940
943{
944 return m_operatingChannel;
945}
946
947void
948WifiPhy::SetFrequency (uint16_t frequency)
949{
950 NS_LOG_FUNCTION (this << frequency);
951
953 {
954 // ConfigureStandardAndBand has not been called yet, so store the frequency
955 // into m_initialFrequency
956 NS_LOG_DEBUG ("Saving frequency configuration for initialization");
957 m_initialFrequency = frequency;
958 return;
959 }
960
961 if (GetFrequency () == frequency)
962 {
963 NS_LOG_DEBUG ("No frequency change requested");
964 return;
965 }
966
967 // if the frequency does not uniquely identify an operating channel,
968 // the simulation aborts
969 SetOperatingChannel (0, frequency, 0);
970}
971
972uint16_t
974{
976}
977
978void
980{
981 NS_LOG_FUNCTION (this << +nch);
982
984 {
985 // ConfigureStandardAndBand has not been called yet, so store the channel
986 // into m_initialChannelNumber
987 NS_LOG_DEBUG ("Saving channel number configuration for initialization");
989 return;
990 }
991
992 if (GetChannelNumber () == nch)
993 {
994 NS_LOG_DEBUG ("No channel change requested");
995 return;
996 }
997
998 // if the channel number does not uniquely identify an operating channel,
999 // the simulation aborts
1000 SetOperatingChannel (nch, 0, 0);
1001}
1002
1003uint8_t
1005{
1006 return m_operatingChannel.GetNumber ();
1007}
1008
1009void
1010WifiPhy::SetChannelWidth (uint16_t channelWidth)
1011{
1012 NS_LOG_FUNCTION (this << channelWidth);
1013
1014 if (channelWidth != 0)
1015 {
1016 AddSupportedChannelWidth (channelWidth);
1017 }
1018
1019 if (!m_operatingChannel.IsSet ())
1020 {
1021 // ConfigureStandardAndBand has not been called yet, so store the channel width
1022 // into m_initialChannelWidth
1023 NS_LOG_DEBUG ("Saving channel width configuration for initialization");
1024 m_initialChannelWidth = channelWidth;
1025 return;
1026 }
1027
1028 if (GetChannelWidth () == channelWidth)
1029 {
1030 NS_LOG_DEBUG ("No channel width change requested");
1031 return;
1032 }
1033
1034 NS_ABORT_MSG ("The channel width does not uniquely identify an operating channel.");
1035}
1036
1037uint16_t
1039{
1040 return m_operatingChannel.GetWidth ();
1041}
1042
1043void
1045{
1046 NS_LOG_FUNCTION (this << +index);
1047
1048 if (!m_operatingChannel.IsSet ())
1049 {
1050 // ConfigureStandardAndBand has not been called yet, so store the primary20
1051 // index into m_initialPrimary20Index
1052 NS_LOG_DEBUG ("Saving primary20 index configuration for initialization");
1054 return;
1055 }
1056
1058}
1059
1060uint8_t
1062{
1064}
1065
1066void
1067WifiPhy::SetOperatingChannel (uint8_t number, uint16_t frequency, uint16_t width)
1068{
1069 Time delay = Seconds (0);
1070
1071 if (IsInitialized ())
1072 {
1073 delay = GetDelayUntilChannelSwitch ();
1074 }
1075
1076 if (delay.IsStrictlyNegative ())
1077 {
1078 // switching channel is not possible now
1079 return;
1080 }
1081 if (delay.IsStrictlyPositive ())
1082 {
1083 // switching channel has been postponed
1084 void (WifiPhy::*fp) (uint8_t, uint16_t, uint16_t) = &WifiPhy::SetOperatingChannel;
1085 Simulator::Schedule (delay, fp, this, number, frequency, width);
1086 return;
1087 }
1088
1089 // channel can be switched now.
1090 uint16_t prevChannelWidth = 0;
1092 {
1093 prevChannelWidth = GetChannelWidth ();
1094 }
1095
1096 m_operatingChannel.Set (number, frequency, width, m_standard, m_band);
1097
1098 if (GetChannelWidth () != prevChannelWidth)
1099 {
1101
1102 // If channel width changed after initialization, invoke the capabilities changed callback
1104 {
1106 }
1107 }
1108}
1109
1110void
1112{
1113 // the generic operator<< for tuples does not give a pretty result
1114 NS_LOG_FUNCTION (this << +std::get<0> (channelTuple) << std::get<1> (channelTuple)
1115 << static_cast<WifiPhyBand> (std::get<2> (channelTuple))
1116 << +std::get<3> (channelTuple));
1117
1118 m_channelSettings = channelTuple;
1119
1121 {
1122 NS_LOG_DEBUG ("Channel information will be applied when a standard is configured");
1123 return;
1124 }
1125
1126 Time delay = Seconds (0);
1127
1128 if (IsInitialized ())
1129 {
1130 delay = GetDelayUntilChannelSwitch ();
1131 }
1132
1133 if (delay.IsStrictlyNegative ())
1134 {
1135 // switching channel is not possible now
1136 return;
1137 }
1138 if (delay.IsStrictlyPositive ())
1139 {
1140 // switching channel has been postponed
1141 void (WifiPhy::*fp) (const ChannelTuple&) = &WifiPhy::SetOperatingChannel;
1142 Simulator::Schedule (delay, fp, this, channelTuple);
1143 return;
1144 }
1145
1146 // channel can be switched now.
1147 DoChannelSwitch ();
1148}
1149
1150Time
1152{
1153 m_powerRestricted = false;
1155 m_currentEvent = 0;
1156 m_currentPreambleEvents.clear ();
1157 if (!IsInitialized ())
1158 {
1159 //this is not channel switch, this is initialization
1160 NS_LOG_DEBUG ("Before initialization, nothing to do");
1161 return Seconds (0);
1162 }
1163
1164 Time delay = Seconds (0);
1165
1167 switch (m_state->GetState ())
1168 {
1169 case WifiPhyState::RX:
1170 NS_LOG_DEBUG ("drop packet because of channel switching while reception");
1172 for (auto & phyEntity : m_phyEntities)
1173 {
1174 phyEntity.second->CancelAllEvents ();
1175 }
1176 break;
1177 case WifiPhyState::TX:
1178 NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
1179 delay = GetDelayUntilIdle ();
1180 break;
1182 case WifiPhyState::IDLE:
1184 for (auto & phyEntity : m_phyEntities)
1185 {
1186 phyEntity.second->CancelAllEvents ();
1187 }
1188 break;
1190 NS_LOG_DEBUG ("channel switching ignored in sleep mode");
1191 delay = Seconds (-1); // negative value to indicate switching not possible
1192 break;
1193 default:
1194 NS_ASSERT (false);
1195 break;
1196 }
1197
1198 return delay;
1199}
1200
1201void
1203{
1204 NS_LOG_FUNCTION (this);
1205
1206 // Update unspecified parameters with default values
1207 if (auto& [number, width, band, primary20] = m_channelSettings; true)
1208 {
1209 if (band == static_cast<int> (WIFI_PHY_BAND_UNSPECIFIED))
1210 {
1211 band = static_cast<int> (GetDefaultPhyBand (m_standard));
1212 }
1213 if (width == 0 && number == 0)
1214 {
1216 }
1217 if (number == 0)
1218 {
1220 }
1221 }
1222
1223 // We need to call SetStandard if this is the first time we set a channel or we
1224 // are changing PHY band. Checking if the new PHY band is different than the
1225 // previous one covers both cases because initially the PHY band is unspecified
1226 bool changingPhyBand = (static_cast<WifiPhyBand> (std::get<2> (m_channelSettings)) != m_band);
1227
1228 m_band = static_cast<WifiPhyBand> (std::get<2> (m_channelSettings));
1229
1230 NS_LOG_DEBUG ("switching channel");
1231 m_operatingChannel.Set (std::get<0> (m_channelSettings), 0, std::get<1> (m_channelSettings),
1234
1235 if (changingPhyBand)
1236 {
1238 }
1239
1241
1242 if (IsInitialized ())
1243 {
1244 // notify channel switching
1245 m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ());
1247 /*
1248 * Needed here to be able to correctly sensed the medium for the first
1249 * time after the switching. The actual switching is not performed until
1250 * after m_channelSwitchDelay. Packets received during the switching
1251 * state are added to the event list and are employed later to figure
1252 * out the state of the medium after the switching.
1253 */
1254 }
1255}
1256
1257void
1259{
1260 NS_ASSERT_MSG (antennas > 0 && antennas <= 4, "unsupported number of antennas");
1261 m_numberOfAntennas = antennas;
1263}
1264
1265uint8_t
1267{
1268 return m_numberOfAntennas;
1269}
1270
1271void
1273{
1274 NS_ASSERT (streams <= GetNumberOfAntennas ());
1275 bool changed = (m_txSpatialStreams != streams);
1276 m_txSpatialStreams = streams;
1277 if (changed)
1278 {
1279 auto phyEntity = m_phyEntities.find (WIFI_MOD_CLASS_HT);
1280 if (phyEntity != m_phyEntities.end ())
1281 {
1282 Ptr<HtPhy> htPhy = DynamicCast<HtPhy> (phyEntity->second);
1283 if (htPhy)
1284 {
1285 htPhy->SetMaxSupportedNss (m_txSpatialStreams); //this is essential to have the right MCSs configured
1286 }
1287
1289 {
1291 }
1292 }
1293 }
1294}
1295
1296uint8_t
1298{
1299 return m_txSpatialStreams;
1300}
1301
1302void
1304{
1305 NS_ASSERT (streams <= GetNumberOfAntennas ());
1306 bool changed = (m_rxSpatialStreams != streams);
1307 m_rxSpatialStreams = streams;
1308 if (changed && !m_capabilitiesChangedCallback.IsNull ())
1309 {
1311 }
1312}
1313
1314uint8_t
1316{
1317 return m_rxSpatialStreams;
1318}
1319
1320std::list<uint8_t>
1322{
1323 std::list<uint8_t> list;
1324 for (const auto & phyEntity : m_phyEntities)
1325 {
1326 Ptr<HtPhy> htPhy = DynamicCast<HtPhy> (phyEntity.second);
1327 if (htPhy)
1328 {
1329 list.emplace_back (htPhy->GetBssMembershipSelector ());
1330 }
1331 }
1332 return list;
1333}
1334
1335void
1337{
1338 NS_LOG_FUNCTION (this << width);
1339 for (std::vector<uint32_t>::size_type i = 0; i != m_supportedChannelWidthSet.size (); i++)
1340 {
1341 if (m_supportedChannelWidthSet[i] == width)
1342 {
1343 return;
1344 }
1345 }
1346 NS_LOG_FUNCTION ("Adding " << width << " to supported channel width set");
1347 m_supportedChannelWidthSet.push_back (width);
1348}
1349
1350std::vector<uint16_t>
1352{
1354}
1355
1356void
1358{
1359 NS_LOG_FUNCTION (this);
1360 m_powerRestricted = false;
1362 switch (m_state->GetState ())
1363 {
1364 case WifiPhyState::TX:
1365 NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmission");
1367 break;
1368 case WifiPhyState::RX:
1369 NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception");
1371 break;
1373 NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching");
1375 break;
1377 case WifiPhyState::IDLE:
1378 NS_LOG_DEBUG ("setting sleep mode");
1379 m_state->SwitchToSleep ();
1380 break;
1382 NS_LOG_DEBUG ("already in sleep mode");
1383 break;
1384 default:
1385 NS_ASSERT (false);
1386 break;
1387 }
1388}
1389
1390void
1392{
1393 NS_LOG_FUNCTION (this);
1394 m_powerRestricted = false;
1398 for (auto & phyEntity : m_phyEntities)
1399 {
1400 phyEntity.second->CancelAllEvents ();
1401 }
1402 m_state->SwitchToOff ();
1403}
1404
1405void
1407{
1408 NS_LOG_FUNCTION (this);
1409 m_currentPreambleEvents.clear ();
1410 switch (m_state->GetState ())
1411 {
1412 case WifiPhyState::TX:
1413 case WifiPhyState::RX:
1414 case WifiPhyState::IDLE:
1417 {
1418 NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume");
1419 break;
1420 }
1422 {
1423 NS_LOG_DEBUG ("resuming from sleep mode");
1425 m_state->SwitchFromSleep (delayUntilCcaEnd);
1426 break;
1427 }
1428 default:
1429 {
1430 NS_ASSERT (false);
1431 break;
1432 }
1433 }
1434}
1435
1436void
1438{
1439 NS_LOG_FUNCTION (this);
1440 switch (m_state->GetState ())
1441 {
1442 case WifiPhyState::TX:
1443 case WifiPhyState::RX:
1444 case WifiPhyState::IDLE:
1448 {
1449 NS_LOG_DEBUG ("not in off mode, there is nothing to resume");
1450 break;
1451 }
1452 case WifiPhyState::OFF:
1453 {
1454 NS_LOG_DEBUG ("resuming from off mode");
1456 m_state->SwitchFromOff (delayUntilCcaEnd);
1457 break;
1458 }
1459 default:
1460 {
1461 NS_ASSERT (false);
1462 break;
1463 }
1464 }
1465}
1466
1467Time
1469{
1470 return MicroSeconds (4);
1471}
1472
1473Time
1475{
1476 return MicroSeconds (4);
1477}
1478
1479Time
1480WifiPhy::GetPayloadDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, MpduType mpdutype, uint16_t staId)
1481{
1482 uint32_t totalAmpduSize;
1483 double totalAmpduNumSymbols;
1484 return GetPayloadDuration (size, txVector, band, mpdutype, false, totalAmpduSize, totalAmpduNumSymbols, staId);
1485}
1486
1487Time
1489 bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols,
1490 uint16_t staId)
1491{
1492 return GetStaticPhyEntity (txVector.GetModulationClass ())->GetPayloadDuration (size, txVector, band, mpdutype,
1493 incFlag, totalAmpduSize, totalAmpduNumSymbols,
1494 staId);
1495}
1496
1497Time
1499{
1500 return GetStaticPhyEntity (txVector.GetModulationClass ())->CalculatePhyPreambleAndHeaderDuration (txVector);
1501}
1502
1503Time
1504WifiPhy::CalculateTxDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, uint16_t staId)
1505{
1506 Time duration = CalculatePhyPreambleAndHeaderDuration (txVector)
1507 + GetPayloadDuration (size, txVector, band, NORMAL_MPDU, staId);
1508 NS_ASSERT (duration.IsStrictlyPositive ());
1509 return duration;
1510}
1511
1512Time
1514{
1515 return CalculateTxDuration (GetWifiConstPsduMap (psdu, txVector), txVector, band);
1516}
1517
1518Time
1520{
1521 return GetStaticPhyEntity (txVector.GetModulationClass ())->CalculateTxDuration (psduMap, txVector, band);
1522}
1523
1526{
1527 return GetStaticPhyEntity (modulation)->GetMaxPsduSize ();
1528}
1529
1530void
1532{
1533 if (!m_phyTxBeginTrace.IsEmpty ())
1534 {
1535 for (auto const& psdu : psdus)
1536 {
1537 for (auto& mpdu : *PeekPointer (psdu.second))
1538 {
1539 m_phyTxBeginTrace (mpdu->GetProtocolDataUnit (), txPowerW);
1540 }
1541 }
1542 }
1543}
1544
1545void
1547{
1548 if (!m_phyTxEndTrace.IsEmpty ())
1549 {
1550 for (auto const& psdu : psdus)
1551 {
1552 for (auto& mpdu : *PeekPointer (psdu.second))
1553 {
1554 m_phyTxEndTrace (mpdu->GetProtocolDataUnit ());
1555 }
1556 }
1557 }
1558}
1559
1560void
1562{
1563 if (!m_phyTxDropTrace.IsEmpty ())
1564 {
1565 for (auto& mpdu : *PeekPointer (psdu))
1566 {
1567 m_phyTxDropTrace (mpdu->GetProtocolDataUnit ());
1568 }
1569 }
1570}
1571
1572void
1574{
1575 if (psdu && !m_phyRxBeginTrace.IsEmpty ())
1576 {
1577 for (auto& mpdu : *PeekPointer (psdu))
1578 {
1579 m_phyRxBeginTrace (mpdu->GetProtocolDataUnit (), rxPowersW);
1580 }
1581 }
1582}
1583
1584void
1586{
1587 if (psdu && !m_phyRxEndTrace.IsEmpty ())
1588 {
1589 for (auto& mpdu : *PeekPointer (psdu))
1590 {
1591 m_phyRxEndTrace (mpdu->GetProtocolDataUnit ());
1592 }
1593 }
1594}
1595
1596void
1598{
1599 if (psdu && !m_phyRxDropTrace.IsEmpty ())
1600 {
1601 for (auto& mpdu : *PeekPointer (psdu))
1602 {
1603 m_phyRxDropTrace (mpdu->GetProtocolDataUnit (), reason);
1604 }
1605 }
1606}
1607
1608void
1609WifiPhy::NotifyMonitorSniffRx (Ptr<const WifiPsdu> psdu, uint16_t channelFreqMhz, WifiTxVector txVector,
1610 SignalNoiseDbm signalNoise, std::vector<bool> statusPerMpdu, uint16_t staId)
1611{
1612 MpduInfo aMpdu;
1613 if (psdu->IsAggregate ())
1614 {
1615 //Expand A-MPDU
1616 NS_ASSERT_MSG (txVector.IsAggregation (), "TxVector with aggregate flag expected here according to PSDU");
1618 size_t nMpdus = psdu->GetNMpdus ();
1619 NS_ASSERT_MSG (statusPerMpdu.size () == nMpdus, "Should have one reception status per MPDU");
1620 if (!m_phyMonitorSniffRxTrace.IsEmpty ())
1621 {
1622 aMpdu.type = (psdu->IsSingle ()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1623 for (size_t i = 0; i < nMpdus;)
1624 {
1625 if (statusPerMpdu.at (i)) //packet received without error, hand over to sniffer
1626 {
1627 m_phyMonitorSniffRxTrace (psdu->GetAmpduSubframe (i), channelFreqMhz, txVector, aMpdu, signalNoise, staId);
1628 }
1629 ++i;
1630 aMpdu.type = (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1631 }
1632 }
1633 }
1634 else
1635 {
1636 NS_ASSERT_MSG (statusPerMpdu.size () == 1, "Should have one reception status for normal MPDU");
1637 if (!m_phyMonitorSniffRxTrace.IsEmpty ())
1638 {
1639 aMpdu.type = NORMAL_MPDU;
1640 m_phyMonitorSniffRxTrace (psdu->GetPacket (), channelFreqMhz, txVector, aMpdu, signalNoise, staId);
1641 }
1642 }
1643}
1644
1645void
1646WifiPhy::NotifyMonitorSniffTx (Ptr<const WifiPsdu> psdu, uint16_t channelFreqMhz, WifiTxVector txVector, uint16_t staId)
1647{
1648 MpduInfo aMpdu;
1649 if (psdu->IsAggregate ())
1650 {
1651 //Expand A-MPDU
1652 NS_ASSERT_MSG (txVector.IsAggregation (), "TxVector with aggregate flag expected here according to PSDU");
1654 if (!m_phyMonitorSniffTxTrace.IsEmpty ())
1655 {
1656 size_t nMpdus = psdu->GetNMpdus ();
1657 aMpdu.type = (psdu->IsSingle ()) ? SINGLE_MPDU: FIRST_MPDU_IN_AGGREGATE;
1658 for (size_t i = 0; i < nMpdus;)
1659 {
1660 m_phyMonitorSniffTxTrace (psdu->GetAmpduSubframe (i), channelFreqMhz, txVector, aMpdu, staId);
1661 ++i;
1662 aMpdu.type = (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1663 }
1664 }
1665 }
1666 else
1667 {
1668 if (!m_phyMonitorSniffTxTrace.IsEmpty ())
1669 {
1670 aMpdu.type = NORMAL_MPDU;
1671 m_phyMonitorSniffTxTrace (psdu->GetPacket (), channelFreqMhz, txVector, aMpdu, staId);
1672 }
1673 }
1674}
1675
1678{
1679 return GetStaticPhyEntity (txVector.GetModulationClass ())->GetWifiConstPsduMap (psdu, txVector);
1680}
1681
1682void
1684{
1685 NS_LOG_FUNCTION (this << *psdu << txVector);
1686 Send (GetWifiConstPsduMap (psdu, txVector), txVector);
1687}
1688
1689void
1691{
1692 NS_LOG_FUNCTION (this << psdus << txVector);
1693 /* Transmission can happen if:
1694 * - we are syncing on a packet. It is the responsibility of the
1695 * MAC layer to avoid doing this but the PHY does nothing to
1696 * prevent it.
1697 * - we are idle
1698 */
1699 NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
1701
1702 if (txVector.GetNssMax () > GetMaxSupportedTxSpatialStreams ())
1703 {
1704 NS_FATAL_ERROR ("Unsupported number of spatial streams!");
1705 }
1706
1707 if (m_state->IsStateSleep ())
1708 {
1709 NS_LOG_DEBUG ("Dropping packet because in sleep mode");
1710 for (auto const& psdu : psdus)
1711 {
1712 NotifyTxDrop (psdu.second);
1713 }
1714 return;
1715 }
1716
1717 // Set RU PHY indices
1718 if (txVector.IsMu ())
1719 {
1720 for (auto& heMuUserInfo : txVector.GetHeMuUserInfoMap ())
1721 {
1722 heMuUserInfo.second.ru.SetPhyIndex (txVector.GetChannelWidth (),
1724 }
1725 }
1726
1727 Time txDuration = CalculateTxDuration (psdus, txVector, GetPhyBand ());
1728
1729 bool noEndPreambleDetectionEvent = true;
1730 for (const auto & it : m_phyEntities)
1731 {
1732 noEndPreambleDetectionEvent &= it.second->NoEndPreambleDetectionEvents ();
1733 }
1734 if (!noEndPreambleDetectionEvent || ((m_currentEvent != 0) && (m_currentEvent->GetEndTime () > (Simulator::Now () + m_state->GetDelayUntilIdle ()))))
1735 {
1737 //that packet will be noise _after_ the transmission.
1739 }
1740
1741 for (auto & it : m_phyEntities)
1742 {
1743 it.second->CancelRunningEndPreambleDetectionEvents ();
1744 }
1745 m_currentPreambleEvents.clear ();
1747
1749 {
1750 NS_LOG_DEBUG ("Transmitting with power restriction for " << txDuration.As (Time::NS));
1751 }
1752 else
1753 {
1754 NS_LOG_DEBUG ("Transmitting without power restriction for " << txDuration.As (Time::NS));
1755 }
1756
1757 if (m_state->GetState () == WifiPhyState::OFF)
1758 {
1759 NS_LOG_DEBUG ("Transmission canceled because device is OFF");
1760 return;
1761 }
1762
1763 Ptr<WifiPpdu> ppdu = GetPhyEntity (txVector.GetModulationClass ())->BuildPpdu (psdus, txVector, txDuration);
1764 m_previouslyRxPpduUid = UINT64_MAX; //reset (after creation of PPDU) to use it only once
1765
1766 double txPowerW = DbmToW (GetTxPowerForTransmission (ppdu) + GetTxGain ());
1767 NotifyTxBegin (psdus, txPowerW);
1768 if (!m_phyTxPsduBeginTrace.IsEmpty ())
1769 {
1770 m_phyTxPsduBeginTrace (psdus, txVector, txPowerW);
1771 }
1772 for (auto const& psdu : psdus)
1773 {
1774 NotifyMonitorSniffTx (psdu.second, GetFrequency (), txVector, psdu.first);
1775 }
1776 m_state->SwitchToTx (txDuration, psdus, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector);
1777
1778 if (m_wifiRadioEnergyModel != 0 && m_wifiRadioEnergyModel->GetMaximumTimeInState (WifiPhyState::TX) < txDuration)
1779 {
1780 ppdu->SetTruncatedTx ();
1781 }
1782
1783 m_endTxEvent = Simulator::Schedule (txDuration, &WifiPhy::NotifyTxEnd, this, psdus); //TODO: fix for MU
1784
1785 StartTx (ppdu);
1786
1788 m_powerRestricted = false;
1789
1790 Simulator::Schedule (txDuration, &WifiPhy::Reset, this);
1791}
1792
1793uint64_t
1795{
1796 return m_previouslyRxPpduUid;
1797}
1798
1799void
1801{
1802 NS_LOG_FUNCTION (this);
1803 m_currentPreambleEvents.clear ();
1804 m_currentEvent = 0;
1805 for (auto & phyEntity : m_phyEntities)
1806 {
1807 phyEntity.second->CancelAllEvents ();
1808 }
1809}
1810
1811void
1813{
1814 WifiModulationClass modulation = ppdu->GetTxVector ().GetModulationClass ();
1815 auto it = m_phyEntities.find (modulation);
1816 if (it != m_phyEntities.end ())
1817 {
1818 it->second->StartReceivePreamble (ppdu, rxPowersW, rxDuration);
1819 }
1820 else
1821 {
1822 //TODO find a fallback PHY for receiving the PPDU (e.g. 11a for 11ax due to preamble structure)
1823 NS_LOG_DEBUG ("Unsupported modulation received (" << modulation << "), consider as noise");
1824 if (ppdu->GetTxDuration () > m_state->GetDelayUntilIdle ())
1825 {
1826 m_interference.Add (ppdu, ppdu->GetTxVector (), rxDuration, rxPowersW);
1828 }
1829 }
1830}
1831
1833WifiPhy::ConvertHeRuSubcarriers (uint16_t bandWidth, uint16_t guardBandwidth,
1834 HeRu::SubcarrierRange range, uint8_t bandIndex) const
1835{
1836 NS_ASSERT_MSG (false, "802.11ax can only be used with SpectrumWifiPhy");
1837 WifiSpectrumBand convertedSubcarriers;
1838 return convertedSubcarriers;
1839}
1840
1841void
1843{
1844 NS_LOG_FUNCTION (this);
1846 {
1847 m_powerRestricted = false;
1848 }
1849}
1850
1851void
1853{
1854 NS_LOG_FUNCTION (this << *event);
1855 NS_ASSERT (!IsStateRx ());
1857 m_currentEvent = 0;
1858 m_currentPreambleEvents.clear ();
1860}
1861
1862void
1864{
1865 NS_LOG_FUNCTION (this);
1867}
1868
1869bool
1871{
1872 for (const auto & phyEntity : m_phyEntities)
1873 {
1874 if (phyEntity.second->IsModeSupported (mode))
1875 {
1876 return true;
1877 }
1878 }
1879 return false;
1880}
1881
1884{
1885 //Start from oldest standards and move up (guaranteed by fact that WifModulationClass is ordered)
1886 for (const auto & phyEntity : m_phyEntities)
1887 {
1888 for (const auto & mode : *(phyEntity.second))
1889 {
1890 return mode;
1891 }
1892 }
1893 NS_ASSERT_MSG (false, "Should have found at least one default mode");
1894 return WifiMode ();
1895}
1896
1897bool
1898WifiPhy::IsMcsSupported (WifiModulationClass modulation, uint8_t mcs) const
1899{
1900 const auto phyEntity = m_phyEntities.find (modulation);
1901 if (phyEntity == m_phyEntities.end ())
1902 {
1903 return false;
1904 }
1905 return phyEntity->second->IsMcsSupported (mcs);
1906}
1907
1908std::list<WifiMode>
1910{
1911 std::list<WifiMode> list;
1912 for (const auto & phyEntity : m_phyEntities)
1913 {
1914 if (!phyEntity.second->HandlesMcsModes ()) //to exclude MCSs from search
1915 {
1916 for (const auto & mode : *(phyEntity.second))
1917 {
1918 list.emplace_back (mode);
1919 }
1920 }
1921 }
1922 return list;
1923}
1924
1925std::list<WifiMode>
1927{
1928 std::list<WifiMode> list;
1929 const auto phyEntity = m_phyEntities.find (modulation);
1930 if (phyEntity != m_phyEntities.end ())
1931 {
1932 if (!phyEntity->second->HandlesMcsModes ()) //to exclude MCSs from search
1933 {
1934 for (const auto & mode : *(phyEntity->second))
1935 {
1936 list.emplace_back (mode);
1937 }
1938 }
1939 }
1940 return list;
1941}
1942
1943uint16_t
1945{
1946 uint16_t numMcs = 0;
1947 for (const auto & phyEntity : m_phyEntities)
1948 {
1949 if (phyEntity.second->HandlesMcsModes ()) //to exclude non-MCS modes from search
1950 {
1951 numMcs += phyEntity.second->GetNumModes ();
1952 }
1953 }
1954 return numMcs;
1955}
1956
1957std::list<WifiMode>
1959{
1960 std::list<WifiMode> list;
1961 for (const auto & phyEntity : m_phyEntities)
1962 {
1963 if (phyEntity.second->HandlesMcsModes ()) //to exclude non-MCS modes from search
1964 {
1965 for (const auto & mode : *(phyEntity.second))
1966 {
1967 list.emplace_back (mode);
1968 }
1969 }
1970 }
1971 return list;
1972}
1973
1974std::list<WifiMode>
1976{
1977 std::list<WifiMode> list;
1978 auto phyEntity = m_phyEntities.find (modulation);
1979 if (phyEntity != m_phyEntities.end ())
1980 {
1981 if (phyEntity->second->HandlesMcsModes ()) //to exclude non-MCS modes from search
1982 {
1983 for (const auto & mode : *(phyEntity->second))
1984 {
1985 list.emplace_back (mode);
1986 }
1987 }
1988 }
1989 return list;
1990}
1991
1993WifiPhy::GetMcs (WifiModulationClass modulation, uint8_t mcs) const
1994{
1995 NS_ASSERT_MSG (IsMcsSupported (modulation, mcs), "Unsupported MCS");
1996 return m_phyEntities.at (modulation)->GetMcs (mcs);
1997}
1998
1999bool
2001{
2002 return m_state->IsStateCcaBusy ();
2003}
2004
2005bool
2007{
2008 return m_state->IsStateIdle ();
2009}
2010
2011bool
2013{
2014 return m_state->IsStateRx ();
2015}
2016
2017bool
2019{
2020 return m_state->IsStateTx ();
2021}
2022
2023bool
2025{
2026 return m_state->IsStateSwitching ();
2027}
2028
2029bool
2031{
2032 return m_state->IsStateSleep ();
2033}
2034
2035bool
2037{
2038 return m_state->IsStateOff ();
2039}
2040
2041Time
2043{
2044 return m_state->GetDelayUntilIdle ();
2045}
2046
2047Time
2049{
2050 return m_state->GetLastRxStartTime ();
2051}
2052
2053Time
2055{
2056 return m_state->GetLastRxEndTime ();
2057}
2058
2059void
2060WifiPhy::SwitchMaybeToCcaBusy (uint16_t channelWidth)
2061{
2062 NS_LOG_FUNCTION (this << channelWidth);
2063 //We are here because we have received the first bit of a packet and we are
2064 //not going to be able to synchronize on it
2065 //In this model, CCA becomes busy when the aggregation of all signals as
2066 //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
2067 Time delayUntilCcaEnd = m_interference.GetEnergyDuration (m_ccaEdThresholdW, GetPrimaryBand (channelWidth));
2068 if (!delayUntilCcaEnd.IsZero ())
2069 {
2070 NS_LOG_DEBUG ("Calling SwitchMaybeToCcaBusy for " << delayUntilCcaEnd.As (Time::S));
2071 m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
2072 }
2073}
2074
2075void
2077{
2078 NS_LOG_FUNCTION (this << reason);
2079 if (reason != OBSS_PD_CCA_RESET || m_currentEvent) //Otherwise abort has already been called previously
2080 {
2081 for (auto & phyEntity : m_phyEntities)
2082 {
2083 phyEntity.second->CancelAllEvents ();
2084 }
2086 {
2088 }
2090 if (!m_currentEvent)
2091 {
2092 return;
2093 }
2094 NotifyRxDrop (GetAddressedPsduInPpdu (m_currentEvent->GetPpdu ()), reason);
2095 if (reason == OBSS_PD_CCA_RESET)
2096 {
2097 m_state->SwitchFromRxAbort ();
2098 }
2099 for (auto it = m_currentPreambleEvents.begin (); it != m_currentPreambleEvents.end (); ++it)
2100 {
2101 if (it->second == m_currentEvent)
2102 {
2103 it = m_currentPreambleEvents.erase (it);
2104 break;
2105 }
2106 }
2107 m_currentEvent = 0;
2108 }
2109}
2110
2111void
2112WifiPhy::ResetCca (bool powerRestricted, double txPowerMaxSiso, double txPowerMaxMimo)
2113{
2114 NS_LOG_FUNCTION (this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
2115 // This method might be called multiple times when receiving TB PPDUs with a BSS color
2116 // different than the one of the receiver. The first time this method is called, the call
2117 // to AbortCurrentReception sets m_currentEvent to 0. Therefore, we need to check whether
2118 // m_currentEvent is not 0 before executing the instructions below.
2119 if (m_currentEvent != 0)
2120 {
2121 m_powerRestricted = powerRestricted;
2122 m_txPowerMaxSiso = txPowerMaxSiso;
2123 m_txPowerMaxMimo = txPowerMaxMimo;
2124 NS_ASSERT ((m_currentEvent->GetEndTime () - Simulator::Now ()).IsPositive ());
2126 Simulator::ScheduleNow (&WifiPhy::AbortCurrentReception, this, OBSS_PD_CCA_RESET); //finish processing field first
2127 }
2128}
2129
2130double
2132{
2133 NS_LOG_FUNCTION (this << m_powerRestricted << ppdu);
2134 const WifiTxVector& txVector = ppdu->GetTxVector ();
2135 // Get transmit power before antenna gain
2136 double txPowerDbm;
2137 if (!m_powerRestricted)
2138 {
2139 txPowerDbm = GetPowerDbm (txVector.GetTxPowerLevel ());
2140 }
2141 else
2142 {
2143 if (txVector.GetNssMax () > 1)
2144 {
2145 txPowerDbm = std::min (m_txPowerMaxMimo, GetPowerDbm (txVector.GetTxPowerLevel ()));
2146 }
2147 else
2148 {
2149 txPowerDbm = std::min (m_txPowerMaxSiso, GetPowerDbm (txVector.GetTxPowerLevel ()));
2150 }
2151 }
2152
2153 //Apply power density constraint on EIRP
2154 uint16_t channelWidth = ppdu->GetTransmissionChannelWidth ();
2155 double txPowerDbmPerMhz = (txPowerDbm + GetTxGain ()) - RatioToDb (channelWidth); //account for antenna gain since EIRP
2156 NS_LOG_INFO ("txPowerDbm=" << txPowerDbm << " with txPowerDbmPerMhz=" << txPowerDbmPerMhz << " over " << channelWidth << " MHz");
2157 txPowerDbm = std::min (txPowerDbmPerMhz, m_powerDensityLimit) + RatioToDb (channelWidth);
2158 txPowerDbm -= GetTxGain (); //remove antenna gain since will be added right afterwards
2159 NS_LOG_INFO ("txPowerDbm=" << txPowerDbm << " after applying m_powerDensityLimit=" << m_powerDensityLimit);
2160 return txPowerDbm;
2161}
2162
2165{
2166 //TODO: wrapper. See if still needed
2167 return GetPhyEntity (ppdu->GetModulation ())->GetAddressedPsduInPpdu (ppdu);
2168}
2169
2170uint16_t
2172{
2173 if (ppdu == nullptr)
2174 {
2175 // Here because PHY was not receiving anything (e.g. resuming from OFF) nor expecting anything (e.g. sleep)
2176 // nor processing a Wi-Fi signal.
2177 return GetChannelWidth () >= 40 ? 20 : GetChannelWidth ();
2178 }
2179 return GetPhyEntity (ppdu->GetModulation ())->GetMeasurementChannelWidth (ppdu);
2180}
2181
2183WifiPhy::GetBand (uint16_t /*bandWidth*/, uint8_t /*bandIndex*/)
2184{
2185 WifiSpectrumBand band;
2186 band.first = 0;
2187 band.second = 0;
2188 return band;
2189}
2190
2192WifiPhy::GetPrimaryBand (uint16_t bandWidth)
2193{
2194 if (GetChannelWidth () % 20 != 0)
2195 {
2196 return GetBand (bandWidth);
2197 }
2198
2199 return GetBand (bandWidth, m_operatingChannel.GetPrimaryChannelIndex (bandWidth));
2200}
2201
2202int64_t
2204{
2205 NS_LOG_FUNCTION (this << stream);
2206 int64_t currentStream = stream;
2207 m_random->SetStream (currentStream++);
2208 currentStream += m_interference.GetErrorRateModel ()->AssignStreams (currentStream);
2209 return (currentStream - stream);
2210}
2211
2212std::ostream& operator<< (std::ostream& os, RxSignalInfo rxSignalInfo)
2213{
2214 os << "SNR:" << RatioToDb (rxSignalInfo.snr) << " dB"
2215 << ", RSSI:" << rxSignalInfo.rssi << " dBm";
2216 return os;
2217}
2218
2219} //namespace ns3
#define min(a, b)
Definition: 80211b.c:42
AttributeValue implementation for Boolean.
Definition: boolean.h:37
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1386
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:71
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:65
std::pair< int16_t, int16_t > SubcarrierRange
(lowest index, highest index) pair defining a subcarrier range
Definition: he-ru.h:53
void SetNoiseFigure(double value)
Set the noise figure.
void EraseEvents(void)
Erase all events.
void NotifyRxEnd(Time endTime)
Notify that RX has ended.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
Time GetEnergyDuration(double energyW, WifiSpectrumBand band)
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model.
Ptr< Event > Add(Ptr< const WifiPpdu > ppdu, const WifiTxVector &txVector, Time duration, RxPowerWattPerChannelBand &rxPower, bool isStartOfdmaRxing=false)
Add the PPDU-related signal to interference helper.
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
Keep track of the current position and velocity of an object.
A base class which provides memory management and object aggregation.
Definition: object.h:88
bool IsInitialized(void) const
Check if the object has been initialized.
Definition: object.cc:208
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Definition: simulator.h:587
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
Hold variables of type string.
Definition: string.h:41
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
Definition: nstime.h:332
@ S
second
Definition: nstime.h:114
@ NS
nanosecond
Definition: nstime.h:117
bool IsStrictlyNegative(void) const
Exactly equivalent to t < 0.
Definition: nstime.h:324
bool IsZero(void) const
Exactly equivalent to t == 0.
Definition: nstime.h:300
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:432
AttributeValue implementation for Time.
Definition: nstime.h:1308
bool IsEmpty() const
Checks if the Callbacks list is empty.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
represent a single transmission mode
Definition: wifi-mode.h:48
Ptr< Node > GetNode(void) const override
802.11 PHY layer model
Definition: wifi-phy.h:49
void SetNumberOfAntennas(uint8_t antennas)
Definition: wifi-phy.cc:1258
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Definition: wifi-phy.h:1214
double m_rxGainDb
Reception gain (dB)
Definition: wifi-phy.h:1440
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
Definition: wifi-phy.h:1459
bool IsStateIdle(void) const
Definition: wifi-phy.cc:2006
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
Definition: wifi-phy.h:1453
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:1683
bool IsStateTx(void) const
Definition: wifi-phy.cc:2018
void StartReceivePreamble(Ptr< WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Definition: wifi-phy.cc:1812
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Definition: wifi-phy.h:1213
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1004
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
Definition: wifi-phy.h:1463
virtual ~WifiPhy()
Definition: wifi-phy.cc:336
Time m_channelSwitchDelay
Time required to switch between channel.
Definition: wifi-phy.h:1456
std::list< WifiMode > GetMcsList(void) const
The WifiPhy::GetMcsList() method is used (e.g., by a WifiRemoteStationManager) to determine the set o...
Definition: wifi-phy.cc:1958
void SetCcaEdThreshold(double threshold)
Sets the CCA threshold (dBm).
Definition: wifi-phy.cc:431
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:1382
WifiPhyOperatingChannel m_operatingChannel
Operating channel.
Definition: wifi-phy.h:1428
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:1343
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:1351
bool m_channelAccessRequested
Flag if channels access has been requested (used for OBSS_PD SR)
Definition: wifi-phy.h:1449
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:1480
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:1320
Ptr< MobilityModel > GetMobility(void) const
Return the mobility model this PHY is associated with.
Definition: wifi-phy.cc:548
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1303
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:942
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:2164
bool GetShortPhyPreambleSupported(void) const
Return whether short PHY preamble is supported.
Definition: wifi-phy.cc:524
void NotifyTxEnd(WifiConstPsduMap psdus)
Public method used to fire a PhyTxEnd trace.
Definition: wifi-phy.cc:1546
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:1223
Time m_slot
Slot duration.
Definition: wifi-phy.h:1432
double m_powerDensityLimit
the power density limit (dBm/MHz)
Definition: wifi-phy.h:1444
WifiMode GetDefaultMode(void) const
Get the default WifiMode supported by the PHY.
Definition: wifi-phy.cc:1883
std::vector< uint16_t > GetSupportedChannelWidthSet(void) const
Definition: wifi-phy.cc:1351
bool IsStateRx(void) const
Definition: wifi-phy.cc:2012
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS) for this PHY.
Definition: wifi-phy.cc:657
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:929
EventId m_endPhyRxEvent
the end of PHY receive event
Definition: wifi-phy.h:1219
double m_txPowerBaseDbm
Minimum transmission power (dBm)
Definition: wifi-phy.h:1441
virtual NS_DEPRECATED_3_35 void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:979
Ptr< WifiPhyStateHelper > GetState(void) const
Return the WifiPhyStateHelper of this PHY.
Definition: wifi-phy.cc:382
uint8_t m_initialChannelNumber
Store channel number until initialization.
Definition: wifi-phy.h:1424
Ptr< WifiNetDevice > GetDevice(void) const
Return the device this PHY is associated with.
Definition: wifi-phy.cc:536
void NotifyRxDrop(Ptr< const WifiPsdu > psdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:1597
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:1898
WifiStandard GetStandard(void) const
Get the configured Wi-Fi standard.
Definition: wifi-phy.cc:936
virtual void DoDispose(void)
Destructor implementation.
Definition: wifi-phy.cc:342
Time m_blockAckTxTime
estimated BlockAck TX time
Definition: wifi-phy.h:1435
void Configure80211a(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
Definition: wifi-phy.cc:705
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1321
void ResetCca(bool powerRestricted, double txPowerMaxSiso=0, double txPowerMaxMimo=0)
Reset PHY to IDLE, with some potential TX power restrictions for the next transmission.
Definition: wifi-phy.cc:2112
double m_txPowerMaxMimo
MIMO maximum transmit power due to OBSS PD SR power restriction (dBm)
Definition: wifi-phy.h:1448
Time GetSlot(void) const
Return the slot duration for this PHY.
Definition: wifi-phy.cc:675
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted.
Definition: wifi-phy.cc:2076
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
Definition: wifi-phy.h:1461
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition: wifi-phy.h:1375
void NotifyRxBegin(Ptr< const WifiPsdu > psdu, const RxPowerWattPerChannelBand &rxPowersW)
Public method used to fire a PhyRxBegin trace.
Definition: wifi-phy.cc:1573
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1272
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const
Return the channel width used to measure the RSSI.
Definition: wifi-phy.cc:2171
double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:472
Time m_sifs
Short Interframe Space (SIFS) duration.
Definition: wifi-phy.h:1431
void SetReceiveErrorCallback(RxErrorCallback callback)
Definition: wifi-phy.cc:394
void ResetReceive(Ptr< Event > event)
Reset PHY at the end of the packet under reception after it has failed the PHY header.
Definition: wifi-phy.cc:1852
InterferenceHelper m_interference
the class handling interference computations
Definition: wifi-phy.h:1212
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:877
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1315
void SetPostReceptionErrorModel(const Ptr< ErrorModel > em)
Attach a receive ErrorModel to the WifiPhy.
Definition: wifi-phy.cc:568
uint16_t m_initialFrequency
Store frequency until initialization (MHz)
Definition: wifi-phy.h:1423
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:1993
uint8_t m_numberOfAntennas
Number of transmitters.
Definition: wifi-phy.h:1452
ChannelTuple m_channelSettings
Store operating channel settings until initialization.
Definition: wifi-phy.h:1427
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition: wifi-phy.cc:1504
Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
Definition: wifi-phy.cc:2048
Time GetBlockAckTxTime(void) const
Return the estimated BlockAck TX time for this PHY.
Definition: wifi-phy.cc:699
void Configure80211p(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11p standard.
Definition: wifi-phy.cc:750
Time GetPifs(void) const
Return the PCF Interframe Space (PIFS) for this PHY.
Definition: wifi-phy.cc:687
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
Definition: wifi-phy.cc:1525
void NotifyTxBegin(WifiConstPsduMap psdus, double txPowerW)
Public method used to fire a PhyTxBegin trace.
Definition: wifi-phy.cc:1531
void Reset(void)
Reset data upon end of TX or RX.
Definition: wifi-phy.cc:1800
void SetShortPhyPreambleSupported(bool preamble)
Enable or disable short PHY preamble.
Definition: wifi-phy.cc:517
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:478
uint8_t m_initialPrimary20Index
Store the index of primary20 until initialization.
Definition: wifi-phy.h:1426
static TypeId GetTypeId(void)
Get the type ID.
Definition: wifi-phy.cc:56
WifiPhyBand m_band
WifiPhyBand.
Definition: wifi-phy.h:1422
void Configure80211b(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
Definition: wifi-phy.cc:720
void SetSleepMode(void)
Put in sleep mode.
Definition: wifi-phy.cc:1357
void SetRxSensitivity(double threshold)
Sets the receive sensitivity threshold (dBm).
Definition: wifi-phy.cc:418
uint8_t GetPrimary20Index(void) const
Definition: wifi-phy.cc:1061
static const Ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
Definition: wifi-phy.cc:623
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1297
void Configure80211g(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
Definition: wifi-phy.cc:737
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:1410
Time GetChannelSwitchDelay(void) const
Definition: wifi-phy.cc:611
virtual WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const
Definition: wifi-phy.cc:1833
double m_txPowerMaxSiso
SISO maximum transmit power due to OBSS PD SR power restriction (dBm)
Definition: wifi-phy.h:1447
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
Definition: wifi-phy.h:1244
void AddPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of supported PHY entities for the given modulation class for the WifiPh...
Definition: wifi-phy.cc:647
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:1396
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
Definition: wifi-phy.h:1464
double GetTxPowerStart(void) const
Return the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:459
EventId m_endTxEvent
the end of transmit event
Definition: wifi-phy.h:1220
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:1677
uint16_t GetNMcs(void) const
Definition: wifi-phy.cc:1944
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition: wifi-phy.cc:669
Ptr< Event > m_currentEvent
Hold the current event.
Definition: wifi-phy.h:1222
virtual NS_DEPRECATED_3_35 void SetChannelWidth(uint16_t channelWidth)
If the operating channel for this object has not been set yet, the given channel width is saved and w...
Definition: wifi-phy.cc:1010
double m_ccaEdThresholdW
Clear channel assessment (CCA) threshold in watts.
Definition: wifi-phy.h:1438
void NotifyMonitorSniffTx(Ptr< const WifiPsdu > psdu, uint16_t channelFreqMhz, 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:1646
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class, for the WifiPhy instance.
Definition: wifi-phy.cc:631
virtual WifiSpectrumBand GetBand(uint16_t bandWidth, uint8_t bandIndex=0)
Get the start band index and the stop band index for a given band.
Definition: wifi-phy.cc:2183
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
Definition: wifi-phy.h:1335
void ResumeFromSleep(void)
Resume from sleep mode.
Definition: wifi-phy.cc:1406
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
Definition: wifi-phy.h:1225
void Configure80211ac(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard.
Definition: wifi-phy.cc:799
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU.
Definition: wifi-phy.h:1217
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
Definition: wifi-phy.cc:587
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:530
void NotifyChannelAccessRequested(void)
Notify the PHY that an access to the channel was requested.
Definition: wifi-phy.cc:1863
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
Definition: wifi-phy.h:1462
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1266
void SwitchMaybeToCcaBusy(uint16_t channelWidth)
Check if PHY state should move to CCA busy state based on current state of interference tracker.
Definition: wifi-phy.cc:2060
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:465
static std::map< WifiModulationClass, Ptr< PhyEntity > > & GetStaticPhyEntities(void)
Definition: wifi-phy.cc:375
static void AddStaticPhyEntity(WifiModulationClass modulation, Ptr< PhyEntity > phyEntity)
Add the PHY entity to the map of implemented PHY entities for the given modulation class.
Definition: wifi-phy.cc:639
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
Definition: wifi-phy.cc:1585
std::list< WifiMode > GetModeList(void) const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
Definition: wifi-phy.cc:1909
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:1327
double m_txGainDb
Transmission gain (dB)
Definition: wifi-phy.h:1439
std::vector< uint16_t > m_supportedChannelWidthSet
Supported channel width set (MHz)
Definition: wifi-phy.h:1429
WifiSpectrumBand GetPrimaryBand(uint16_t bandWidth)
If the operating channel width is a multiple of 20 MHz, return the start band index and the stop band...
Definition: wifi-phy.cc:2192
Time GetDelayUntilIdle(void)
Definition: wifi-phy.cc:2042
uint64_t GetPreviouslyRxPpduUid(void) const
Definition: wifi-phy.cc:1794
WifiStandard m_standard
WifiStandard.
Definition: wifi-phy.h:1421
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:593
uint8_t m_nTxPower
Number of available transmission power levels.
Definition: wifi-phy.h:1443
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
Definition: wifi-phy.cc:581
void SetPifs(Time pifs)
Set the PCF Interframe Space (PIFS) for this PHY.
Definition: wifi-phy.cc:681
Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
Definition: wifi-phy.cc:663
static Time GetStartOfPacketDuration(const WifiTxVector &txVector)
Definition: wifi-phy.cc:1474
virtual void StartTx(Ptr< WifiPpdu > ppdu)=0
Time GetAckTxTime(void) const
Return the estimated Ack TX time for this PHY.
Definition: wifi-phy.cc:693
void UnregisterListener(WifiPhyListener *listener)
Definition: wifi-phy.cc:406
virtual NS_DEPRECATED_3_35 void ConfigureStandardAndBand(WifiStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:822
void SetRxGain(double gain)
Sets the reception gain (dB).
Definition: wifi-phy.cc:504
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:542
double GetRxGain(void) const
Return the reception gain (dB).
Definition: wifi-phy.cc:511
void SetTxGain(double gain)
Sets the transmission gain (dB).
Definition: wifi-phy.cc:491
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
Definition: wifi-phy.h:1454
double m_txPowerEndDbm
Maximum transmission power (dBm)
Definition: wifi-phy.h:1442
void SetOffMode(void)
Put in off mode.
Definition: wifi-phy.cc:1391
double CalculateSnr(const WifiTxVector &txVector, double ber) const
Definition: wifi-phy.cc:617
void Configure80211n(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
Definition: wifi-phy.cc:780
bool IsStateSwitching(void) const
Definition: wifi-phy.cc:2024
double GetTxGain(void) const
Return the transmission gain (dB).
Definition: wifi-phy.cc:498
uint8_t GetNTxPower(void) const
Return the number of available transmission power levels.
Definition: wifi-phy.cc:485
Time GetDelayUntilChannelSwitch(void)
Perform any actions necessary when user changes operating channel after initialization.
Definition: wifi-phy.cc:1151
void EndReceiveInterBss(void)
For HE receptions only, check and possibly modify the transmit power restriction state at the end of ...
Definition: wifi-phy.cc:1842
double GetCcaEdThreshold(void) const
Return the CCA threshold (dBm).
Definition: wifi-phy.cc:438
double GetRxSensitivity(void) const
Return the receive sensitivity threshold (dBm).
Definition: wifi-phy.cc:425
void RegisterListener(WifiPhyListener *listener)
Definition: wifi-phy.cc:400
Ptr< WifiNetDevice > m_device
Pointer to the device.
Definition: wifi-phy.h:1458
bool IsStateSleep(void) const
Definition: wifi-phy.cc:2030
bool IsStateCcaBusy(void) const
Definition: wifi-phy.cc:2000
bool m_shortPreamble
Flag if short PHY preamble is supported.
Definition: wifi-phy.h:1451
Time m_pifs
PCF Interframe Space (PIFS) duration.
Definition: wifi-phy.h:1433
NS_DEPRECATED_3_35 void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
Definition: wifi-phy.cc:1044
void SetRxNoiseFigure(double noiseFigureDb)
Sets the RX loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
Definition: wifi-phy.cc:444
double GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
Definition: wifi-phy.cc:2131
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition: wifi-phy.cc:412
void SetReceiveOkCallback(RxOkCallback callback)
Definition: wifi-phy.cc:388
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
Definition: wifi-phy.cc:575
void ResumeFromOff(void)
Resume from off mode.
Definition: wifi-phy.cc:1437
void Configure80211ax(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard.
Definition: wifi-phy.cc:807
bool m_powerRestricted
Flag whether transmit power is restricted by OBSS PD SR.
Definition: wifi-phy.h:1446
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
Definition: wifi-phy.h:1467
void AddSupportedChannelWidth(uint16_t width)
Definition: wifi-phy.cc:1336
void NotifyMonitorSniffRx(Ptr< const WifiPsdu > psdu, uint16_t channelFreqMhz, WifiTxVector txVector, SignalNoiseDbm signalNoise, 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:1609
virtual void DoChannelSwitch(void)
Actually switch channel based on the stored channel settings.
Definition: wifi-phy.cc:1202
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
Definition: wifi-phy.h:1367
void SetOperatingChannel(uint8_t number, uint16_t frequency, uint16_t width)
Set the operating channel according to the specified parameters.
Definition: wifi-phy.cc:1067
static Time GetPreambleDetectionDuration(void)
Definition: wifi-phy.cc:1468
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
Definition: wifi-phy.h:877
double m_rxSensitivityW
Receive sensitivity threshold in watts.
Definition: wifi-phy.h:1437
uint16_t m_initialChannelWidth
Store channel width (MHz) until initialization.
Definition: wifi-phy.h:1425
Time GetLastRxEndTime(void) const
Return the end time of the last received packet.
Definition: wifi-phy.cc:2054
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1038
bool IsStateOff(void) const
Definition: wifi-phy.cc:2036
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:452
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:2203
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition: wifi-phy.cc:1498
bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
Definition: wifi-phy.cc:1870
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:973
Time m_ackTxTime
estimated Ack TX time
Definition: wifi-phy.h:1434
void NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
Definition: wifi-phy.cc:1561
virtual NS_DEPRECATED_3_35 void SetFrequency(uint16_t freq)
If the operating channel for this object has not been set yet, the given center frequency is saved an...
Definition: wifi-phy.cc:948
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:561
receive notifications about PHY events.
Class that keeps track of all information about the current PHY operating channel.
uint8_t GetNumber(void) const
Return the channel number identifying the whole operating channel.
bool IsSet(void) const
Return true if a valid channel has been set, false otherwise.
uint8_t GetPrimaryChannelIndex(uint16_t primaryChannelWidth) const
If the operating channel width is a multiple of 20 MHz, return the index of the primary channel of th...
void SetPrimary20Index(uint8_t index)
Set the index of the primary 20 MHz channel (0 indicates the 20 MHz subchannel with the lowest center...
uint16_t GetWidth(void) const
Return the width of the whole operating channel (in MHz).
void Set(uint8_t number, uint16_t frequency, uint16_t width, WifiStandard standard, WifiPhyBand band)
Set the channel according to the specified parameters if a unique frequency channel matches the speci...
void SetDefault(uint16_t width, WifiStandard standard, WifiPhyBand band)
Set the default channel of the given width and for the given standard and band.
static uint8_t GetDefaultChannelNumber(uint16_t width, WifiStandard standard, WifiPhyBand band)
Get the default channel number of the given width and for the given standard and band.
uint16_t GetFrequency(void) const
Return the center frequency of the operating channel (in MHz).
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Definition: wifi-psdu.cc:319
Ptr< Packet > GetAmpduSubframe(std::size_t i) const
Get a copy of the i-th A-MPDU subframe (includes subframe header, MPDU, and possibly padding)
Definition: wifi-psdu.cc:290
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
Definition: wifi-psdu.cc:81
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
Definition: wifi-psdu.cc:75
Ptr< const Packet > GetPacket(void) const
Get the PSDU as a single packet.
Definition: wifi-psdu.cc:87
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint8_t GetTxPowerLevel(void) const
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
const HeMuUserInfoMap & GetHeMuUserInfoMap(void) const
Get a const reference to the map HE MU user-specific transmission information indexed by STA-ID.
bool IsMu(void) const
Return true if this TX vector is used for a multi-user transmission.
uint16_t GetChannelWidth(void) const
uint8_t GetNssMax(void) const
WifiModulationClass GetModulationClass(void) const
Get the modulation class specified by this TXVECTOR.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
#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:88
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Definition: boolean.h:85
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:42
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:227
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1309
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:45
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1260
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
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.
Definition: wifi-phy-band.h:33
WifiModulationClass
This enumeration defines the modulation classes per (Table 10-6 "Modulation classes"; IEEE 802....
MpduType
The type of an MPDU.
@ WIFI_STANDARD_80211a
@ WIFI_STANDARD_80211p
@ WIFI_STANDARD_80211n
@ WIFI_STANDARD_80211g
@ WIFI_STANDARD_80211ax
@ WIFI_STANDARD_UNSPECIFIED
@ WIFI_STANDARD_80211ac
@ WIFI_STANDARD_80211b
@ OBSS_PD_CCA_RESET
@ RECEPTION_ABORTED_BY_TX
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
Definition: wifi-phy-band.h:39
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
Definition: wifi-phy-band.h:41
@ WIFI_PHY_BAND_2_4GHZ
The 2.4 GHz band.
Definition: wifi-phy-band.h:35
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Definition: wifi-phy-band.h:37
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ WIFI_MOD_CLASS_HR_DSSS
HR/DSSS (Clause 16)
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ 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:46
@ OFDM_PHY_5_MHZ
Definition: ofdm-phy.h:47
@ LAST_MPDU_IN_AGGREGATE
The MPDU is the last aggregate in an A-MPDU with multiple MPDUs.
@ NORMAL_MPDU
The MPDU is not part of an A-MPDU.
@ FIRST_MPDU_IN_AGGREGATE
The MPDU is the first aggregate in an A-MPDU with multiple MPDUs, but is not the last aggregate.
@ SINGLE_MPDU
The MPDU is a single MPDU.
@ MIDDLE_MPDU_IN_AGGREGATE
The MPDU is part of an A-MPDU with multiple MPDUs, but is neither the first nor the last aggregate.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:415
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition: wifi-utils.cc:49
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:43
std::pair< uint32_t, uint32_t > WifiSpectrumBand
typedef for a pair of start and stop sub-band indexes
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:37
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:536
std::map< WifiSpectrumBand, double > RxPowerWattPerChannelBand
A map of the received power (Watts) for each band.
Definition: phy-entity.h:75
WifiPhyBand GetDefaultPhyBand(WifiStandard standard)
Get the default PHY band for the given standard.
uint16_t GetDefaultChannelWidth(WifiStandard standard, WifiPhyBand band)
Get the default channel width for the given PHY standard and band.
double DbToRatio(double dB)
Convert from dB to ratio.
Definition: wifi-utils.cc:31
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:162
mobility
Definition: third.py:108
def start()
Definition: core.py:1853
#define list
MpduInfo structure.
Definition: phy-entity.h:60
MpduType type
type of MPDU
Definition: phy-entity.h:61
uint32_t mpduRefNumber
MPDU ref number.
Definition: phy-entity.h:62
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:67
double rssi
RSSI in dBm.
Definition: phy-entity.h:69
double snr
SNR in linear scale.
Definition: phy-entity.h:68
SignalNoiseDbm structure.
Definition: phy-entity.h:53
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
@ SWITCHING
The PHY layer is switching to other channel.
@ RX
The PHY layer is receiving a packet.
@ TX
The PHY layer is sending a packet.
@ OFF
The PHY layer is switched off.
@ SLEEP
The PHY layer is sleeping.
@ IDLE
The PHY layer is IDLE.
Declaration of ns3::WifiPpdu class and ns3::WifiConstPsduMap.