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 "wifi-phy.h"
23 #include "ns3/simulator.h"
24 #include "ns3/log.h"
25 #include "ns3/boolean.h"
26 #include "ns3/double.h"
27 #include "ns3/uinteger.h"
28 #include "ns3/pointer.h"
29 #include "wifi-phy-tag.h"
30 #include "ampdu-tag.h"
31 #include "wifi-utils.h"
32 #include "frame-capture-model.h"
34 
35 namespace ns3 {
36 
37 NS_LOG_COMPONENT_DEFINE ("WifiPhy");
38 
39 /****************************************************************
40  * The actual WifiPhy class
41  ****************************************************************/
42 
44 
54 {
55  // 802.11b uses width of 22, while OFDM modes use width of 20
56  { std::make_pair (1, WIFI_PHY_STANDARD_80211b), std::make_pair (2412, 22) },
57  { std::make_pair (1, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2412, 20) },
58  { std::make_pair (2, WIFI_PHY_STANDARD_80211b), std::make_pair (2417, 22) },
59  { std::make_pair (2, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2417, 20) },
60  { std::make_pair (3, WIFI_PHY_STANDARD_80211b), std::make_pair (2422, 22) },
61  { std::make_pair (3, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2422, 20) },
62  { std::make_pair (4, WIFI_PHY_STANDARD_80211b), std::make_pair (2427, 22) },
63  { std::make_pair (4, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2427, 20) },
64  { std::make_pair (5, WIFI_PHY_STANDARD_80211b), std::make_pair (2432, 22) },
65  { std::make_pair (5, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2432, 20) },
66  { std::make_pair (6, WIFI_PHY_STANDARD_80211b), std::make_pair (2437, 22) },
67  { std::make_pair (6, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2437, 20) },
68  { std::make_pair (7, WIFI_PHY_STANDARD_80211b), std::make_pair (2442, 22) },
69  { std::make_pair (7, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2442, 20) },
70  { std::make_pair (8, WIFI_PHY_STANDARD_80211b), std::make_pair (2447, 22) },
71  { std::make_pair (8, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2447, 20) },
72  { std::make_pair (9, WIFI_PHY_STANDARD_80211b), std::make_pair (2452, 22) },
73  { std::make_pair (9, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2452, 20) },
74  { std::make_pair (10, WIFI_PHY_STANDARD_80211b), std::make_pair (2457, 22) },
75  { std::make_pair (10, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2457, 20) },
76  { std::make_pair (11, WIFI_PHY_STANDARD_80211b), std::make_pair (2462, 22) },
77  { std::make_pair (11, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2462, 20) },
78  { std::make_pair (12, WIFI_PHY_STANDARD_80211b), std::make_pair (2467, 22) },
79  { std::make_pair (12, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2467, 20) },
80  { std::make_pair (13, WIFI_PHY_STANDARD_80211b), std::make_pair (2472, 22) },
81  { std::make_pair (13, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2472, 20) },
82  // Only defined for 802.11b
83  { std::make_pair (14, WIFI_PHY_STANDARD_80211b), std::make_pair (2484, 22) },
84 
85  // Now the 5GHz channels; UNSPECIFIED for 802.11a/n/ac/ax channels
86  // 20 MHz channels
87  { std::make_pair (36, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5180, 20) },
88  { std::make_pair (40, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5200, 20) },
89  { std::make_pair (44, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5220, 20) },
90  { std::make_pair (48, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5240, 20) },
91  { std::make_pair (52, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5260, 20) },
92  { std::make_pair (56, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5280, 20) },
93  { std::make_pair (60, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5300, 20) },
94  { std::make_pair (64, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5320, 20) },
95  { std::make_pair (100, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5500, 20) },
96  { std::make_pair (104, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5520, 20) },
97  { std::make_pair (108, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5540, 20) },
98  { std::make_pair (112, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5560, 20) },
99  { std::make_pair (116, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5580, 20) },
100  { std::make_pair (120, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5600, 20) },
101  { std::make_pair (124, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5620, 20) },
102  { std::make_pair (128, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5640, 20) },
103  { std::make_pair (132, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5660, 20) },
104  { std::make_pair (136, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5680, 20) },
105  { std::make_pair (140, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5700, 20) },
106  { std::make_pair (144, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5720, 20) },
107  { std::make_pair (149, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5745, 20) },
108  { std::make_pair (153, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5765, 20) },
109  { std::make_pair (157, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5785, 20) },
110  { std::make_pair (161, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5805, 20) },
111  { std::make_pair (165, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5825, 20) },
112  // 40 MHz channels
113  { std::make_pair (38, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5190, 40) },
114  { std::make_pair (46, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5230, 40) },
115  { std::make_pair (54, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5230, 40) },
116  { std::make_pair (62, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5310, 40) },
117  { std::make_pair (102, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5510, 40) },
118  { std::make_pair (110, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5550, 40) },
119  { std::make_pair (118, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5590, 40) },
120  { std::make_pair (126, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5590, 40) },
121  { std::make_pair (134, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5670, 40) },
122  { std::make_pair (142, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5710, 40) },
123  { std::make_pair (151, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5755, 40) },
124  { std::make_pair (159, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5795, 40) },
125  // 80 MHz channels
126  { std::make_pair (42, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5210, 80) },
127  { std::make_pair (58, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5290, 80) },
128  { std::make_pair (106, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5530, 80) },
129  { std::make_pair (122, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5610, 80) },
130  { std::make_pair (138, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5690, 80) },
131  { std::make_pair (155, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5775, 80) },
132  // 160 MHz channels
133  { std::make_pair (50, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5250, 160) },
134  { std::make_pair (114, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5570, 160) },
135 
136  // 802.11p (10 MHz channels at the 5.855-5.925 band
137  { std::make_pair (172, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5860, 10) },
138  { std::make_pair (174, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5870, 10) },
139  { std::make_pair (176, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5880, 10) },
140  { std::make_pair (178, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5890, 10) },
141  { std::make_pair (180, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5900, 10) },
142  { std::make_pair (182, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5910, 10) },
143  { std::make_pair (184, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5920, 10) }
144 };
145 
146 TypeId
148 {
149  static TypeId tid = TypeId ("ns3::WifiPhy")
150  .SetParent<Object> ()
151  .SetGroupName ("Wifi")
152  .AddAttribute ("Frequency",
153  "The operating center frequency (MHz)",
154  UintegerValue (0),
157  MakeUintegerChecker<uint16_t> ())
158  .AddAttribute ("ChannelWidth",
159  "Whether 5MHz, 10MHz, 20MHz, 22MHz, 40MHz, 80 MHz or 160 MHz.",
160  UintegerValue (20),
163  MakeUintegerChecker<uint8_t> (5, 160))
164  .AddAttribute ("ChannelNumber",
165  "If set to non-zero defined value, will control Frequency and ChannelWidth assignment",
166  UintegerValue (0),
169  MakeUintegerChecker<uint8_t> (0, 196))
170  .AddAttribute ("EnergyDetectionThreshold",
171  "The energy of a received signal should be higher than "
172  "this threshold (dbm) to allow the PHY layer to detect the signal.",
173  DoubleValue (-96.0),
176  MakeDoubleChecker<double> ())
177  .AddAttribute ("CcaMode1Threshold",
178  "The energy of a received signal should be higher than "
179  "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.",
180  DoubleValue (-99.0),
183  MakeDoubleChecker<double> ())
184  .AddAttribute ("TxGain",
185  "Transmission gain (dB).",
186  DoubleValue (0.0),
189  MakeDoubleChecker<double> ())
190  .AddAttribute ("RxGain",
191  "Reception gain (dB).",
192  DoubleValue (0.0),
195  MakeDoubleChecker<double> ())
196  .AddAttribute ("TxPowerLevels",
197  "Number of transmission power levels available between "
198  "TxPowerStart and TxPowerEnd included.",
199  UintegerValue (1),
201  MakeUintegerChecker<uint8_t> ())
202  .AddAttribute ("TxPowerEnd",
203  "Maximum available transmission level (dbm).",
204  DoubleValue (16.0206),
207  MakeDoubleChecker<double> ())
208  .AddAttribute ("TxPowerStart",
209  "Minimum available transmission level (dbm).",
210  DoubleValue (16.0206),
213  MakeDoubleChecker<double> ())
214  .AddAttribute ("RxNoiseFigure",
215  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
216  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
217  "\"the difference in decibels (dB) between"
218  " the noise output of the actual receiver to the noise output of an "
219  " ideal receiver with the same overall gain and bandwidth when the receivers "
220  " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
221  DoubleValue (7),
224  MakeDoubleChecker<double> ())
225  .AddAttribute ("State",
226  "The state of the PHY layer.",
227  PointerValue (),
229  MakePointerChecker<WifiPhyStateHelper> ())
230  .AddAttribute ("ChannelSwitchDelay",
231  "Delay between two short frames transmitted on different frequencies.",
232  TimeValue (MicroSeconds (250)),
234  MakeTimeChecker ())
235  .AddAttribute ("Antennas",
236  "The number of antennas on the device.",
237  UintegerValue (1),
240  MakeUintegerChecker<uint8_t> (1, 8))
241  .AddAttribute ("MaxSupportedTxSpatialStreams",
242  "The maximum number of supported TX spatial streams."
243  "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
244  UintegerValue (1),
247  MakeUintegerChecker<uint8_t> (1, 8))
248  .AddAttribute ("MaxSupportedRxSpatialStreams",
249  "The maximum number of supported RX spatial streams."
250  "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
251  UintegerValue (1),
254  MakeUintegerChecker<uint8_t> (1, 8))
255  .AddAttribute ("ShortGuardEnabled",
256  "Whether or not short guard interval is enabled for HT/VHT transmissions."
257  "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
258  BooleanValue (false),
262  .AddAttribute ("GuardInterval",
263  "Whether 800ns, 1600ns or 3200ns guard interval is used for HE transmissions."
264  "This parameter is only valuable for 802.11ax STAs and APs.",
265  TimeValue (NanoSeconds (3200)),
268  MakeTimeChecker (NanoSeconds (400), NanoSeconds (3200)))
269  .AddAttribute ("LdpcEnabled",
270  "Whether or not LDPC is enabled (not supported yet!).",
271  BooleanValue (false),
275  .AddAttribute ("STBCEnabled",
276  "Whether or not STBC is enabled (not supported yet!).",
277  BooleanValue (false),
281  .AddAttribute ("GreenfieldEnabled",
282  "Whether or not Greenfield is enabled."
283  "This parameter is only valuable for 802.11n STAs and APs.",
284  BooleanValue (false),
288  .AddAttribute ("ShortPlcpPreambleSupported",
289  "Whether or not short PLCP preamble is supported."
290  "This parameter is only valuable for 802.11b STAs and APs."
291  "Note: 802.11g APs and STAs always support short PLCP preamble.",
292  BooleanValue (false),
296  .AddAttribute ("FrameCaptureModel",
297  "Ptr to an object that implements the frame capture model",
298  PointerValue (0), //StringValue ("ns3::SimpleFrameCaptureModel"),
301  MakePointerChecker <FrameCaptureModel> ())
302  .AddTraceSource ("PhyTxBegin",
303  "Trace source indicating a packet "
304  "has begun transmitting over the channel medium",
306  "ns3::Packet::TracedCallback")
307  .AddTraceSource ("PhyTxEnd",
308  "Trace source indicating a packet "
309  "has been completely transmitted over the channel. "
310  "NOTE: the only official WifiPhy implementation "
311  "available to this date never fires "
312  "this trace source.",
314  "ns3::Packet::TracedCallback")
315  .AddTraceSource ("PhyTxDrop",
316  "Trace source indicating a packet "
317  "has been dropped by the device during transmission",
319  "ns3::Packet::TracedCallback")
320  .AddTraceSource ("PhyRxBegin",
321  "Trace source indicating a packet "
322  "has begun being received from the channel medium "
323  "by the device",
325  "ns3::Packet::TracedCallback")
326  .AddTraceSource ("PhyRxEnd",
327  "Trace source indicating a packet "
328  "has been completely received from the channel medium "
329  "by the device",
331  "ns3::Packet::TracedCallback")
332  .AddTraceSource ("PhyRxDrop",
333  "Trace source indicating a packet "
334  "has been dropped by the device during reception",
336  "ns3::Packet::TracedCallback")
337  .AddTraceSource ("MonitorSnifferRx",
338  "Trace source simulating a wifi device in monitor mode "
339  "sniffing all received frames",
341  "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
342  .AddTraceSource ("MonitorSnifferTx",
343  "Trace source simulating the capability of a wifi device "
344  "in monitor mode to sniff all frames being transmitted",
346  "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
347  ;
348  return tid;
349 }
350 
352  : m_mpdusNum (0),
353  m_plcpSuccess (false),
354  m_txMpduReferenceNumber (0xffffffff),
355  m_rxMpduReferenceNumber (0xffffffff),
356  m_endRxEvent (),
357  m_endPlcpRxEvent (),
358  m_standard (WIFI_PHY_STANDARD_UNSPECIFIED),
359  m_isConstructed (false),
360  m_channelCenterFrequency (0),
361  m_initialFrequency (0),
362  m_frequencyChannelNumberInitialized (false),
363  m_channelNumber (0),
364  m_initialChannelNumber (0),
365  m_totalAmpduSize (0),
366  m_totalAmpduNumSymbols (0),
367  m_currentEvent (0),
368  m_wifiRadioEnergyModel (0)
369 {
370  NS_LOG_FUNCTION (this);
371  m_random = CreateObject<UniformRandomVariable> ();
372  m_state = CreateObject<WifiPhyStateHelper> ();
373 }
374 
376 {
377  NS_LOG_FUNCTION (this);
378 }
379 
380 void
382 {
383  NS_LOG_FUNCTION (this);
384  m_device = 0;
385  m_mobility = 0;
386  m_state = 0;
388  m_deviceRateSet.clear ();
389  m_deviceMcsSet.clear ();
390 }
391 
392 void
394 {
395  NS_LOG_FUNCTION (this);
396  m_isConstructed = true;
398  {
399  NS_LOG_DEBUG ("Frequency already initialized");
400  return;
401  }
403 }
404 
405 void
407 {
408  m_state->SetReceiveOkCallback (callback);
409 }
410 
411 void
413 {
414  m_state->SetReceiveErrorCallback (callback);
415 }
416 
417 void
419 {
420  m_state->RegisterListener (listener);
421 }
422 
423 void
425 {
426  m_state->UnregisterListener (listener);
427 }
428 
429 void
431 {
433 }
434 
435 void
437 {
438  NS_LOG_FUNCTION (this);
439 
440  NS_ASSERT_MSG (m_frequencyChannelNumberInitialized == false, "Initialization called twice");
441 
442  // If frequency has been set to a non-zero value during attribute
443  // construction phase, the frequency and channel width will drive the
444  // initial configuration. If frequency has not been set, but both
445  // standard and channel number have been set, that pair will instead
446  // drive the configuration, and frequency and channel number will be
447  // aligned
448  if (m_initialFrequency != 0)
449  {
451  }
453  {
455  }
457  {
458  NS_FATAL_ERROR ("Error, ChannelNumber " << +GetChannelNumber () << " was set by user, but neither a standard nor a frequency");
459  }
461 }
462 
463 void
464 WifiPhy::SetEdThreshold (double threshold)
465 {
466  NS_LOG_FUNCTION (this << threshold);
467  m_edThresholdW = DbmToW (threshold);
468 }
469 
470 double
472 {
473  return m_edThresholdW;
474 }
475 
476 double
478 {
479  return WToDbm (m_edThresholdW);
480 }
481 
482 void
484 {
485  NS_LOG_FUNCTION (this << threshold);
486  m_ccaMode1ThresholdW = DbmToW (threshold);
487 }
488 
489 double
491 {
492  return WToDbm (m_ccaMode1ThresholdW);
493 }
494 
495 void
496 WifiPhy::SetRxNoiseFigure (double noiseFigureDb)
497 {
498  NS_LOG_FUNCTION (this << noiseFigureDb);
499  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
501 }
502 
503 double
505 {
507 }
508 
509 void
511 {
512  NS_LOG_FUNCTION (this << start);
514 }
515 
516 double
518 {
519  return m_txPowerBaseDbm;
520 }
521 
522 void
524 {
525  NS_LOG_FUNCTION (this << end);
526  m_txPowerEndDbm = end;
527 }
528 
529 double
531 {
532  return m_txPowerEndDbm;
533 }
534 
535 void
537 {
538  NS_LOG_FUNCTION (this << +n);
539  m_nTxPower = n;
540 }
541 
542 uint8_t
544 {
545  return m_nTxPower;
546 }
547 
548 void
549 WifiPhy::SetTxGain (double gain)
550 {
551  NS_LOG_FUNCTION (this << gain);
552  m_txGainDb = gain;
553 }
554 
555 double
556 WifiPhy::GetTxGain (void) const
557 {
558  return m_txGainDb;
559 }
560 
561 void
562 WifiPhy::SetRxGain (double gain)
563 {
564  NS_LOG_FUNCTION (this << gain);
565  m_rxGainDb = gain;
566 }
567 
568 double
569 WifiPhy::GetRxGain (void) const
570 {
571  return m_rxGainDb;
572 }
573 
574 void
575 WifiPhy::SetLdpc (bool ldpc)
576 {
577  NS_LOG_FUNCTION (this << ldpc);
578  m_ldpc = ldpc;
579 }
580 
581 bool
582 WifiPhy::GetLdpc (void) const
583 {
584  return m_ldpc;
585 }
586 
587 void
588 WifiPhy::SetStbc (bool stbc)
589 {
590  NS_LOG_FUNCTION (this << stbc);
591  m_stbc = stbc;
592 }
593 
594 bool
595 WifiPhy::GetStbc (void) const
596 {
597  return m_stbc;
598 }
599 
600 void
601 WifiPhy::SetGreenfield (bool greenfield)
602 {
603  NS_LOG_FUNCTION (this << greenfield);
604  m_greenfield = greenfield;
605 }
606 
607 bool
609 {
610  return m_greenfield;
611 }
612 
613 void
614 WifiPhy::SetShortGuardInterval (bool shortGuardInterval)
615 {
616  NS_LOG_FUNCTION (this << shortGuardInterval);
617  m_shortGuardInterval = shortGuardInterval;
618 }
619 
620 bool
622 {
623  return m_shortGuardInterval;
624 }
625 
626 void
628 {
629  NS_LOG_FUNCTION (this << guardInterval);
630  NS_ASSERT (guardInterval == NanoSeconds (800) || guardInterval == NanoSeconds (1600) || guardInterval == NanoSeconds (3200));
631  m_guardInterval = guardInterval;
632 }
633 
634 Time
636 {
637  return m_guardInterval;
638 }
639 
640 void
642 {
643  NS_LOG_FUNCTION (this << enable);
644  m_shortPreamble = enable;
645 }
646 
647 bool
649 {
650  return m_shortPreamble;
651 }
652 
653 void
655 {
656  m_device = device;
657 }
658 
660 WifiPhy::GetDevice (void) const
661 {
662  return m_device;
663 }
664 
665 void
667 {
669 }
670 
673 {
674  if (m_mobility != 0)
675  {
676  return m_mobility;
677  }
678  else
679  {
680  return m_device->GetNode ()->GetObject<MobilityModel> ();
681  }
682 }
683 
684 void
686 {
689 }
690 
693 {
695 }
696 
697 void
699 {
700  m_frameCaptureModel = model;
701 }
702 
705 {
706  return m_frameCaptureModel;
707 }
708 
709 void
711 {
712  m_wifiRadioEnergyModel = wifiRadioEnergyModel;
713 }
714 
715 double
716 WifiPhy::GetPowerDbm (uint8_t power) const
717 {
719  NS_ASSERT (m_nTxPower > 0);
720  double dbm;
721  if (m_nTxPower > 1)
722  {
723  dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
724  }
725  else
726  {
727  NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
728  dbm = m_txPowerBaseDbm;
729  }
730  return dbm;
731 }
732 
733 Time
735 {
736  return m_channelSwitchDelay;
737 }
738 
739 double
740 WifiPhy::CalculateSnr (WifiTxVector txVector, double ber) const
741 {
742  return m_interference.GetErrorRateModel ()->CalculateSnr (txVector, ber);
743 }
744 
745 void
747 {
748  NS_LOG_FUNCTION (this << standard);
749  switch (standard)
750  {
752  SetChannelWidth (20);
753  SetFrequency (5180);
754  // Channel number should be aligned by SetFrequency () to 36
755  NS_ASSERT (GetChannelNumber () == 36);
756  break;
758  SetChannelWidth (22);
759  SetFrequency (2412);
760  // Channel number should be aligned by SetFrequency () to 1
761  NS_ASSERT (GetChannelNumber () == 1);
762  break;
764  SetChannelWidth (20);
765  SetFrequency (2412);
766  // Channel number should be aligned by SetFrequency () to 1
767  NS_ASSERT (GetChannelNumber () == 1);
768  break;
770  SetChannelWidth (10);
771  SetFrequency (5860);
772  // Channel number should be aligned by SetFrequency () to 172
773  NS_ASSERT (GetChannelNumber () == 172);
774  break;
776  SetChannelWidth (5);
777  SetFrequency (5860);
778  // Channel number should be aligned by SetFrequency () to 0
779  NS_ASSERT (GetChannelNumber () == 0);
780  break;
782  SetChannelWidth (20);
783  SetFrequency (5180);
784  // Channel number should be aligned by SetFrequency () to 36
785  NS_ASSERT (GetChannelNumber () == 36);
786  break;
788  SetChannelWidth (20);
789  SetFrequency (2412);
790  // Channel number should be aligned by SetFrequency () to 1
791  NS_ASSERT (GetChannelNumber () == 1);
792  break;
794  SetChannelWidth (20);
795  SetFrequency (5180);
796  // Channel number should be aligned by SetFrequency () to 36
797  NS_ASSERT (GetChannelNumber () == 36);
798  break;
800  SetChannelWidth (80);
801  SetFrequency (5210);
802  // Channel number should be aligned by SetFrequency () to 42
803  NS_ASSERT (GetChannelNumber () == 42);
804  break;
806  SetChannelWidth (20);
807  SetFrequency (2412);
808  // Channel number should be aligned by SetFrequency () to 1
809  NS_ASSERT (GetChannelNumber () == 1);
810  break;
812  SetChannelWidth (80);
813  SetFrequency (5210);
814  // Channel number should be aligned by SetFrequency () to 42
815  NS_ASSERT (GetChannelNumber () == 42);
816  break;
818  NS_LOG_WARN ("Configuring unspecified standard; performing no action");
819  break;
820  default:
821  NS_ASSERT (false);
822  break;
823  }
824 }
825 
826 void
828 {
829  NS_LOG_FUNCTION (this);
830 
839 }
840 
841 void
843 {
844  NS_LOG_FUNCTION (this);
845 
850 }
851 
852 void
854 {
855  NS_LOG_FUNCTION (this);
856  Configure80211b ();
857 
866 }
867 
868 void
870 {
871  NS_LOG_FUNCTION (this);
872 
881 }
882 
883 void
885 {
886  NS_LOG_FUNCTION (this);
887 
896 }
897 
898 void
900 {
901  NS_LOG_FUNCTION (this);
902 
908 }
909 
910 void
912 {
913  NS_LOG_FUNCTION (this);
914 
915  bool htFound = false;
916  for (std::vector<uint8_t>::size_type i = 0; i < m_bssMembershipSelectorSet.size (); i++)
917  {
919  {
920  htFound = true;
921  break;
922  }
923  }
924  if (htFound)
925  {
926  // erase all HtMcs modes from deviceMcsSet
927  size_t index = m_deviceMcsSet.size () - 1;
928  for (std::vector<WifiMode>::reverse_iterator rit = m_deviceMcsSet.rbegin (); rit != m_deviceMcsSet.rend (); ++rit, --index)
929  {
930  if (m_deviceMcsSet[index].GetModulationClass () == WIFI_MOD_CLASS_HT)
931  {
932  m_deviceMcsSet.erase (m_deviceMcsSet.begin () + index);
933  }
934  }
935  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs0 ());
936  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs1 ());
937  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs2 ());
938  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs3 ());
939  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs4 ());
940  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs5 ());
941  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs6 ());
942  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs7 ());
944  {
945  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs8 ());
946  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs9 ());
947  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs10 ());
948  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs11 ());
949  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs12 ());
950  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs13 ());
951  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs14 ());
952  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs15 ());
953  }
955  {
956  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs16 ());
957  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs17 ());
958  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs18 ());
959  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs19 ());
960  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs20 ());
961  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs21 ());
962  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs22 ());
963  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs23 ());
964  }
966  {
967  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs24 ());
968  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs25 ());
969  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs26 ());
970  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs27 ());
971  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs28 ());
972  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs29 ());
973  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs30 ());
974  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs31 ());
975  }
976  }
977 }
978 
979 void
981 {
982  NS_LOG_FUNCTION (this);
983  if (Is2_4Ghz (GetFrequency ()))
984  {
985  Configure80211b ();
986  Configure80211g ();
987  }
988  if (Is5Ghz (GetFrequency ()))
989  {
990  Configure80211a ();
991  }
994 }
995 
996 void
998 {
999  NS_LOG_FUNCTION (this);
1000  Configure80211n ();
1001 
1002  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs0 ());
1003  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs1 ());
1004  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs2 ());
1005  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs3 ());
1006  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs4 ());
1007  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs5 ());
1008  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs6 ());
1009  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs7 ());
1010  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs8 ());
1011  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs9 ());
1012 
1013  m_bssMembershipSelectorSet.push_back (VHT_PHY);
1014 }
1015 
1016 void
1018 {
1019  NS_LOG_FUNCTION (this);
1020  Configure80211n ();
1021  if (Is5Ghz (GetFrequency ()))
1022  {
1023  Configure80211ac ();
1024  }
1025  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs0 ());
1026  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs1 ());
1027  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs2 ());
1028  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs3 ());
1029  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs4 ());
1030  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs5 ());
1031  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs6 ());
1032  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs7 ());
1033  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs8 ());
1034  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs9 ());
1035  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs10 ());
1036  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs11 ());
1037 
1038  m_bssMembershipSelectorSet.push_back (HE_PHY);
1039 }
1040 
1041 bool
1042 WifiPhy::DefineChannelNumber (uint8_t channelNumber, WifiPhyStandard standard, uint16_t frequency, uint8_t channelWidth)
1043 {
1044  NS_LOG_FUNCTION (this << +channelNumber << standard << frequency << +channelWidth);
1045  ChannelNumberStandardPair p = std::make_pair (channelNumber, standard);
1046  ChannelToFrequencyWidthMap::const_iterator it;
1047  it = m_channelToFrequencyWidth.find (p);
1048  if (it != m_channelToFrequencyWidth.end ())
1049  {
1050  NS_LOG_DEBUG ("channel number/standard already defined; returning false");
1051  return false;
1052  }
1053  FrequencyWidthPair f = std::make_pair (frequency, channelWidth);
1055  return true;
1056 }
1057 
1058 uint8_t
1059 WifiPhy::FindChannelNumberForFrequencyWidth (uint16_t frequency, uint8_t width) const
1060 {
1061  NS_LOG_FUNCTION (this << frequency << +width);
1062  bool found = false;
1063  FrequencyWidthPair f = std::make_pair (frequency, width);
1064  ChannelToFrequencyWidthMap::const_iterator it = m_channelToFrequencyWidth.begin ();
1065  while (it != m_channelToFrequencyWidth.end ())
1066  {
1067  if (it->second == f)
1068  {
1069  found = true;
1070  break;
1071  }
1072  ++it;
1073  }
1074  if (found)
1075  {
1076  NS_LOG_DEBUG ("Found, returning " << +it->first.first);
1077  return (it->first.first);
1078  }
1079  else
1080  {
1081  NS_LOG_DEBUG ("Not found, returning 0");
1082  return 0;
1083  }
1084 }
1085 
1086 void
1088 {
1089  NS_LOG_FUNCTION (this << standard);
1090  // If the user has configured both Frequency and ChannelNumber, Frequency
1091  // takes precedence
1092  if (GetFrequency () != 0)
1093  {
1094  // If Frequency is already set, then see whether a ChannelNumber can
1095  // be found that matches Frequency and ChannelWidth. If so, configure
1096  // the ChannelNumber to that channel number. If not, set ChannelNumber to zero.
1097  NS_LOG_DEBUG ("Frequency set; checking whether a channel number corresponds");
1098  uint8_t channelNumberSearched = FindChannelNumberForFrequencyWidth (GetFrequency (), GetChannelWidth ());
1099  if (channelNumberSearched)
1100  {
1101  NS_LOG_DEBUG ("Channel number found; setting to " << +channelNumberSearched);
1102  SetChannelNumber (channelNumberSearched);
1103  }
1104  else
1105  {
1106  NS_LOG_DEBUG ("Channel number not found; setting to zero");
1107  SetChannelNumber (0);
1108  }
1109  }
1110  else if (GetChannelNumber () != 0)
1111  {
1112  // If the channel number is known for this particular standard or for
1113  // the unspecified standard, configure using the known values;
1114  // otherwise, this is a configuration error
1115  NS_LOG_DEBUG ("Configuring for channel number " << +GetChannelNumber ());
1117  if (f.first == 0)
1118  {
1119  // the specific pair of number/standard is not known
1120  NS_LOG_DEBUG ("Falling back to check WIFI_PHY_STANDARD_UNSPECIFIED");
1122  }
1123  if (f.first == 0)
1124  {
1125  NS_FATAL_ERROR ("Error, ChannelNumber " << +GetChannelNumber () << " is unknown for this standard");
1126  }
1127  else
1128  {
1129  NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << +f.second);
1130  SetFrequency (f.first);
1131  SetChannelWidth (f.second);
1132  }
1133  }
1134 }
1135 
1136 void
1138 {
1139  NS_LOG_FUNCTION (this << standard);
1140  m_standard = standard;
1141  m_isConstructed = true;
1143  {
1145  }
1146  if (GetFrequency () == 0 && GetChannelNumber () == 0)
1147  {
1148  ConfigureDefaultsForStandard (standard);
1149  }
1150  else
1151  {
1152  // The user has configured either (or both) Frequency or ChannelNumber
1153  ConfigureChannelForStandard (standard);
1154  }
1155  switch (standard)
1156  {
1158  Configure80211a ();
1159  break;
1161  Configure80211b ();
1162  break;
1164  Configure80211g ();
1165  break;
1168  break;
1171  break;
1173  ConfigureHolland ();
1174  break;
1176  Configure80211n ();
1177  break;
1179  Configure80211n ();
1180  break;
1182  Configure80211ac ();
1183  break;
1185  Configure80211ax ();
1186  break;
1188  Configure80211ax ();
1189  break;
1190  default:
1191  NS_ASSERT (false);
1192  break;
1193  }
1194 }
1195 
1198 {
1199  return m_standard;
1200 }
1201 
1202 void
1203 WifiPhy::SetFrequency (uint16_t frequency)
1204 {
1205  NS_LOG_FUNCTION (this << frequency);
1206  if (m_isConstructed == false)
1207  {
1208  NS_LOG_DEBUG ("Saving frequency configuration for initialization");
1209  m_initialFrequency = frequency;
1210  return;
1211  }
1212  if (GetFrequency () == frequency)
1213  {
1214  NS_LOG_DEBUG ("No frequency change requested");
1215  return;
1216  }
1217  if (frequency == 0)
1218  {
1219  DoFrequencySwitch (0);
1220  NS_LOG_DEBUG ("Setting frequency and channel number to zero");
1222  m_channelNumber = 0;
1223  return;
1224  }
1225  // If the user has configured both Frequency and ChannelNumber, Frequency
1226  // takes precedence. Lookup the channel number corresponding to the
1227  // requested frequency.
1228  uint8_t nch = FindChannelNumberForFrequencyWidth (frequency, GetChannelWidth ());
1229  if (nch != 0)
1230  {
1231  NS_LOG_DEBUG ("Setting frequency " << frequency << " corresponds to channel " << +nch);
1232  if (DoFrequencySwitch (frequency))
1233  {
1234  NS_LOG_DEBUG ("Channel frequency switched to " << frequency << "; channel number to " << +nch);
1235  m_channelCenterFrequency = frequency;
1236  m_channelNumber = nch;
1237  }
1238  else
1239  {
1240  NS_LOG_DEBUG ("Suppressing reassignment of frequency");
1241  }
1242  }
1243  else
1244  {
1245  NS_LOG_DEBUG ("Channel number is unknown for frequency " << frequency);
1246  if (DoFrequencySwitch (frequency))
1247  {
1248  NS_LOG_DEBUG ("Channel frequency switched to " << frequency << "; channel number to " << 0);
1249  m_channelCenterFrequency = frequency;
1250  m_channelNumber = 0;
1251  }
1252  else
1253  {
1254  NS_LOG_DEBUG ("Suppressing reassignment of frequency");
1255  }
1256  }
1257 }
1258 
1259 uint16_t
1261 {
1262  return m_channelCenterFrequency;
1263 }
1264 
1265 void
1266 WifiPhy::SetChannelWidth (uint8_t channelwidth)
1267 {
1268  NS_LOG_FUNCTION (this << +channelwidth);
1269  NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 || channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth == 160, "wrong channel width value");
1270  bool changed = (m_channelWidth == channelwidth);
1271  m_channelWidth = channelwidth;
1272  AddSupportedChannelWidth (channelwidth);
1273  if (changed && !m_capabilitiesChangedCallback.IsNull ())
1274  {
1276  }
1277 }
1278 
1279 uint8_t
1281 {
1282  return m_channelWidth;
1283 }
1284 
1285 void
1287 {
1288  NS_ASSERT_MSG (antennas > 0 && antennas <= 4, "unsupported number of antennas");
1289  m_numberOfAntennas = antennas;
1291 }
1292 
1293 uint8_t
1295 {
1296  return m_numberOfAntennas;
1297 }
1298 
1299 void
1301 {
1302  NS_ASSERT (streams <= GetNumberOfAntennas ());
1303  bool changed = (m_txSpatialStreams == streams);
1304  m_txSpatialStreams = streams;
1306  if (changed && !m_capabilitiesChangedCallback.IsNull ())
1307  {
1309  }
1310 }
1311 
1312 uint8_t
1314 {
1315  return m_txSpatialStreams;
1316 }
1317 
1318 void
1320 {
1321  NS_ASSERT (streams <= GetNumberOfAntennas ());
1322  bool changed = (m_rxSpatialStreams == streams);
1323  m_rxSpatialStreams = streams;
1324  if (changed && !m_capabilitiesChangedCallback.IsNull ())
1325  {
1327  }
1328 }
1329 
1330 uint8_t
1332 {
1333  return m_rxSpatialStreams;
1334 }
1335 
1336 uint8_t
1338 {
1339  return m_bssMembershipSelectorSet.size ();
1340 }
1341 
1342 uint8_t
1343 WifiPhy::GetBssMembershipSelector (uint8_t selector) const
1344 {
1345  return m_bssMembershipSelectorSet[selector];
1346 }
1347 
1350 {
1351  uint32_t id = GetBssMembershipSelector (selector);
1352  WifiModeList supportedmodes;
1353  if (id == HT_PHY || id == VHT_PHY || id == HE_PHY)
1354  {
1355  //mandatory MCS 0 to 7
1356  supportedmodes.push_back (WifiPhy::GetHtMcs0 ());
1357  supportedmodes.push_back (WifiPhy::GetHtMcs1 ());
1358  supportedmodes.push_back (WifiPhy::GetHtMcs2 ());
1359  supportedmodes.push_back (WifiPhy::GetHtMcs3 ());
1360  supportedmodes.push_back (WifiPhy::GetHtMcs4 ());
1361  supportedmodes.push_back (WifiPhy::GetHtMcs5 ());
1362  supportedmodes.push_back (WifiPhy::GetHtMcs6 ());
1363  supportedmodes.push_back (WifiPhy::GetHtMcs7 ());
1364  }
1365  if (id == VHT_PHY || id == HE_PHY)
1366  {
1367  //mandatory MCS 0 to 9
1368  supportedmodes.push_back (WifiPhy::GetVhtMcs0 ());
1369  supportedmodes.push_back (WifiPhy::GetVhtMcs1 ());
1370  supportedmodes.push_back (WifiPhy::GetVhtMcs2 ());
1371  supportedmodes.push_back (WifiPhy::GetVhtMcs3 ());
1372  supportedmodes.push_back (WifiPhy::GetVhtMcs4 ());
1373  supportedmodes.push_back (WifiPhy::GetVhtMcs5 ());
1374  supportedmodes.push_back (WifiPhy::GetVhtMcs6 ());
1375  supportedmodes.push_back (WifiPhy::GetVhtMcs7 ());
1376  supportedmodes.push_back (WifiPhy::GetVhtMcs8 ());
1377  supportedmodes.push_back (WifiPhy::GetVhtMcs9 ());
1378  }
1379  if (id == HE_PHY)
1380  {
1381  //mandatory MCS 0 to 11
1382  supportedmodes.push_back (WifiPhy::GetHeMcs0 ());
1383  supportedmodes.push_back (WifiPhy::GetHeMcs1 ());
1384  supportedmodes.push_back (WifiPhy::GetHeMcs2 ());
1385  supportedmodes.push_back (WifiPhy::GetHeMcs3 ());
1386  supportedmodes.push_back (WifiPhy::GetHeMcs4 ());
1387  supportedmodes.push_back (WifiPhy::GetHeMcs5 ());
1388  supportedmodes.push_back (WifiPhy::GetHeMcs6 ());
1389  supportedmodes.push_back (WifiPhy::GetHeMcs7 ());
1390  supportedmodes.push_back (WifiPhy::GetHeMcs8 ());
1391  supportedmodes.push_back (WifiPhy::GetHeMcs9 ());
1392  supportedmodes.push_back (WifiPhy::GetHeMcs10 ());
1393  supportedmodes.push_back (WifiPhy::GetHeMcs11 ());
1394  }
1395  return supportedmodes;
1396 }
1397 
1398 void
1400 {
1401  NS_LOG_FUNCTION (this << +width);
1402  for (std::vector<uint32_t>::size_type i = 0; i != m_supportedChannelWidthSet.size (); i++)
1403  {
1404  if (m_supportedChannelWidthSet[i] == width)
1405  {
1406  return;
1407  }
1408  }
1409  NS_LOG_FUNCTION ("Adding " << +width << " to supported channel width set");
1410  m_supportedChannelWidthSet.push_back (width);
1411 }
1412 
1413 std::vector<uint8_t>
1415 {
1417 }
1418 
1421 {
1422  ChannelNumberStandardPair p = std::make_pair (channelNumber, standard);
1424  return f;
1425 }
1426 
1427 void
1429 {
1430  NS_LOG_FUNCTION (this << +nch);
1431  if (m_isConstructed == false)
1432  {
1433  NS_LOG_DEBUG ("Saving channel number configuration for initialization");
1434  m_initialChannelNumber = nch;
1435  return;
1436  }
1437  if (GetChannelNumber () == nch)
1438  {
1439  NS_LOG_DEBUG ("No channel change requested");
1440  return;
1441  }
1442  if (nch == 0)
1443  {
1444  // This case corresponds to when there is not a known channel
1445  // number for the requested frequency. There is no need to call
1446  // DoChannelSwitch () because DoFrequencySwitch () should have been
1447  // called by the client
1448  NS_LOG_DEBUG ("Setting channel number to zero");
1449  m_channelNumber = 0;
1450  return;
1451  }
1452 
1453  // First make sure that the channel number is defined for the standard
1454  // in use
1456  if (f.first == 0)
1457  {
1459  }
1460  if (f.first != 0)
1461  {
1462  if (DoChannelSwitch (nch))
1463  {
1464  NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << +f.second);
1465  m_channelCenterFrequency = f.first;
1466  SetChannelWidth (f.second);
1467  m_channelNumber = nch;
1468  }
1469  else
1470  {
1471  // Subclass may have suppressed (e.g. waiting for state change)
1472  NS_LOG_DEBUG ("Channel switch suppressed");
1473  }
1474  }
1475  else
1476  {
1477  NS_FATAL_ERROR ("Frequency not found for channel number " << nch);
1478  }
1479 }
1480 
1481 uint8_t
1483 {
1484  return m_channelNumber;
1485 }
1486 
1487 bool
1489 {
1490  if (!IsInitialized ())
1491  {
1492  //this is not channel switch, this is initialization
1493  NS_LOG_DEBUG ("initialize to channel " << +nch);
1494  return true;
1495  }
1496 
1498  switch (m_state->GetState ())
1499  {
1500  case WifiPhyState::RX:
1501  NS_LOG_DEBUG ("drop packet because of channel switching while reception");
1503  m_endRxEvent.Cancel ();
1504  goto switchChannel;
1505  break;
1506  case WifiPhyState::TX:
1507  NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
1509  break;
1511  case WifiPhyState::IDLE:
1512  goto switchChannel;
1513  break;
1514  case WifiPhyState::SLEEP:
1515  NS_LOG_DEBUG ("channel switching ignored in sleep mode");
1516  break;
1517  default:
1518  NS_ASSERT (false);
1519  break;
1520  }
1521 
1522  return false;
1523 
1524 switchChannel:
1525 
1526  NS_LOG_DEBUG ("switching channel " << +GetChannelNumber () << " -> " << +nch);
1527  m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ());
1529  /*
1530  * Needed here to be able to correctly sensed the medium for the first
1531  * time after the switching. The actual switching is not performed until
1532  * after m_channelSwitchDelay. Packets received during the switching
1533  * state are added to the event list and are employed later to figure
1534  * out the state of the medium after the switching.
1535  */
1536  return true;
1537 }
1538 
1539 bool
1540 WifiPhy::DoFrequencySwitch (uint16_t frequency)
1541 {
1542  if (!IsInitialized ())
1543  {
1544  //this is not channel switch, this is initialization
1545  NS_LOG_DEBUG ("start at frequency " << frequency);
1546  return true;
1547  }
1548 
1550  switch (m_state->GetState ())
1551  {
1552  case WifiPhyState::RX:
1553  NS_LOG_DEBUG ("drop packet because of channel/frequency switching while reception");
1555  m_endRxEvent.Cancel ();
1556  goto switchFrequency;
1557  break;
1558  case WifiPhyState::TX:
1559  NS_LOG_DEBUG ("channel/frequency switching postponed until end of current transmission");
1561  break;
1563  case WifiPhyState::IDLE:
1564  goto switchFrequency;
1565  break;
1566  case WifiPhyState::SLEEP:
1567  NS_LOG_DEBUG ("frequency switching ignored in sleep mode");
1568  break;
1569  default:
1570  NS_ASSERT (false);
1571  break;
1572  }
1573 
1574  return false;
1575 
1576 switchFrequency:
1577 
1578  NS_LOG_DEBUG ("switching frequency " << GetFrequency () << " -> " << frequency);
1579  m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ());
1581  /*
1582  * Needed here to be able to correctly sensed the medium for the first
1583  * time after the switching. The actual switching is not performed until
1584  * after m_channelSwitchDelay. Packets received during the switching
1585  * state are added to the event list and are employed later to figure
1586  * out the state of the medium after the switching.
1587  */
1588  return true;
1589 }
1590 
1591 void
1593 {
1594  NS_LOG_FUNCTION (this);
1595  switch (m_state->GetState ())
1596  {
1597  case WifiPhyState::TX:
1598  NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmission");
1600  break;
1601  case WifiPhyState::RX:
1602  NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception");
1604  break;
1606  NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching");
1608  break;
1610  case WifiPhyState::IDLE:
1611  NS_LOG_DEBUG ("setting sleep mode");
1612  m_state->SwitchToSleep ();
1613  break;
1614  case WifiPhyState::SLEEP:
1615  NS_LOG_DEBUG ("already in sleep mode");
1616  break;
1617  default:
1618  NS_ASSERT (false);
1619  break;
1620  }
1621 }
1622 
1623 void
1625 {
1626  NS_LOG_FUNCTION (this);
1627  switch (m_state->GetState ())
1628  {
1629  case WifiPhyState::RX:
1631  m_endRxEvent.Cancel ();
1632  case WifiPhyState::TX:
1635  case WifiPhyState::IDLE:
1636  case WifiPhyState::SLEEP:
1637  m_state->SwitchToOff ();
1638  break;
1639  default:
1640  NS_ASSERT (false);
1641  break;
1642  }
1643 }
1644 
1645 void
1647 {
1648  NS_LOG_FUNCTION (this);
1649  switch (m_state->GetState ())
1650  {
1651  case WifiPhyState::TX:
1652  case WifiPhyState::RX:
1653  case WifiPhyState::IDLE:
1656  {
1657  NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume");
1658  break;
1659  }
1660  case WifiPhyState::SLEEP:
1661  {
1662  NS_LOG_DEBUG ("resuming from sleep mode");
1664  m_state->SwitchFromSleep (delayUntilCcaEnd);
1665  break;
1666  }
1667  default:
1668  {
1669  NS_ASSERT (false);
1670  break;
1671  }
1672  }
1673 }
1674 
1675 void
1677 {
1678  NS_LOG_FUNCTION (this);
1679  switch (m_state->GetState ())
1680  {
1681  case WifiPhyState::TX:
1682  case WifiPhyState::RX:
1683  case WifiPhyState::IDLE:
1686  case WifiPhyState::SLEEP:
1687  {
1688  NS_LOG_DEBUG ("not in off mode, there is nothing to resume");
1689  break;
1690  }
1691  case WifiPhyState::OFF:
1692  {
1693  NS_LOG_DEBUG ("resuming from off mode");
1695  m_state->SwitchFromOff (delayUntilCcaEnd);
1696  break;
1697  }
1698  default:
1699  {
1700  NS_ASSERT (false);
1701  break;
1702  }
1703  }
1704 }
1705 
1706 WifiMode
1708 {
1709  return WifiPhy::GetHtMcs0 ();
1710 }
1711 
1712 WifiMode
1714 {
1715  return WifiPhy::GetVhtMcs0 ();
1716 }
1717 
1718 WifiMode
1720 {
1721  return WifiPhy::GetHeMcs0 ();
1722 }
1723 
1724 Time
1726 {
1727  uint8_t Ndltf, Neltf;
1728  //We suppose here that STBC = 0.
1729  //If STBC > 0, we need a different mapping between Nss and Nltf (IEEE 802.11n-2012 standard, page 1682).
1730  if (txVector.GetNss () < 3)
1731  {
1732  Ndltf = txVector.GetNss ();
1733  }
1734  else if (txVector.GetNss () < 5)
1735  {
1736  Ndltf = 4;
1737  }
1738  else if (txVector.GetNss () < 7)
1739  {
1740  Ndltf = 6;
1741  }
1742  else
1743  {
1744  Ndltf = 8;
1745  }
1746 
1747  if (txVector.GetNess () < 3)
1748  {
1749  Neltf = txVector.GetNess ();
1750  }
1751  else
1752  {
1753  Neltf = 4;
1754  }
1755 
1756  switch (txVector.GetPreambleType ())
1757  {
1758  case WIFI_PREAMBLE_HT_MF:
1759  return MicroSeconds (4 + (4 * Ndltf) + (4 * Neltf));
1760  case WIFI_PREAMBLE_HT_GF:
1761  return MicroSeconds ((4 * Ndltf) + (4 * Neltf));
1762  case WIFI_PREAMBLE_VHT:
1763  return MicroSeconds (4 + (4 * Ndltf));
1764  case WIFI_PREAMBLE_HE_SU:
1765  return MicroSeconds (4 + (8 * Ndltf));
1766  default:
1767  return MicroSeconds (0);
1768  }
1769 }
1770 
1771 Time
1773 {
1774  switch (preamble)
1775  {
1776  case WIFI_PREAMBLE_HT_MF:
1777  case WIFI_PREAMBLE_HT_GF:
1778  //HT-SIG
1779  return MicroSeconds (8);
1780  default:
1781  //no HT-SIG for non HT
1782  return MicroSeconds (0);
1783  }
1784 }
1785 
1786 Time
1788 {
1789  switch (preamble)
1790  {
1791  case WIFI_PREAMBLE_VHT:
1792  case WIFI_PREAMBLE_HE_SU:
1793  //VHT-SIG-A1 and HE-SIG-A1
1794  return MicroSeconds (4);
1795  default:
1796  // no SIG-A1
1797  return MicroSeconds (0);
1798  }
1799 }
1800 
1801 Time
1803 {
1804  switch (preamble)
1805  {
1806  case WIFI_PREAMBLE_VHT:
1807  case WIFI_PREAMBLE_HE_SU:
1808  //VHT-SIG-A2 and HE-SIG-A2
1809  return MicroSeconds (4);
1810  default:
1811  // no SIG-A2
1812  return MicroSeconds (0);
1813  }
1814 }
1815 
1816 Time
1818 {
1819  switch (preamble)
1820  {
1821  case WIFI_PREAMBLE_VHT:
1822  //VHT-SIG-B
1823  return MicroSeconds (4);
1824  case WIFI_PREAMBLE_HE_SU:
1825  //HE-SIG-B: MU not supported so HE-SIG-B not used
1826  return MicroSeconds (0);
1827  default:
1828  // no SIG-B
1829  return MicroSeconds (0);
1830  }
1831 }
1832 
1833 WifiMode
1835 {
1836  switch (txVector.GetMode ().GetModulationClass ())
1837  {
1838  case WIFI_MOD_CLASS_OFDM:
1839  case WIFI_MOD_CLASS_HT:
1840  case WIFI_MOD_CLASS_VHT:
1841  case WIFI_MOD_CLASS_HE:
1842  switch (txVector.GetChannelWidth ())
1843  {
1844  case 5:
1846  case 10:
1848  case 20:
1849  case 40:
1850  case 80:
1851  case 160:
1852  default:
1853  //(Section 18.3.2 "PLCP frame format"; IEEE Std 802.11-2012)
1854  //actually this is only the first part of the PlcpHeader,
1855  //because the last 16 bits of the PlcpHeader are using the
1856  //same mode of the payload
1857  return WifiPhy::GetOfdmRate6Mbps ();
1858  }
1860  return WifiPhy::GetErpOfdmRate6Mbps ();
1861  case WIFI_MOD_CLASS_DSSS:
1863  if (txVector.GetPreambleType () == WIFI_PREAMBLE_LONG || txVector.GetMode () == WifiPhy::GetDsssRate1Mbps ())
1864  {
1865  //(Section 16.2.3 "PLCP field definitions" and Section 17.2.2.2 "Long PPDU format"; IEEE Std 802.11-2012)
1866  return WifiPhy::GetDsssRate1Mbps ();
1867  }
1868  else //WIFI_PREAMBLE_SHORT
1869  {
1870  //(Section 17.2.2.3 "Short PPDU format"; IEEE Std 802.11-2012)
1871  return WifiPhy::GetDsssRate2Mbps ();
1872  }
1873  default:
1874  NS_FATAL_ERROR ("unsupported modulation class");
1875  return WifiMode ();
1876  }
1877 }
1878 
1879 Time
1881 {
1882  WifiPreamble preamble = txVector.GetPreambleType ();
1883  if (preamble == WIFI_PREAMBLE_NONE)
1884  {
1885  return MicroSeconds (0);
1886  }
1887  switch (txVector.GetMode ().GetModulationClass ())
1888  {
1889  case WIFI_MOD_CLASS_OFDM:
1890  {
1891  switch (txVector.GetChannelWidth ())
1892  {
1893  case 20:
1894  default:
1895  //(Section 18.3.3 "PLCP preamble (SYNC))" and Figure 18-4 "OFDM training structure"; IEEE Std 802.11-2012)
1896  //also (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
1897  //We return the duration of the SIGNAL field only, since the
1898  //SERVICE field (which strictly speaking belongs to the PLCP
1899  //header, see Section 18.3.2 and Figure 18-1) is sent using the
1900  //payload mode.
1901  return MicroSeconds (4);
1902  case 10:
1903  //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
1904  return MicroSeconds (8);
1905  case 5:
1906  //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
1907  return MicroSeconds (16);
1908  }
1909  }
1910  case WIFI_MOD_CLASS_HT:
1911  {
1912  //L-SIG
1913  //IEEE 802.11n Figure 20.1
1914  switch (preamble)
1915  {
1916  case WIFI_PREAMBLE_HT_MF:
1917  default:
1918  return MicroSeconds (4);
1919  case WIFI_PREAMBLE_HT_GF:
1920  return MicroSeconds (0);
1921  }
1922  }
1924  case WIFI_MOD_CLASS_VHT:
1925  //L-SIG
1926  return MicroSeconds (4);
1927  case WIFI_MOD_CLASS_HE:
1928  //LSIG + R-LSIG
1929  return MicroSeconds (8);
1930  case WIFI_MOD_CLASS_DSSS:
1932  if ((preamble == WIFI_PREAMBLE_SHORT) && (txVector.GetMode ().GetDataRate (22) > 1000000))
1933  {
1934  //(Section 17.2.2.3 "Short PPDU format" and Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
1935  return MicroSeconds (24);
1936  }
1937  else //WIFI_PREAMBLE_LONG
1938  {
1939  //(Section 17.2.2.2 "Long PPDU format" and Figure 17-1 "Short PPDU format"; IEEE Std 802.11-2012)
1940  return MicroSeconds (48);
1941  }
1942  default:
1943  NS_FATAL_ERROR ("unsupported modulation class");
1944  return MicroSeconds (0);
1945  }
1946 }
1947 
1948 Time
1950 {
1951  WifiPreamble preamble = txVector.GetPreambleType ();
1952  if (preamble == WIFI_PREAMBLE_NONE)
1953  {
1954  return MicroSeconds (0);
1955  }
1956  switch (txVector.GetMode ().GetModulationClass ())
1957  {
1958  case WIFI_MOD_CLASS_OFDM:
1959  {
1960  switch (txVector.GetChannelWidth ())
1961  {
1962  case 20:
1963  default:
1964  //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
1965  //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
1966  return MicroSeconds (16);
1967  case 10:
1968  //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
1969  //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
1970  return MicroSeconds (32);
1971  case 5:
1972  //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
1973  //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
1974  return MicroSeconds (64);
1975  }
1976  }
1977  case WIFI_MOD_CLASS_HT:
1978  case WIFI_MOD_CLASS_VHT:
1979  case WIFI_MOD_CLASS_HE:
1980  //L-STF + L-LTF
1981  return MicroSeconds (16);
1983  return MicroSeconds (16);
1984  case WIFI_MOD_CLASS_DSSS:
1986  if ((preamble == WIFI_PREAMBLE_SHORT) && (txVector.GetMode ().GetDataRate (22) > 1000000))
1987  {
1988  //(Section 17.2.2.3 "Short PPDU format)" Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
1989  return MicroSeconds (72);
1990  }
1991  else //WIFI_PREAMBLE_LONG
1992  {
1993  //(Section 17.2.2.2 "Long PPDU format)" Figure 17-1 "Long PPDU format"; IEEE Std 802.11-2012)
1994  return MicroSeconds (144);
1995  }
1996  default:
1997  NS_FATAL_ERROR ("unsupported modulation class");
1998  return MicroSeconds (0);
1999  }
2000 }
2001 
2002 Time
2003 WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, uint16_t frequency)
2004 {
2005  return GetPayloadDuration (size, txVector, frequency, NORMAL_MPDU, 0);
2006 }
2007 
2008 Time
2009 WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, uint16_t frequency, MpduType mpdutype, uint8_t incFlag)
2010 {
2011  WifiMode payloadMode = txVector.GetMode ();
2012  WifiPreamble preamble = txVector.GetPreambleType ();
2013  NS_LOG_FUNCTION (size << payloadMode);
2014 
2015  double stbc = 1;
2016  if (txVector.IsStbc ()
2017  && (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_HT
2018  || payloadMode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
2019  {
2020  stbc = 2;
2021  }
2022 
2023  double Nes = 1;
2024  //todo: improve logic to reduce the number of if cases
2025  //todo: extend to NSS > 4 for VHT rates
2026  if (payloadMode.GetUniqueName () == "HtMcs21"
2027  || payloadMode.GetUniqueName () == "HtMcs22"
2028  || payloadMode.GetUniqueName () == "HtMcs23"
2029  || payloadMode.GetUniqueName () == "HtMcs28"
2030  || payloadMode.GetUniqueName () == "HtMcs29"
2031  || payloadMode.GetUniqueName () == "HtMcs30"
2032  || payloadMode.GetUniqueName () == "HtMcs31")
2033  {
2034  Nes = 2;
2035  }
2036  if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
2037  {
2038  if (txVector.GetChannelWidth () == 40
2039  && txVector.GetNss () == 3
2040  && payloadMode.GetMcsValue () >= 8)
2041  {
2042  Nes = 2;
2043  }
2044  if (txVector.GetChannelWidth () == 80
2045  && txVector.GetNss () == 2
2046  && payloadMode.GetMcsValue () >= 7)
2047  {
2048  Nes = 2;
2049  }
2050  if (txVector.GetChannelWidth () == 80
2051  && txVector.GetNss () == 3
2052  && payloadMode.GetMcsValue () >= 7)
2053  {
2054  Nes = 2;
2055  }
2056  if (txVector.GetChannelWidth () == 80
2057  && txVector.GetNss () == 3
2058  && payloadMode.GetMcsValue () == 9)
2059  {
2060  Nes = 3;
2061  }
2062  if (txVector.GetChannelWidth () == 80
2063  && txVector.GetNss () == 4
2064  && payloadMode.GetMcsValue () >= 4)
2065  {
2066  Nes = 2;
2067  }
2068  if (txVector.GetChannelWidth () == 80
2069  && txVector.GetNss () == 4
2070  && payloadMode.GetMcsValue () >= 7)
2071  {
2072  Nes = 3;
2073  }
2074  if (txVector.GetChannelWidth () == 160
2075  && payloadMode.GetMcsValue () >= 7)
2076  {
2077  Nes = 2;
2078  }
2079  if (txVector.GetChannelWidth () == 160
2080  && txVector.GetNss () == 2
2081  && payloadMode.GetMcsValue () >= 4)
2082  {
2083  Nes = 2;
2084  }
2085  if (txVector.GetChannelWidth () == 160
2086  && txVector.GetNss () == 2
2087  && payloadMode.GetMcsValue () >= 7)
2088  {
2089  Nes = 3;
2090  }
2091  if (txVector.GetChannelWidth () == 160
2092  && txVector.GetNss () == 3
2093  && payloadMode.GetMcsValue () >= 3)
2094  {
2095  Nes = 2;
2096  }
2097  if (txVector.GetChannelWidth () == 160
2098  && txVector.GetNss () == 3
2099  && payloadMode.GetMcsValue () >= 5)
2100  {
2101  Nes = 3;
2102  }
2103  if (txVector.GetChannelWidth () == 160
2104  && txVector.GetNss () == 3
2105  && payloadMode.GetMcsValue () >= 7)
2106  {
2107  Nes = 4;
2108  }
2109  if (txVector.GetChannelWidth () == 160
2110  && txVector.GetNss () == 4
2111  && payloadMode.GetMcsValue () >= 2)
2112  {
2113  Nes = 2;
2114  }
2115  if (txVector.GetChannelWidth () == 160
2116  && txVector.GetNss () == 4
2117  && payloadMode.GetMcsValue () >= 4)
2118  {
2119  Nes = 3;
2120  }
2121  if (txVector.GetChannelWidth () == 160
2122  && txVector.GetNss () == 4
2123  && payloadMode.GetMcsValue () >= 5)
2124  {
2125  Nes = 4;
2126  }
2127  if (txVector.GetChannelWidth () == 160
2128  && txVector.GetNss () == 4
2129  && payloadMode.GetMcsValue () >= 7)
2130  {
2131  Nes = 6;
2132  }
2133  }
2134 
2135  Time symbolDuration = Seconds (0);
2136  switch (payloadMode.GetModulationClass ())
2137  {
2138  case WIFI_MOD_CLASS_OFDM:
2140  {
2141  //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012
2142  //corresponds to T_{SYM} in the table)
2143  switch (txVector.GetChannelWidth ())
2144  {
2145  case 20:
2146  default:
2147  symbolDuration = MicroSeconds (4);
2148  break;
2149  case 10:
2150  symbolDuration = MicroSeconds (8);
2151  break;
2152  case 5:
2153  symbolDuration = MicroSeconds (16);
2154  break;
2155  }
2156  break;
2157  }
2158  case WIFI_MOD_CLASS_HT:
2159  case WIFI_MOD_CLASS_VHT:
2160  {
2161  //if short GI data rate is used then symbol duration is 3.6us else symbol duration is 4us
2162  //In the future has to create a stationmanager that only uses these data rates if sender and receiver support GI
2163  uint16_t gi = txVector.GetGuardInterval ();
2164  NS_ASSERT (gi == 400 || gi == 800);
2165  symbolDuration = NanoSeconds (3200 + gi);
2166  }
2167  break;
2168  case WIFI_MOD_CLASS_HE:
2169  {
2170  //if short GI data rate is used then symbol duration is 3.6us else symbol duration is 4us
2171  //In the future has to create a stationmanager that only uses these data rates if sender and receiver support GI
2172  uint16_t gi = txVector.GetGuardInterval ();
2173  NS_ASSERT (gi == 800 || gi == 1600 || gi == 3200);
2174  symbolDuration = NanoSeconds (12800 + gi);
2175  }
2176  break;
2177  default:
2178  break;
2179  }
2180 
2181  double numDataBitsPerSymbol = payloadMode.GetDataRate (txVector) * symbolDuration.GetNanoSeconds () / 1e9;
2182 
2183  double numSymbols = 0;
2184  if (mpdutype == MPDU_IN_AGGREGATE && preamble != WIFI_PREAMBLE_NONE)
2185  {
2186  //First packet in an A-MPDU
2187  numSymbols = (stbc * (16 + size * 8.0 + 6 * Nes) / (stbc * numDataBitsPerSymbol));
2188  if (incFlag == 1)
2189  {
2190  m_totalAmpduSize += size;
2191  m_totalAmpduNumSymbols += numSymbols;
2192  }
2193  }
2194  else if (mpdutype == MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE)
2195  {
2196  //consecutive packets in an A-MPDU
2197  numSymbols = (stbc * size * 8.0) / (stbc * numDataBitsPerSymbol);
2198  if (incFlag == 1)
2199  {
2200  m_totalAmpduSize += size;
2201  m_totalAmpduNumSymbols += numSymbols;
2202  }
2203  }
2204  else if (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE)
2205  {
2206  //last packet in an A-MPDU
2207  uint32_t totalAmpduSize = m_totalAmpduSize + size;
2208  numSymbols = lrint (stbc * ceil ((16 + totalAmpduSize * 8.0 + 6 * Nes) / (stbc * numDataBitsPerSymbol)));
2209  NS_ASSERT (m_totalAmpduNumSymbols <= numSymbols);
2210  numSymbols -= m_totalAmpduNumSymbols;
2211  if (incFlag == 1)
2212  {
2213  m_totalAmpduSize = 0;
2215  }
2216  }
2217  else if (mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE)
2218  {
2219  //Not an A-MPDU
2220  numSymbols = lrint (stbc * ceil ((16 + size * 8.0 + 6.0 * Nes) / (stbc * numDataBitsPerSymbol)));
2221  }
2222  else
2223  {
2224  NS_FATAL_ERROR ("Wrong combination of preamble and packet type");
2225  }
2226 
2227  switch (payloadMode.GetModulationClass ())
2228  {
2229  case WIFI_MOD_CLASS_OFDM:
2231  {
2232  //Add signal extension for ERP PHY
2233  if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
2234  {
2235  return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ()) + MicroSeconds (6);
2236  }
2237  else
2238  {
2239  return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ());
2240  }
2241  }
2242  case WIFI_MOD_CLASS_HT:
2243  case WIFI_MOD_CLASS_VHT:
2244  {
2245  if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_HT && Is2_4Ghz (frequency)
2246  && ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE)
2247  || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE))) //at 2.4 GHz
2248  {
2249  return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ()) + MicroSeconds (6);
2250  }
2251  else //at 5 GHz
2252  {
2253  return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ());
2254  }
2255  }
2256  case WIFI_MOD_CLASS_HE:
2257  {
2258  if (Is2_4Ghz (frequency)
2259  && ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE)
2260  || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE))) //at 2.4 GHz
2261  {
2262  return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ()) + MicroSeconds (6);
2263  }
2264  else //at 5 GHz
2265  {
2266  return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ());
2267  }
2268  }
2269  case WIFI_MOD_CLASS_DSSS:
2271  return MicroSeconds (lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate (22) / 1.0e6))));
2272  default:
2273  NS_FATAL_ERROR ("unsupported modulation class");
2274  return MicroSeconds (0);
2275  }
2276 }
2277 
2278 Time
2280 {
2281  WifiPreamble preamble = txVector.GetPreambleType ();
2282  Time duration = GetPlcpPreambleDuration (txVector)
2283  + GetPlcpHeaderDuration (txVector)
2284  + GetPlcpHtSigHeaderDuration (preamble)
2285  + GetPlcpSigA1Duration (preamble)
2286  + GetPlcpSigA2Duration (preamble)
2287  + GetPlcpTrainingSymbolDuration (txVector)
2288  + GetPlcpSigBDuration (preamble);
2289  return duration;
2290 }
2291 
2292 Time
2293 WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txVector, uint16_t frequency, MpduType mpdutype, uint8_t incFlag)
2294 {
2295  Time duration = CalculatePlcpPreambleAndHeaderDuration (txVector)
2296  + GetPayloadDuration (size, txVector, frequency, mpdutype, incFlag);
2297  return duration;
2298 }
2299 
2300 Time
2301 WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txVector, uint16_t frequency)
2302 {
2303  return CalculateTxDuration (size, txVector, frequency, NORMAL_MPDU, 0);
2304 }
2305 
2306 void
2308 {
2309  m_phyTxBeginTrace (packet);
2310 }
2311 
2312 void
2314 {
2315  m_phyTxEndTrace (packet);
2316 }
2317 
2318 void
2320 {
2321  m_phyTxDropTrace (packet);
2322 }
2323 
2324 void
2326 {
2327  m_phyRxBeginTrace (packet);
2328 }
2329 
2330 void
2332 {
2333  m_phyRxEndTrace (packet);
2334 }
2335 
2336 void
2338 {
2339  m_phyRxDropTrace (packet);
2340 }
2341 
2342 void
2343 WifiPhy::NotifyMonitorSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise)
2344 {
2345  m_phyMonitorSniffRxTrace (packet, channelFreqMhz, txVector, aMpdu, signalNoise);
2346 }
2347 
2348 void
2349 WifiPhy::NotifyMonitorSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu)
2350 {
2351  m_phyMonitorSniffTxTrace (packet, channelFreqMhz, txVector, aMpdu);
2352 }
2353 
2354 void
2356 {
2357  NS_LOG_FUNCTION (this << packet << txVector.GetMode ()
2358  << txVector.GetMode ().GetDataRate (txVector)
2359  << txVector.GetPreambleType ()
2360  << +txVector.GetTxPowerLevel ()
2361  << +mpdutype);
2362  /* Transmission can happen if:
2363  * - we are syncing on a packet. It is the responsability of the
2364  * MAC layer to avoid doing this but the PHY does nothing to
2365  * prevent it.
2366  * - we are idle
2367  */
2368  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
2369 
2370  if (txVector.GetNss () > GetMaxSupportedTxSpatialStreams ())
2371  {
2372  NS_FATAL_ERROR ("Unsupported number of spatial streams!");
2373  }
2374 
2375  if (m_state->IsStateSleep ())
2376  {
2377  NS_LOG_DEBUG ("Dropping packet because in sleep mode");
2378  NotifyTxDrop (packet);
2379  return;
2380  }
2381 
2382  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, GetFrequency (), mpdutype, 1);
2383  NS_ASSERT (txDuration.IsStrictlyPositive ());
2384 
2385  if (m_state->IsStateRx ())
2386  {
2388  m_endRxEvent.Cancel ();
2390  }
2391  NotifyTxBegin (packet);
2392  if ((mpdutype == MPDU_IN_AGGREGATE) && (txVector.GetPreambleType () != WIFI_PREAMBLE_NONE))
2393  {
2394  //send the first MPDU in an MPDU
2396  }
2397  MpduInfo aMpdu;
2398  aMpdu.type = mpdutype;
2400  NotifyMonitorSniffTx (packet, GetFrequency (), txVector, aMpdu);
2401  m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector);
2402 
2403  Ptr<Packet> newPacket = packet->Copy (); // obtain non-const Packet
2404  WifiPhyTag oldtag;
2405  newPacket->RemovePacketTag (oldtag);
2406  if (m_state->GetState () == WifiPhyState::OFF)
2407  {
2408  NS_LOG_DEBUG ("Transmission canceled because device is OFF");
2409  return;
2410  }
2411  uint8_t isFrameComplete = 1;
2412  if (m_wifiRadioEnergyModel != 0 && m_wifiRadioEnergyModel->GetMaximumTimeInState (WifiPhyState::TX) < txDuration)
2413  {
2414  isFrameComplete = 0;
2415  }
2416  WifiPhyTag tag (txVector, mpdutype, isFrameComplete);
2417  newPacket->AddPacketTag (tag);
2418 
2419  StartTx (newPacket, txVector, txDuration);
2420 }
2421 
2422 void
2423 WifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, double rxPowerW, Time rxDuration)
2424 {
2425  WifiPhyTag tag;
2426  bool found = packet->RemovePacketTag (tag);
2427  if (!found)
2428  {
2429  NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag");
2430  return;
2431  }
2432 
2433  WifiTxVector txVector = tag.GetWifiTxVector ();
2435  event = m_interference.Add (packet,
2436  txVector,
2437  rxDuration,
2438  rxPowerW);
2439 
2440  //This function should be later split to check separately whether plcp preamble and plcp header can be successfully received.
2441  //Note: plcp preamble reception is not yet modeled.
2442  if (m_state->GetState () == WifiPhyState::OFF)
2443  {
2444  NS_LOG_DEBUG ("Cannot start RX because device is OFF");
2445  return;
2446  }
2447 
2448  NS_LOG_FUNCTION (this << packet << WToDbm (rxPowerW) << rxDuration);
2449 
2450  if (tag.GetFrameComplete () == 0)
2451  {
2452  NS_LOG_DEBUG ("drop packet because of incomplete frame");
2453  NotifyRxDrop (packet);
2454  m_plcpSuccess = false;
2455  return;
2456  }
2457 
2458  if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT
2459  && (txVector.GetNss () != (1 + (txVector.GetMode ().GetMcsValue () / 8))))
2460  {
2461  NS_FATAL_ERROR ("MCS value does not match NSS value: MCS = " << +txVector.GetMode ().GetMcsValue () << ", NSS = " << +txVector.GetNss ());
2462  }
2463 
2464  Time endRx = Simulator::Now () + rxDuration;
2465  if (txVector.GetNss () > GetMaxSupportedRxSpatialStreams ())
2466  {
2467  NS_LOG_DEBUG ("drop packet because not enough RX antennas");
2468  NotifyRxDrop (packet);
2469  m_plcpSuccess = false;
2470  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
2471  {
2472  //that packet will be noise _after_ the transmission of the
2473  //currently-transmitted packet.
2475  return;
2476  }
2477  }
2478 
2479  MpduType mpdutype = tag.GetMpduType ();
2480  switch (m_state->GetState ())
2481  {
2483  NS_LOG_DEBUG ("drop packet because of channel switching");
2484  NotifyRxDrop (packet);
2485  m_plcpSuccess = false;
2486  /*
2487  * Packets received on the upcoming channel are added to the event list
2488  * during the switching state. This way the medium can be correctly sensed
2489  * when the device listens to the channel for the first time after the
2490  * switching e.g. after channel switching, the channel may be sensed as
2491  * busy due to other devices' tramissions started before the end of
2492  * the switching.
2493  */
2494  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
2495  {
2496  //that packet will be noise _after_ the completion of the
2497  //channel switching.
2499  return;
2500  }
2501  break;
2502  case WifiPhyState::RX:
2503  NS_ASSERT (m_currentEvent != 0);
2504  if (m_frameCaptureModel != 0
2505  && m_frameCaptureModel->CaptureNewFrame (m_currentEvent, event))
2506  {
2508  NS_LOG_DEBUG ("Switch to new packet");
2509  StartRx (packet, txVector, mpdutype, rxPowerW, rxDuration, event);
2510  }
2511  else
2512  {
2513  NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
2514  rxPowerW << "W)");
2515  NotifyRxDrop (packet);
2516  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
2517  {
2518  //that packet will be noise _after_ the reception of the
2519  //currently-received packet.
2521  return;
2522  }
2523  }
2524  break;
2525  case WifiPhyState::TX:
2526  NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
2527  rxPowerW << "W)");
2528  NotifyRxDrop (packet);
2529  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
2530  {
2531  //that packet will be noise _after_ the transmission of the
2532  //currently-transmitted packet.
2534  return;
2535  }
2536  break;
2538  case WifiPhyState::IDLE:
2539  StartRx (packet, txVector, mpdutype, rxPowerW, rxDuration, event);
2540  break;
2541  case WifiPhyState::SLEEP:
2542  NS_LOG_DEBUG ("drop packet because in sleep mode");
2543  NotifyRxDrop (packet);
2544  m_plcpSuccess = false;
2545  break;
2546  default:
2547  NS_FATAL_ERROR ("Invalid WifiPhy state.");
2548  break;
2549  }
2550 }
2551 
2552 void
2554 {
2555  //We are here because we have received the first bit of a packet and we are
2556  //not going to be able to synchronize on it
2557  //In this model, CCA becomes busy when the aggregation of all signals as
2558  //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
2559 
2561  if (!delayUntilCcaEnd.IsZero ())
2562  {
2563  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
2564  }
2565 }
2566 
2567 void
2569  WifiTxVector txVector,
2570  MpduType mpdutype,
2572 {
2573  NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetPreambleType () << +mpdutype);
2574  NS_ASSERT (IsStateRx ());
2576  WifiMode txMode = txVector.GetMode ();
2577 
2579  snrPer = m_interference.CalculatePlcpHeaderSnrPer (event);
2580 
2581  NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per);
2582 
2583  if (m_random->GetValue () > snrPer.per) //plcp reception succeeded
2584  {
2585  if (IsModeSupported (txMode) || IsMcsSupported (txMode))
2586  {
2587  NS_LOG_DEBUG ("receiving plcp payload"); //endReceive is already scheduled
2588  m_plcpSuccess = true;
2589  }
2590  else //mode is not allowed
2591  {
2592  NS_LOG_DEBUG ("drop packet because it was sent using an unsupported mode (" << txMode << ")");
2593  NotifyRxDrop (packet);
2594  m_plcpSuccess = false;
2595  }
2596  }
2597  else //plcp reception failed
2598  {
2599  NS_LOG_DEBUG ("drop packet because plcp preamble/header reception failed");
2600  NotifyRxDrop (packet);
2601  m_plcpSuccess = false;
2602  }
2603 }
2604 
2605 void
2607 {
2608  NS_LOG_FUNCTION (this << packet << event);
2609  NS_ASSERT (IsStateRx ());
2610  NS_ASSERT (event->GetEndTime () == Simulator::Now ());
2611 
2613  snrPer = m_interference.CalculatePlcpPayloadSnrPer (event);
2615  m_currentEvent = 0;
2616 
2617  if (m_plcpSuccess == true)
2618  {
2619  NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate (event->GetTxVector ())) <<
2620  ", snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
2621 
2622  if (m_random->GetValue () > snrPer.per)
2623  {
2624  NotifyRxEnd (packet);
2625  SignalNoiseDbm signalNoise;
2626  signalNoise.signal = RatioToDb (event->GetRxPowerW ()) + 30;
2627  signalNoise.noise = RatioToDb (event->GetRxPowerW () / snrPer.snr) + 30;
2628  MpduInfo aMpdu;
2629  aMpdu.type = mpdutype;
2630  aMpdu.mpduRefNumber = m_rxMpduReferenceNumber;
2631  NotifyMonitorSniffRx (packet, GetFrequency (), event->GetTxVector (), aMpdu, signalNoise);
2632  m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector ());
2633  }
2634  else
2635  {
2636  /* failure. */
2637  NotifyRxDrop (packet);
2638  m_state->SwitchFromRxEndError (packet, snrPer.snr);
2639  }
2640  }
2641  else
2642  {
2643  m_state->SwitchFromRxEndError (packet, snrPer.snr);
2644  }
2645 
2646  if (preamble == WIFI_PREAMBLE_NONE && mpdutype == LAST_MPDU_IN_AGGREGATE)
2647  {
2648  m_plcpSuccess = false;
2649  }
2650 
2651 }
2652 
2653 
2654 // Clause 15 rates (DSSS)
2655 
2656 WifiMode
2658 {
2659  static WifiMode mode =
2660  WifiModeFactory::CreateWifiMode ("DsssRate1Mbps",
2662  true,
2664  2);
2665  return mode;
2666 }
2667 
2668 WifiMode
2670 {
2671  static WifiMode mode =
2672  WifiModeFactory::CreateWifiMode ("DsssRate2Mbps",
2674  true,
2676  4);
2677  return mode;
2678 }
2679 
2680 
2681 // Clause 18 rates (HR/DSSS)
2682 
2683 WifiMode
2685 {
2686  static WifiMode mode =
2687  WifiModeFactory::CreateWifiMode ("DsssRate5_5Mbps",
2689  true,
2691  16);
2692  return mode;
2693 }
2694 
2695 WifiMode
2697 {
2698  static WifiMode mode =
2699  WifiModeFactory::CreateWifiMode ("DsssRate11Mbps",
2701  true,
2703  256);
2704  return mode;
2705 }
2706 
2707 
2708 // Clause 19.5 rates (ERP-OFDM)
2709 
2710 WifiMode
2712 {
2713  static WifiMode mode =
2714  WifiModeFactory::CreateWifiMode ("ErpOfdmRate6Mbps",
2716  true,
2718  2);
2719  return mode;
2720 }
2721 
2722 WifiMode
2724 {
2725  static WifiMode mode =
2726  WifiModeFactory::CreateWifiMode ("ErpOfdmRate9Mbps",
2728  false,
2730  2);
2731  return mode;
2732 }
2733 
2734 WifiMode
2736 {
2737  static WifiMode mode =
2738  WifiModeFactory::CreateWifiMode ("ErpOfdmRate12Mbps",
2740  true,
2742  4);
2743  return mode;
2744 }
2745 
2746 WifiMode
2748 {
2749  static WifiMode mode =
2750  WifiModeFactory::CreateWifiMode ("ErpOfdmRate18Mbps",
2752  false,
2754  4);
2755  return mode;
2756 }
2757 
2758 WifiMode
2760 {
2761  static WifiMode mode =
2762  WifiModeFactory::CreateWifiMode ("ErpOfdmRate24Mbps",
2764  true,
2766  16);
2767  return mode;
2768 }
2769 
2770 WifiMode
2772 {
2773  static WifiMode mode =
2774  WifiModeFactory::CreateWifiMode ("ErpOfdmRate36Mbps",
2776  false,
2778  16);
2779  return mode;
2780 }
2781 
2782 WifiMode
2784 {
2785  static WifiMode mode =
2786  WifiModeFactory::CreateWifiMode ("ErpOfdmRate48Mbps",
2788  false,
2790  64);
2791  return mode;
2792 }
2793 
2794 WifiMode
2796 {
2797  static WifiMode mode =
2798  WifiModeFactory::CreateWifiMode ("ErpOfdmRate54Mbps",
2800  false,
2802  64);
2803  return mode;
2804 }
2805 
2806 
2807 // Clause 17 rates (OFDM)
2808 
2809 WifiMode
2811 {
2812  static WifiMode mode =
2813  WifiModeFactory::CreateWifiMode ("OfdmRate6Mbps",
2815  true,
2817  2);
2818  return mode;
2819 }
2820 
2821 WifiMode
2823 {
2824  static WifiMode mode =
2825  WifiModeFactory::CreateWifiMode ("OfdmRate9Mbps",
2827  false,
2829  2);
2830  return mode;
2831 }
2832 
2833 WifiMode
2835 {
2836  static WifiMode mode =
2837  WifiModeFactory::CreateWifiMode ("OfdmRate12Mbps",
2839  true,
2841  4);
2842  return mode;
2843 }
2844 
2845 WifiMode
2847 {
2848  static WifiMode mode =
2849  WifiModeFactory::CreateWifiMode ("OfdmRate18Mbps",
2851  false,
2853  4);
2854  return mode;
2855 }
2856 
2857 WifiMode
2859 {
2860  static WifiMode mode =
2861  WifiModeFactory::CreateWifiMode ("OfdmRate24Mbps",
2863  true,
2865  16);
2866  return mode;
2867 }
2868 
2869 WifiMode
2871 {
2872  static WifiMode mode =
2873  WifiModeFactory::CreateWifiMode ("OfdmRate36Mbps",
2875  false,
2877  16);
2878  return mode;
2879 }
2880 
2881 WifiMode
2883 {
2884  static WifiMode mode =
2885  WifiModeFactory::CreateWifiMode ("OfdmRate48Mbps",
2887  false,
2889  64);
2890  return mode;
2891 }
2892 
2893 WifiMode
2895 {
2896  static WifiMode mode =
2897  WifiModeFactory::CreateWifiMode ("OfdmRate54Mbps",
2899  false,
2901  64);
2902  return mode;
2903 }
2904 
2905 
2906 // 10 MHz channel rates
2907 
2908 WifiMode
2910 {
2911  static WifiMode mode =
2912  WifiModeFactory::CreateWifiMode ("OfdmRate3MbpsBW10MHz",
2914  true,
2916  2);
2917  return mode;
2918 }
2919 
2920 WifiMode
2922 {
2923  static WifiMode mode =
2924  WifiModeFactory::CreateWifiMode ("OfdmRate4_5MbpsBW10MHz",
2926  false,
2928  2);
2929  return mode;
2930 }
2931 
2932 WifiMode
2934 {
2935  static WifiMode mode =
2936  WifiModeFactory::CreateWifiMode ("OfdmRate6MbpsBW10MHz",
2938  true,
2940  4);
2941  return mode;
2942 }
2943 
2944 WifiMode
2946 {
2947  static WifiMode mode =
2948  WifiModeFactory::CreateWifiMode ("OfdmRate9MbpsBW10MHz",
2950  false,
2952  4);
2953  return mode;
2954 }
2955 
2956 WifiMode
2958 {
2959  static WifiMode mode =
2960  WifiModeFactory::CreateWifiMode ("OfdmRate12MbpsBW10MHz",
2962  true,
2964  16);
2965  return mode;
2966 }
2967 
2968 WifiMode
2970 {
2971  static WifiMode mode =
2972  WifiModeFactory::CreateWifiMode ("OfdmRate18MbpsBW10MHz",
2974  false,
2976  16);
2977  return mode;
2978 }
2979 
2980 WifiMode
2982 {
2983  static WifiMode mode =
2984  WifiModeFactory::CreateWifiMode ("OfdmRate24MbpsBW10MHz",
2986  false,
2988  64);
2989  return mode;
2990 }
2991 
2992 WifiMode
2994 {
2995  static WifiMode mode =
2996  WifiModeFactory::CreateWifiMode ("OfdmRate27MbpsBW10MHz",
2998  false,
3000  64);
3001  return mode;
3002 }
3003 
3004 
3005 // 5 MHz channel rates
3006 
3007 WifiMode
3009 {
3010  static WifiMode mode =
3011  WifiModeFactory::CreateWifiMode ("OfdmRate1_5MbpsBW5MHz",
3013  true,
3015  2);
3016  return mode;
3017 }
3018 
3019 WifiMode
3021 {
3022  static WifiMode mode =
3023  WifiModeFactory::CreateWifiMode ("OfdmRate2_25MbpsBW5MHz",
3025  false,
3027  2);
3028  return mode;
3029 }
3030 
3031 WifiMode
3033 {
3034  static WifiMode mode =
3035  WifiModeFactory::CreateWifiMode ("OfdmRate3MbpsBW5MHz",
3037  true,
3039  4);
3040  return mode;
3041 }
3042 
3043 WifiMode
3045 {
3046  static WifiMode mode =
3047  WifiModeFactory::CreateWifiMode ("OfdmRate4_5MbpsBW5MHz",
3049  false,
3051  4);
3052  return mode;
3053 }
3054 
3055 WifiMode
3057 {
3058  static WifiMode mode =
3059  WifiModeFactory::CreateWifiMode ("OfdmRate6MbpsBW5MHz",
3061  true,
3063  16);
3064  return mode;
3065 }
3066 
3067 WifiMode
3069 {
3070  static WifiMode mode =
3071  WifiModeFactory::CreateWifiMode ("OfdmRate9MbpsBW5MHz",
3073  false,
3075  16);
3076  return mode;
3077 }
3078 
3079 WifiMode
3081 {
3082  static WifiMode mode =
3083  WifiModeFactory::CreateWifiMode ("OfdmRate12MbpsBW5MHz",
3085  false,
3087  64);
3088  return mode;
3089 }
3090 
3091 WifiMode
3093 {
3094  static WifiMode mode =
3095  WifiModeFactory::CreateWifiMode ("OfdmRate13_5MbpsBW5MHz",
3097  false,
3099  64);
3100  return mode;
3101 }
3102 
3103 
3104 // Clause 20
3105 
3106 WifiMode
3108 {
3109  static WifiMode mcs =
3111  return mcs;
3112 }
3113 
3114 WifiMode
3116 {
3117  static WifiMode mcs =
3119  return mcs;
3120 }
3121 
3122 WifiMode
3124 {
3125  static WifiMode mcs =
3127  return mcs;
3128 }
3129 
3130 WifiMode
3132 {
3133  static WifiMode mcs =
3135  return mcs;
3136 }
3137 
3138 WifiMode
3140 {
3141  static WifiMode mcs =
3143  return mcs;
3144 }
3145 
3146 WifiMode
3148 {
3149  static WifiMode mcs =
3151  return mcs;
3152 }
3153 
3154 WifiMode
3156 {
3157  static WifiMode mcs =
3159  return mcs;
3160 }
3161 
3162 WifiMode
3164 {
3165  static WifiMode mcs =
3167  return mcs;
3168 }
3169 
3170 WifiMode
3172 {
3173  static WifiMode mcs =
3175  return mcs;
3176 }
3177 
3178 WifiMode
3180 {
3181  static WifiMode mcs =
3183  return mcs;
3184 }
3185 
3186 WifiMode
3188 {
3189  static WifiMode mcs =
3191  return mcs;
3192 }
3193 
3194 WifiMode
3196 {
3197  static WifiMode mcs =
3199  return mcs;
3200 }
3201 
3202 WifiMode
3204 {
3205  static WifiMode mcs =
3207  return mcs;
3208 }
3209 
3210 WifiMode
3212 {
3213  static WifiMode mcs =
3215  return mcs;
3216 }
3217 
3218 WifiMode
3220 {
3221  static WifiMode mcs =
3223  return mcs;
3224 }
3225 
3226 WifiMode
3228 {
3229  static WifiMode mcs =
3231  return mcs;
3232 }
3233 
3234 WifiMode
3236 {
3237  static WifiMode mcs =
3239  return mcs;
3240 }
3241 
3242 WifiMode
3244 {
3245  static WifiMode mcs =
3247  return mcs;
3248 }
3249 
3250 WifiMode
3252 {
3253  static WifiMode mcs =
3255  return mcs;
3256 }
3257 
3258 WifiMode
3260 {
3261  static WifiMode mcs =
3263  return mcs;
3264 }
3265 
3266 WifiMode
3268 {
3269  static WifiMode mcs =
3271  return mcs;
3272 }
3273 
3274 WifiMode
3276 {
3277  static WifiMode mcs =
3279  return mcs;
3280 }
3281 
3282 WifiMode
3284 {
3285  static WifiMode mcs =
3287  return mcs;
3288 }
3289 
3290 WifiMode
3292 {
3293  static WifiMode mcs =
3295  return mcs;
3296 }
3297 
3298 WifiMode
3300 {
3301  static WifiMode mcs =
3303  return mcs;
3304 }
3305 
3306 WifiMode
3308 {
3309  static WifiMode mcs =
3311  return mcs;
3312 }
3313 
3314 WifiMode
3316 {
3317  static WifiMode mcs =
3319  return mcs;
3320 }
3321 
3322 WifiMode
3324 {
3325  static WifiMode mcs =
3327  return mcs;
3328 }
3329 
3330 WifiMode
3332 {
3333  static WifiMode mcs =
3335  return mcs;
3336 }
3337 
3338 WifiMode
3340 {
3341  static WifiMode mcs =
3343  return mcs;
3344 }
3345 
3346 WifiMode
3348 {
3349  static WifiMode mcs =
3351  return mcs;
3352 }
3353 
3354 WifiMode
3356 {
3357  static WifiMode mcs =
3359  return mcs;
3360 }
3361 
3362 
3363 // Clause 22
3364 
3365 WifiMode
3367 {
3368  static WifiMode mcs =
3370  return mcs;
3371 }
3372 
3373 WifiMode
3375 {
3376  static WifiMode mcs =
3378  return mcs;
3379 }
3380 
3381 WifiMode
3383 {
3384  static WifiMode mcs =
3386  return mcs;
3387 }
3388 
3389 WifiMode
3391 {
3392  static WifiMode mcs =
3394  return mcs;
3395 }
3396 
3397 WifiMode
3399 {
3400  static WifiMode mcs =
3402  return mcs;
3403 }
3404 
3405 WifiMode
3407 {
3408  static WifiMode mcs =
3410  return mcs;
3411 }
3412 
3413 WifiMode
3415 {
3416  static WifiMode mcs =
3418  return mcs;
3419 }
3420 
3421 WifiMode
3423 {
3424  static WifiMode mcs =
3426  return mcs;
3427 }
3428 
3429 WifiMode
3431 {
3432  static WifiMode mcs =
3434  return mcs;
3435 }
3436 
3437 WifiMode
3439 {
3440  static WifiMode mcs =
3442  return mcs;
3443 }
3444 
3445 // Clause 26
3446 
3447 WifiMode
3449 {
3450  static WifiMode mcs =
3452  return mcs;
3453 }
3454 
3455 WifiMode
3457 {
3458  static WifiMode mcs =
3460  return mcs;
3461 }
3462 
3463 WifiMode
3465 {
3466  static WifiMode mcs =
3468  return mcs;
3469 }
3470 
3471 WifiMode
3473 {
3474  static WifiMode mcs =
3476  return mcs;
3477 }
3478 
3479 WifiMode
3481 {
3482  static WifiMode mcs =
3484  return mcs;
3485 }
3486 
3487 WifiMode
3489 {
3490  static WifiMode mcs =
3492  return mcs;
3493 }
3494 
3495 WifiMode
3497 {
3498  static WifiMode mcs =
3500  return mcs;
3501 }
3502 
3503 WifiMode
3505 {
3506  static WifiMode mcs =
3508  return mcs;
3509 }
3510 
3511 WifiMode
3513 {
3514  static WifiMode mcs =
3516  return mcs;
3517 }
3518 
3519 WifiMode
3521 {
3522  static WifiMode mcs =
3524  return mcs;
3525 }
3526 
3527 WifiMode
3529 {
3530  static WifiMode mcs =
3532  return mcs;
3533 }
3534 
3535 WifiMode
3537 {
3538  static WifiMode mcs =
3540  return mcs;
3541 }
3542 
3543 bool
3545 {
3546  for (uint8_t i = 0; i < GetNModes (); i++)
3547  {
3548  if (mode == GetMode (i))
3549  {
3550  return true;
3551  }
3552  }
3553  return false;
3554 }
3555 
3556 bool
3558 {
3559  for (uint8_t i = 0; i < GetNMcs (); i++)
3560  {
3561  if (mcs == GetMcs (i))
3562  {
3563  return true;
3564  }
3565  }
3566  return false;
3567 }
3568 
3569 uint8_t
3571 {
3572  return m_deviceRateSet.size ();
3573 }
3574 
3575 WifiMode
3576 WifiPhy::GetMode (uint8_t mode) const
3577 {
3578  return m_deviceRateSet[mode];
3579 }
3580 
3581 uint8_t
3582 WifiPhy::GetNMcs (void) const
3583 {
3584  return m_deviceMcsSet.size ();
3585 }
3586 
3587 WifiMode
3588 WifiPhy::GetMcs (uint8_t mcs) const
3589 {
3590  return m_deviceMcsSet[mcs];
3591 }
3592 
3593 bool
3595 {
3596  return m_state->IsStateCcaBusy ();
3597 }
3598 
3599 bool
3601 {
3602  return m_state->IsStateIdle ();
3603 }
3604 
3605 bool
3607 {
3608  return m_state->IsStateRx ();
3609 }
3610 
3611 bool
3613 {
3614  return m_state->IsStateTx ();
3615 }
3616 
3617 bool
3619 {
3620  return m_state->IsStateSwitching ();
3621 }
3622 
3623 bool
3625 {
3626  return m_state->IsStateSleep ();
3627 }
3628 
3629 bool
3631 {
3632  return m_state->IsStateOff ();
3633 }
3634 
3635 Time
3637 {
3638  return m_state->GetDelayUntilIdle ();
3639 }
3640 
3641 Time
3643 {
3644  return m_state->GetLastRxStartTime ();
3645 }
3646 
3647 void
3649 {
3650  NS_LOG_FUNCTION (this);
3651  //We are here because we have received the first bit of a packet and we are
3652  //not going to be able to synchronize on it
3653  //In this model, CCA becomes busy when the aggregation of all signals as
3654  //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
3655 
3657  if (!delayUntilCcaEnd.IsZero ())
3658  {
3659  NS_LOG_DEBUG ("Calling SwitchMaybeToCcaBusy for " << delayUntilCcaEnd.As (Time::S));
3660  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
3661  }
3662 }
3663 
3664 void
3666 {
3667  NS_LOG_FUNCTION (this);
3668  if (m_endPlcpRxEvent.IsRunning ())
3669  {
3671  }
3672  if (m_endRxEvent.IsRunning ())
3673  {
3674  m_endRxEvent.Cancel ();
3675  }
3676  NotifyRxDrop (m_currentEvent->GetPacket ());
3678  m_state->SwitchFromRxAbort ();
3679  m_currentEvent = 0;
3680 }
3681 
3682 void
3683 WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype, double rxPowerW, Time rxDuration, Ptr<InterferenceHelper::Event> event)
3684 {
3685  NS_LOG_FUNCTION (this << packet << txVector << +mpdutype << rxPowerW << rxDuration);
3686  if (rxPowerW > GetEdThresholdW ()) //checked here, no need to check in the payload reception (current implementation assumes constant rx power over the packet duration)
3687  {
3688  AmpduTag ampduTag;
3689  WifiPreamble preamble = txVector.GetPreambleType ();
3690  if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false))
3691  {
3692  m_plcpSuccess = false;
3693  m_mpdusNum = 0;
3694  NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been received");
3695  NotifyRxDrop (packet);
3697  return;
3698  }
3699  else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
3700  {
3701  //received the first MPDU in an MPDU
3702  m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3704  }
3705  else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
3706  {
3707  //received the other MPDUs that are part of the A-MPDU
3708  if (ampduTag.GetRemainingNbOfMpdus () < (m_mpdusNum - 1))
3709  {
3710  NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetRemainingNbOfMpdus ());
3711  m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3712  }
3713  else
3714  {
3715  m_mpdusNum--;
3716  }
3717  }
3718  else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
3719  {
3720  NS_LOG_DEBUG ("New A-MPDU started while " << m_mpdusNum << " MPDUs from previous are lost");
3721  m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3722  }
3723  else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 )
3724  {
3725  NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum);
3726  m_mpdusNum = 0;
3727  }
3728 
3729  NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
3730  m_currentEvent = event;
3731  m_state->SwitchToRx (rxDuration);
3733  NotifyRxBegin (packet);
3735 
3736  if (preamble != WIFI_PREAMBLE_NONE)
3737  {
3739  Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector);
3740  m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &WifiPhy::StartReceivePacket, this,
3741  packet, txVector, mpdutype, event);
3742  }
3743 
3746  packet, preamble, mpdutype, event);
3747  }
3748  else
3749  {
3750  NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
3751  rxPowerW << "<" << GetEdThresholdW () << ")");
3752  NotifyRxDrop (packet);
3753  m_plcpSuccess = false;
3755  }
3756 }
3757 
3758 int64_t
3759 WifiPhy::AssignStreams (int64_t stream)
3760 {
3761  NS_LOG_FUNCTION (this << stream);
3762  m_random->SetStream (stream);
3763  return 1;
3764 }
3765 
3766 std::ostream& operator<< (std::ostream& os, WifiPhyState state)
3767 {
3768  switch (state)
3769  {
3770  case WifiPhyState::IDLE:
3771  return (os << "IDLE");
3773  return (os << "CCA_BUSY");
3774  case WifiPhyState::TX:
3775  return (os << "TX");
3776  case WifiPhyState::RX:
3777  return (os << "RX");
3779  return (os << "SWITCHING");
3780  case WifiPhyState::SLEEP:
3781  return (os << "SLEEP");
3782  case WifiPhyState::OFF:
3783  return (os << "OFF");
3784  default:
3785  NS_FATAL_ERROR ("Invalid WifiPhy state");
3786  return (os << "INVALID");
3787  }
3788 }
3789 
3790 } //namespace ns3
3791 
3792 namespace {
3793 
3797 static class Constructor
3798 {
3799 public:
3801  {
3892  }
3893 } g_constructor;
3894 
3895 }
uint8_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
Definition: wifi-phy.cc:1337
static class anonymous_namespace{wifi-phy.cc}::Constructor g_constructor
the constructor
ERP-OFDM PHY (Clause 19, Section 19.5)
uint8_t GetNTxPower(void) const
Return the number of available transmission power levels.
Definition: wifi-phy.cc:543
MpduInfo structure.
Definition: wifi-phy.h:79
static WifiMode GetVhtMcs6()
Return MCS 6 from VHT MCS values.
Definition: wifi-phy.cc:3414
static WifiMode GetOfdmRate9MbpsBW5MHz()
Return a WifiMode for OFDM at 9Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:3068
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
Definition: wifi-phy.h:1729
Ptr< NetDevice > m_device
Pointer to the device.
Definition: wifi-phy.h:1853
static WifiMode GetErpOfdmRate24Mbps()
Return a WifiMode for ERP-OFDM at 24Mbps.
Definition: wifi-phy.cc:2759
uint32_t m_txMpduReferenceNumber
A-MPDU reference number to identify all transmitted subframes belonging to the same received A-MPDU...
Definition: wifi-phy.h:1570
static WifiMode GetDsssRate11Mbps()
Return a WifiMode for DSSS at 11Mbps.
Definition: wifi-phy.cc:2696
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1482
uint16_t GetGuardInterval(void) const
double signal
in dBm
Definition: wifi-phy.h:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
static WifiMode GetHeMcs7()
Return MCS 7 from HE MCS values.
Definition: wifi-phy.cc:3504
std::pair< uint8_t, WifiPhyStandard > ChannelNumberStandardPair
A pair of a ChannelNumber and WifiPhyStandard.
Definition: wifi-phy.h:535
static WifiMode GetErpOfdmRate36Mbps()
Return a WifiMode for ERP-OFDM at 36Mbps.
Definition: wifi-phy.cc:2771
A struct for both SNR and PER.
Ptr< InterferenceHelper::Event > Add(Ptr< const Packet > packet, WifiTxVector txVector, Time duration, double rxPower)
Add the packet-related signal to interference helper.
The MPDU is not part of an A-MPDU.
Definition: wifi-phy.h:64
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
OFDM PHY for the 5 GHz band (Clause 17 with 5 MHz channel bandwidth)
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
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:536
uint8_t m_channelNumber
Operating channel number.
Definition: wifi-phy.h:1846
double m_rxGainDb
Reception gain (dB)
Definition: wifi-phy.h:1825
static WifiMode GetVhtMcs8()
Return MCS 8 from VHT MCS values.
Definition: wifi-phy.cc:3430
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:54
double GetTxGain(void) const
Return the transmission gain (dB).
Definition: wifi-phy.cc:556
double GetRxNoiseFigure(void) const
Return the RX noise figure (dBm).
Definition: wifi-phy.cc:504
void SetShortPlcpPreambleSupported(bool preamble)
Enable or disable short PLCP preamble.
Definition: wifi-phy.cc:641
AttributeValue implementation for Boolean.
Definition: boolean.h:36
bool IsMcsSupported(WifiMode mcs) const
Check if the given WifiMode is supported by the PHY.
Definition: wifi-phy.cc:3557
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model.
static WifiMode GetOfdmRate9Mbps()
Return a WifiMode for OFDM at 9Mbps.
Definition: wifi-phy.cc:2822
HT PHY for the 5 GHz band (clause 20)
static WifiMode GetOfdmRate18MbpsBW10MHz()
Return a WifiMode for OFDM at 18Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2969
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
static WifiMode GetOfdmRate27MbpsBW10MHz()
Return a WifiMode for OFDM at 27Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2993
uint8_t GetRemainingNbOfMpdus(void) const
Definition: ampdu-tag.cc:90
std::vector< uint8_t > m_supportedChannelWidthSet
Supported channel width.
Definition: wifi-phy.h:1845
TracedCallback< Ptr< const Packet >, uint16_t, WifiTxVector, MpduInfo, SignalNoiseDbm > m_phyMonitorSniffRxTrace
A trace source that emulates a wifi device in monitor mode sniffing a packet being received...
Definition: wifi-phy.h:1758
double m_txGainDb
Transmission gain (dB)
Definition: wifi-phy.h:1824
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
static WifiMode GetOfdmRate3MbpsBW5MHz()
Return a WifiMode for OFDM at 3Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:3032
static WifiMode GetVhtMcs0()
Return MCS 0 from VHT MCS values.
Definition: wifi-phy.cc:3366
void MaybeCcaBusyDuration(void)
Eventually switch to CCA busy.
Definition: wifi-phy.cc:2553
virtual ~WifiPhy()
Definition: wifi-phy.cc:375
void SetLdpc(bool ldpc)
Enable or disable LDPC.
Definition: wifi-phy.cc:575
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1Mbps.
Definition: wifi-phy.cc:2657
bool m_ldpc
Flag if LDPC is used.
Definition: wifi-phy.h:1830
void ResumeFromOff(void)
Resume from off mode.
Definition: wifi-phy.cc:1676
void ResumeFromSleep(void)
Resume from sleep mode.
Definition: wifi-phy.cc:1646
bool GetGreenfield(void) const
Return whether Greenfield is supported.
Definition: wifi-phy.cc:608
static WifiMode GetHeMcs5()
Return MCS 5 from HE MCS values.
Definition: wifi-phy.cc:3488
static WifiMode GetErpOfdmRate18Mbps()
Return a WifiMode for ERP-OFDM at 18Mbps.
Definition: wifi-phy.cc:2747
void SetTxGain(double gain)
Sets the transmission gain (dB).
Definition: wifi-phy.cc:549
void Configure80211ax(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard...
Definition: wifi-phy.cc:1017
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:42
static WifiMode GetHtMcs7()
Return MCS 7 from HT MCS values.
Definition: wifi-phy.cc:3163
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:84
virtual void DoDispose(void)
Destructor implementation.
Definition: wifi-phy.cc:381
bool IsStateRx(void) const
Definition: wifi-phy.cc:3606
bool IsZero(void) const
Definition: nstime.h:288
def start()
Definition: core.py:1790
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:852
bool Is2_4Ghz(double frequency)
Definition: wifi-utils.cc:61
void SetStbc(bool stbc)
Enable or disable STBC.
Definition: wifi-phy.cc:588
static Time GetPlcpHtSigHeaderDuration(WifiPreamble preamble)
Definition: wifi-phy.cc:1772
static WifiMode GetVhtMcs5()
Return MCS 5 from VHT MCS values.
Definition: wifi-phy.cc:3406
uint8_t GetFrameComplete(void) const
Getter for frameComplete parameter.
Definition: wifi-phy-tag.cc:91
The PHY layer is sleeping.
static WifiMode GetHtMcs22()
Return MCS 22 from HT MCS values.
Definition: wifi-phy.cc:3283
static WifiMode GetHtMcs14()
Return MCS 14 from HT MCS values.
Definition: wifi-phy.cc:3219
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1331
static WifiMode GetOfdmRate12Mbps()
Return a WifiMode for OFDM at 12Mbps.
Definition: wifi-phy.cc:2834
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition: wifi-phy.h:1737
void EndReceive(Ptr< Packet > packet, WifiPreamble preamble, MpduType mpdutype, Ptr< InterferenceHelper::Event > event)
The last bit of the packet has arrived.
Definition: wifi-phy.cc:2606
#define HE_PHY
Definition: wifi-phy.h:38
void SetReceiveErrorCallback(RxErrorCallback callback)
Definition: wifi-phy.cc:412
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
static WifiMode GetHtMcs31()
Return MCS 31 from HT MCS values.
Definition: wifi-phy.cc:3355
static WifiMode GetHtMcs21()
Return MCS 21 from HT MCS values.
Definition: wifi-phy.cc:3275
bool IsStateCcaBusy(void) const
Definition: wifi-phy.cc:3594
#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
uint8_t m_channelWidth
Channel width.
Definition: wifi-phy.h:1820
static WifiMode GetHtMcs30()
Return MCS 30 from HT MCS values.
Definition: wifi-phy.cc:3347
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
std::vector< uint8_t > m_bssMembershipSelectorSet
the BSS membership selector set
Definition: wifi-phy.h:1813
HE PHY for the 2.4 GHz band (clause 26)
static WifiMode GetHtMcs10()
Return MCS 10 from HT MCS values.
Definition: wifi-phy.cc:3187
void StartReceivePreambleAndHeader(Ptr< Packet > packet, double rxPowerW, Time rxDuration)
Starting receiving the plcp of a packet (i.e.
Definition: wifi-phy.cc:2423
The MPDU is the last aggregate in an A-MPDU.
Definition: wifi-phy.h:68
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model this PHY is using.
Definition: wifi-phy.cc:692
static WifiMode GetHtMcs26()
Return MCS 26 from HT MCS values.
Definition: wifi-phy.cc:3315
static WifiMode GetOfdmRate1_5MbpsBW5MHz()
Return a WifiMode for OFDM at 1.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:3008
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:821
second
Definition: nstime.h:114
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
static WifiMode GetHtMcs17()
Return MCS 17 from HT MCS values.
Definition: wifi-phy.cc:3243
static WifiMode GetHtMcs24()
Return MCS 24 from HT MCS values.
Definition: wifi-phy.cc:3299
bool GetShortGuardInterval(void) const
Return whether short guard interval is supported.
Definition: wifi-phy.cc:621
static WifiMode GetOfdmRate4_5MbpsBW10MHz()
Return a WifiMode for OFDM at 4.5Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2921
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54Mbps.
Definition: wifi-phy.cc:2894
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:666
void UnregisterListener(WifiPhyListener *listener)
Definition: wifi-phy.cc:424
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:496
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
static WifiMode GetHeMcs4()
Return MCS 4 from HE MCS values.
Definition: wifi-phy.cc:3480
void SendPacket(Ptr< const Packet > packet, WifiTxVector txVector, MpduType mpdutype=NORMAL_MPDU)
Definition: wifi-phy.cc:2355
void ConfigureHolland(void)
Configure WifiPhy with appropriate channel frequency and supported rates for holland.
Definition: wifi-phy.cc:899
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
bool Is5Ghz(double frequency)
Definition: wifi-utils.cc:71
uint8_t GetNMcs(void) const
The WifiPhy::GetNMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of t...
Definition: wifi-phy.cc:3582
void NotifyTxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyTxDrop trace.
Definition: wifi-phy.cc:2319
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:375
HT PHY for the 2.4 GHz band (clause 20)
void SetGreenfield(bool greenfield)
Enable or disable Greenfield support.
Definition: wifi-phy.cc:601
VHT PHY (Clause 22)
Definition: wifi-mode.h:60
void Configure80211_10Mhz(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard with 10...
Definition: wifi-phy.cc:869
HR/DSSS PHY (Clause 18)
Definition: wifi-mode.h:48
static WifiMode GetHtMcs8()
Return MCS 8 from HT MCS values.
Definition: wifi-phy.cc:3171
uint8_t m_nTxPower
Number of available transmission power levels.
Definition: wifi-phy.h:1828
static WifiMode GetHtMcs18()
Return MCS 18 from HT MCS values.
Definition: wifi-phy.cc:3251
void NotifyTxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyTxBegin trace.
Definition: wifi-phy.cc:2307
virtual void SetFrequency(uint16_t freq)
Definition: wifi-phy.cc:1203
Ptr< FrameCaptureModel > GetFrameCaptureModel(void) const
Return the frame capture model this PHY is using.
Definition: wifi-phy.cc:704
static WifiMode GetVhtMcs4()
Return MCS 4 from VHT MCS values.
Definition: wifi-phy.cc:3398
static WifiMode GetHtMcs27()
Return MCS 27 from HT MCS values.
Definition: wifi-phy.cc:3323
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
Definition: wifi-phy.cc:698
bool IsStateSwitching(void) const
Definition: wifi-phy.cc:3618
TracedCallback< Ptr< const Packet >, uint16_t, WifiTxVector, MpduInfo > m_phyMonitorSniffTxTrace
A trace source that emulates a wifi device in monitor mode sniffing a packet being transmitted...
Definition: wifi-phy.h:1772
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1260
std::vector< uint8_t > GetSupportedChannelWidthSet(void) const
Definition: wifi-phy.cc:1414
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
Definition: wifi-phy.cc:3544
static WifiMode GetOfdmRate36Mbps()
Return a WifiMode for OFDM at 36Mbps.
Definition: wifi-phy.cc:2870
uint8_t m_initialChannelNumber
Initial channel number.
Definition: wifi-phy.h:1847
static WifiMode GetVhtMcs7()
Return MCS 7 from VHT MCS values.
Definition: wifi-phy.cc:3422
static WifiMode GetOfdmRate6MbpsBW5MHz()
Return a WifiMode for OFDM at 6Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:3056
bool GetStbc(void) const
Return whether STBC is supported.
Definition: wifi-phy.cc:595
static WifiMode GetVhtMcs3()
Return MCS 3 from VHT MCS values.
Definition: wifi-phy.cc:3390
void ConfigureDefaultsForStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:746
static Time GetPlcpSigA1Duration(WifiPreamble preamble)
Definition: wifi-phy.cc:1787
uint8_t GetTxPowerLevel(void) const
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
WifiModeList m_deviceMcsSet
the device MCS set
Definition: wifi-phy.h:1811
uint8_t GetChannelWidth(void) const
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
uint16_t m_channelCenterFrequency
Center frequency in MHz.
Definition: wifi-phy.h:1817
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:654
static WifiMode GetHtMcs16()
Return MCS 16 from HT MCS values.
Definition: wifi-phy.cc:3235
static WifiMode GetErpOfdmRate54Mbps()
Return a WifiMode for ERP-OFDM at 54Mbps.
Definition: wifi-phy.cc:2795
bool GetLdpc(void) const
Return if LDPC is supported.
Definition: wifi-phy.cc:582
uint16_t m_mpdusNum
carries the number of expected mpdus that are part of an A-MPDU
Definition: wifi-phy.h:1568
static WifiMode GetHtMcs29()
Return MCS 29 from HT MCS values.
Definition: wifi-phy.cc:3339
static WifiMode GetHtMcs11()
Return MCS 11 from HT MCS values.
Definition: wifi-phy.cc:3195
void NotifyRxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:2337
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, uint16_t frequency)
Definition: wifi-phy.cc:2301
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
Keep track of the current position and velocity of an object.
static ChannelToFrequencyWidthMap m_channelToFrequencyWidth
the channel to frequency width map
Definition: wifi-phy.h:1843
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:716
double GetEdThreshold(void) const
Return the energy detection threshold (dBm).
Definition: wifi-phy.cc:477
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:874
static Time GetPlcpSigA2Duration(WifiPreamble preamble)
Definition: wifi-phy.cc:1802
HE PHY for the 5 GHz band (clause 26)
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
bool DoFrequencySwitch(uint16_t frequency)
The default implementation does nothing and returns true.
Definition: wifi-phy.cc:1540
static WifiMode GetHtMcs2()
Return MCS 2 from HT MCS values.
Definition: wifi-phy.cc:3123
tuple mobility
Definition: third.py:101
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:220
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1375
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
Definition: wifi-phy.h:1854
virtual void StartTx(Ptr< Packet > packet, WifiTxVector txVector, Time txDuration)=0
AttributeValue implementation for Time.
Definition: nstime.h:1069
static Time GetPlcpPreambleDuration(WifiTxVector txVector)
Definition: wifi-phy.cc:1949
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1031
receive notifications about phy events.
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:1721
void NotifyMonitorSniffRx(Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise)
Public method used to fire a MonitorSniffer trace for a wifi packet being received.
Definition: wifi-phy.cc:2343
bool m_shortPreamble
Flag if short PLCP preamble is supported.
Definition: wifi-phy.h:1834
bool IsStrictlyPositive(void) const
Definition: nstime.h:308
static WifiMode GetHeMcs3()
Return MCS 3 from HE MCS values.
Definition: wifi-phy.cc:3472
static Time GetPlcpSigBDuration(WifiPreamble preamble)
Definition: wifi-phy.cc:1817
Hold an unsigned integer type.
Definition: uinteger.h:44
static WifiMode CreateWifiMode(std::string uniqueName, WifiModulationClass modClass, bool isMandatory, WifiCodeRate codingRate, uint16_t constellationSize)
Definition: wifi-mode.cc:681
EventId m_endPlcpRxEvent
the end PLCP receive event
Definition: wifi-phy.h:1574
static WifiMode GetHtMcs12()
Return MCS 12 from HT MCS values.
Definition: wifi-phy.cc:3203
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
Definition: wifi-phy.h:1858
static WifiMode GetErpOfdmRate48Mbps()
Return a WifiMode for ERP-OFDM at 48Mbps.
Definition: wifi-phy.cc:2783
static Time CalculatePlcpPreambleAndHeaderDuration(WifiTxVector txVector)
Definition: wifi-phy.cc:2279
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:523
uint64_t GetDataRate(uint8_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:143
uint8_t GetNess(void) const
Time GetGuardInterval(void) const
Definition: wifi-phy.cc:635
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3576
static WifiMode GetOfdmRate12MbpsBW10MHz()
Return a WifiMode for OFDM at 12Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2957
static WifiMode GetHeMcs11()
Return MCS 11 from HE MCS values.
Definition: wifi-phy.cc:3536
The PHY layer has sense the medium busy through the CCA mechanism.
HT PHY (Clause 20)
Definition: wifi-mode.h:58
Time GetDelayUntilIdle(void)
Definition: wifi-phy.cc:3636
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:465
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:450
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU...
Definition: wifi-phy.h:1571
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
Definition: wifi-phy.h:1744
double m_edThresholdW
Energy detection threshold in watts.
Definition: wifi-phy.h:1822
void Configure80211_5Mhz()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard with 5M...
Definition: wifi-phy.cc:884
void StartReceivePacket(Ptr< Packet > packet, WifiTxVector txVector, MpduType mpdutype, Ptr< InterferenceHelper::Event > event)
Starting receiving the payload of a packet (i.e.
Definition: wifi-phy.cc:2568
The aim of the AmpduTag is to provide means for a MAC to specify that a packet includes A-MPDU since ...
Definition: ampdu-tag.h:36
struct InterferenceHelper::SnrPer CalculatePlcpHeaderSnrPer(Ptr< InterferenceHelper::Event > event) const
Calculate the SNIR at the start of the plcp header and accumulate all SNIR changes in the snir vector...
void NotifyRxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyRxBegin trace.
Definition: wifi-phy.cc:2325
bool IsStateSleep(void) const
Definition: wifi-phy.cc:3624
static WifiMode GetOfdmRate18Mbps()
Return a WifiMode for OFDM at 18Mbps.
Definition: wifi-phy.cc:2846
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition: wifi-phy.cc:430
void SetOffMode(void)
Put in off mode.
Definition: wifi-phy.cc:1624
static WifiMode GetOfdmRate9MbpsBW10MHz()
Return a WifiMode for OFDM at 9Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2945
bool IsStbc(void) const
Check if STBC is used or not.
static WifiMode GetOfdmRate12MbpsBW5MHz()
Return a WifiMode for OFDM at 12Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:3080
WifiModeList GetMembershipSelectorModes(uint32_t selector)
The WifiPhy::GetMembershipSelectorModes() method is used (e.g., by a WifiRemoteStationManager) to det...
Definition: wifi-phy.cc:1349
void AbortCurrentReception(void)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted...
Definition: wifi-phy.cc:3665
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
Definition: wifi-phy.h:1705
static WifiMode GetVhtMcs1()
Return MCS 1 from VHT MCS values.
Definition: wifi-phy.cc:3374
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
static WifiMode GetOfdmRate48Mbps()
Return a WifiMode for OFDM at 48Mbps.
Definition: wifi-phy.cc:2882
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:685
Time GetEnergyDuration(double energyW) const
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
static WifiMode GetHeMcs9()
Return MCS 9 from HE MCS values.
Definition: wifi-phy.cc:3520
double f(double x, void *params)
Definition: 80211b.c:72
static WifiMode GetHtMcs0()
Return MCS 0 from HT MCS values.
Definition: wifi-phy.cc:3107
WifiMode GetMcs(uint8_t mcs) const
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
Definition: wifi-phy.cc:3588
static TypeId GetTypeId(void)
Get the type ID.
Definition: wifi-phy.cc:147
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void NotifyRxStart()
Notify that RX has started.
virtual void SetChannelWidth(uint8_t channelwidth)
Definition: wifi-phy.cc:1266
Hold objects of type Ptr.
Definition: pointer.h:36
double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:530
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
Definition: wifi-phy.cc:710
Time m_guardInterval
Supported HE guard interval.
Definition: wifi-phy.h:1836
void EraseEvents(void)
Erase all events.
The PHY layer is IDLE.
static WifiMode GetOfdmRate24Mbps()
Return a WifiMode for OFDM at 24Mbps.
Definition: wifi-phy.cc:2858
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
WifiPhyState
The state of the PHY layer.
static WifiMode GetHeMcs1()
Return MCS 1 from HE MCS values.
Definition: wifi-phy.cc:3456
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
std::pair< uint16_t, uint8_t > FrequencyWidthPair
A pair of a center Frequency and a ChannelWidth.
Definition: wifi-phy.h:539
static WifiMode GetHtMcs13()
Return MCS 13 from HT MCS values.
Definition: wifi-phy.cc:3211
void SetShortGuardInterval(bool shortGuardInterval)
Enable or disable support for HT/VHT short guard interval.
Definition: wifi-phy.cc:614
static WifiMode GetHeMcs0()
Return MCS 0 from HE MCS values.
Definition: wifi-phy.cc:3448
double CalculateSnr(WifiTxVector txVector, double ber) const
Definition: wifi-phy.cc:740
bool IsInitialized(void) const
Check if the object has been initialized.
Definition: object.cc:208
static WifiMode GetHeMcs10()
Return MCS 10 from HE MCS values.
Definition: wifi-phy.cc:3528
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
static WifiMode GetHtMcs20()
Return MCS 20 from HT MCS values.
Definition: wifi-phy.cc:3267
static WifiMode GetHeMcs2()
Return MCS 2 from HE MCS values.
Definition: wifi-phy.cc:3464
static WifiMode GetHtMcs5()
Return MCS 5 from HT MCS values.
Definition: wifi-phy.cc:3147
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1319
void SetCcaMode1Threshold(double threshold)
Sets the CCA threshold (dBm).
Definition: wifi-phy.cc:483
Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
Definition: wifi-phy.cc:3642
static WifiMode GetVhtMcs2()
Return MCS 2 from VHT MCS values.
Definition: wifi-phy.cc:3382
FrequencyWidthPair GetFrequencyWidthForChannelNumberStandard(uint8_t channelNumber, WifiPhyStandard standard) const
Lookup frequency/width pair for channelNumber/standard pair.
Definition: wifi-phy.cc:1420
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1428
static WifiMode GetDsssRate5_5Mbps()
Return a WifiMode for DSSS at 5.5Mbps.
Definition: wifi-phy.cc:2684
void Configure80211ac(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard...
Definition: wifi-phy.cc:997
virtual void DoInitialize(void)
Initialize() implementation.
Definition: wifi-phy.cc:393
static WifiMode GetOfdmRate2_25MbpsBW5MHz()
Return a WifiMode for OFDM at 2.25Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:3020
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:1070
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:49
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes...
Definition: wifi-mode.h:251
WifiPhyStandard m_standard
WifiPhyStandard.
Definition: wifi-phy.h:1815
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
void SetGuardInterval(Time guardInterval)
Definition: wifi-phy.cc:627
static WifiMode GetErpOfdmRate9Mbps()
Return a WifiMode for ERP-OFDM at 9Mbps.
Definition: wifi-phy.cc:2723
void NotifyTxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyTxEnd trace.
Definition: wifi-phy.cc:2313
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Definition: wifi-phy.h:1565
double DbToRatio(double dB)
Convert from dB to ratio.
Definition: wifi-utils.cc:35
bool IsStateTx(void) const
Definition: wifi-phy.cc:3612
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
Definition: wifi-phy.h:1839
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1313
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition: wifi-utils.cc:55
void InitializeFrequencyChannelNumber(void)
post-construction setting of frequency and/or channel number
Definition: wifi-phy.cc:436
WifiPreamble GetPreambleType(void) const
Ptr< FrameCaptureModel > m_frameCaptureModel
Frame capture model.
Definition: wifi-phy.h:1857
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
uint8_t GetBssMembershipSelector(uint8_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1343
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:367
Ptr< NetDevice > GetDevice(void) const
Return the device this PHY is associated with.
Definition: wifi-phy.cc:660
void SetRxGain(double gain)
Sets the reception gain (dB).
Definition: wifi-phy.cc:562
uint8_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1280
void Configure80211b(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard...
Definition: wifi-phy.cc:842
No explicit coding (e.g., DSSS rates)
Definition: wifi-mode.h:75
WifiTxVector GetWifiTxVector(void) const
Getter for WifiTxVector parameter.
Definition: wifi-phy-tag.cc:79
void SetReceiveOkCallback(RxOkCallback callback)
Definition: wifi-phy.cc:406
static WifiMode GetErpOfdmRate6Mbps()
Return a WifiMode for ERP-OFDM at 6Mbps.
Definition: wifi-phy.cc:2711
void RegisterListener(WifiPhyListener *listener)
Definition: wifi-phy.cc:418
void ConfigureChannelForStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1087
uint8_t GetNss(void) const
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1300
The PHY layer is sending a packet.
static WifiMode GetErpOfdmRate12Mbps()
Return a WifiMode for ERP-OFDM at 12Mbps.
Definition: wifi-phy.cc:2735
bool m_plcpSuccess
Flag if the PLCP of the packet or the first MPDU in an A-MPDU has been received.
Definition: wifi-phy.h:1569
bool m_greenfield
Flag if GreenField format is supported.
Definition: wifi-phy.h:1832
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:388
EventId m_endRxEvent
the end reeive event
Definition: wifi-phy.h:1573
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Definition: wifi-phy.h:1566
void SetEdThreshold(double threshold)
Sets the energy detection threshold (dBm).
Definition: wifi-phy.cc:464
void NotifyRxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyRxEnd trace.
Definition: wifi-phy.cc:2331
void Configure80211n(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard...
Definition: wifi-phy.cc:980
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:510
double m_txPowerBaseDbm
Minimum transmission power (dBm)
Definition: wifi-phy.h:1826
void NotifyRxEnd()
Notify that RX has ended.
void SetNoiseFigure(double value)
Set the noise figure.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:261
SignalNoiseDbm structure.
Definition: wifi-phy.h:72
uint32_t mpduRefNumber
MPDU ref number.
Definition: wifi-phy.h:82
bool m_frequencyChannelNumberInitialized
Store initialization state.
Definition: wifi-phy.h:1819
static WifiMode GetHtMcs19()
Return MCS 19 from HT MCS values.
Definition: wifi-phy.cc:3259
InterferenceHelper m_interference
Pointer to InterferenceHelper.
Definition: wifi-phy.h:1564
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:859
static WifiMode GetHtMcs6()
Return MCS 6 from HT MCS values.
Definition: wifi-phy.cc:3155
bool m_isConstructed
true when ready to set frequency
Definition: wifi-phy.h:1816
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:269
void ConfigureHtDeviceMcsSet(void)
Configure the device Mcs set with the appropriate HtMcs modes for the number of available transmit sp...
Definition: wifi-phy.cc:911
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1007
The PHY layer is receiving a packet.
OFDM PHY (Clause 17)
Definition: wifi-mode.h:56
static WifiMode GetVhtPlcpHeaderMode()
Definition: wifi-phy.cc:1713
double m_totalAmpduNumSymbols
Number of symbols previously transmitted for the MPDUs in an A-MPDU, used for the computation of the ...
Definition: wifi-phy.h:1851
static WifiMode GetHtMcs28()
Return MCS 28 from HT MCS values.
Definition: wifi-phy.cc:3331
bool IsStateOff(void) const
Definition: wifi-phy.cc:3630
static WifiMode GetHtMcs9()
Return MCS 9 from HT MCS values.
Definition: wifi-phy.cc:3179
Ptr< MobilityModel > GetMobility(void) const
Return the mobility model this PHY is associated with.
Definition: wifi-phy.cc:672
Time GetChannelSwitchDelay(void) const
Definition: wifi-phy.cc:734
static WifiMode GetHtMcs4()
Return MCS 4 from HT MCS values.
Definition: wifi-phy.cc:3139
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
static WifiMode GetHtMcs25()
Return MCS 25 from HT MCS values.
Definition: wifi-phy.cc:3307
static WifiMode GetHeMcs8()
Return MCS 8 from HE MCS values.
Definition: wifi-phy.cc:3512
Tag for WifiTxVector and WifiPreamble information to be embedded in outgoing transmissions as a Packe...
Definition: wifi-phy-tag.h:35
The PHY layer is switched off.
void Configure80211g(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard...
Definition: wifi-phy.cc:853
static WifiMode GetHePlcpHeaderMode()
Definition: wifi-phy.cc:1719
bool DefineChannelNumber(uint8_t channelNumber, WifiPhyStandard standard, uint16_t frequency, uint8_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:1042
The PHY layer is switching to other channel.
void SetSleepMode(void)
Put in sleep mode.
Definition: wifi-phy.cc:1592
uint32_t m_totalAmpduSize
Total size of the previously transmitted MPDUs in an A-MPDU, used for the computation of the number o...
Definition: wifi-phy.h:1850
double noise
in dBm
Definition: wifi-phy.h:75
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1023
void StartRx(Ptr< Packet > packet, WifiTxVector txVector, MpduType mpdutype, double rxPowerW, Time rxDuration, Ptr< InterferenceHelper::Event > event)
Starting receiving the packet after having detected the medium is idle or after a reception switch...
Definition: wifi-phy.cc:3683
WifiModeList m_deviceRateSet
This vector holds the set of transmission modes that this WifiPhy(-derived class) can support...
Definition: wifi-phy.h:1810
void NotifyMonitorSniffTx(Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu)
Public method used to fire a MonitorSniffer trace for a wifi packet being transmitted.
Definition: wifi-phy.cc:2349
Time GetPayloadDuration(uint32_t size, WifiTxVector txVector, uint16_t frequency)
Definition: wifi-phy.cc:2003
void SetNumberOfAntennas(uint8_t antennas)
Definition: wifi-phy.cc:1286
static WifiMode GetHtMcs1()
Return MCS 1 from HT MCS values.
Definition: wifi-phy.cc:3115
static WifiMode GetHtMcs23()
Return MCS 23 from HT MCS values.
Definition: wifi-phy.cc:3291
A base class which provides memory management and object aggregation.
Definition: object.h:87
Time FemtoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1047
static WifiMode GetDsssRate2Mbps()
Return a WifiMode for DSSS at 2Mbps.
Definition: wifi-phy.cc:2669
static WifiMode GetVhtMcs9()
Return MCS 9 from VHT MCS values.
Definition: wifi-phy.cc:3438
#define HT_PHY
Definition: wifi-phy.h:40
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1137
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:487
void AddSupportedChannelWidth(uint8_t channelwidth)
Definition: wifi-phy.cc:1399
static WifiMode GetOfdmRate6MbpsBW10MHz()
Return a WifiMode for OFDM at 6Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2933
double GetEdThresholdW(void) const
Return the energy detection threshold.
Definition: wifi-phy.cc:471
WifiMode GetMode(void) const
double m_txPowerEndDbm
Maximum transmission power (dBm)
Definition: wifi-phy.h:1827
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1294
#define VHT_PHY
Definition: wifi-phy.h:39
The MPDU is part of an A-MPDU, but is not the last aggregate.
Definition: wifi-phy.h:66
bool GetShortPlcpPreambleSupported(void) const
Return whether short PLCP preamble is supported.
Definition: wifi-phy.cc:648
double GetNoiseFigure(void) const
Return the noise figure.
static WifiMode GetPlcpHeaderMode(WifiTxVector txVector)
Definition: wifi-phy.cc:1834
static Time GetPlcpTrainingSymbolDuration(WifiTxVector txVector)
Definition: wifi-phy.cc:1725
Ptr< InterferenceHelper::Event > m_currentEvent
Hold the current event.
Definition: wifi-phy.h:1856
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
static WifiMode GetOfdmRate24MbpsBW10MHz()
Return a WifiMode for OFDM at 24Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2981
MpduType type
type
Definition: wifi-phy.h:81
Time m_channelSwitchDelay
Time required to switch between channel.
Definition: wifi-phy.h:1849
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
Return a WifiMode for OFDM at 13.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:3092
double m_ccaMode1ThresholdW
Clear channel assessment (CCA) threshold in watts.
Definition: wifi-phy.h:1823
double GetCcaMode1Threshold(void) const
Return the CCA threshold (dBm).
Definition: wifi-phy.cc:490
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
uint8_t FindChannelNumberForFrequencyWidth(uint16_t frequency, uint8_t width) const
Look for channel number matching the frequency and width.
Definition: wifi-phy.cc:1059
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
static WifiMode CreateWifiMcs(std::string uniqueName, uint8_t mcsValue, WifiModulationClass modClass)
Definition: wifi-mode.cc:719
bool IsStateIdle(void) const
Definition: wifi-phy.cc:3600
uint8_t m_numberOfAntennas
Number of transmitters.
Definition: wifi-phy.h:1838
static Time GetPlcpHeaderDuration(WifiTxVector txVector)
Definition: wifi-phy.cc:1880
a unique identifier for an interface.
Definition: type-id.h:58
MpduType
This enumeration defines the type of an MPDU.
Definition: wifi-phy.h:61
static WifiMode GetHtMcs15()
Return MCS 15 from HT MCS values.
Definition: wifi-phy.cc:3227
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
static WifiMode GetHtMcs3()
Return MCS 3 from HT MCS values.
Definition: wifi-phy.cc:3131
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
Definition: wifi-phy.h:1840
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6Mbps.
Definition: wifi-phy.cc:2810
void SwitchMaybeToCcaBusy(void)
Check if Phy state should move to CCA busy state based on current state of interference tracker...
Definition: wifi-phy.cc:3648
bool m_shortGuardInterval
Flag if HT/VHT short guard interval is supported.
Definition: wifi-phy.h:1833
WifiPhyStandard GetStandard(void) const
Get the configured Wi-Fi standard.
Definition: wifi-phy.cc:1197
double GetRxGain(void) const
Return the reception gain (dB).
Definition: wifi-phy.cc:569
struct InterferenceHelper::SnrPer CalculatePlcpPayloadSnrPer(Ptr< InterferenceHelper::Event > event) const
Calculate the SNIR at the start of the plcp payload and accumulate all SNIR changes in the snir vecto...
HE PHY (Clause 26)
Definition: wifi-mode.h:62
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:3759
DSSS PHY (Clause 15)
Definition: wifi-mode.h:46
static WifiMode GetHeMcs6()
Return MCS 6 from HE MCS values.
Definition: wifi-phy.cc:3496
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3570
static WifiMode GetHtPlcpHeaderMode()
Definition: wifi-phy.cc:1707
double GetTxPowerStart(void) const
Return the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:517
static WifiMode GetOfdmRate4_5MbpsBW5MHz()
Return a WifiMode for OFDM at 4.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:3044
bool m_stbc
Flag if STBC is used.
Definition: wifi-phy.h:1831
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
Definition: wifi-phy.h:1860
MpduType GetMpduType(void) const
Getter for mpduType parameter.
Definition: wifi-phy-tag.cc:85
void Configure80211a(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard...
Definition: wifi-phy.cc:827
std::map< ChannelNumberStandardPair, FrequencyWidthPair > ChannelToFrequencyWidthMap
channel to frequency width map typedef
Definition: wifi-phy.h:1842
static WifiMode GetOfdmRate3MbpsBW10MHz()
Return a WifiMode for OFDM at 3Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2909
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...
Definition: wifi-phy.h:1713
uint16_t m_initialFrequency
Store frequency until initialization.
Definition: wifi-phy.h:1818
bool DoChannelSwitch(uint8_t id)
The default implementation does nothing and returns true.
Definition: wifi-phy.cc:1488