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 "interference-helper.h"
35 #include "frame-capture-model.h"
38 #include "error-rate-model.h"
39 #include "wifi-net-device.h"
40 #include "wifi-psdu.h"
41 #include "wifi-ppdu.h"
42 #include "ns3/dsss-phy.h"
43 #include "ns3/erp-ofdm-phy.h"
44 #include "ns3/he-phy.h" //includes OFDM, HT, and VHT
45 
46 namespace ns3 {
47 
48 NS_LOG_COMPONENT_DEFINE ("WifiPhy");
49 
50 /****************************************************************
51  * The actual WifiPhy class
52  ****************************************************************/
53 
55 
56 TypeId
58 {
59  static TypeId tid = TypeId ("ns3::WifiPhy")
60  .SetParent<Object> ()
61  .SetGroupName ("Wifi")
62  .AddAttribute ("ChannelSettings",
63  "Tuple {channel number, channel width (MHz), PHY band, primary20 index} "
64  "describing the settings of the operating channel. The primary20 index is "
65  "the index of the primary 20 MHz channel within the operating channel "
66  "(0 indicates the 20 MHz subchannel with the lowest center frequency) and "
67  "is only valid if the width of the operating channel is a multiple of 20 MHz. "
68  "If the standard for this object has not been set yet, the value of this "
69  "attribute is saved and will be used to set the operating channel when the "
70  "standard is configured. If the PHY band is left unspecified, the default "
71  "band for the configured standard is used. If the channel width and the "
72  "channel number are both 0, the default channel width for the configured "
73  "standard and band are used. If the channel number is 0, the default "
74  "channel number for the configured standard, band and channel width is used."
75  "Note that the channel width can be left unspecified (0) if the channel "
76  "number uniquely identify a frequency channel for the given standard and band. ",
77  StringValue ("{0, 0, BAND_UNSPECIFIED, 0}"),
78  MakeTupleAccessor <UintegerValue, UintegerValue, EnumValue, UintegerValue> ((void (WifiPhy::*) (const ChannelTuple&))(&WifiPhy::SetOperatingChannel)),
79  MakeTupleChecker<UintegerValue, UintegerValue, EnumValue, UintegerValue>
80  (MakeUintegerChecker<uint8_t> (0, 233),
81  MakeUintegerChecker<uint16_t> (0, 160),
85  WifiPhyBand::WIFI_PHY_BAND_UNSPECIFIED, "BAND_UNSPECIFIED"),
86  MakeUintegerChecker<uint8_t> (0, 7)))
87  .AddAttribute ("Frequency",
88  "The center frequency (MHz) of the current operating channel.",
89  UintegerValue (0),
91  MakeUintegerChecker<uint16_t> ())
92  .AddAttribute ("ChannelNumber",
93  "The channel number of the current operating channel.",
94  UintegerValue (0),
96  MakeUintegerChecker<uint8_t> (0, 233))
97  .AddAttribute ("ChannelWidth",
98  "The width in MHz of the current operating channel (5, 10, 20, 22, 40, 80 or 160).",
99  UintegerValue (0),
101  MakeUintegerChecker<uint16_t> (5, 160))
102  .AddAttribute ("Primary20MHzIndex",
103  "The index of the primary 20 MHz channel within the current operating channel "
104  "(0 indicates the 20 MHz subchannel with the lowest center frequency).",
105  UintegerValue (0),
107  MakeUintegerChecker<uint8_t> (0, 7))
108  .AddAttribute ("RxSensitivity",
109  "The energy of a received signal should be higher than "
110  "this threshold (dBm) for the PHY to detect the signal. "
111  "This threshold refers to a width of 20 MHz and will be "
112  "scaled to match the width of the received signal.",
113  DoubleValue (-101.0),
116  MakeDoubleChecker<double> ())
117  .AddAttribute ("CcaEdThreshold",
118  "The energy of a non Wi-Fi received signal should be higher than "
119  "this threshold (dBm) to allow the PHY layer to declare CCA BUSY state. "
120  "This check is performed on the 20 MHz primary channel only.",
121  DoubleValue (-62.0),
124  MakeDoubleChecker<double> ())
125  .AddAttribute ("TxGain",
126  "Transmission gain (dB).",
127  DoubleValue (0.0),
130  MakeDoubleChecker<double> ())
131  .AddAttribute ("RxGain",
132  "Reception gain (dB).",
133  DoubleValue (0.0),
136  MakeDoubleChecker<double> ())
137  .AddAttribute ("TxPowerLevels",
138  "Number of transmission power levels available between "
139  "TxPowerStart and TxPowerEnd included.",
140  UintegerValue (1),
142  MakeUintegerChecker<uint8_t> ())
143  .AddAttribute ("TxPowerEnd",
144  "Maximum available transmission level (dBm).",
145  DoubleValue (16.0206),
148  MakeDoubleChecker<double> ())
149  .AddAttribute ("TxPowerStart",
150  "Minimum available transmission level (dBm).",
151  DoubleValue (16.0206),
154  MakeDoubleChecker<double> ())
155  .AddAttribute ("RxNoiseFigure",
156  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
157  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
158  "\"the difference in decibels (dB) between"
159  " the noise output of the actual receiver to the noise output of an "
160  " ideal receiver with the same overall gain and bandwidth when the receivers "
161  " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
162  DoubleValue (7),
164  MakeDoubleChecker<double> ())
165  .AddAttribute ("State",
166  "The state of the PHY layer.",
167  PointerValue (),
169  MakePointerChecker<WifiPhyStateHelper> ())
170  .AddAttribute ("ChannelSwitchDelay",
171  "Delay between two short frames transmitted on different frequencies.",
172  TimeValue (MicroSeconds (250)),
174  MakeTimeChecker ())
175  .AddAttribute ("Antennas",
176  "The number of antennas on the device.",
177  UintegerValue (1),
180  MakeUintegerChecker<uint8_t> (1, 8))
181  .AddAttribute ("MaxSupportedTxSpatialStreams",
182  "The maximum number of supported TX spatial streams."
183  "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
184  UintegerValue (1),
187  MakeUintegerChecker<uint8_t> (1, 8))
188  .AddAttribute ("MaxSupportedRxSpatialStreams",
189  "The maximum number of supported RX spatial streams."
190  "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
191  UintegerValue (1),
194  MakeUintegerChecker<uint8_t> (1, 8))
195  .AddAttribute ("ShortPlcpPreambleSupported",
196  "Whether or not short PHY preamble is supported."
197  "This parameter is only valuable for 802.11b STAs and APs."
198  "Note: 802.11g APs and STAs always support short PHY preamble.",
199  BooleanValue (false),
203  .AddAttribute ("FrameCaptureModel",
204  "Ptr to an object that implements the frame capture model",
205  PointerValue (),
207  MakePointerChecker <FrameCaptureModel> ())
208  .AddAttribute ("PreambleDetectionModel",
209  "Ptr to an object that implements the preamble detection model",
210  PointerValue (),
212  MakePointerChecker <PreambleDetectionModel> ())
213  .AddAttribute ("PostReceptionErrorModel",
214  "An optional packet error model can be added to the receive "
215  "packet process after any propagation-based (SNR-based) error "
216  "models have been applied. Typically this is used to force "
217  "specific packet drops, for testing purposes.",
218  PointerValue (),
220  MakePointerChecker<ErrorModel> ())
221  .AddAttribute ("Sifs",
222  "The duration of the Short Interframe Space. "
223  "NOTE that the default value is overwritten by the value defined "
224  "by the standard; if you want to set this attribute, you have to "
225  "do it after that the PHY object is initialized.",
226  TimeValue (MicroSeconds (0)),
228  MakeTimeChecker ())
229  .AddAttribute ("Slot",
230  "The duration of a slot. "
231  "NOTE that the default value is overwritten by the value defined "
232  "by the standard; if you want to set this attribute, you have to "
233  "do it after that the PHY object is initialized.",
234  TimeValue (MicroSeconds (0)),
236  MakeTimeChecker ())
237  .AddAttribute ("Pifs",
238  "The duration of the PCF Interframe Space. "
239  "NOTE that the default value is overwritten by the value defined "
240  "by the standard; if you want to set this attribute, you have to "
241  "do it after that the PHY object is initialized.",
242  TimeValue (MicroSeconds (0)),
244  MakeTimeChecker ())
245  .AddAttribute ("PowerDensityLimit",
246  "The mean equivalent isotropically radiated power density"
247  "limit (in dBm/MHz) set by regulators.",
248  DoubleValue (100.0), //set to a high value so as to have no effect
250  MakeDoubleChecker<double> ())
251  .AddTraceSource ("PhyTxBegin",
252  "Trace source indicating a packet "
253  "has begun transmitting over the channel medium",
255  "ns3::WifiPhy::PhyTxBeginTracedCallback")
256  .AddTraceSource ("PhyTxPsduBegin",
257  "Trace source indicating a PSDU "
258  "has begun transmitting over the channel medium",
260  "ns3::WifiPhy::PsduTxBeginCallback")
261  .AddTraceSource ("PhyTxEnd",
262  "Trace source indicating a packet "
263  "has been completely transmitted over the channel.",
265  "ns3::Packet::TracedCallback")
266  .AddTraceSource ("PhyTxDrop",
267  "Trace source indicating a packet "
268  "has been dropped by the device during transmission",
270  "ns3::Packet::TracedCallback")
271  .AddTraceSource ("PhyRxBegin",
272  "Trace source indicating a packet "
273  "has begun being received from the channel medium "
274  "by the device",
276  "ns3::WifiPhy::PhyRxBeginTracedCallback")
277  .AddTraceSource ("PhyRxPayloadBegin",
278  "Trace source indicating the reception of the "
279  "payload of a PPDU has begun",
281  "ns3::WifiPhy::PhyRxPayloadBeginTracedCallback")
282  .AddTraceSource ("PhyRxEnd",
283  "Trace source indicating a packet "
284  "has been completely received from the channel medium "
285  "by the device",
287  "ns3::Packet::TracedCallback")
288  .AddTraceSource ("PhyRxDrop",
289  "Trace source indicating a packet "
290  "has been dropped by the device during reception",
292  "ns3::Packet::TracedCallback")
293  .AddTraceSource ("MonitorSnifferRx",
294  "Trace source simulating a wifi device in monitor mode "
295  "sniffing all received frames",
297  "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
298  .AddTraceSource ("MonitorSnifferTx",
299  "Trace source simulating the capability of a wifi device "
300  "in monitor mode to sniff all frames being transmitted",
302  "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
303  ;
304  return tid;
305 }
306 
308  : m_txMpduReferenceNumber (0xffffffff),
309  m_rxMpduReferenceNumber (0xffffffff),
310  m_endPhyRxEvent (),
311  m_endTxEvent (),
312  m_currentEvent (0),
313  m_previouslyRxPpduUid (UINT64_MAX),
314  m_standard (WIFI_STANDARD_UNSPECIFIED),
315  m_band (WIFI_PHY_BAND_UNSPECIFIED),
316  m_sifs (Seconds (0)),
317  m_slot (Seconds (0)),
318  m_pifs (Seconds (0)),
319  m_ackTxTime (Seconds (0)),
320  m_blockAckTxTime (Seconds (0)),
321  m_powerRestricted (false),
322  m_channelAccessRequested (false),
323  m_txSpatialStreams (0),
324  m_rxSpatialStreams (0),
325  m_wifiRadioEnergyModel (0),
326  m_timeLastPreambleDetected (Seconds (0))
327 {
328  NS_LOG_FUNCTION (this);
329  m_random = CreateObject<UniformRandomVariable> ();
330  m_state = CreateObject<WifiPhyStateHelper> ();
331 }
332 
334 {
335  NS_LOG_FUNCTION (this);
336 }
337 
338 void
340 {
341  NS_LOG_FUNCTION (this);
342  m_endTxEvent.Cancel ();
344  for (auto & phyEntity : m_phyEntities)
345  {
346  phyEntity.second->CancelAllEvents ();
347  }
348  m_device = 0;
349  m_mobility = 0;
355  if (m_interference != nullptr)
356  {
357  m_interference->Dispose ();
358  }
359  m_interference = 0;
360  m_random = 0;
361  m_state = 0;
362  m_currentEvent = 0;
363  for (auto & preambleEvent : m_currentPreambleEvents)
364  {
365  preambleEvent.second = 0;
366  }
367  m_currentPreambleEvents.clear ();
368 
369  for (auto & phyEntity : m_phyEntities)
370  {
371  phyEntity.second = 0;
372  }
373  m_phyEntities.clear ();
374 }
375 
376 std::map<WifiModulationClass, Ptr<PhyEntity> > &
378 {
379  static std::map<WifiModulationClass, Ptr<PhyEntity> > g_staticPhyEntities;
380  return g_staticPhyEntities;
381 }
382 
384 WifiPhy::GetState (void) const
385 {
386  return m_state;
387 }
388 
389 void
391 {
392  m_state->SetReceiveOkCallback (callback);
393 }
394 
395 void
397 {
398  m_state->SetReceiveErrorCallback (callback);
399 }
400 
401 void
403 {
404  m_state->RegisterListener (listener);
405 }
406 
407 void
409 {
410  m_state->UnregisterListener (listener);
411 }
412 
413 void
415 {
417 }
418 
419 void
420 WifiPhy::SetRxSensitivity (double threshold)
421 {
422  NS_LOG_FUNCTION (this << threshold);
423  m_rxSensitivityW = DbmToW (threshold);
424 }
425 
426 double
428 {
429  return WToDbm (m_rxSensitivityW);
430 }
431 
432 void
433 WifiPhy::SetCcaEdThreshold (double threshold)
434 {
435  NS_LOG_FUNCTION (this << threshold);
436  m_ccaEdThresholdW = DbmToW (threshold);
437 }
438 
439 double
441 {
442  return WToDbm (m_ccaEdThresholdW);
443 }
444 
445 void
446 WifiPhy::SetRxNoiseFigure (double noiseFigureDb)
447 {
448  NS_LOG_FUNCTION (this << noiseFigureDb);
449  if (m_interference)
450  {
451  m_interference->SetNoiseFigure (DbToRatio (noiseFigureDb));
452  }
453  m_noiseFigureDb = noiseFigureDb;
454 }
455 
456 void
458 {
459  NS_LOG_FUNCTION (this << start);
461 }
462 
463 double
465 {
466  return m_txPowerBaseDbm;
467 }
468 
469 void
471 {
472  NS_LOG_FUNCTION (this << end);
473  m_txPowerEndDbm = end;
474 }
475 
476 double
478 {
479  return m_txPowerEndDbm;
480 }
481 
482 void
484 {
485  NS_LOG_FUNCTION (this << +n);
486  m_nTxPower = n;
487 }
488 
489 uint8_t
491 {
492  return m_nTxPower;
493 }
494 
495 void
496 WifiPhy::SetTxGain (double gain)
497 {
498  NS_LOG_FUNCTION (this << gain);
499  m_txGainDb = gain;
500 }
501 
502 double
503 WifiPhy::GetTxGain (void) const
504 {
505  return m_txGainDb;
506 }
507 
508 void
509 WifiPhy::SetRxGain (double gain)
510 {
511  NS_LOG_FUNCTION (this << gain);
512  m_rxGainDb = gain;
513 }
514 
515 double
516 WifiPhy::GetRxGain (void) const
517 {
518  return m_rxGainDb;
519 }
520 
521 void
523 {
524  NS_LOG_FUNCTION (this << enable);
525  m_shortPreamble = enable;
526 }
527 
528 bool
530 {
531  return m_shortPreamble;
532 }
533 
534 void
536 {
537  m_device = device;
538 }
539 
541 WifiPhy::GetDevice (void) const
542 {
543  return m_device;
544 }
545 
546 void
548 {
550 }
551 
554 {
555  if (m_mobility != 0)
556  {
557  return m_mobility;
558  }
559  else
560  {
561  return m_device->GetNode ()->GetObject<MobilityModel> ();
562  }
563 }
564 
565 void
567 {
568  m_interference = helper;
569  m_interference->SetNoiseFigure (DbToRatio (m_noiseFigureDb));
570  m_interference->SetNumberOfReceiveAntennas (m_numberOfAntennas);
571 }
572 
573 void
575 {
576  NS_ASSERT (m_interference != nullptr);
577  m_interference->SetErrorRateModel (model);
578 }
579 
580 void
582 {
583  NS_LOG_FUNCTION (this << em);
585 }
586 
587 void
589 {
590  m_frameCaptureModel = model;
591 }
592 
593 void
595 {
596  m_preambleDetectionModel = model;
597 }
598 
599 void
601 {
602  m_wifiRadioEnergyModel = wifiRadioEnergyModel;
603 }
604 
605 double
606 WifiPhy::GetPowerDbm (uint8_t power) const
607 {
609  NS_ASSERT (m_nTxPower > 0);
610  double dbm;
611  if (m_nTxPower > 1)
612  {
613  dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
614  }
615  else
616  {
617  NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
618  dbm = m_txPowerBaseDbm;
619  }
620  return dbm;
621 }
622 
623 Time
625 {
626  return m_channelSwitchDelay;
627 }
628 
629 double
630 WifiPhy::CalculateSnr (const WifiTxVector& txVector, double ber) const
631 {
632  return m_interference->GetErrorRateModel ()->CalculateSnr (txVector, ber);
633 }
634 
637 {
638  const auto it = GetStaticPhyEntities ().find (modulation);
639  NS_ABORT_MSG_IF (it == GetStaticPhyEntities ().end (), "Unimplemented Wi-Fi modulation class");
640  return it->second;
641 }
642 
645 {
646  const auto it = m_phyEntities.find (modulation);
647  NS_ABORT_MSG_IF (it == m_phyEntities.end (), "Unsupported Wi-Fi modulation class " << modulation);
648  return it->second;
649 }
650 
651 void
653 {
654  NS_LOG_FUNCTION (modulation);
655  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");
656  GetStaticPhyEntities ()[modulation] = phyEntity;
657 }
658 
659 void
661 {
662  NS_LOG_FUNCTION (this << modulation);
663  NS_ABORT_MSG_IF (GetStaticPhyEntities ().find (modulation) == GetStaticPhyEntities ().end (), "Cannot add an unimplemented PHY to supported list. Update the former first.");
664  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");
665  phyEntity->SetOwner (this);
666  m_phyEntities[modulation] = phyEntity;
667 }
668 
669 void
671 {
672  m_sifs = sifs;
673 }
674 
675 Time
676 WifiPhy::GetSifs (void) const
677 {
678  return m_sifs;
679 }
680 
681 void
683 {
684  m_slot = slot;
685 }
686 
687 Time
688 WifiPhy::GetSlot (void) const
689 {
690  return m_slot;
691 }
692 
693 void
695 {
696  m_pifs = pifs;
697 }
698 
699 Time
700 WifiPhy::GetPifs (void) const
701 {
702  return m_pifs;
703 }
704 
705 Time
707 {
708  return m_ackTxTime;
709 }
710 
711 Time
713 {
714  return m_blockAckTxTime;
715 }
716 
717 void
719 {
720  NS_LOG_FUNCTION (this);
721  AddPhyEntity (WIFI_MOD_CLASS_OFDM, Create<OfdmPhy> ());
722 
723  // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
724  SetSifs (MicroSeconds (16));
725  SetSlot (MicroSeconds (9));
726  SetPifs (GetSifs () + GetSlot ());
727  // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
728  // of the PPDU causing the EIFS" of 802.11-2016
729  m_ackTxTime = MicroSeconds (44);
730 }
731 
732 void
734 {
735  NS_LOG_FUNCTION (this);
736  Ptr<DsssPhy> phyEntity = Create<DsssPhy> ();
738  AddPhyEntity (WIFI_MOD_CLASS_DSSS, phyEntity); //when plain DSSS modes are used
739 
740  // See Table 16-4 "HR/DSSS PHY characteristics" of 802.11-2016
741  SetSifs (MicroSeconds (10));
742  SetSlot (MicroSeconds (20));
743  SetPifs (GetSifs () + GetSlot ());
744  // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
745  // of the PPDU causing the EIFS" of 802.11-2016
746  m_ackTxTime = MicroSeconds (304);
747 }
748 
749 void
751 {
752  NS_LOG_FUNCTION (this);
753  // See Table 18-5 "ERP characteristics" of 802.11-2016
754  // Slot time defaults to the "long slot time" of 20 us in the standard
755  // according to mixed 802.11b/g deployments. Short slot time is enabled
756  // if the user sets the ShortSlotTimeSupported flag to true and when the BSS
757  // consists of only ERP STAs capable of supporting this option.
758  Configure80211b ();
759  AddPhyEntity (WIFI_MOD_CLASS_ERP_OFDM, Create<ErpOfdmPhy> ());
760 }
761 
762 void
764 {
765  NS_LOG_FUNCTION (this);
766  if (GetChannelWidth () == 10)
767  {
768  AddPhyEntity (WIFI_MOD_CLASS_OFDM, Create<OfdmPhy> (OFDM_PHY_10_MHZ));
769 
770  // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
771  SetSifs (MicroSeconds (32));
772  SetSlot (MicroSeconds (13));
773  SetPifs (GetSifs () + GetSlot ());
774  m_ackTxTime = MicroSeconds (88);
775  }
776  else if (GetChannelWidth () == 5)
777  {
778  AddPhyEntity (WIFI_MOD_CLASS_OFDM, Create<OfdmPhy> (OFDM_PHY_5_MHZ));
779 
780  // See Table 17-21 "OFDM PHY characteristics" of 802.11-2016
781  SetSifs (MicroSeconds (64));
782  SetSlot (MicroSeconds (21));
783  SetPifs (GetSifs () + GetSlot ());
784  m_ackTxTime = MicroSeconds (176);
785  }
786  else
787  {
788  NS_FATAL_ERROR ("802.11p configured with a wrong channel width!");
789  }
790 }
791 
792 void
794 {
795  NS_LOG_FUNCTION (this);
797  {
798  Configure80211g ();
799  }
800  else
801  {
802  Configure80211a ();
803  }
805 
806  // See Table 10-5 "Determination of the EstimatedAckTxTime based on properties
807  // of the PPDU causing the EIFS" of 802.11-2016
809 }
810 
811 void
813 {
814  NS_LOG_FUNCTION (this);
815  Configure80211n ();
816  AddPhyEntity (WIFI_MOD_CLASS_VHT, Create<VhtPhy> ());
817 }
818 
819 void
821 {
822  NS_LOG_FUNCTION (this);
824  {
825  Configure80211n ();
826  }
827  else
828  {
829  Configure80211ac ();
830  }
831  AddPhyEntity (WIFI_MOD_CLASS_HE, Create<HePhy> ());
832 }
833 
834 void
836 {
837  NS_LOG_FUNCTION (this << standard);
838 
840  "Cannot change standard");
841 
842  m_standard = standard;
843 
844  if (!m_operatingChannel.IsSet ())
845  {
846  NS_LOG_DEBUG ("Setting the operating channel first");
848  // return because we are called back by SetOperatingChannel
849  return;
850  }
851 
852  // this function is called when changing PHY band, hence we have to delete
853  // the previous PHY entities
854  m_phyEntities.clear ();
855 
856  switch (standard)
857  {
859  Configure80211a ();
860  break;
862  Configure80211b ();
863  break;
865  Configure80211g ();
866  break;
868  Configure80211p ();
869  break;
871  Configure80211n ();
872  break;
874  Configure80211ac ();
875  break;
877  Configure80211ax ();
878  break;
880  default:
881  NS_ASSERT_MSG (false, "Unsupported standard");
882  break;
883  }
884 }
885 
888 {
889  return m_band;
890 }
891 
892 
895 {
896  return m_standard;
897 }
898 
901 {
902  return m_operatingChannel;
903 }
904 
905 uint16_t
907 {
909 }
910 
911 uint8_t
913 {
914  return m_operatingChannel.GetNumber ();
915 }
916 
917 uint16_t
919 {
920  return m_operatingChannel.GetWidth ();
921 }
922 
923 uint8_t
925 {
927 }
928 
929 void
931 {
932  // the generic operator<< for tuples does not give a pretty result
933  NS_LOG_FUNCTION (this << +std::get<0> (channelTuple) << std::get<1> (channelTuple)
934  << static_cast<WifiPhyBand> (std::get<2> (channelTuple))
935  << +std::get<3> (channelTuple));
936 
937  m_channelSettings = channelTuple;
938 
940  {
941  NS_LOG_DEBUG ("Channel information will be applied when a standard is configured");
942  return;
943  }
944 
945  Time delay = Seconds (0);
946 
947  if (IsInitialized ())
948  {
949  delay = GetDelayUntilChannelSwitch ();
950  }
951 
952  if (delay.IsStrictlyNegative ())
953  {
954  // switching channel is not possible now
955  return;
956  }
957  if (delay.IsStrictlyPositive ())
958  {
959  // switching channel has been postponed
960  void (WifiPhy::*fp) (const ChannelTuple&) = &WifiPhy::SetOperatingChannel;
961  Simulator::Schedule (delay, fp, this, channelTuple);
962  return;
963  }
964 
965  // channel can be switched now.
966  DoChannelSwitch ();
967 }
968 
969 Time
971 {
972  m_powerRestricted = false;
973  m_channelAccessRequested = false;
974  m_currentEvent = 0;
975  m_currentPreambleEvents.clear ();
976  if (!IsInitialized ())
977  {
978  //this is not channel switch, this is initialization
979  NS_LOG_DEBUG ("Before initialization, nothing to do");
980  return Seconds (0);
981  }
982 
983  Time delay = Seconds (0);
984 
986  switch (m_state->GetState ())
987  {
988  case WifiPhyState::RX:
989  NS_LOG_DEBUG ("drop packet because of channel switching while reception");
991  for (auto & phyEntity : m_phyEntities)
992  {
993  phyEntity.second->CancelAllEvents ();
994  }
995  break;
996  case WifiPhyState::TX:
997  NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
998  delay = GetDelayUntilIdle ();
999  break;
1001  case WifiPhyState::IDLE:
1003  for (auto & phyEntity : m_phyEntities)
1004  {
1005  phyEntity.second->CancelAllEvents ();
1006  }
1007  break;
1008  case WifiPhyState::SLEEP:
1009  NS_LOG_DEBUG ("channel switching ignored in sleep mode");
1010  delay = Seconds (-1); // negative value to indicate switching not possible
1011  break;
1012  default:
1013  NS_ASSERT (false);
1014  break;
1015  }
1016 
1017  return delay;
1018 }
1019 
1020 void
1022 {
1023  NS_LOG_FUNCTION (this);
1024 
1025  // Update unspecified parameters with default values
1026  if (auto& [number, width, band, primary20] = m_channelSettings; true)
1027  {
1028  if (band == static_cast<int> (WIFI_PHY_BAND_UNSPECIFIED))
1029  {
1030  band = static_cast<int> (GetDefaultPhyBand (m_standard));
1031  }
1032  if (width == 0 && number == 0)
1033  {
1034  width = GetDefaultChannelWidth (m_standard, static_cast<WifiPhyBand> (band));
1035  }
1036  if (number == 0)
1037  {
1038  number = WifiPhyOperatingChannel::GetDefaultChannelNumber (width, m_standard, static_cast<WifiPhyBand> (band));
1039  }
1040  }
1041 
1042  // We need to call SetStandard if this is the first time we set a channel or we
1043  // are changing PHY band. Checking if the new PHY band is different than the
1044  // previous one covers both cases because initially the PHY band is unspecified
1045  bool changingPhyBand = (static_cast<WifiPhyBand> (std::get<2> (m_channelSettings)) != m_band);
1046 
1047  m_band = static_cast<WifiPhyBand> (std::get<2> (m_channelSettings));
1048 
1049  NS_LOG_DEBUG ("switching channel");
1050  m_operatingChannel.Set (std::get<0> (m_channelSettings), 0, std::get<1> (m_channelSettings),
1051  m_standard, m_band);
1053 
1054  if (changingPhyBand)
1055  {
1057  }
1058 
1060 
1061  if (IsInitialized ())
1062  {
1063  // notify channel switching
1064  m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ());
1065  m_interference->EraseEvents ();
1066  /*
1067  * Needed here to be able to correctly sensed the medium for the first
1068  * time after the switching. The actual switching is not performed until
1069  * after m_channelSwitchDelay. Packets received during the switching
1070  * state are added to the event list and are employed later to figure
1071  * out the state of the medium after the switching.
1072  */
1073  }
1074 }
1075 
1076 void
1078 {
1079  NS_LOG_FUNCTION (this << +antennas);
1080  NS_ASSERT_MSG (antennas > 0 && antennas <= 4, "unsupported number of antennas");
1081  m_numberOfAntennas = antennas;
1082  if (m_interference)
1083  {
1084  m_interference->SetNumberOfReceiveAntennas (antennas);
1085  }
1086 }
1087 
1088 uint8_t
1090 {
1091  return m_numberOfAntennas;
1092 }
1093 
1094 void
1096 {
1097  NS_ASSERT (streams <= GetNumberOfAntennas ());
1098  bool changed = (m_txSpatialStreams != streams);
1099  m_txSpatialStreams = streams;
1100  if (changed)
1101  {
1102  auto phyEntity = m_phyEntities.find (WIFI_MOD_CLASS_HT);
1103  if (phyEntity != m_phyEntities.end ())
1104  {
1105  Ptr<HtPhy> htPhy = DynamicCast<HtPhy> (phyEntity->second);
1106  if (htPhy)
1107  {
1108  htPhy->SetMaxSupportedNss (m_txSpatialStreams); //this is essential to have the right MCSs configured
1109  }
1110 
1112  {
1114  }
1115  }
1116  }
1117 }
1118 
1119 uint8_t
1121 {
1122  return m_txSpatialStreams;
1123 }
1124 
1125 void
1127 {
1128  NS_ASSERT (streams <= GetNumberOfAntennas ());
1129  bool changed = (m_rxSpatialStreams != streams);
1130  m_rxSpatialStreams = streams;
1131  if (changed && !m_capabilitiesChangedCallback.IsNull ())
1132  {
1134  }
1135 }
1136 
1137 uint8_t
1139 {
1140  return m_rxSpatialStreams;
1141 }
1142 
1143 std::list<uint8_t>
1145 {
1146  std::list<uint8_t> list;
1147  for (const auto & phyEntity : m_phyEntities)
1148  {
1149  Ptr<HtPhy> htPhy = DynamicCast<HtPhy> (phyEntity.second);
1150  if (htPhy)
1151  {
1152  list.emplace_back (htPhy->GetBssMembershipSelector ());
1153  }
1154  }
1155  return list;
1156 }
1157 
1158 void
1160 {
1161  NS_LOG_FUNCTION (this << width);
1162  for (std::vector<uint32_t>::size_type i = 0; i != m_supportedChannelWidthSet.size (); i++)
1163  {
1164  if (m_supportedChannelWidthSet[i] == width)
1165  {
1166  return;
1167  }
1168  }
1169  NS_LOG_FUNCTION ("Adding " << width << " to supported channel width set");
1170  m_supportedChannelWidthSet.push_back (width);
1171 }
1172 
1173 std::vector<uint16_t>
1175 {
1177 }
1178 
1179 void
1181 {
1182  NS_LOG_FUNCTION (this);
1183  m_powerRestricted = false;
1184  m_channelAccessRequested = false;
1185  switch (m_state->GetState ())
1186  {
1187  case WifiPhyState::TX:
1188  NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmission");
1190  break;
1191  case WifiPhyState::RX:
1192  NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception");
1194  break;
1196  NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching");
1198  break;
1200  case WifiPhyState::IDLE:
1201  NS_LOG_DEBUG ("setting sleep mode");
1202  m_state->SwitchToSleep ();
1203  break;
1204  case WifiPhyState::SLEEP:
1205  NS_LOG_DEBUG ("already in sleep mode");
1206  break;
1207  default:
1208  NS_ASSERT (false);
1209  break;
1210  }
1211 }
1212 
1213 void
1215 {
1216  NS_LOG_FUNCTION (this);
1217  m_powerRestricted = false;
1218  m_channelAccessRequested = false;
1220  m_endTxEvent.Cancel ();
1221  for (auto & phyEntity : m_phyEntities)
1222  {
1223  phyEntity.second->CancelAllEvents ();
1224  }
1225  m_state->SwitchToOff ();
1226 }
1227 
1228 void
1230 {
1231  NS_LOG_FUNCTION (this);
1232  m_currentPreambleEvents.clear ();
1233  switch (m_state->GetState ())
1234  {
1235  case WifiPhyState::TX:
1236  case WifiPhyState::RX:
1237  case WifiPhyState::IDLE:
1240  {
1241  NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume");
1242  break;
1243  }
1244  case WifiPhyState::SLEEP:
1245  {
1246  NS_LOG_DEBUG ("resuming from sleep mode");
1247  m_state->SwitchFromSleep ();
1249  break;
1250  }
1251  default:
1252  {
1253  NS_ASSERT (false);
1254  break;
1255  }
1256  }
1257 }
1258 
1259 void
1261 {
1262  NS_LOG_FUNCTION (this);
1263  switch (m_state->GetState ())
1264  {
1265  case WifiPhyState::TX:
1266  case WifiPhyState::RX:
1267  case WifiPhyState::IDLE:
1270  case WifiPhyState::SLEEP:
1271  {
1272  NS_LOG_DEBUG ("not in off mode, there is nothing to resume");
1273  break;
1274  }
1275  case WifiPhyState::OFF:
1276  {
1277  NS_LOG_DEBUG ("resuming from off mode");
1278  m_state->SwitchFromOff ();
1280  break;
1281  }
1282  default:
1283  {
1284  NS_ASSERT (false);
1285  break;
1286  }
1287  }
1288 }
1289 
1290 Time
1292 {
1293  return MicroSeconds (4);
1294 }
1295 
1296 Time
1298 {
1299  return MicroSeconds (4);
1300 }
1301 
1302 Time
1303 WifiPhy::GetPayloadDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, MpduType mpdutype, uint16_t staId)
1304 {
1305  uint32_t totalAmpduSize;
1306  double totalAmpduNumSymbols;
1307  return GetPayloadDuration (size, txVector, band, mpdutype, false, totalAmpduSize, totalAmpduNumSymbols, staId);
1308 }
1309 
1310 Time
1311 WifiPhy::GetPayloadDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, MpduType mpdutype,
1312  bool incFlag, uint32_t &totalAmpduSize, double &totalAmpduNumSymbols,
1313  uint16_t staId)
1314 {
1315  return GetStaticPhyEntity (txVector.GetModulationClass ())->GetPayloadDuration (size, txVector, band, mpdutype,
1316  incFlag, totalAmpduSize, totalAmpduNumSymbols,
1317  staId);
1318 }
1319 
1320 Time
1322 {
1323  return GetStaticPhyEntity (txVector.GetModulationClass ())->CalculatePhyPreambleAndHeaderDuration (txVector);
1324 }
1325 
1326 Time
1327 WifiPhy::CalculateTxDuration (uint32_t size, const WifiTxVector& txVector, WifiPhyBand band, uint16_t staId)
1328 {
1329  Time duration = CalculatePhyPreambleAndHeaderDuration (txVector)
1330  + GetPayloadDuration (size, txVector, band, NORMAL_MPDU, staId);
1331  NS_ASSERT (duration.IsStrictlyPositive ());
1332  return duration;
1333 }
1334 
1335 Time
1337 {
1338  return CalculateTxDuration (GetWifiConstPsduMap (psdu, txVector), txVector, band);
1339 }
1340 
1341 Time
1343 {
1344  return GetStaticPhyEntity (txVector.GetModulationClass ())->CalculateTxDuration (psduMap, txVector, band);
1345 }
1346 
1347 uint32_t
1349 {
1350  return GetStaticPhyEntity (modulation)->GetMaxPsduSize ();
1351 }
1352 
1353 void
1355 {
1356  if (!m_phyTxBeginTrace.IsEmpty ())
1357  {
1358  for (auto const& psdu : psdus)
1359  {
1360  for (auto& mpdu : *PeekPointer (psdu.second))
1361  {
1362  m_phyTxBeginTrace (mpdu->GetProtocolDataUnit (), txPowerW);
1363  }
1364  }
1365  }
1366 }
1367 
1368 void
1370 {
1371  if (!m_phyTxEndTrace.IsEmpty ())
1372  {
1373  for (auto const& psdu : psdus)
1374  {
1375  for (auto& mpdu : *PeekPointer (psdu.second))
1376  {
1377  m_phyTxEndTrace (mpdu->GetProtocolDataUnit ());
1378  }
1379  }
1380  }
1381 }
1382 
1383 void
1385 {
1386  if (!m_phyTxDropTrace.IsEmpty ())
1387  {
1388  for (auto& mpdu : *PeekPointer (psdu))
1389  {
1390  m_phyTxDropTrace (mpdu->GetProtocolDataUnit ());
1391  }
1392  }
1393 }
1394 
1395 void
1397 {
1398  if (psdu && !m_phyRxBeginTrace.IsEmpty ())
1399  {
1400  for (auto& mpdu : *PeekPointer (psdu))
1401  {
1402  m_phyRxBeginTrace (mpdu->GetProtocolDataUnit (), rxPowersW);
1403  }
1404  }
1405 }
1406 
1407 void
1409 {
1410  if (psdu && !m_phyRxEndTrace.IsEmpty ())
1411  {
1412  for (auto& mpdu : *PeekPointer (psdu))
1413  {
1414  m_phyRxEndTrace (mpdu->GetProtocolDataUnit ());
1415  }
1416  }
1417 }
1418 
1419 void
1421 {
1422  if (psdu && !m_phyRxDropTrace.IsEmpty ())
1423  {
1424  for (auto& mpdu : *PeekPointer (psdu))
1425  {
1426  m_phyRxDropTrace (mpdu->GetProtocolDataUnit (), reason);
1427  }
1428  }
1429 }
1430 
1431 void
1432 WifiPhy::NotifyMonitorSniffRx (Ptr<const WifiPsdu> psdu, uint16_t channelFreqMhz, WifiTxVector txVector,
1433  SignalNoiseDbm signalNoise, std::vector<bool> statusPerMpdu, uint16_t staId)
1434 {
1435  MpduInfo aMpdu;
1436  if (psdu->IsAggregate ())
1437  {
1438  //Expand A-MPDU
1439  NS_ASSERT_MSG (txVector.IsAggregation (), "TxVector with aggregate flag expected here according to PSDU");
1441  size_t nMpdus = psdu->GetNMpdus ();
1442  NS_ASSERT_MSG (statusPerMpdu.size () == nMpdus, "Should have one reception status per MPDU");
1443  if (!m_phyMonitorSniffRxTrace.IsEmpty ())
1444  {
1445  aMpdu.type = (psdu->IsSingle ()) ? SINGLE_MPDU : FIRST_MPDU_IN_AGGREGATE;
1446  for (size_t i = 0; i < nMpdus;)
1447  {
1448  if (statusPerMpdu.at (i)) //packet received without error, hand over to sniffer
1449  {
1450  m_phyMonitorSniffRxTrace (psdu->GetAmpduSubframe (i), channelFreqMhz, txVector, aMpdu, signalNoise, staId);
1451  }
1452  ++i;
1453  aMpdu.type = (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1454  }
1455  }
1456  }
1457  else
1458  {
1459  NS_ASSERT_MSG (statusPerMpdu.size () == 1, "Should have one reception status for normal MPDU");
1460  if (!m_phyMonitorSniffRxTrace.IsEmpty ())
1461  {
1462  aMpdu.type = NORMAL_MPDU;
1463  m_phyMonitorSniffRxTrace (psdu->GetPacket (), channelFreqMhz, txVector, aMpdu, signalNoise, staId);
1464  }
1465  }
1466 }
1467 
1468 void
1469 WifiPhy::NotifyMonitorSniffTx (Ptr<const WifiPsdu> psdu, uint16_t channelFreqMhz, WifiTxVector txVector, uint16_t staId)
1470 {
1471  MpduInfo aMpdu;
1472  if (psdu->IsAggregate ())
1473  {
1474  //Expand A-MPDU
1475  NS_ASSERT_MSG (txVector.IsAggregation (), "TxVector with aggregate flag expected here according to PSDU");
1477  if (!m_phyMonitorSniffTxTrace.IsEmpty ())
1478  {
1479  size_t nMpdus = psdu->GetNMpdus ();
1480  aMpdu.type = (psdu->IsSingle ()) ? SINGLE_MPDU: FIRST_MPDU_IN_AGGREGATE;
1481  for (size_t i = 0; i < nMpdus;)
1482  {
1483  m_phyMonitorSniffTxTrace (psdu->GetAmpduSubframe (i), channelFreqMhz, txVector, aMpdu, staId);
1484  ++i;
1485  aMpdu.type = (i == (nMpdus - 1)) ? LAST_MPDU_IN_AGGREGATE : MIDDLE_MPDU_IN_AGGREGATE;
1486  }
1487  }
1488  }
1489  else
1490  {
1491  if (!m_phyMonitorSniffTxTrace.IsEmpty ())
1492  {
1493  aMpdu.type = NORMAL_MPDU;
1494  m_phyMonitorSniffTxTrace (psdu->GetPacket (), channelFreqMhz, txVector, aMpdu, staId);
1495  }
1496  }
1497 }
1498 
1501 {
1502  return GetStaticPhyEntity (txVector.GetModulationClass ())->GetWifiConstPsduMap (psdu, txVector);
1503 }
1504 
1505 void
1507 {
1508  NS_LOG_FUNCTION (this << *psdu << txVector);
1509  Send (GetWifiConstPsduMap (psdu, txVector), txVector);
1510 }
1511 
1512 void
1514 {
1515  NS_LOG_FUNCTION (this << psdus << txVector);
1516  /* Transmission can happen if:
1517  * - we are syncing on a packet. It is the responsibility of the
1518  * MAC layer to avoid doing this but the PHY does nothing to
1519  * prevent it.
1520  * - we are idle
1521  */
1522  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
1524 
1525  if (txVector.GetNssMax () > GetMaxSupportedTxSpatialStreams ())
1526  {
1527  NS_FATAL_ERROR ("Unsupported number of spatial streams!");
1528  }
1529 
1530  if (m_state->IsStateSleep ())
1531  {
1532  NS_LOG_DEBUG ("Dropping packet because in sleep mode");
1533  for (auto const& psdu : psdus)
1534  {
1535  NotifyTxDrop (psdu.second);
1536  }
1537  return;
1538  }
1539 
1540  Time txDuration = CalculateTxDuration (psdus, txVector, GetPhyBand ());
1541 
1542  bool noEndPreambleDetectionEvent = true;
1543  for (const auto & it : m_phyEntities)
1544  {
1545  noEndPreambleDetectionEvent &= it.second->NoEndPreambleDetectionEvents ();
1546  }
1547  if (!noEndPreambleDetectionEvent || ((m_currentEvent != 0) && (m_currentEvent->GetEndTime () > (Simulator::Now () + m_state->GetDelayUntilIdle ()))))
1548  {
1550  }
1551 
1552  for (auto & it : m_phyEntities)
1553  {
1554  it.second->CancelRunningEndPreambleDetectionEvents ();
1555  }
1556  m_currentPreambleEvents.clear ();
1558 
1559  if (m_powerRestricted)
1560  {
1561  NS_LOG_DEBUG ("Transmitting with power restriction for " << txDuration.As (Time::NS));
1562  }
1563  else
1564  {
1565  NS_LOG_DEBUG ("Transmitting without power restriction for " << txDuration.As (Time::NS));
1566  }
1567 
1568  if (m_state->GetState () == WifiPhyState::OFF)
1569  {
1570  NS_LOG_DEBUG ("Transmission canceled because device is OFF");
1571  return;
1572  }
1573 
1574  Ptr<WifiPpdu> ppdu = GetPhyEntity (txVector.GetModulationClass ())->BuildPpdu (psdus, txVector, txDuration);
1575  m_previouslyRxPpduUid = UINT64_MAX; //reset (after creation of PPDU) to use it only once
1576 
1577  double txPowerW = DbmToW (GetTxPowerForTransmission (ppdu) + GetTxGain ());
1578  NotifyTxBegin (psdus, txPowerW);
1579  if (!m_phyTxPsduBeginTrace.IsEmpty ())
1580  {
1581  m_phyTxPsduBeginTrace (psdus, txVector, txPowerW);
1582  }
1583  for (auto const& psdu : psdus)
1584  {
1585  NotifyMonitorSniffTx (psdu.second, GetFrequency (), txVector, psdu.first);
1586  }
1587  m_state->SwitchToTx (txDuration, psdus, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector);
1588 
1589  if (m_wifiRadioEnergyModel != 0 && m_wifiRadioEnergyModel->GetMaximumTimeInState (WifiPhyState::TX) < txDuration)
1590  {
1591  ppdu->SetTruncatedTx ();
1592  }
1593 
1594  m_endTxEvent = Simulator::Schedule (txDuration, &WifiPhy::NotifyTxEnd, this, psdus); //TODO: fix for MU
1595 
1596  StartTx (ppdu);
1597 
1598  m_channelAccessRequested = false;
1599  m_powerRestricted = false;
1600 
1601  Simulator::Schedule (txDuration, &WifiPhy::Reset, this);
1602 }
1603 
1604 uint64_t
1606 {
1607  return m_previouslyRxPpduUid;
1608 }
1609 
1610 void
1612 {
1613  NS_LOG_FUNCTION (this);
1614  m_currentPreambleEvents.clear ();
1615  m_currentEvent = 0;
1616  for (auto & phyEntity : m_phyEntities)
1617  {
1618  phyEntity.second->CancelAllEvents ();
1619  }
1621 }
1622 
1623 void
1625 {
1626  WifiModulationClass modulation = ppdu->GetTxVector ().GetModulationClass ();
1627  auto it = m_phyEntities.find (modulation);
1628  if (it != m_phyEntities.end ())
1629  {
1630  it->second->StartReceivePreamble (ppdu, rxPowersW, rxDuration);
1631  }
1632  else
1633  {
1634  //TODO find a fallback PHY for receiving the PPDU (e.g. 11a for 11ax due to preamble structure)
1635  NS_LOG_DEBUG ("Unsupported modulation received (" << modulation << "), consider as noise");
1636  m_interference->Add (ppdu, ppdu->GetTxVector (), rxDuration, rxPowersW);
1638  }
1639 }
1640 
1642 WifiPhy::ConvertHeRuSubcarriers (uint16_t bandWidth, uint16_t guardBandwidth,
1643  HeRu::SubcarrierRange range, uint8_t bandIndex) const
1644 {
1645  NS_ASSERT_MSG (false, "802.11ax can only be used with SpectrumWifiPhy");
1646  WifiSpectrumBand convertedSubcarriers;
1647  return convertedSubcarriers;
1648 }
1649 
1650 void
1652 {
1653  NS_LOG_FUNCTION (this);
1655  {
1656  m_powerRestricted = false;
1657  }
1658 }
1659 
1660 void
1662 {
1663  NS_LOG_FUNCTION (this << *event);
1664  NS_ASSERT (!IsStateRx ());
1665  m_interference->NotifyRxEnd (Simulator::Now ());
1666  m_currentEvent = 0;
1667  m_currentPreambleEvents.clear ();
1668  SwitchMaybeToCcaBusy (GetMeasurementChannelWidth (event->GetPpdu ()));
1669 }
1670 
1671 void
1673 {
1674  NS_LOG_FUNCTION (this);
1675  m_channelAccessRequested = true;
1676 }
1677 
1678 bool
1680 {
1681  for (const auto & phyEntity : m_phyEntities)
1682  {
1683  if (phyEntity.second->IsModeSupported (mode))
1684  {
1685  return true;
1686  }
1687  }
1688  return false;
1689 }
1690 
1691 WifiMode
1693 {
1694  //Start from oldest standards and move up (guaranteed by fact that WifModulationClass is ordered)
1695  for (const auto & phyEntity : m_phyEntities)
1696  {
1697  for (const auto & mode : *(phyEntity.second))
1698  {
1699  return mode;
1700  }
1701  }
1702  NS_ASSERT_MSG (false, "Should have found at least one default mode");
1703  return WifiMode ();
1704 }
1705 
1706 bool
1707 WifiPhy::IsMcsSupported (WifiModulationClass modulation, uint8_t mcs) const
1708 {
1709  const auto phyEntity = m_phyEntities.find (modulation);
1710  if (phyEntity == m_phyEntities.end ())
1711  {
1712  return false;
1713  }
1714  return phyEntity->second->IsMcsSupported (mcs);
1715 }
1716 
1717 std::list<WifiMode>
1719 {
1720  std::list<WifiMode> list;
1721  for (const auto & phyEntity : m_phyEntities)
1722  {
1723  if (!phyEntity.second->HandlesMcsModes ()) //to exclude MCSs from search
1724  {
1725  for (const auto & mode : *(phyEntity.second))
1726  {
1727  list.emplace_back (mode);
1728  }
1729  }
1730  }
1731  return list;
1732 }
1733 
1734 std::list<WifiMode>
1736 {
1737  std::list<WifiMode> list;
1738  const auto phyEntity = m_phyEntities.find (modulation);
1739  if (phyEntity != m_phyEntities.end ())
1740  {
1741  if (!phyEntity->second->HandlesMcsModes ()) //to exclude MCSs from search
1742  {
1743  for (const auto & mode : *(phyEntity->second))
1744  {
1745  list.emplace_back (mode);
1746  }
1747  }
1748  }
1749  return list;
1750 }
1751 
1752 uint16_t
1753 WifiPhy::GetNMcs (void) const
1754 {
1755  uint16_t numMcs = 0;
1756  for (const auto & phyEntity : m_phyEntities)
1757  {
1758  if (phyEntity.second->HandlesMcsModes ()) //to exclude non-MCS modes from search
1759  {
1760  numMcs += phyEntity.second->GetNumModes ();
1761  }
1762  }
1763  return numMcs;
1764 }
1765 
1766 std::list<WifiMode>
1768 {
1769  std::list<WifiMode> list;
1770  for (const auto & phyEntity : m_phyEntities)
1771  {
1772  if (phyEntity.second->HandlesMcsModes ()) //to exclude non-MCS modes from search
1773  {
1774  for (const auto & mode : *(phyEntity.second))
1775  {
1776  list.emplace_back (mode);
1777  }
1778  }
1779  }
1780  return list;
1781 }
1782 
1783 std::list<WifiMode>
1785 {
1786  std::list<WifiMode> list;
1787  auto phyEntity = m_phyEntities.find (modulation);
1788  if (phyEntity != m_phyEntities.end ())
1789  {
1790  if (phyEntity->second->HandlesMcsModes ()) //to exclude non-MCS modes from search
1791  {
1792  for (const auto & mode : *(phyEntity->second))
1793  {
1794  list.emplace_back (mode);
1795  }
1796  }
1797  }
1798  return list;
1799 }
1800 
1801 WifiMode
1802 WifiPhy::GetMcs (WifiModulationClass modulation, uint8_t mcs) const
1803 {
1804  NS_ASSERT_MSG (IsMcsSupported (modulation, mcs), "Unsupported MCS");
1805  return m_phyEntities.at (modulation)->GetMcs (mcs);
1806 }
1807 
1808 bool
1810 {
1811  return m_state->IsStateCcaBusy ();
1812 }
1813 
1814 bool
1816 {
1817  return m_state->IsStateIdle ();
1818 }
1819 
1820 bool
1822 {
1823  return m_state->IsStateRx ();
1824 }
1825 
1826 bool
1828 {
1829  return m_state->IsStateTx ();
1830 }
1831 
1832 bool
1834 {
1835  return m_state->IsStateSwitching ();
1836 }
1837 
1838 bool
1840 {
1841  return m_state->IsStateSleep ();
1842 }
1843 
1844 bool
1846 {
1847  return m_state->IsStateOff ();
1848 }
1849 
1850 Time
1852 {
1853  return m_state->GetDelayUntilIdle ();
1854 }
1855 
1856 Time
1858 {
1859  return m_state->GetLastRxStartTime ();
1860 }
1861 
1862 Time
1864 {
1865  return m_state->GetLastRxEndTime ();
1866 }
1867 
1868 void
1869 WifiPhy::SwitchMaybeToCcaBusy (uint16_t channelWidth)
1870 {
1871  NS_LOG_FUNCTION (this << channelWidth);
1872  //We are here because we have received the first bit of a packet and we are
1873  //not going to be able to synchronize on it
1874  //In this model, CCA becomes busy when the aggregation of all signals as
1875  //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
1876  Time delayUntilCcaEnd = m_interference->GetEnergyDuration (m_ccaEdThresholdW, GetPrimaryBand (channelWidth));
1877  if (!delayUntilCcaEnd.IsZero ())
1878  {
1879  NS_LOG_DEBUG ("Calling SwitchMaybeToCcaBusy for " << delayUntilCcaEnd.As (Time::S));
1880  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
1881  }
1882 }
1883 
1884 void
1886 {
1887  NS_LOG_FUNCTION (this << reason);
1888  if (reason != OBSS_PD_CCA_RESET || m_currentEvent) //Otherwise abort has already been called previously
1889  {
1890  for (auto & phyEntity : m_phyEntities)
1891  {
1892  phyEntity.second->CancelAllEvents ();
1893  }
1894  if (m_endPhyRxEvent.IsRunning ())
1895  {
1897  }
1898  m_interference->NotifyRxEnd (Simulator::Now ());
1899  if (!m_currentEvent)
1900  {
1901  return;
1902  }
1903  NotifyRxDrop (GetAddressedPsduInPpdu (m_currentEvent->GetPpdu ()), reason);
1904  if (reason == OBSS_PD_CCA_RESET)
1905  {
1906  m_state->SwitchFromRxAbort ();
1907  }
1908  for (auto it = m_currentPreambleEvents.begin (); it != m_currentPreambleEvents.end (); ++it)
1909  {
1910  if (it->second == m_currentEvent)
1911  {
1912  it = m_currentPreambleEvents.erase (it);
1913  break;
1914  }
1915  }
1916  m_currentEvent = 0;
1917  }
1918 }
1919 
1920 void
1921 WifiPhy::ResetCca (bool powerRestricted, double txPowerMaxSiso, double txPowerMaxMimo)
1922 {
1923  NS_LOG_FUNCTION (this << powerRestricted << txPowerMaxSiso << txPowerMaxMimo);
1924  // This method might be called multiple times when receiving TB PPDUs with a BSS color
1925  // different than the one of the receiver. The first time this method is called, the call
1926  // to AbortCurrentReception sets m_currentEvent to 0. Therefore, we need to check whether
1927  // m_currentEvent is not 0 before executing the instructions below.
1928  if (m_currentEvent != 0)
1929  {
1930  m_powerRestricted = powerRestricted;
1931  m_txPowerMaxSiso = txPowerMaxSiso;
1932  m_txPowerMaxMimo = txPowerMaxMimo;
1933  NS_ASSERT ((m_currentEvent->GetEndTime () - Simulator::Now ()).IsPositive ());
1935  Simulator::ScheduleNow (&WifiPhy::AbortCurrentReception, this, OBSS_PD_CCA_RESET); //finish processing field first
1936  }
1937 }
1938 
1939 double
1941 {
1942  NS_LOG_FUNCTION (this << m_powerRestricted << ppdu);
1943  const WifiTxVector& txVector = ppdu->GetTxVector ();
1944  // Get transmit power before antenna gain
1945  double txPowerDbm;
1946  if (!m_powerRestricted)
1947  {
1948  txPowerDbm = GetPowerDbm (txVector.GetTxPowerLevel ());
1949  }
1950  else
1951  {
1952  if (txVector.GetNssMax () > 1)
1953  {
1954  txPowerDbm = std::min (m_txPowerMaxMimo, GetPowerDbm (txVector.GetTxPowerLevel ()));
1955  }
1956  else
1957  {
1958  txPowerDbm = std::min (m_txPowerMaxSiso, GetPowerDbm (txVector.GetTxPowerLevel ()));
1959  }
1960  }
1961 
1962  //Apply power density constraint on EIRP
1963  uint16_t channelWidth = ppdu->GetTransmissionChannelWidth ();
1964  double txPowerDbmPerMhz = (txPowerDbm + GetTxGain ()) - RatioToDb (channelWidth); //account for antenna gain since EIRP
1965  NS_LOG_INFO ("txPowerDbm=" << txPowerDbm << " with txPowerDbmPerMhz=" << txPowerDbmPerMhz << " over " << channelWidth << " MHz");
1966  txPowerDbm = std::min (txPowerDbmPerMhz, m_powerDensityLimit) + RatioToDb (channelWidth);
1967  txPowerDbm -= GetTxGain (); //remove antenna gain since will be added right afterwards
1968  NS_LOG_INFO ("txPowerDbm=" << txPowerDbm << " after applying m_powerDensityLimit=" << m_powerDensityLimit);
1969  return txPowerDbm;
1970 }
1971 
1974 {
1975  //TODO: wrapper. See if still needed
1976  return GetPhyEntity (ppdu->GetModulation ())->GetAddressedPsduInPpdu (ppdu);
1977 }
1978 
1979 uint16_t
1981 {
1982  if (ppdu == nullptr)
1983  {
1984  // Here because PHY was not receiving anything (e.g. resuming from OFF) nor expecting anything (e.g. sleep)
1985  // nor processing a Wi-Fi signal.
1986  return GetChannelWidth () >= 40 ? 20 : GetChannelWidth ();
1987  }
1988  return GetPhyEntity (ppdu->GetModulation ())->GetMeasurementChannelWidth (ppdu);
1989 }
1990 
1992 WifiPhy::GetBand (uint16_t /*bandWidth*/, uint8_t /*bandIndex*/)
1993 {
1994  WifiSpectrumBand band;
1995  band.first = 0;
1996  band.second = 0;
1997  return band;
1998 }
1999 
2001 WifiPhy::GetPrimaryBand (uint16_t bandWidth)
2002 {
2003  if (GetChannelWidth () % 20 != 0)
2004  {
2005  return GetBand (bandWidth);
2006  }
2007 
2008  return GetBand (bandWidth, m_operatingChannel.GetPrimaryChannelIndex (bandWidth));
2009 }
2010 
2011 int64_t
2012 WifiPhy::AssignStreams (int64_t stream)
2013 {
2014  NS_LOG_FUNCTION (this << stream);
2015  int64_t currentStream = stream;
2016  m_random->SetStream (currentStream++);
2017  currentStream += m_interference->GetErrorRateModel ()->AssignStreams (currentStream);
2018  return (currentStream - stream);
2019 }
2020 
2021 std::ostream& operator<< (std::ostream& os, RxSignalInfo rxSignalInfo)
2022 {
2023  os << "SNR:" << RatioToDb (rxSignalInfo.snr) << " dB"
2024  << ", RSSI:" << rxSignalInfo.rssi << " dBm";
2025  return os;
2026 }
2027 
2028 uint8_t
2029 WifiPhy::GetPrimaryChannelNumber (uint16_t primaryChannelWidth) const
2030 {
2031  return m_operatingChannel.GetPrimaryChannelNumber (primaryChannelWidth, m_standard);
2032 }
2033 
2034 } //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
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:418
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:50
void SetNumberOfAntennas(uint8_t antennas)
Definition: wifi-phy.cc:1077
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Definition: wifi-phy.h:1145
double m_rxGainDb
Reception gain (dB)
Definition: wifi-phy.h:1367
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
Definition: wifi-phy.h:1388
bool IsStateIdle(void) const
Definition: wifi-phy.cc:1815
virtual void SetInterferenceHelper(const Ptr< InterferenceHelper > helper)
Sets the interference helper.
Definition: wifi-phy.cc:566
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
Definition: wifi-phy.h:1380
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:1506
bool IsStateTx(void) const
Definition: wifi-phy.cc:1827
void StartReceivePreamble(Ptr< WifiPpdu > ppdu, RxPowerWattPerChannelBand &rxPowersW, Time rxDuration)
Start receiving the PHY preamble of a PPDU (i.e.
Definition: wifi-phy.cc:1624
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Definition: wifi-phy.h:1144
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:912
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
Definition: wifi-phy.h:1392
virtual ~WifiPhy()
Definition: wifi-phy.cc:333
Time m_channelSwitchDelay
Time required to switch between channel.
Definition: wifi-phy.h:1385
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:1767
void SetCcaEdThreshold(double threshold)
Sets the CCA threshold (dBm).
Definition: wifi-phy.cc:433
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:1313
WifiPhyOperatingChannel m_operatingChannel
Operating channel.
Definition: wifi-phy.h:1355
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:1274
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:1282
void SetErrorRateModel(const Ptr< ErrorRateModel > model)
Sets the error rate model.
Definition: wifi-phy.cc:574
bool m_channelAccessRequested
Flag if channels access has been requested (used for OBSS_PD SR)
Definition: wifi-phy.h:1376
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:1303
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:1251
Ptr< MobilityModel > GetMobility(void) const
Return the mobility model this PHY is associated with.
Definition: wifi-phy.cc:553
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1126
const WifiPhyOperatingChannel & GetOperatingChannel(void) const
Get a const reference to the operating channel.
Definition: wifi-phy.cc:900
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:1973
bool GetShortPhyPreambleSupported(void) const
Return whether short PHY preamble is supported.
Definition: wifi-phy.cc:529
void NotifyTxEnd(WifiConstPsduMap psdus)
Public method used to fire a PhyTxEnd trace.
Definition: wifi-phy.cc:1369
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:1154
Time m_slot
Slot duration.
Definition: wifi-phy.h:1359
double m_powerDensityLimit
the power density limit (dBm/MHz)
Definition: wifi-phy.h:1371
WifiMode GetDefaultMode(void) const
Get the default WifiMode supported by the PHY.
Definition: wifi-phy.cc:1692
std::vector< uint16_t > GetSupportedChannelWidthSet(void) const
Definition: wifi-phy.cc:1174
bool IsStateRx(void) const
Definition: wifi-phy.cc:1821
void SetSifs(Time sifs)
Set the Short Interframe Space (SIFS) for this PHY.
Definition: wifi-phy.cc:670
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:887
EventId m_endPhyRxEvent
the end of PHY receive event
Definition: wifi-phy.h:1150
double m_txPowerBaseDbm
Minimum transmission power (dBm)
Definition: wifi-phy.h:1368
Ptr< WifiPhyStateHelper > GetState(void) const
Return the WifiPhyStateHelper of this PHY.
Definition: wifi-phy.cc:384
Ptr< WifiNetDevice > GetDevice(void) const
Return the device this PHY is associated with.
Definition: wifi-phy.cc:541
void NotifyRxDrop(Ptr< const WifiPsdu > psdu, WifiPhyRxfailureReason reason)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:1420
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:1707
WifiStandard GetStandard(void) const
Get the configured Wi-Fi standard.
Definition: wifi-phy.cc:894
virtual void DoDispose(void)
Destructor implementation.
Definition: wifi-phy.cc:339
Time m_blockAckTxTime
estimated BlockAck TX time
Definition: wifi-phy.h:1362
uint8_t GetPrimaryChannelNumber(uint16_t primaryChannelWidth) const
Get channel number of the primary channel.
Definition: wifi-phy.cc:2029
void Configure80211a(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
Definition: wifi-phy.cc:718
std::list< uint8_t > GetBssMembershipSelectorList(void) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1144
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:1921
double m_txPowerMaxMimo
MIMO maximum transmit power due to OBSS PD SR power restriction (dBm)
Definition: wifi-phy.h:1375
Time GetSlot(void) const
Return the slot duration for this PHY.
Definition: wifi-phy.cc:688
void AbortCurrentReception(WifiPhyRxfailureReason reason)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted.
Definition: wifi-phy.cc:1885
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
Definition: wifi-phy.h:1390
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition: wifi-phy.h:1306
void NotifyRxBegin(Ptr< const WifiPsdu > psdu, const RxPowerWattPerChannelBand &rxPowersW)
Public method used to fire a PhyRxBegin trace.
Definition: wifi-phy.cc:1396
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1095
uint16_t GetMeasurementChannelWidth(const Ptr< const WifiPpdu > ppdu) const
Return the channel width used to measure the RSSI.
Definition: wifi-phy.cc:1980
double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:477
Time m_sifs
Short Interframe Space (SIFS) duration.
Definition: wifi-phy.h:1358
void SetReceiveErrorCallback(RxErrorCallback callback)
Definition: wifi-phy.cc:396
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:1661
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:835
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1138
void SetPostReceptionErrorModel(const Ptr< ErrorModel > em)
Attach a receive ErrorModel to the WifiPhy.
Definition: wifi-phy.cc:581
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:1802
uint8_t m_numberOfAntennas
Number of transmitters.
Definition: wifi-phy.h:1379
ChannelTuple m_channelSettings
Store operating channel settings until initialization.
Definition: wifi-phy.h:1354
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition: wifi-phy.cc:1327
Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
Definition: wifi-phy.cc:1857
Time GetBlockAckTxTime(void) const
Return the estimated BlockAck TX time for this PHY.
Definition: wifi-phy.cc:712
void Configure80211p(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11p standard.
Definition: wifi-phy.cc:763
Time GetPifs(void) const
Return the PCF Interframe Space (PIFS) for this PHY.
Definition: wifi-phy.cc:700
static uint32_t GetMaxPsduSize(WifiModulationClass modulation)
Get the maximum PSDU size in bytes for the given modulation class.
Definition: wifi-phy.cc:1348
void NotifyTxBegin(WifiConstPsduMap psdus, double txPowerW)
Public method used to fire a PhyTxBegin trace.
Definition: wifi-phy.cc:1354
void Reset(void)
Reset data upon end of TX or RX.
Definition: wifi-phy.cc:1611
void SetShortPhyPreambleSupported(bool preamble)
Enable or disable short PHY preamble.
Definition: wifi-phy.cc:522
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:483
static TypeId GetTypeId(void)
Get the type ID.
Definition: wifi-phy.cc:57
WifiPhyBand m_band
WifiPhyBand.
Definition: wifi-phy.h:1353
void Configure80211b(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
Definition: wifi-phy.cc:733
void SetSleepMode(void)
Put in sleep mode.
Definition: wifi-phy.cc:1180
void SetRxSensitivity(double threshold)
Sets the receive sensitivity threshold (dBm).
Definition: wifi-phy.cc:420
uint8_t GetPrimary20Index(void) const
Definition: wifi-phy.cc:924
static const Ptr< const PhyEntity > GetStaticPhyEntity(WifiModulationClass modulation)
Get the implemented PHY entity corresponding to the modulation class.
Definition: wifi-phy.cc:636
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1120
void Configure80211g(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
Definition: wifi-phy.cc:750
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:1341
Time GetChannelSwitchDelay(void) const
Definition: wifi-phy.cc:624
virtual WifiSpectrumBand ConvertHeRuSubcarriers(uint16_t bandWidth, uint16_t guardBandwidth, HeRu::SubcarrierRange range, uint8_t bandIndex=0) const
Definition: wifi-phy.cc:1642
double m_txPowerMaxSiso
SISO maximum transmit power due to OBSS PD SR power restriction (dBm)
Definition: wifi-phy.h:1374
std::map< WifiModulationClass, Ptr< PhyEntity > > m_phyEntities
This map holds the supported PHY entities.
Definition: wifi-phy.h:1175
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:660
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:1327
Ptr< ErrorModel > m_postReceptionErrorModel
Error model for receive packet events.
Definition: wifi-phy.h:1393
double GetTxPowerStart(void) const
Return the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:464
EventId m_endTxEvent
the end of transmit event
Definition: wifi-phy.h:1151
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:1500
uint16_t GetNMcs(void) const
Definition: wifi-phy.cc:1753
void SetSlot(Time slot)
Set the slot duration for this PHY.
Definition: wifi-phy.cc:682
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
Definition: wifi-phy.cc:930
Ptr< Event > m_currentEvent
Hold the current event.
Definition: wifi-phy.h:1153
double m_ccaEdThresholdW
Clear channel assessment (CCA) threshold in watts.
Definition: wifi-phy.h:1365
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:1469
Ptr< PhyEntity > GetPhyEntity(WifiModulationClass modulation) const
Get the supported PHY entity corresponding to the modulation class, for the WifiPhy instance.
Definition: wifi-phy.cc:644
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:1992
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium.
Definition: wifi-phy.h:1266
void ResumeFromSleep(void)
Resume from sleep mode.
Definition: wifi-phy.cc:1229
uint64_t m_previouslyRxPpduUid
UID of the previously received PPDU, reset to UINT64_MAX upon transmission.
Definition: wifi-phy.h:1156
void Configure80211ac(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard.
Definition: wifi-phy.cc:812
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU.
Definition: wifi-phy.h:1148
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
Definition: wifi-phy.cc:600
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:535
void NotifyChannelAccessRequested(void)
Notify the PHY that an access to the channel was requested.
Definition: wifi-phy.cc:1672
Ptr< PreambleDetectionModel > m_preambleDetectionModel
Preamble detection model.
Definition: wifi-phy.h:1391
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1089
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:1869
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:470
static std::map< WifiModulationClass, Ptr< PhyEntity > > & GetStaticPhyEntities(void)
Definition: wifi-phy.cc:377
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:652
void NotifyRxEnd(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyRxEnd trace.
Definition: wifi-phy.cc:1408
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:1718
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:1258
double m_txGainDb
Transmission gain (dB)
Definition: wifi-phy.h:1366
std::vector< uint16_t > m_supportedChannelWidthSet
Supported channel width set (MHz)
Definition: wifi-phy.h:1356
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:2001
Time GetDelayUntilIdle(void)
Definition: wifi-phy.cc:1851
uint64_t GetPreviouslyRxPpduUid(void) const
Definition: wifi-phy.cc:1605
WifiStandard m_standard
WifiStandard.
Definition: wifi-phy.h:1352
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:606
uint8_t m_nTxPower
Number of available transmission power levels.
Definition: wifi-phy.h:1370
double m_noiseFigureDb
The noise figure in dB.
Definition: wifi-phy.h:1383
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
Definition: wifi-phy.cc:594
void SetPifs(Time pifs)
Set the PCF Interframe Space (PIFS) for this PHY.
Definition: wifi-phy.cc:694
Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
Definition: wifi-phy.cc:676
static Time GetStartOfPacketDuration(const WifiTxVector &txVector)
Definition: wifi-phy.cc:1297
virtual void StartTx(Ptr< WifiPpdu > ppdu)=0
Time GetAckTxTime(void) const
Return the estimated Ack TX time for this PHY.
Definition: wifi-phy.cc:706
void UnregisterListener(WifiPhyListener *listener)
Definition: wifi-phy.cc:408
void SetRxGain(double gain)
Sets the reception gain (dB).
Definition: wifi-phy.cc:509
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:547
double GetRxGain(void) const
Return the reception gain (dB).
Definition: wifi-phy.cc:516
void SetTxGain(double gain)
Sets the transmission gain (dB).
Definition: wifi-phy.cc:496
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
Definition: wifi-phy.h:1381
double m_txPowerEndDbm
Maximum transmission power (dBm)
Definition: wifi-phy.h:1369
void SetOffMode(void)
Put in off mode.
Definition: wifi-phy.cc:1214
double CalculateSnr(const WifiTxVector &txVector, double ber) const
Definition: wifi-phy.cc:630
void Configure80211n(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
Definition: wifi-phy.cc:793
bool IsStateSwitching(void) const
Definition: wifi-phy.cc:1833
double GetTxGain(void) const
Return the transmission gain (dB).
Definition: wifi-phy.cc:503
uint8_t GetNTxPower(void) const
Return the number of available transmission power levels.
Definition: wifi-phy.cc:490
Time GetDelayUntilChannelSwitch(void)
Perform any actions necessary when user changes operating channel after initialization.
Definition: wifi-phy.cc:970
void EndReceiveInterBss(void)
For HE receptions only, check and possibly modify the transmit power restriction state at the end of ...
Definition: wifi-phy.cc:1651
double GetCcaEdThreshold(void) const
Return the CCA threshold (dBm).
Definition: wifi-phy.cc:440
double GetRxSensitivity(void) const
Return the receive sensitivity threshold (dBm).
Definition: wifi-phy.cc:427
void RegisterListener(WifiPhyListener *listener)
Definition: wifi-phy.cc:402
Ptr< WifiNetDevice > m_device
Pointer to the device.
Definition: wifi-phy.h:1387
Ptr< InterferenceHelper > m_interference
Pointer to a helper responsible for interference computations.
Definition: wifi-phy.h:1142
bool IsStateSleep(void) const
Definition: wifi-phy.cc:1839
bool IsStateCcaBusy(void) const
Definition: wifi-phy.cc:1809
bool m_shortPreamble
Flag if short PHY preamble is supported.
Definition: wifi-phy.h:1378
Time m_pifs
PCF Interframe Space (PIFS) duration.
Definition: wifi-phy.h:1360
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:446
double GetTxPowerForTransmission(Ptr< const WifiPpdu > ppdu) const
Compute the transmit power for the next transmission.
Definition: wifi-phy.cc:1940
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition: wifi-phy.cc:414
void SetReceiveOkCallback(RxOkCallback callback)
Definition: wifi-phy.cc:390
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
Definition: wifi-phy.cc:588
void ResumeFromOff(void)
Resume from off mode.
Definition: wifi-phy.cc:1260
void Configure80211ax(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard.
Definition: wifi-phy.cc:820
bool m_powerRestricted
Flag whether transmit power is restricted by OBSS PD SR.
Definition: wifi-phy.h:1373
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
Definition: wifi-phy.h:1396
void AddSupportedChannelWidth(uint16_t width)
Definition: wifi-phy.cc:1159
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:1432
virtual void DoChannelSwitch(void)
Actually switch channel based on the stored channel settings.
Definition: wifi-phy.cc:1021
TracedCallback< WifiTxVector, Time > m_phyRxPayloadBeginTrace
The trace source fired when the reception of the PHY payload (PSDU) begins.
Definition: wifi-phy.h:1298
static Time GetPreambleDetectionDuration(void)
Definition: wifi-phy.cc:1291
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
Definition: wifi-phy.h:833
double m_rxSensitivityW
Receive sensitivity threshold in watts.
Definition: wifi-phy.h:1364
Time GetLastRxEndTime(void) const
Return the end time of the last received packet.
Definition: wifi-phy.cc:1863
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:918
bool IsStateOff(void) const
Definition: wifi-phy.cc:1845
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:457
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:2012
static Time CalculatePhyPreambleAndHeaderDuration(const WifiTxVector &txVector)
Definition: wifi-phy.cc:1321
bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
Definition: wifi-phy.cc:1679
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:906
Time m_ackTxTime
estimated Ack TX time
Definition: wifi-phy.h:1361
void NotifyTxDrop(Ptr< const WifiPsdu > psdu)
Public method used to fire a PhyTxDrop trace.
Definition: wifi-phy.cc:1384
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...
uint8_t GetPrimaryChannelNumber(uint16_t primaryChannelWidth, WifiStandard standard) const
Get channel number of the primary channel.
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.
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)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: boolean.h:85
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:42
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:227
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:1309
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:45
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#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.
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
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:37
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
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:522
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.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:139
double DbToRatio(double dB)
Convert from dB to ratio.
Definition: wifi-utils.cc:31
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:415
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.