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 "ns3/simulator.h"
23 #include "ns3/log.h"
24 #include "ns3/pointer.h"
25 #include "ns3/mobility-model.h"
26 #include "ns3/random-variable-stream.h"
27 #include "wifi-phy.h"
28 #include "wifi-phy-tag.h"
29 #include "ampdu-tag.h"
30 #include "wifi-utils.h"
31 #include "frame-capture-model.h"
33 #include "error-rate-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<uint16_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),
175  MakeDoubleChecker<double> ())
176  .AddAttribute ("CcaMode1Threshold",
177  "The energy of a received signal should be higher than "
178  "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.",
179  DoubleValue (-99.0),
182  MakeDoubleChecker<double> ())
183  .AddAttribute ("TxGain",
184  "Transmission gain (dB).",
185  DoubleValue (0.0),
188  MakeDoubleChecker<double> ())
189  .AddAttribute ("RxGain",
190  "Reception gain (dB).",
191  DoubleValue (0.0),
194  MakeDoubleChecker<double> ())
195  .AddAttribute ("TxPowerLevels",
196  "Number of transmission power levels available between "
197  "TxPowerStart and TxPowerEnd included.",
198  UintegerValue (1),
200  MakeUintegerChecker<uint8_t> ())
201  .AddAttribute ("TxPowerEnd",
202  "Maximum available transmission level (dbm).",
203  DoubleValue (16.0206),
206  MakeDoubleChecker<double> ())
207  .AddAttribute ("TxPowerStart",
208  "Minimum available transmission level (dbm).",
209  DoubleValue (16.0206),
212  MakeDoubleChecker<double> ())
213  .AddAttribute ("RxNoiseFigure",
214  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
215  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
216  "\"the difference in decibels (dB) between"
217  " the noise output of the actual receiver to the noise output of an "
218  " ideal receiver with the same overall gain and bandwidth when the receivers "
219  " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
220  DoubleValue (7),
222  MakeDoubleChecker<double> ())
223  .AddAttribute ("State",
224  "The state of the PHY layer.",
225  PointerValue (),
227  MakePointerChecker<WifiPhyStateHelper> ())
228  .AddAttribute ("ChannelSwitchDelay",
229  "Delay between two short frames transmitted on different frequencies.",
230  TimeValue (MicroSeconds (250)),
232  MakeTimeChecker ())
233  .AddAttribute ("Antennas",
234  "The number of antennas on the device.",
235  UintegerValue (1),
238  MakeUintegerChecker<uint8_t> (1, 8))
239  .AddAttribute ("MaxSupportedTxSpatialStreams",
240  "The maximum number of supported TX spatial streams."
241  "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
242  UintegerValue (1),
245  MakeUintegerChecker<uint8_t> (1, 8))
246  .AddAttribute ("MaxSupportedRxSpatialStreams",
247  "The maximum number of supported RX spatial streams."
248  "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
249  UintegerValue (1),
252  MakeUintegerChecker<uint8_t> (1, 8))
253  .AddAttribute ("ShortGuardEnabled",
254  "Whether or not short guard interval is enabled for HT/VHT transmissions."
255  "This parameter is only valuable for 802.11n/ac/ax STAs and APs.",
256  BooleanValue (false),
260  .AddAttribute ("GuardInterval",
261  "Whether 800ns, 1600ns or 3200ns guard interval is used for HE transmissions."
262  "This parameter is only valuable for 802.11ax STAs and APs.",
263  TimeValue (NanoSeconds (3200)),
266  MakeTimeChecker (NanoSeconds (400), NanoSeconds (3200)))
267  .AddAttribute ("LdpcEnabled",
268  "Whether or not LDPC is enabled (not supported yet!).",
269  BooleanValue (false),
273  .AddAttribute ("STBCEnabled",
274  "Whether or not STBC is enabled (not supported yet!).",
275  BooleanValue (false),
279  .AddAttribute ("GreenfieldEnabled",
280  "Whether or not Greenfield is enabled."
281  "This parameter is only valuable for 802.11n STAs and APs.",
282  BooleanValue (false),
286  .AddAttribute ("ShortPlcpPreambleSupported",
287  "Whether or not short PLCP preamble is supported."
288  "This parameter is only valuable for 802.11b STAs and APs."
289  "Note: 802.11g APs and STAs always support short PLCP preamble.",
290  BooleanValue (false),
294  .AddAttribute ("FrameCaptureModel",
295  "Ptr to an object that implements the frame capture model",
296  PointerValue (),
298  MakePointerChecker <FrameCaptureModel> ())
299  .AddTraceSource ("PhyTxBegin",
300  "Trace source indicating a packet "
301  "has begun transmitting over the channel medium",
303  "ns3::Packet::TracedCallback")
304  .AddTraceSource ("PhyTxEnd",
305  "Trace source indicating a packet "
306  "has been completely transmitted over the channel. "
307  "NOTE: the only official WifiPhy implementation "
308  "available to this date never fires "
309  "this trace source.",
311  "ns3::Packet::TracedCallback")
312  .AddTraceSource ("PhyTxDrop",
313  "Trace source indicating a packet "
314  "has been dropped by the device during transmission",
316  "ns3::Packet::TracedCallback")
317  .AddTraceSource ("PhyRxBegin",
318  "Trace source indicating a packet "
319  "has begun being received from the channel medium "
320  "by the device",
322  "ns3::Packet::TracedCallback")
323  .AddTraceSource ("PhyRxEnd",
324  "Trace source indicating a packet "
325  "has been completely received from the channel medium "
326  "by the device",
328  "ns3::Packet::TracedCallback")
329  .AddTraceSource ("PhyRxDrop",
330  "Trace source indicating a packet "
331  "has been dropped by the device during reception",
333  "ns3::Packet::TracedCallback")
334  .AddTraceSource ("MonitorSnifferRx",
335  "Trace source simulating a wifi device in monitor mode "
336  "sniffing all received frames",
338  "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
339  .AddTraceSource ("MonitorSnifferTx",
340  "Trace source simulating the capability of a wifi device "
341  "in monitor mode to sniff all frames being transmitted",
343  "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
344  ;
345  return tid;
346 }
347 
349  : m_mpdusNum (0),
350  m_plcpSuccess (false),
351  m_txMpduReferenceNumber (0xffffffff),
352  m_rxMpduReferenceNumber (0xffffffff),
353  m_endRxEvent (),
354  m_endPlcpRxEvent (),
356  m_isConstructed (false),
358  m_initialFrequency (0),
360  m_channelWidth (0),
361  m_txSpatialStreams (0),
362  m_rxSpatialStreams (0),
363  m_channelNumber (0),
365  m_totalAmpduSize (0),
367  m_currentEvent (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 WToDbm (m_edThresholdW);
474 }
475 
476 void
478 {
479  NS_LOG_FUNCTION (this << threshold);
480  m_ccaMode1ThresholdW = DbmToW (threshold);
481 }
482 
483 double
485 {
486  return WToDbm (m_ccaMode1ThresholdW);
487 }
488 
489 void
490 WifiPhy::SetRxNoiseFigure (double noiseFigureDb)
491 {
492  NS_LOG_FUNCTION (this << noiseFigureDb);
493  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
495 }
496 
497 void
499 {
500  NS_LOG_FUNCTION (this << start);
502 }
503 
504 double
506 {
507  return m_txPowerBaseDbm;
508 }
509 
510 void
512 {
513  NS_LOG_FUNCTION (this << end);
514  m_txPowerEndDbm = end;
515 }
516 
517 double
519 {
520  return m_txPowerEndDbm;
521 }
522 
523 void
525 {
526  NS_LOG_FUNCTION (this << +n);
527  m_nTxPower = n;
528 }
529 
530 uint8_t
532 {
533  return m_nTxPower;
534 }
535 
536 void
537 WifiPhy::SetTxGain (double gain)
538 {
539  NS_LOG_FUNCTION (this << gain);
540  m_txGainDb = gain;
541 }
542 
543 double
544 WifiPhy::GetTxGain (void) const
545 {
546  return m_txGainDb;
547 }
548 
549 void
550 WifiPhy::SetRxGain (double gain)
551 {
552  NS_LOG_FUNCTION (this << gain);
553  m_rxGainDb = gain;
554 }
555 
556 double
557 WifiPhy::GetRxGain (void) const
558 {
559  return m_rxGainDb;
560 }
561 
562 void
563 WifiPhy::SetLdpc (bool ldpc)
564 {
565  NS_LOG_FUNCTION (this << ldpc);
566  m_ldpc = ldpc;
567 }
568 
569 bool
570 WifiPhy::GetLdpc (void) const
571 {
572  return m_ldpc;
573 }
574 
575 void
576 WifiPhy::SetStbc (bool stbc)
577 {
578  NS_LOG_FUNCTION (this << stbc);
579  m_stbc = stbc;
580 }
581 
582 bool
583 WifiPhy::GetStbc (void) const
584 {
585  return m_stbc;
586 }
587 
588 void
589 WifiPhy::SetGreenfield (bool greenfield)
590 {
591  NS_LOG_FUNCTION (this << greenfield);
592  m_greenfield = greenfield;
593 }
594 
595 bool
597 {
598  return m_greenfield;
599 }
600 
601 void
602 WifiPhy::SetShortGuardInterval (bool shortGuardInterval)
603 {
604  NS_LOG_FUNCTION (this << shortGuardInterval);
605  m_shortGuardInterval = shortGuardInterval;
606 }
607 
608 bool
610 {
611  return m_shortGuardInterval;
612 }
613 
614 void
616 {
617  NS_LOG_FUNCTION (this << guardInterval);
618  NS_ASSERT (guardInterval == NanoSeconds (800) || guardInterval == NanoSeconds (1600) || guardInterval == NanoSeconds (3200));
619  m_guardInterval = guardInterval;
620 }
621 
622 Time
624 {
625  return m_guardInterval;
626 }
627 
628 void
630 {
631  NS_LOG_FUNCTION (this << enable);
632  m_shortPreamble = enable;
633 }
634 
635 bool
637 {
638  return m_shortPreamble;
639 }
640 
641 void
643 {
644  m_device = device;
645 }
646 
648 WifiPhy::GetDevice (void) const
649 {
650  return m_device;
651 }
652 
653 void
655 {
657 }
658 
661 {
662  if (m_mobility != 0)
663  {
664  return m_mobility;
665  }
666  else
667  {
668  return m_device->GetNode ()->GetObject<MobilityModel> ();
669  }
670 }
671 
672 void
674 {
677 }
678 
679 void
681 {
682  m_frameCaptureModel = model;
683 }
684 
685 void
687 {
688  m_wifiRadioEnergyModel = wifiRadioEnergyModel;
689 }
690 
691 double
692 WifiPhy::GetPowerDbm (uint8_t power) const
693 {
695  NS_ASSERT (m_nTxPower > 0);
696  double dbm;
697  if (m_nTxPower > 1)
698  {
699  dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
700  }
701  else
702  {
703  NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
704  dbm = m_txPowerBaseDbm;
705  }
706  return dbm;
707 }
708 
709 Time
711 {
712  return m_channelSwitchDelay;
713 }
714 
715 double
716 WifiPhy::CalculateSnr (WifiTxVector txVector, double ber) const
717 {
718  return m_interference.GetErrorRateModel ()->CalculateSnr (txVector, ber);
719 }
720 
721 void
723 {
724  NS_LOG_FUNCTION (this << standard);
725  switch (standard)
726  {
728  SetChannelWidth (20);
729  SetFrequency (5180);
730  // Channel number should be aligned by SetFrequency () to 36
731  NS_ASSERT (GetChannelNumber () == 36);
732  break;
734  SetChannelWidth (22);
735  SetFrequency (2412);
736  // Channel number should be aligned by SetFrequency () to 1
737  NS_ASSERT (GetChannelNumber () == 1);
738  break;
740  SetChannelWidth (20);
741  SetFrequency (2412);
742  // Channel number should be aligned by SetFrequency () to 1
743  NS_ASSERT (GetChannelNumber () == 1);
744  break;
746  SetChannelWidth (10);
747  SetFrequency (5860);
748  // Channel number should be aligned by SetFrequency () to 172
749  NS_ASSERT (GetChannelNumber () == 172);
750  break;
752  SetChannelWidth (5);
753  SetFrequency (5860);
754  // Channel number should be aligned by SetFrequency () to 0
755  NS_ASSERT (GetChannelNumber () == 0);
756  break;
758  SetChannelWidth (20);
759  SetFrequency (5180);
760  // Channel number should be aligned by SetFrequency () to 36
761  NS_ASSERT (GetChannelNumber () == 36);
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 (20);
771  SetFrequency (5180);
772  // Channel number should be aligned by SetFrequency () to 36
773  NS_ASSERT (GetChannelNumber () == 36);
774  break;
776  SetChannelWidth (80);
777  SetFrequency (5210);
778  // Channel number should be aligned by SetFrequency () to 42
779  NS_ASSERT (GetChannelNumber () == 42);
780  break;
782  SetChannelWidth (20);
783  SetFrequency (2412);
784  // Channel number should be aligned by SetFrequency () to 1
785  NS_ASSERT (GetChannelNumber () == 1);
786  break;
788  SetChannelWidth (80);
789  SetFrequency (5210);
790  // Channel number should be aligned by SetFrequency () to 42
791  NS_ASSERT (GetChannelNumber () == 42);
792  break;
794  default:
795  NS_LOG_WARN ("Configuring unspecified standard; performing no action");
796  break;
797  }
798 }
799 
800 void
802 {
803  NS_LOG_FUNCTION (this);
804 
813 }
814 
815 void
817 {
818  NS_LOG_FUNCTION (this);
819 
824 }
825 
826 void
828 {
829  NS_LOG_FUNCTION (this);
830  Configure80211b ();
831 
840 }
841 
842 void
844 {
845  NS_LOG_FUNCTION (this);
846 
855 }
856 
857 void
859 {
860  NS_LOG_FUNCTION (this);
861 
870 }
871 
872 void
874 {
875  NS_LOG_FUNCTION (this);
876 
882 }
883 
884 void
886 {
887  NS_LOG_FUNCTION (this);
888 
889  bool htFound = false;
890  for (std::vector<uint8_t>::size_type i = 0; i < m_bssMembershipSelectorSet.size (); i++)
891  {
893  {
894  htFound = true;
895  break;
896  }
897  }
898  if (htFound)
899  {
900  // erase all HtMcs modes from deviceMcsSet
901  std::size_t index = m_deviceMcsSet.size () - 1;
902  for (std::vector<WifiMode>::reverse_iterator rit = m_deviceMcsSet.rbegin (); rit != m_deviceMcsSet.rend (); ++rit, --index)
903  {
904  if (m_deviceMcsSet[index].GetModulationClass () == WIFI_MOD_CLASS_HT)
905  {
906  m_deviceMcsSet.erase (m_deviceMcsSet.begin () + index);
907  }
908  }
909  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs0 ());
910  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs1 ());
911  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs2 ());
912  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs3 ());
913  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs4 ());
914  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs5 ());
915  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs6 ());
916  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs7 ());
918  {
919  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs8 ());
920  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs9 ());
921  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs10 ());
922  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs11 ());
923  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs12 ());
924  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs13 ());
925  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs14 ());
926  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs15 ());
927  }
929  {
930  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs16 ());
931  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs17 ());
932  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs18 ());
933  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs19 ());
934  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs20 ());
935  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs21 ());
936  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs22 ());
937  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs23 ());
938  }
940  {
941  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs24 ());
942  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs25 ());
943  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs26 ());
944  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs27 ());
945  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs28 ());
946  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs29 ());
947  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs30 ());
948  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs31 ());
949  }
950  }
951 }
952 
953 void
955 {
956  NS_LOG_FUNCTION (this);
957  if (Is2_4Ghz (GetFrequency ()))
958  {
959  Configure80211b ();
960  Configure80211g ();
961  }
962  if (Is5Ghz (GetFrequency ()))
963  {
964  Configure80211a ();
965  }
968 }
969 
970 void
972 {
973  NS_LOG_FUNCTION (this);
974  Configure80211n ();
975 
976  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs0 ());
977  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs1 ());
978  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs2 ());
979  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs3 ());
980  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs4 ());
981  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs5 ());
982  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs6 ());
983  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs7 ());
984  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs8 ());
985  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs9 ());
986 
988 }
989 
990 void
992 {
993  NS_LOG_FUNCTION (this);
994  Configure80211n ();
995  if (Is5Ghz (GetFrequency ()))
996  {
997  Configure80211ac ();
998  }
999  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs0 ());
1000  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs1 ());
1001  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs2 ());
1002  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs3 ());
1003  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs4 ());
1004  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs5 ());
1005  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs6 ());
1006  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs7 ());
1007  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs8 ());
1008  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs9 ());
1009  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs10 ());
1010  m_deviceMcsSet.push_back (WifiPhy::GetHeMcs11 ());
1011 
1012  m_bssMembershipSelectorSet.push_back (HE_PHY);
1013 }
1014 
1015 bool
1016 WifiPhy::DefineChannelNumber (uint8_t channelNumber, WifiPhyStandard standard, uint16_t frequency, uint16_t channelWidth)
1017 {
1018  NS_LOG_FUNCTION (this << +channelNumber << standard << frequency << channelWidth);
1019  ChannelNumberStandardPair p = std::make_pair (channelNumber, standard);
1020  ChannelToFrequencyWidthMap::const_iterator it;
1021  it = m_channelToFrequencyWidth.find (p);
1022  if (it != m_channelToFrequencyWidth.end ())
1023  {
1024  NS_LOG_DEBUG ("channel number/standard already defined; returning false");
1025  return false;
1026  }
1027  FrequencyWidthPair f = std::make_pair (frequency, channelWidth);
1029  return true;
1030 }
1031 
1032 uint8_t
1033 WifiPhy::FindChannelNumberForFrequencyWidth (uint16_t frequency, uint16_t width) const
1034 {
1035  NS_LOG_FUNCTION (this << frequency << width);
1036  bool found = false;
1037  FrequencyWidthPair f = std::make_pair (frequency, width);
1038  ChannelToFrequencyWidthMap::const_iterator it = m_channelToFrequencyWidth.begin ();
1039  while (it != m_channelToFrequencyWidth.end ())
1040  {
1041  if (it->second == f)
1042  {
1043  found = true;
1044  break;
1045  }
1046  ++it;
1047  }
1048  if (found)
1049  {
1050  NS_LOG_DEBUG ("Found, returning " << +it->first.first);
1051  return (it->first.first);
1052  }
1053  else
1054  {
1055  NS_LOG_DEBUG ("Not found, returning 0");
1056  return 0;
1057  }
1058 }
1059 
1060 void
1062 {
1063  NS_LOG_FUNCTION (this << standard);
1064  // If the user has configured both Frequency and ChannelNumber, Frequency
1065  // takes precedence
1066  if (GetFrequency () != 0)
1067  {
1068  // If Frequency is already set, then see whether a ChannelNumber can
1069  // be found that matches Frequency and ChannelWidth. If so, configure
1070  // the ChannelNumber to that channel number. If not, set ChannelNumber to zero.
1071  NS_LOG_DEBUG ("Frequency set; checking whether a channel number corresponds");
1072  uint8_t channelNumberSearched = FindChannelNumberForFrequencyWidth (GetFrequency (), GetChannelWidth ());
1073  if (channelNumberSearched)
1074  {
1075  NS_LOG_DEBUG ("Channel number found; setting to " << +channelNumberSearched);
1076  SetChannelNumber (channelNumberSearched);
1077  }
1078  else
1079  {
1080  NS_LOG_DEBUG ("Channel number not found; setting to zero");
1081  SetChannelNumber (0);
1082  }
1083  }
1084  else if (GetChannelNumber () != 0)
1085  {
1086  // If the channel number is known for this particular standard or for
1087  // the unspecified standard, configure using the known values;
1088  // otherwise, this is a configuration error
1089  NS_LOG_DEBUG ("Configuring for channel number " << +GetChannelNumber ());
1091  if (f.first == 0)
1092  {
1093  // the specific pair of number/standard is not known
1094  NS_LOG_DEBUG ("Falling back to check WIFI_PHY_STANDARD_UNSPECIFIED");
1096  }
1097  if (f.first == 0)
1098  {
1099  NS_FATAL_ERROR ("Error, ChannelNumber " << +GetChannelNumber () << " is unknown for this standard");
1100  }
1101  else
1102  {
1103  NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << +f.second);
1104  SetFrequency (f.first);
1105  SetChannelWidth (f.second);
1106  }
1107  }
1108 }
1109 
1110 void
1112 {
1113  NS_LOG_FUNCTION (this << standard);
1114  m_standard = standard;
1115  m_isConstructed = true;
1117  {
1119  }
1120  if (GetFrequency () == 0 && GetChannelNumber () == 0)
1121  {
1122  ConfigureDefaultsForStandard (standard);
1123  }
1124  else
1125  {
1126  // The user has configured either (or both) Frequency or ChannelNumber
1127  ConfigureChannelForStandard (standard);
1128  }
1129  switch (standard)
1130  {
1132  Configure80211a ();
1133  break;
1135  Configure80211b ();
1136  break;
1138  Configure80211g ();
1139  break;
1142  break;
1145  break;
1147  ConfigureHolland ();
1148  break;
1150  Configure80211n ();
1151  break;
1153  Configure80211n ();
1154  break;
1156  Configure80211ac ();
1157  break;
1159  Configure80211ax ();
1160  break;
1162  Configure80211ax ();
1163  break;
1165  default:
1166  NS_ASSERT (false);
1167  break;
1168  }
1169 }
1170 
1173 {
1174  return m_standard;
1175 }
1176 
1177 void
1178 WifiPhy::SetFrequency (uint16_t frequency)
1179 {
1180  NS_LOG_FUNCTION (this << frequency);
1181  if (m_isConstructed == false)
1182  {
1183  NS_LOG_DEBUG ("Saving frequency configuration for initialization");
1184  m_initialFrequency = frequency;
1185  return;
1186  }
1187  if (GetFrequency () == frequency)
1188  {
1189  NS_LOG_DEBUG ("No frequency change requested");
1190  return;
1191  }
1192  if (frequency == 0)
1193  {
1194  DoFrequencySwitch (0);
1195  NS_LOG_DEBUG ("Setting frequency and channel number to zero");
1197  m_channelNumber = 0;
1198  return;
1199  }
1200  // If the user has configured both Frequency and ChannelNumber, Frequency
1201  // takes precedence. Lookup the channel number corresponding to the
1202  // requested frequency.
1203  uint8_t nch = FindChannelNumberForFrequencyWidth (frequency, GetChannelWidth ());
1204  if (nch != 0)
1205  {
1206  NS_LOG_DEBUG ("Setting frequency " << frequency << " corresponds to channel " << +nch);
1207  if (DoFrequencySwitch (frequency))
1208  {
1209  NS_LOG_DEBUG ("Channel frequency switched to " << frequency << "; channel number to " << +nch);
1210  m_channelCenterFrequency = frequency;
1211  m_channelNumber = nch;
1212  }
1213  else
1214  {
1215  NS_LOG_DEBUG ("Suppressing reassignment of frequency");
1216  }
1217  }
1218  else
1219  {
1220  NS_LOG_DEBUG ("Channel number is unknown for frequency " << frequency);
1221  if (DoFrequencySwitch (frequency))
1222  {
1223  NS_LOG_DEBUG ("Channel frequency switched to " << frequency << "; channel number to " << 0);
1224  m_channelCenterFrequency = frequency;
1225  m_channelNumber = 0;
1226  }
1227  else
1228  {
1229  NS_LOG_DEBUG ("Suppressing reassignment of frequency");
1230  }
1231  }
1232 }
1233 
1234 uint16_t
1236 {
1237  return m_channelCenterFrequency;
1238 }
1239 
1240 void
1241 WifiPhy::SetChannelWidth (uint16_t channelwidth)
1242 {
1243  NS_LOG_FUNCTION (this << channelwidth);
1244  NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 || channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth == 160, "wrong channel width value");
1245  bool changed = (m_channelWidth == channelwidth);
1246  m_channelWidth = channelwidth;
1247  AddSupportedChannelWidth (channelwidth);
1248  if (changed && !m_capabilitiesChangedCallback.IsNull ())
1249  {
1251  }
1252 }
1253 
1254 uint16_t
1256 {
1257  return m_channelWidth;
1258 }
1259 
1260 void
1262 {
1263  NS_ASSERT_MSG (antennas > 0 && antennas <= 4, "unsupported number of antennas");
1264  m_numberOfAntennas = antennas;
1266 }
1267 
1268 uint8_t
1270 {
1271  return m_numberOfAntennas;
1272 }
1273 
1274 void
1276 {
1277  NS_ASSERT (streams <= GetNumberOfAntennas ());
1278  bool changed = (m_txSpatialStreams == streams);
1279  m_txSpatialStreams = streams;
1281  if (changed && !m_capabilitiesChangedCallback.IsNull ())
1282  {
1284  }
1285 }
1286 
1287 uint8_t
1289 {
1290  return m_txSpatialStreams;
1291 }
1292 
1293 void
1295 {
1296  NS_ASSERT (streams <= GetNumberOfAntennas ());
1297  bool changed = (m_rxSpatialStreams == streams);
1298  m_rxSpatialStreams = streams;
1299  if (changed && !m_capabilitiesChangedCallback.IsNull ())
1300  {
1302  }
1303 }
1304 
1305 uint8_t
1307 {
1308  return m_rxSpatialStreams;
1309 }
1310 
1311 uint8_t
1313 {
1314  return static_cast<uint8_t> (m_bssMembershipSelectorSet.size ());
1315 }
1316 
1317 uint8_t
1318 WifiPhy::GetBssMembershipSelector (uint8_t selector) const
1319 {
1320  return m_bssMembershipSelectorSet[selector];
1321 }
1322 
1323 void
1325 {
1326  NS_LOG_FUNCTION (this << width);
1327  for (std::vector<uint32_t>::size_type i = 0; i != m_supportedChannelWidthSet.size (); i++)
1328  {
1329  if (m_supportedChannelWidthSet[i] == width)
1330  {
1331  return;
1332  }
1333  }
1334  NS_LOG_FUNCTION ("Adding " << width << " to supported channel width set");
1335  m_supportedChannelWidthSet.push_back (width);
1336 }
1337 
1338 std::vector<uint16_t>
1340 {
1342 }
1343 
1346 {
1347  ChannelNumberStandardPair p = std::make_pair (channelNumber, standard);
1349  return f;
1350 }
1351 
1352 void
1354 {
1355  NS_LOG_FUNCTION (this << +nch);
1356  if (m_isConstructed == false)
1357  {
1358  NS_LOG_DEBUG ("Saving channel number configuration for initialization");
1359  m_initialChannelNumber = nch;
1360  return;
1361  }
1362  if (GetChannelNumber () == nch)
1363  {
1364  NS_LOG_DEBUG ("No channel change requested");
1365  return;
1366  }
1367  if (nch == 0)
1368  {
1369  // This case corresponds to when there is not a known channel
1370  // number for the requested frequency. There is no need to call
1371  // DoChannelSwitch () because DoFrequencySwitch () should have been
1372  // called by the client
1373  NS_LOG_DEBUG ("Setting channel number to zero");
1374  m_channelNumber = 0;
1375  return;
1376  }
1377 
1378  // First make sure that the channel number is defined for the standard
1379  // in use
1381  if (f.first == 0)
1382  {
1384  }
1385  if (f.first != 0)
1386  {
1387  if (DoChannelSwitch (nch))
1388  {
1389  NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << +f.second);
1390  m_channelCenterFrequency = f.first;
1391  SetChannelWidth (f.second);
1392  m_channelNumber = nch;
1393  }
1394  else
1395  {
1396  // Subclass may have suppressed (e.g. waiting for state change)
1397  NS_LOG_DEBUG ("Channel switch suppressed");
1398  }
1399  }
1400  else
1401  {
1402  NS_FATAL_ERROR ("Frequency not found for channel number " << nch);
1403  }
1404 }
1405 
1406 uint8_t
1408 {
1409  return m_channelNumber;
1410 }
1411 
1412 bool
1414 {
1415  if (!IsInitialized ())
1416  {
1417  //this is not channel switch, this is initialization
1418  NS_LOG_DEBUG ("initialize to channel " << +nch);
1419  return true;
1420  }
1421 
1423  switch (m_state->GetState ())
1424  {
1425  case WifiPhyState::RX:
1426  NS_LOG_DEBUG ("drop packet because of channel switching while reception");
1428  m_endRxEvent.Cancel ();
1429  goto switchChannel;
1430  break;
1431  case WifiPhyState::TX:
1432  NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
1434  break;
1436  case WifiPhyState::IDLE:
1437  goto switchChannel;
1438  break;
1439  case WifiPhyState::SLEEP:
1440  NS_LOG_DEBUG ("channel switching ignored in sleep mode");
1441  break;
1442  default:
1443  NS_ASSERT (false);
1444  break;
1445  }
1446 
1447  return false;
1448 
1449 switchChannel:
1450 
1451  NS_LOG_DEBUG ("switching channel " << +GetChannelNumber () << " -> " << +nch);
1452  m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ());
1454  /*
1455  * Needed here to be able to correctly sensed the medium for the first
1456  * time after the switching. The actual switching is not performed until
1457  * after m_channelSwitchDelay. Packets received during the switching
1458  * state are added to the event list and are employed later to figure
1459  * out the state of the medium after the switching.
1460  */
1461  return true;
1462 }
1463 
1464 bool
1465 WifiPhy::DoFrequencySwitch (uint16_t frequency)
1466 {
1467  if (!IsInitialized ())
1468  {
1469  //this is not channel switch, this is initialization
1470  NS_LOG_DEBUG ("start at frequency " << frequency);
1471  return true;
1472  }
1473 
1475  switch (m_state->GetState ())
1476  {
1477  case WifiPhyState::RX:
1478  NS_LOG_DEBUG ("drop packet because of channel/frequency switching while reception");
1480  m_endRxEvent.Cancel ();
1481  goto switchFrequency;
1482  break;
1483  case WifiPhyState::TX:
1484  NS_LOG_DEBUG ("channel/frequency switching postponed until end of current transmission");
1486  break;
1488  case WifiPhyState::IDLE:
1489  goto switchFrequency;
1490  break;
1491  case WifiPhyState::SLEEP:
1492  NS_LOG_DEBUG ("frequency switching ignored in sleep mode");
1493  break;
1494  default:
1495  NS_ASSERT (false);
1496  break;
1497  }
1498 
1499  return false;
1500 
1501 switchFrequency:
1502 
1503  NS_LOG_DEBUG ("switching frequency " << GetFrequency () << " -> " << frequency);
1504  m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ());
1506  /*
1507  * Needed here to be able to correctly sensed the medium for the first
1508  * time after the switching. The actual switching is not performed until
1509  * after m_channelSwitchDelay. Packets received during the switching
1510  * state are added to the event list and are employed later to figure
1511  * out the state of the medium after the switching.
1512  */
1513  return true;
1514 }
1515 
1516 void
1518 {
1519  NS_LOG_FUNCTION (this);
1520  switch (m_state->GetState ())
1521  {
1522  case WifiPhyState::TX:
1523  NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmission");
1525  break;
1526  case WifiPhyState::RX:
1527  NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception");
1529  break;
1531  NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching");
1533  break;
1535  case WifiPhyState::IDLE:
1536  NS_LOG_DEBUG ("setting sleep mode");
1537  m_state->SwitchToSleep ();
1538  break;
1539  case WifiPhyState::SLEEP:
1540  NS_LOG_DEBUG ("already in sleep mode");
1541  break;
1542  default:
1543  NS_ASSERT (false);
1544  break;
1545  }
1546 }
1547 
1548 void
1550 {
1551  NS_LOG_FUNCTION (this);
1552  switch (m_state->GetState ())
1553  {
1554  case WifiPhyState::RX:
1556  m_endRxEvent.Cancel ();
1557  case WifiPhyState::TX:
1560  case WifiPhyState::IDLE:
1561  case WifiPhyState::SLEEP:
1562  m_state->SwitchToOff ();
1563  break;
1564  default:
1565  NS_ASSERT (false);
1566  break;
1567  }
1568 }
1569 
1570 void
1572 {
1573  NS_LOG_FUNCTION (this);
1574  switch (m_state->GetState ())
1575  {
1576  case WifiPhyState::TX:
1577  case WifiPhyState::RX:
1578  case WifiPhyState::IDLE:
1581  {
1582  NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume");
1583  break;
1584  }
1585  case WifiPhyState::SLEEP:
1586  {
1587  NS_LOG_DEBUG ("resuming from sleep mode");
1589  m_state->SwitchFromSleep (delayUntilCcaEnd);
1590  break;
1591  }
1592  default:
1593  {
1594  NS_ASSERT (false);
1595  break;
1596  }
1597  }
1598 }
1599 
1600 void
1602 {
1603  NS_LOG_FUNCTION (this);
1604  switch (m_state->GetState ())
1605  {
1606  case WifiPhyState::TX:
1607  case WifiPhyState::RX:
1608  case WifiPhyState::IDLE:
1611  case WifiPhyState::SLEEP:
1612  {
1613  NS_LOG_DEBUG ("not in off mode, there is nothing to resume");
1614  break;
1615  }
1616  case WifiPhyState::OFF:
1617  {
1618  NS_LOG_DEBUG ("resuming from off mode");
1620  m_state->SwitchFromOff (delayUntilCcaEnd);
1621  break;
1622  }
1623  default:
1624  {
1625  NS_ASSERT (false);
1626  break;
1627  }
1628  }
1629 }
1630 
1631 WifiMode
1633 {
1634  return WifiPhy::GetHtMcs0 ();
1635 }
1636 
1637 WifiMode
1639 {
1640  return WifiPhy::GetVhtMcs0 ();
1641 }
1642 
1643 WifiMode
1645 {
1646  return WifiPhy::GetHeMcs0 ();
1647 }
1648 
1649 Time
1651 {
1652  uint8_t Ndltf, Neltf;
1653  //We suppose here that STBC = 0.
1654  //If STBC > 0, we need a different mapping between Nss and Nltf (IEEE 802.11n-2012 standard, page 1682).
1655  if (txVector.GetNss () < 3)
1656  {
1657  Ndltf = txVector.GetNss ();
1658  }
1659  else if (txVector.GetNss () < 5)
1660  {
1661  Ndltf = 4;
1662  }
1663  else if (txVector.GetNss () < 7)
1664  {
1665  Ndltf = 6;
1666  }
1667  else
1668  {
1669  Ndltf = 8;
1670  }
1671 
1672  if (txVector.GetNess () < 3)
1673  {
1674  Neltf = txVector.GetNess ();
1675  }
1676  else
1677  {
1678  Neltf = 4;
1679  }
1680 
1681  switch (txVector.GetPreambleType ())
1682  {
1683  case WIFI_PREAMBLE_HT_MF:
1684  return MicroSeconds (4 + (4 * Ndltf) + (4 * Neltf));
1685  case WIFI_PREAMBLE_HT_GF:
1686  return MicroSeconds ((4 * Ndltf) + (4 * Neltf));
1687  case WIFI_PREAMBLE_VHT:
1688  return MicroSeconds (4 + (4 * Ndltf));
1689  case WIFI_PREAMBLE_HE_SU:
1690  return MicroSeconds (4 + (8 * Ndltf));
1691  default:
1692  return MicroSeconds (0);
1693  }
1694 }
1695 
1696 Time
1698 {
1699  switch (preamble)
1700  {
1701  case WIFI_PREAMBLE_HT_MF:
1702  case WIFI_PREAMBLE_HT_GF:
1703  //HT-SIG
1704  return MicroSeconds (8);
1705  default:
1706  //no HT-SIG for non HT
1707  return MicroSeconds (0);
1708  }
1709 }
1710 
1711 Time
1713 {
1714  switch (preamble)
1715  {
1716  case WIFI_PREAMBLE_VHT:
1717  case WIFI_PREAMBLE_HE_SU:
1718  //VHT-SIG-A1 and HE-SIG-A1
1719  return MicroSeconds (4);
1720  default:
1721  // no SIG-A1
1722  return MicroSeconds (0);
1723  }
1724 }
1725 
1726 Time
1728 {
1729  switch (preamble)
1730  {
1731  case WIFI_PREAMBLE_VHT:
1732  case WIFI_PREAMBLE_HE_SU:
1733  //VHT-SIG-A2 and HE-SIG-A2
1734  return MicroSeconds (4);
1735  default:
1736  // no SIG-A2
1737  return MicroSeconds (0);
1738  }
1739 }
1740 
1741 Time
1743 {
1744  switch (preamble)
1745  {
1746  case WIFI_PREAMBLE_VHT:
1747  //VHT-SIG-B
1748  return MicroSeconds (4);
1749  case WIFI_PREAMBLE_HE_SU:
1750  //HE-SIG-B: MU not supported so HE-SIG-B not used
1751  return MicroSeconds (0);
1752  default:
1753  // no SIG-B
1754  return MicroSeconds (0);
1755  }
1756 }
1757 
1758 WifiMode
1760 {
1761  switch (txVector.GetMode ().GetModulationClass ())
1762  {
1763  case WIFI_MOD_CLASS_OFDM:
1764  case WIFI_MOD_CLASS_HT:
1765  case WIFI_MOD_CLASS_VHT:
1766  case WIFI_MOD_CLASS_HE:
1767  switch (txVector.GetChannelWidth ())
1768  {
1769  case 5:
1771  case 10:
1773  case 20:
1774  case 40:
1775  case 80:
1776  case 160:
1777  default:
1778  //(Section 18.3.2 "PLCP frame format"; IEEE Std 802.11-2012)
1779  //actually this is only the first part of the PlcpHeader,
1780  //because the last 16 bits of the PlcpHeader are using the
1781  //same mode of the payload
1782  return WifiPhy::GetOfdmRate6Mbps ();
1783  }
1785  return WifiPhy::GetErpOfdmRate6Mbps ();
1786  case WIFI_MOD_CLASS_DSSS:
1788  if (txVector.GetPreambleType () == WIFI_PREAMBLE_LONG || txVector.GetMode () == WifiPhy::GetDsssRate1Mbps ())
1789  {
1790  //(Section 16.2.3 "PLCP field definitions" and Section 17.2.2.2 "Long PPDU format"; IEEE Std 802.11-2012)
1791  return WifiPhy::GetDsssRate1Mbps ();
1792  }
1793  else //WIFI_PREAMBLE_SHORT
1794  {
1795  //(Section 17.2.2.3 "Short PPDU format"; IEEE Std 802.11-2012)
1796  return WifiPhy::GetDsssRate2Mbps ();
1797  }
1798  default:
1799  NS_FATAL_ERROR ("unsupported modulation class");
1800  return WifiMode ();
1801  }
1802 }
1803 
1804 Time
1806 {
1807  WifiPreamble preamble = txVector.GetPreambleType ();
1808  if (preamble == WIFI_PREAMBLE_NONE)
1809  {
1810  return MicroSeconds (0);
1811  }
1812  switch (txVector.GetMode ().GetModulationClass ())
1813  {
1814  case WIFI_MOD_CLASS_OFDM:
1815  {
1816  switch (txVector.GetChannelWidth ())
1817  {
1818  case 20:
1819  default:
1820  //(Section 18.3.3 "PLCP preamble (SYNC))" and Figure 18-4 "OFDM training structure"; IEEE Std 802.11-2012)
1821  //also (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
1822  //We return the duration of the SIGNAL field only, since the
1823  //SERVICE field (which strictly speaking belongs to the PLCP
1824  //header, see Section 18.3.2 and Figure 18-1) is sent using the
1825  //payload mode.
1826  return MicroSeconds (4);
1827  case 10:
1828  //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
1829  return MicroSeconds (8);
1830  case 5:
1831  //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
1832  return MicroSeconds (16);
1833  }
1834  }
1835  case WIFI_MOD_CLASS_HT:
1836  {
1837  //L-SIG
1838  //IEEE 802.11n Figure 20.1
1839  switch (preamble)
1840  {
1841  case WIFI_PREAMBLE_HT_MF:
1842  default:
1843  return MicroSeconds (4);
1844  case WIFI_PREAMBLE_HT_GF:
1845  return MicroSeconds (0);
1846  }
1847  }
1849  case WIFI_MOD_CLASS_VHT:
1850  //L-SIG
1851  return MicroSeconds (4);
1852  case WIFI_MOD_CLASS_HE:
1853  //LSIG + R-LSIG
1854  return MicroSeconds (8);
1855  case WIFI_MOD_CLASS_DSSS:
1857  if ((preamble == WIFI_PREAMBLE_SHORT) && (txVector.GetMode ().GetDataRate (22) > 1000000))
1858  {
1859  //(Section 17.2.2.3 "Short PPDU format" and Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
1860  return MicroSeconds (24);
1861  }
1862  else //WIFI_PREAMBLE_LONG
1863  {
1864  //(Section 17.2.2.2 "Long PPDU format" and Figure 17-1 "Short PPDU format"; IEEE Std 802.11-2012)
1865  return MicroSeconds (48);
1866  }
1867  default:
1868  NS_FATAL_ERROR ("unsupported modulation class");
1869  return MicroSeconds (0);
1870  }
1871 }
1872 
1873 Time
1875 {
1876  WifiPreamble preamble = txVector.GetPreambleType ();
1877  if (preamble == WIFI_PREAMBLE_NONE)
1878  {
1879  return MicroSeconds (0);
1880  }
1881  switch (txVector.GetMode ().GetModulationClass ())
1882  {
1883  case WIFI_MOD_CLASS_OFDM:
1884  {
1885  switch (txVector.GetChannelWidth ())
1886  {
1887  case 20:
1888  default:
1889  //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
1890  //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
1891  return MicroSeconds (16);
1892  case 10:
1893  //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
1894  //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
1895  return MicroSeconds (32);
1896  case 5:
1897  //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
1898  //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
1899  return MicroSeconds (64);
1900  }
1901  }
1902  case WIFI_MOD_CLASS_HT:
1903  case WIFI_MOD_CLASS_VHT:
1904  case WIFI_MOD_CLASS_HE:
1905  //L-STF + L-LTF
1906  return MicroSeconds (16);
1908  return MicroSeconds (16);
1909  case WIFI_MOD_CLASS_DSSS:
1911  if ((preamble == WIFI_PREAMBLE_SHORT) && (txVector.GetMode ().GetDataRate (22) > 1000000))
1912  {
1913  //(Section 17.2.2.3 "Short PPDU format)" Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
1914  return MicroSeconds (72);
1915  }
1916  else //WIFI_PREAMBLE_LONG
1917  {
1918  //(Section 17.2.2.2 "Long PPDU format)" Figure 17-1 "Long PPDU format"; IEEE Std 802.11-2012)
1919  return MicroSeconds (144);
1920  }
1921  default:
1922  NS_FATAL_ERROR ("unsupported modulation class");
1923  return MicroSeconds (0);
1924  }
1925 }
1926 
1927 Time
1928 WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, uint16_t frequency)
1929 {
1930  return GetPayloadDuration (size, txVector, frequency, NORMAL_MPDU, 0);
1931 }
1932 
1933 Time
1934 WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, uint16_t frequency, MpduType mpdutype, uint8_t incFlag)
1935 {
1936  WifiMode payloadMode = txVector.GetMode ();
1937  WifiPreamble preamble = txVector.GetPreambleType ();
1938  NS_LOG_FUNCTION (size << payloadMode);
1939 
1940  double stbc = 1;
1941  if (txVector.IsStbc ()
1942  && (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_HT
1943  || payloadMode.GetModulationClass () == WIFI_MOD_CLASS_VHT))
1944  {
1945  stbc = 2;
1946  }
1947 
1948  double Nes = 1;
1949  //todo: improve logic to reduce the number of if cases
1950  //todo: extend to NSS > 4 for VHT rates
1951  if (payloadMode.GetUniqueName () == "HtMcs21"
1952  || payloadMode.GetUniqueName () == "HtMcs22"
1953  || payloadMode.GetUniqueName () == "HtMcs23"
1954  || payloadMode.GetUniqueName () == "HtMcs28"
1955  || payloadMode.GetUniqueName () == "HtMcs29"
1956  || payloadMode.GetUniqueName () == "HtMcs30"
1957  || payloadMode.GetUniqueName () == "HtMcs31")
1958  {
1959  Nes = 2;
1960  }
1961  if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
1962  {
1963  if (txVector.GetChannelWidth () == 40
1964  && txVector.GetNss () == 3
1965  && payloadMode.GetMcsValue () >= 8)
1966  {
1967  Nes = 2;
1968  }
1969  if (txVector.GetChannelWidth () == 80
1970  && txVector.GetNss () == 2
1971  && payloadMode.GetMcsValue () >= 7)
1972  {
1973  Nes = 2;
1974  }
1975  if (txVector.GetChannelWidth () == 80
1976  && txVector.GetNss () == 3
1977  && payloadMode.GetMcsValue () >= 7)
1978  {
1979  Nes = 2;
1980  }
1981  if (txVector.GetChannelWidth () == 80
1982  && txVector.GetNss () == 3
1983  && payloadMode.GetMcsValue () == 9)
1984  {
1985  Nes = 3;
1986  }
1987  if (txVector.GetChannelWidth () == 80
1988  && txVector.GetNss () == 4
1989  && payloadMode.GetMcsValue () >= 4)
1990  {
1991  Nes = 2;
1992  }
1993  if (txVector.GetChannelWidth () == 80
1994  && txVector.GetNss () == 4
1995  && payloadMode.GetMcsValue () >= 7)
1996  {
1997  Nes = 3;
1998  }
1999  if (txVector.GetChannelWidth () == 160
2000  && payloadMode.GetMcsValue () >= 7)
2001  {
2002  Nes = 2;
2003  }
2004  if (txVector.GetChannelWidth () == 160
2005  && txVector.GetNss () == 2
2006  && payloadMode.GetMcsValue () >= 4)
2007  {
2008  Nes = 2;
2009  }
2010  if (txVector.GetChannelWidth () == 160
2011  && txVector.GetNss () == 2
2012  && payloadMode.GetMcsValue () >= 7)
2013  {
2014  Nes = 3;
2015  }
2016  if (txVector.GetChannelWidth () == 160
2017  && txVector.GetNss () == 3
2018  && payloadMode.GetMcsValue () >= 3)
2019  {
2020  Nes = 2;
2021  }
2022  if (txVector.GetChannelWidth () == 160
2023  && txVector.GetNss () == 3
2024  && payloadMode.GetMcsValue () >= 5)
2025  {
2026  Nes = 3;
2027  }
2028  if (txVector.GetChannelWidth () == 160
2029  && txVector.GetNss () == 3
2030  && payloadMode.GetMcsValue () >= 7)
2031  {
2032  Nes = 4;
2033  }
2034  if (txVector.GetChannelWidth () == 160
2035  && txVector.GetNss () == 4
2036  && payloadMode.GetMcsValue () >= 2)
2037  {
2038  Nes = 2;
2039  }
2040  if (txVector.GetChannelWidth () == 160
2041  && txVector.GetNss () == 4
2042  && payloadMode.GetMcsValue () >= 4)
2043  {
2044  Nes = 3;
2045  }
2046  if (txVector.GetChannelWidth () == 160
2047  && txVector.GetNss () == 4
2048  && payloadMode.GetMcsValue () >= 5)
2049  {
2050  Nes = 4;
2051  }
2052  if (txVector.GetChannelWidth () == 160
2053  && txVector.GetNss () == 4
2054  && payloadMode.GetMcsValue () >= 7)
2055  {
2056  Nes = 6;
2057  }
2058  }
2059 
2060  Time symbolDuration = Seconds (0);
2061  switch (payloadMode.GetModulationClass ())
2062  {
2063  case WIFI_MOD_CLASS_OFDM:
2065  {
2066  //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012
2067  //corresponds to T_{SYM} in the table)
2068  switch (txVector.GetChannelWidth ())
2069  {
2070  case 20:
2071  default:
2072  symbolDuration = MicroSeconds (4);
2073  break;
2074  case 10:
2075  symbolDuration = MicroSeconds (8);
2076  break;
2077  case 5:
2078  symbolDuration = MicroSeconds (16);
2079  break;
2080  }
2081  break;
2082  }
2083  case WIFI_MOD_CLASS_HT:
2084  case WIFI_MOD_CLASS_VHT:
2085  {
2086  //if short GI data rate is used then symbol duration is 3.6us else symbol duration is 4us
2087  //In the future has to create a stationmanager that only uses these data rates if sender and receiver support GI
2088  uint16_t gi = txVector.GetGuardInterval ();
2089  NS_ASSERT (gi == 400 || gi == 800);
2090  symbolDuration = NanoSeconds (3200 + gi);
2091  }
2092  break;
2093  case WIFI_MOD_CLASS_HE:
2094  {
2095  //if short GI data rate is used then symbol duration is 3.6us else symbol duration is 4us
2096  //In the future has to create a stationmanager that only uses these data rates if sender and receiver support GI
2097  uint16_t gi = txVector.GetGuardInterval ();
2098  NS_ASSERT (gi == 800 || gi == 1600 || gi == 3200);
2099  symbolDuration = NanoSeconds (12800 + gi);
2100  }
2101  break;
2102  default:
2103  break;
2104  }
2105 
2106  double numDataBitsPerSymbol = payloadMode.GetDataRate (txVector) * symbolDuration.GetNanoSeconds () / 1e9;
2107 
2108  double numSymbols = 0;
2109  if (mpdutype == MPDU_IN_AGGREGATE && preamble != WIFI_PREAMBLE_NONE)
2110  {
2111  //First packet in an A-MPDU
2112  numSymbols = (stbc * (16 + size * 8.0 + 6 * Nes) / (stbc * numDataBitsPerSymbol));
2113  if (incFlag == 1)
2114  {
2115  m_totalAmpduSize += size;
2116  m_totalAmpduNumSymbols += numSymbols;
2117  }
2118  }
2119  else if (mpdutype == MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE)
2120  {
2121  //consecutive packets in an A-MPDU
2122  numSymbols = (stbc * size * 8.0) / (stbc * numDataBitsPerSymbol);
2123  if (incFlag == 1)
2124  {
2125  m_totalAmpduSize += size;
2126  m_totalAmpduNumSymbols += numSymbols;
2127  }
2128  }
2129  else if (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE)
2130  {
2131  //last packet in an A-MPDU
2132  uint32_t totalAmpduSize = m_totalAmpduSize + size;
2133  numSymbols = lrint (stbc * ceil ((16 + totalAmpduSize * 8.0 + 6 * Nes) / (stbc * numDataBitsPerSymbol)));
2134  NS_ASSERT (m_totalAmpduNumSymbols <= numSymbols);
2135  numSymbols -= m_totalAmpduNumSymbols;
2136  if (incFlag == 1)
2137  {
2138  m_totalAmpduSize = 0;
2140  }
2141  }
2142  else if (mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE)
2143  {
2144  //Not an A-MPDU
2145  numSymbols = lrint (stbc * ceil ((16 + size * 8.0 + 6.0 * Nes) / (stbc * numDataBitsPerSymbol)));
2146  }
2147  else
2148  {
2149  NS_FATAL_ERROR ("Wrong combination of preamble and packet type");
2150  }
2151 
2152  switch (payloadMode.GetModulationClass ())
2153  {
2154  case WIFI_MOD_CLASS_OFDM:
2156  {
2157  //Add signal extension for ERP PHY
2158  if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
2159  {
2160  return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ())) + MicroSeconds (6);
2161  }
2162  else
2163  {
2164  return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ()));
2165  }
2166  }
2167  case WIFI_MOD_CLASS_HT:
2168  case WIFI_MOD_CLASS_VHT:
2169  {
2170  if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_HT && Is2_4Ghz (frequency)
2171  && ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE)
2172  || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE))) //at 2.4 GHz
2173  {
2174  return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ())) + MicroSeconds (6);
2175  }
2176  else //at 5 GHz
2177  {
2178  return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ()));
2179  }
2180  }
2181  case WIFI_MOD_CLASS_HE:
2182  {
2183  if (Is2_4Ghz (frequency)
2184  && ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE)
2185  || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE))) //at 2.4 GHz
2186  {
2187  return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ())) + MicroSeconds (6);
2188  }
2189  else //at 5 GHz
2190  {
2191  return FemtoSeconds (static_cast<uint64_t> (numSymbols * symbolDuration.GetFemtoSeconds ()));
2192  }
2193  }
2194  case WIFI_MOD_CLASS_DSSS:
2196  return MicroSeconds (lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate (22) / 1.0e6))));
2197  default:
2198  NS_FATAL_ERROR ("unsupported modulation class");
2199  return MicroSeconds (0);
2200  }
2201 }
2202 
2203 Time
2205 {
2206  WifiPreamble preamble = txVector.GetPreambleType ();
2207  Time duration = GetPlcpPreambleDuration (txVector)
2208  + GetPlcpHeaderDuration (txVector)
2209  + GetPlcpHtSigHeaderDuration (preamble)
2210  + GetPlcpSigA1Duration (preamble)
2211  + GetPlcpSigA2Duration (preamble)
2212  + GetPlcpTrainingSymbolDuration (txVector)
2213  + GetPlcpSigBDuration (preamble);
2214  return duration;
2215 }
2216 
2217 Time
2218 WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txVector, uint16_t frequency, MpduType mpdutype, uint8_t incFlag)
2219 {
2220  Time duration = CalculatePlcpPreambleAndHeaderDuration (txVector)
2221  + GetPayloadDuration (size, txVector, frequency, mpdutype, incFlag);
2222  return duration;
2223 }
2224 
2225 Time
2226 WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txVector, uint16_t frequency)
2227 {
2228  return CalculateTxDuration (size, txVector, frequency, NORMAL_MPDU, 0);
2229 }
2230 
2231 void
2233 {
2234  m_phyTxBeginTrace (packet);
2235 }
2236 
2237 void
2239 {
2240  m_phyTxEndTrace (packet);
2241 }
2242 
2243 void
2245 {
2246  m_phyTxDropTrace (packet);
2247 }
2248 
2249 void
2251 {
2252  m_phyRxBeginTrace (packet);
2253 }
2254 
2255 void
2257 {
2258  m_phyRxEndTrace (packet);
2259 }
2260 
2261 void
2263 {
2264  m_phyRxDropTrace (packet);
2265 }
2266 
2267 void
2268 WifiPhy::NotifyMonitorSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise)
2269 {
2270  m_phyMonitorSniffRxTrace (packet, channelFreqMhz, txVector, aMpdu, signalNoise);
2271 }
2272 
2273 void
2274 WifiPhy::NotifyMonitorSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu)
2275 {
2276  m_phyMonitorSniffTxTrace (packet, channelFreqMhz, txVector, aMpdu);
2277 }
2278 
2279 void
2281 {
2282  NS_LOG_FUNCTION (this << packet << txVector.GetMode ()
2283  << txVector.GetMode ().GetDataRate (txVector)
2284  << txVector.GetPreambleType ()
2285  << +txVector.GetTxPowerLevel ()
2286  << +mpdutype);
2287  /* Transmission can happen if:
2288  * - we are syncing on a packet. It is the responsibility of the
2289  * MAC layer to avoid doing this but the PHY does nothing to
2290  * prevent it.
2291  * - we are idle
2292  */
2293  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
2294 
2295  if (txVector.GetNss () > GetMaxSupportedTxSpatialStreams ())
2296  {
2297  NS_FATAL_ERROR ("Unsupported number of spatial streams!");
2298  }
2299 
2300  if (m_state->IsStateSleep ())
2301  {
2302  NS_LOG_DEBUG ("Dropping packet because in sleep mode");
2303  NotifyTxDrop (packet);
2304  return;
2305  }
2306 
2307  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, GetFrequency (), mpdutype, 1);
2308  NS_ASSERT (txDuration.IsStrictlyPositive ());
2309 
2310  if (m_state->IsStateRx ())
2311  {
2313  m_endRxEvent.Cancel ();
2315  }
2316  NotifyTxBegin (packet);
2317  if ((mpdutype == MPDU_IN_AGGREGATE) && (txVector.GetPreambleType () != WIFI_PREAMBLE_NONE))
2318  {
2319  //send the first MPDU in an MPDU
2321  }
2322  MpduInfo aMpdu;
2323  aMpdu.type = mpdutype;
2325  NotifyMonitorSniffTx (packet, GetFrequency (), txVector, aMpdu);
2326  m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector);
2327 
2328  Ptr<Packet> newPacket = packet->Copy (); // obtain non-const Packet
2329  WifiPhyTag oldtag;
2330  newPacket->RemovePacketTag (oldtag);
2331  if (m_state->GetState () == WifiPhyState::OFF)
2332  {
2333  NS_LOG_DEBUG ("Transmission canceled because device is OFF");
2334  return;
2335  }
2336  uint8_t isFrameComplete = 1;
2337  if (m_wifiRadioEnergyModel != 0 && m_wifiRadioEnergyModel->GetMaximumTimeInState (WifiPhyState::TX) < txDuration)
2338  {
2339  isFrameComplete = 0;
2340  }
2341  WifiPhyTag tag (txVector, mpdutype, isFrameComplete);
2342  newPacket->AddPacketTag (tag);
2343 
2344  StartTx (newPacket, txVector, txDuration);
2345 }
2346 
2347 void
2348 WifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, double rxPowerW, Time rxDuration)
2349 {
2350  WifiPhyTag tag;
2351  bool found = packet->RemovePacketTag (tag);
2352  if (!found)
2353  {
2354  NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag");
2355  return;
2356  }
2357 
2358  WifiTxVector txVector = tag.GetWifiTxVector ();
2359  Ptr<Event> event;
2360  event = m_interference.Add (packet,
2361  txVector,
2362  rxDuration,
2363  rxPowerW);
2364 
2365  //This function should be later split to check separately whether plcp preamble and plcp header can be successfully received.
2366  //Note: plcp preamble reception is not yet modeled.
2367  if (m_state->GetState () == WifiPhyState::OFF)
2368  {
2369  NS_LOG_DEBUG ("Cannot start RX because device is OFF");
2370  return;
2371  }
2372 
2373  NS_LOG_FUNCTION (this << packet << WToDbm (rxPowerW) << rxDuration);
2374 
2375  if (tag.GetFrameComplete () == 0)
2376  {
2377  NS_LOG_DEBUG ("drop packet because of incomplete frame");
2378  NotifyRxDrop (packet);
2379  m_plcpSuccess = false;
2380  return;
2381  }
2382 
2383  if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT
2384  && (txVector.GetNss () != (1 + (txVector.GetMode ().GetMcsValue () / 8))))
2385  {
2386  NS_FATAL_ERROR ("MCS value does not match NSS value: MCS = " << +txVector.GetMode ().GetMcsValue () << ", NSS = " << +txVector.GetNss ());
2387  }
2388 
2389  Time endRx = Simulator::Now () + rxDuration;
2390  if (txVector.GetNss () > GetMaxSupportedRxSpatialStreams ())
2391  {
2392  NS_LOG_DEBUG ("drop packet because not enough RX antennas");
2393  NotifyRxDrop (packet);
2394  m_plcpSuccess = false;
2395  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
2396  {
2397  //that packet will be noise _after_ the transmission of the
2398  //currently-transmitted packet.
2400  return;
2401  }
2402  }
2403 
2404  MpduType mpdutype = tag.GetMpduType ();
2405  switch (m_state->GetState ())
2406  {
2408  NS_LOG_DEBUG ("drop packet because of channel switching");
2409  NotifyRxDrop (packet);
2410  m_plcpSuccess = false;
2411  /*
2412  * Packets received on the upcoming channel are added to the event list
2413  * during the switching state. This way the medium can be correctly sensed
2414  * when the device listens to the channel for the first time after the
2415  * switching e.g. after channel switching, the channel may be sensed as
2416  * busy due to other devices' tramissions started before the end of
2417  * the switching.
2418  */
2419  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
2420  {
2421  //that packet will be noise _after_ the completion of the
2422  //channel switching.
2424  return;
2425  }
2426  break;
2427  case WifiPhyState::RX:
2428  NS_ASSERT (m_currentEvent != 0);
2429  if (m_frameCaptureModel != 0
2430  && m_frameCaptureModel->CaptureNewFrame (m_currentEvent, event))
2431  {
2433  NS_LOG_DEBUG ("Switch to new packet");
2434  StartRx (packet, txVector, mpdutype, rxPowerW, rxDuration, event);
2435  }
2436  else
2437  {
2438  NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
2439  rxPowerW << "W)");
2440  NotifyRxDrop (packet);
2441  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
2442  {
2443  //that packet will be noise _after_ the reception of the
2444  //currently-received packet.
2446  return;
2447  }
2448  }
2449  break;
2450  case WifiPhyState::TX:
2451  NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
2452  rxPowerW << "W)");
2453  NotifyRxDrop (packet);
2454  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
2455  {
2456  //that packet will be noise _after_ the transmission of the
2457  //currently-transmitted packet.
2459  return;
2460  }
2461  break;
2463  case WifiPhyState::IDLE:
2464  StartRx (packet, txVector, mpdutype, rxPowerW, rxDuration, event);
2465  break;
2466  case WifiPhyState::SLEEP:
2467  NS_LOG_DEBUG ("drop packet because in sleep mode");
2468  NotifyRxDrop (packet);
2469  m_plcpSuccess = false;
2470  break;
2471  default:
2472  NS_FATAL_ERROR ("Invalid WifiPhy state.");
2473  break;
2474  }
2475 }
2476 
2477 void
2479 {
2480  //We are here because we have received the first bit of a packet and we are
2481  //not going to be able to synchronize on it
2482  //In this model, CCA becomes busy when the aggregation of all signals as
2483  //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
2484 
2486  if (!delayUntilCcaEnd.IsZero ())
2487  {
2488  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
2489  }
2490 }
2491 
2492 void
2494  WifiTxVector txVector,
2495  MpduType mpdutype,
2496  Ptr<Event> event)
2497 {
2498  NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetPreambleType () << +mpdutype);
2499  NS_ASSERT (IsStateRx ());
2501  WifiMode txMode = txVector.GetMode ();
2502 
2504  snrPer = m_interference.CalculatePlcpHeaderSnrPer (event);
2505 
2506  NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per);
2507 
2508  if (m_random->GetValue () > snrPer.per) //plcp reception succeeded
2509  {
2510  if (IsModeSupported (txMode) || IsMcsSupported (txMode))
2511  {
2512  NS_LOG_DEBUG ("receiving plcp payload"); //endReceive is already scheduled
2513  m_plcpSuccess = true;
2514  }
2515  else //mode is not allowed
2516  {
2517  NS_LOG_DEBUG ("drop packet because it was sent using an unsupported mode (" << txMode << ")");
2518  NotifyRxDrop (packet);
2519  m_plcpSuccess = false;
2520  }
2521  }
2522  else //plcp reception failed
2523  {
2524  NS_LOG_DEBUG ("drop packet because plcp preamble/header reception failed");
2525  NotifyRxDrop (packet);
2526  m_plcpSuccess = false;
2527  }
2528 }
2529 
2530 void
2532 {
2533  NS_LOG_FUNCTION (this << packet << event);
2534  NS_ASSERT (IsStateRx ());
2535  NS_ASSERT (event->GetEndTime () == Simulator::Now ());
2536 
2538  snrPer = m_interference.CalculatePlcpPayloadSnrPer (event);
2540  m_currentEvent = 0;
2541 
2542  if (m_plcpSuccess == true)
2543  {
2544  NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate (event->GetTxVector ())) <<
2545  ", snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
2546 
2547  if (m_random->GetValue () > snrPer.per)
2548  {
2549  NotifyRxEnd (packet);
2550  SignalNoiseDbm signalNoise;
2551  signalNoise.signal = RatioToDb (event->GetRxPowerW ()) + 30;
2552  signalNoise.noise = RatioToDb (event->GetRxPowerW () / snrPer.snr) + 30;
2553  MpduInfo aMpdu;
2554  aMpdu.type = mpdutype;
2555  aMpdu.mpduRefNumber = m_rxMpduReferenceNumber;
2556  NotifyMonitorSniffRx (packet, GetFrequency (), event->GetTxVector (), aMpdu, signalNoise);
2557  m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector ());
2558  }
2559  else
2560  {
2561  /* failure. */
2562  NotifyRxDrop (packet);
2563  m_state->SwitchFromRxEndError (packet, snrPer.snr);
2564  }
2565  }
2566  else
2567  {
2568  m_state->SwitchFromRxEndError (packet, snrPer.snr);
2569  }
2570 
2571  if (preamble == WIFI_PREAMBLE_NONE && mpdutype == LAST_MPDU_IN_AGGREGATE)
2572  {
2573  m_plcpSuccess = false;
2574  }
2575 
2576 }
2577 
2578 
2579 // Clause 15 rates (DSSS)
2580 
2581 WifiMode
2583 {
2584  static WifiMode mode =
2585  WifiModeFactory::CreateWifiMode ("DsssRate1Mbps",
2587  true,
2589  2);
2590  return mode;
2591 }
2592 
2593 WifiMode
2595 {
2596  static WifiMode mode =
2597  WifiModeFactory::CreateWifiMode ("DsssRate2Mbps",
2599  true,
2601  4);
2602  return mode;
2603 }
2604 
2605 
2606 // Clause 18 rates (HR/DSSS)
2607 
2608 WifiMode
2610 {
2611  static WifiMode mode =
2612  WifiModeFactory::CreateWifiMode ("DsssRate5_5Mbps",
2614  true,
2616  16);
2617  return mode;
2618 }
2619 
2620 WifiMode
2622 {
2623  static WifiMode mode =
2624  WifiModeFactory::CreateWifiMode ("DsssRate11Mbps",
2626  true,
2628  256);
2629  return mode;
2630 }
2631 
2632 
2633 // Clause 19.5 rates (ERP-OFDM)
2634 
2635 WifiMode
2637 {
2638  static WifiMode mode =
2639  WifiModeFactory::CreateWifiMode ("ErpOfdmRate6Mbps",
2641  true,
2643  2);
2644  return mode;
2645 }
2646 
2647 WifiMode
2649 {
2650  static WifiMode mode =
2651  WifiModeFactory::CreateWifiMode ("ErpOfdmRate9Mbps",
2653  false,
2655  2);
2656  return mode;
2657 }
2658 
2659 WifiMode
2661 {
2662  static WifiMode mode =
2663  WifiModeFactory::CreateWifiMode ("ErpOfdmRate12Mbps",
2665  true,
2667  4);
2668  return mode;
2669 }
2670 
2671 WifiMode
2673 {
2674  static WifiMode mode =
2675  WifiModeFactory::CreateWifiMode ("ErpOfdmRate18Mbps",
2677  false,
2679  4);
2680  return mode;
2681 }
2682 
2683 WifiMode
2685 {
2686  static WifiMode mode =
2687  WifiModeFactory::CreateWifiMode ("ErpOfdmRate24Mbps",
2689  true,
2691  16);
2692  return mode;
2693 }
2694 
2695 WifiMode
2697 {
2698  static WifiMode mode =
2699  WifiModeFactory::CreateWifiMode ("ErpOfdmRate36Mbps",
2701  false,
2703  16);
2704  return mode;
2705 }
2706 
2707 WifiMode
2709 {
2710  static WifiMode mode =
2711  WifiModeFactory::CreateWifiMode ("ErpOfdmRate48Mbps",
2713  false,
2715  64);
2716  return mode;
2717 }
2718 
2719 WifiMode
2721 {
2722  static WifiMode mode =
2723  WifiModeFactory::CreateWifiMode ("ErpOfdmRate54Mbps",
2725  false,
2727  64);
2728  return mode;
2729 }
2730 
2731 
2732 // Clause 17 rates (OFDM)
2733 
2734 WifiMode
2736 {
2737  static WifiMode mode =
2738  WifiModeFactory::CreateWifiMode ("OfdmRate6Mbps",
2740  true,
2742  2);
2743  return mode;
2744 }
2745 
2746 WifiMode
2748 {
2749  static WifiMode mode =
2750  WifiModeFactory::CreateWifiMode ("OfdmRate9Mbps",
2752  false,
2754  2);
2755  return mode;
2756 }
2757 
2758 WifiMode
2760 {
2761  static WifiMode mode =
2762  WifiModeFactory::CreateWifiMode ("OfdmRate12Mbps",
2764  true,
2766  4);
2767  return mode;
2768 }
2769 
2770 WifiMode
2772 {
2773  static WifiMode mode =
2774  WifiModeFactory::CreateWifiMode ("OfdmRate18Mbps",
2776  false,
2778  4);
2779  return mode;
2780 }
2781 
2782 WifiMode
2784 {
2785  static WifiMode mode =
2786  WifiModeFactory::CreateWifiMode ("OfdmRate24Mbps",
2788  true,
2790  16);
2791  return mode;
2792 }
2793 
2794 WifiMode
2796 {
2797  static WifiMode mode =
2798  WifiModeFactory::CreateWifiMode ("OfdmRate36Mbps",
2800  false,
2802  16);
2803  return mode;
2804 }
2805 
2806 WifiMode
2808 {
2809  static WifiMode mode =
2810  WifiModeFactory::CreateWifiMode ("OfdmRate48Mbps",
2812  false,
2814  64);
2815  return mode;
2816 }
2817 
2818 WifiMode
2820 {
2821  static WifiMode mode =
2822  WifiModeFactory::CreateWifiMode ("OfdmRate54Mbps",
2824  false,
2826  64);
2827  return mode;
2828 }
2829 
2830 
2831 // 10 MHz channel rates
2832 
2833 WifiMode
2835 {
2836  static WifiMode mode =
2837  WifiModeFactory::CreateWifiMode ("OfdmRate3MbpsBW10MHz",
2839  true,
2841  2);
2842  return mode;
2843 }
2844 
2845 WifiMode
2847 {
2848  static WifiMode mode =
2849  WifiModeFactory::CreateWifiMode ("OfdmRate4_5MbpsBW10MHz",
2851  false,
2853  2);
2854  return mode;
2855 }
2856 
2857 WifiMode
2859 {
2860  static WifiMode mode =
2861  WifiModeFactory::CreateWifiMode ("OfdmRate6MbpsBW10MHz",
2863  true,
2865  4);
2866  return mode;
2867 }
2868 
2869 WifiMode
2871 {
2872  static WifiMode mode =
2873  WifiModeFactory::CreateWifiMode ("OfdmRate9MbpsBW10MHz",
2875  false,
2877  4);
2878  return mode;
2879 }
2880 
2881 WifiMode
2883 {
2884  static WifiMode mode =
2885  WifiModeFactory::CreateWifiMode ("OfdmRate12MbpsBW10MHz",
2887  true,
2889  16);
2890  return mode;
2891 }
2892 
2893 WifiMode
2895 {
2896  static WifiMode mode =
2897  WifiModeFactory::CreateWifiMode ("OfdmRate18MbpsBW10MHz",
2899  false,
2901  16);
2902  return mode;
2903 }
2904 
2905 WifiMode
2907 {
2908  static WifiMode mode =
2909  WifiModeFactory::CreateWifiMode ("OfdmRate24MbpsBW10MHz",
2911  false,
2913  64);
2914  return mode;
2915 }
2916 
2917 WifiMode
2919 {
2920  static WifiMode mode =
2921  WifiModeFactory::CreateWifiMode ("OfdmRate27MbpsBW10MHz",
2923  false,
2925  64);
2926  return mode;
2927 }
2928 
2929 
2930 // 5 MHz channel rates
2931 
2932 WifiMode
2934 {
2935  static WifiMode mode =
2936  WifiModeFactory::CreateWifiMode ("OfdmRate1_5MbpsBW5MHz",
2938  true,
2940  2);
2941  return mode;
2942 }
2943 
2944 WifiMode
2946 {
2947  static WifiMode mode =
2948  WifiModeFactory::CreateWifiMode ("OfdmRate2_25MbpsBW5MHz",
2950  false,
2952  2);
2953  return mode;
2954 }
2955 
2956 WifiMode
2958 {
2959  static WifiMode mode =
2960  WifiModeFactory::CreateWifiMode ("OfdmRate3MbpsBW5MHz",
2962  true,
2964  4);
2965  return mode;
2966 }
2967 
2968 WifiMode
2970 {
2971  static WifiMode mode =
2972  WifiModeFactory::CreateWifiMode ("OfdmRate4_5MbpsBW5MHz",
2974  false,
2976  4);
2977  return mode;
2978 }
2979 
2980 WifiMode
2982 {
2983  static WifiMode mode =
2984  WifiModeFactory::CreateWifiMode ("OfdmRate6MbpsBW5MHz",
2986  true,
2988  16);
2989  return mode;
2990 }
2991 
2992 WifiMode
2994 {
2995  static WifiMode mode =
2996  WifiModeFactory::CreateWifiMode ("OfdmRate9MbpsBW5MHz",
2998  false,
3000  16);
3001  return mode;
3002 }
3003 
3004 WifiMode
3006 {
3007  static WifiMode mode =
3008  WifiModeFactory::CreateWifiMode ("OfdmRate12MbpsBW5MHz",
3010  false,
3012  64);
3013  return mode;
3014 }
3015 
3016 WifiMode
3018 {
3019  static WifiMode mode =
3020  WifiModeFactory::CreateWifiMode ("OfdmRate13_5MbpsBW5MHz",
3022  false,
3024  64);
3025  return mode;
3026 }
3027 
3028 
3029 // Clause 20
3030 
3031 WifiMode
3033 {
3034  static WifiMode mcs =
3036  return mcs;
3037 }
3038 
3039 WifiMode
3041 {
3042  static WifiMode mcs =
3044  return mcs;
3045 }
3046 
3047 WifiMode
3049 {
3050  static WifiMode mcs =
3052  return mcs;
3053 }
3054 
3055 WifiMode
3057 {
3058  static WifiMode mcs =
3060  return mcs;
3061 }
3062 
3063 WifiMode
3065 {
3066  static WifiMode mcs =
3068  return mcs;
3069 }
3070 
3071 WifiMode
3073 {
3074  static WifiMode mcs =
3076  return mcs;
3077 }
3078 
3079 WifiMode
3081 {
3082  static WifiMode mcs =
3084  return mcs;
3085 }
3086 
3087 WifiMode
3089 {
3090  static WifiMode mcs =
3092  return mcs;
3093 }
3094 
3095 WifiMode
3097 {
3098  static WifiMode mcs =
3100  return mcs;
3101 }
3102 
3103 WifiMode
3105 {
3106  static WifiMode mcs =
3108  return mcs;
3109 }
3110 
3111 WifiMode
3113 {
3114  static WifiMode mcs =
3116  return mcs;
3117 }
3118 
3119 WifiMode
3121 {
3122  static WifiMode mcs =
3124  return mcs;
3125 }
3126 
3127 WifiMode
3129 {
3130  static WifiMode mcs =
3132  return mcs;
3133 }
3134 
3135 WifiMode
3137 {
3138  static WifiMode mcs =
3140  return mcs;
3141 }
3142 
3143 WifiMode
3145 {
3146  static WifiMode mcs =
3148  return mcs;
3149 }
3150 
3151 WifiMode
3153 {
3154  static WifiMode mcs =
3156  return mcs;
3157 }
3158 
3159 WifiMode
3161 {
3162  static WifiMode mcs =
3164  return mcs;
3165 }
3166 
3167 WifiMode
3169 {
3170  static WifiMode mcs =
3172  return mcs;
3173 }
3174 
3175 WifiMode
3177 {
3178  static WifiMode mcs =
3180  return mcs;
3181 }
3182 
3183 WifiMode
3185 {
3186  static WifiMode mcs =
3188  return mcs;
3189 }
3190 
3191 WifiMode
3193 {
3194  static WifiMode mcs =
3196  return mcs;
3197 }
3198 
3199 WifiMode
3201 {
3202  static WifiMode mcs =
3204  return mcs;
3205 }
3206 
3207 WifiMode
3209 {
3210  static WifiMode mcs =
3212  return mcs;
3213 }
3214 
3215 WifiMode
3217 {
3218  static WifiMode mcs =
3220  return mcs;
3221 }
3222 
3223 WifiMode
3225 {
3226  static WifiMode mcs =
3228  return mcs;
3229 }
3230 
3231 WifiMode
3233 {
3234  static WifiMode mcs =
3236  return mcs;
3237 }
3238 
3239 WifiMode
3241 {
3242  static WifiMode mcs =
3244  return mcs;
3245 }
3246 
3247 WifiMode
3249 {
3250  static WifiMode mcs =
3252  return mcs;
3253 }
3254 
3255 WifiMode
3257 {
3258  static WifiMode mcs =
3260  return mcs;
3261 }
3262 
3263 WifiMode
3265 {
3266  static WifiMode mcs =
3268  return mcs;
3269 }
3270 
3271 WifiMode
3273 {
3274  static WifiMode mcs =
3276  return mcs;
3277 }
3278 
3279 WifiMode
3281 {
3282  static WifiMode mcs =
3284  return mcs;
3285 }
3286 
3287 
3288 // Clause 22
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 WifiMode
3364 {
3365  static WifiMode mcs =
3367  return mcs;
3368 }
3369 
3370 // Clause 26
3371 
3372 WifiMode
3374 {
3375  static WifiMode mcs =
3377  return mcs;
3378 }
3379 
3380 WifiMode
3382 {
3383  static WifiMode mcs =
3385  return mcs;
3386 }
3387 
3388 WifiMode
3390 {
3391  static WifiMode mcs =
3393  return mcs;
3394 }
3395 
3396 WifiMode
3398 {
3399  static WifiMode mcs =
3401  return mcs;
3402 }
3403 
3404 WifiMode
3406 {
3407  static WifiMode mcs =
3409  return mcs;
3410 }
3411 
3412 WifiMode
3414 {
3415  static WifiMode mcs =
3417  return mcs;
3418 }
3419 
3420 WifiMode
3422 {
3423  static WifiMode mcs =
3425  return mcs;
3426 }
3427 
3428 WifiMode
3430 {
3431  static WifiMode mcs =
3433  return mcs;
3434 }
3435 
3436 WifiMode
3438 {
3439  static WifiMode mcs =
3441  return mcs;
3442 }
3443 
3444 WifiMode
3446 {
3447  static WifiMode mcs =
3449  return mcs;
3450 }
3451 
3452 WifiMode
3454 {
3455  static WifiMode mcs =
3457  return mcs;
3458 }
3459 
3460 WifiMode
3462 {
3463  static WifiMode mcs =
3465  return mcs;
3466 }
3467 
3468 bool
3470 {
3471  for (uint8_t i = 0; i < GetNModes (); i++)
3472  {
3473  if (mode == GetMode (i))
3474  {
3475  return true;
3476  }
3477  }
3478  return false;
3479 }
3480 
3481 bool
3483 {
3484  for (uint8_t i = 0; i < GetNMcs (); i++)
3485  {
3486  if (mcs == GetMcs (i))
3487  {
3488  return true;
3489  }
3490  }
3491  return false;
3492 }
3493 
3494 uint8_t
3496 {
3497  return static_cast<uint8_t> (m_deviceRateSet.size ());
3498 }
3499 
3500 WifiMode
3501 WifiPhy::GetMode (uint8_t mode) const
3502 {
3503  return m_deviceRateSet[mode];
3504 }
3505 
3506 uint8_t
3507 WifiPhy::GetNMcs (void) const
3508 {
3509  return static_cast<uint8_t> (m_deviceMcsSet.size ());
3510 }
3511 
3512 WifiMode
3513 WifiPhy::GetMcs (uint8_t mcs) const
3514 {
3515  return m_deviceMcsSet[mcs];
3516 }
3517 
3518 bool
3520 {
3521  return m_state->IsStateCcaBusy ();
3522 }
3523 
3524 bool
3526 {
3527  return m_state->IsStateIdle ();
3528 }
3529 
3530 bool
3532 {
3533  return m_state->IsStateRx ();
3534 }
3535 
3536 bool
3538 {
3539  return m_state->IsStateTx ();
3540 }
3541 
3542 bool
3544 {
3545  return m_state->IsStateSwitching ();
3546 }
3547 
3548 bool
3550 {
3551  return m_state->IsStateSleep ();
3552 }
3553 
3554 bool
3556 {
3557  return m_state->IsStateOff ();
3558 }
3559 
3560 Time
3562 {
3563  return m_state->GetDelayUntilIdle ();
3564 }
3565 
3566 Time
3568 {
3569  return m_state->GetLastRxStartTime ();
3570 }
3571 
3572 void
3574 {
3575  NS_LOG_FUNCTION (this);
3576  //We are here because we have received the first bit of a packet and we are
3577  //not going to be able to synchronize on it
3578  //In this model, CCA becomes busy when the aggregation of all signals as
3579  //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
3580 
3582  if (!delayUntilCcaEnd.IsZero ())
3583  {
3584  NS_LOG_DEBUG ("Calling SwitchMaybeToCcaBusy for " << delayUntilCcaEnd.As (Time::S));
3585  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
3586  }
3587 }
3588 
3589 void
3591 {
3592  NS_LOG_FUNCTION (this);
3593  if (m_endPlcpRxEvent.IsRunning ())
3594  {
3596  }
3597  if (m_endRxEvent.IsRunning ())
3598  {
3599  m_endRxEvent.Cancel ();
3600  }
3601  NotifyRxDrop (m_currentEvent->GetPacket ());
3603  m_state->SwitchFromRxAbort ();
3604  m_currentEvent = 0;
3605 }
3606 
3607 void
3608 WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype, double rxPowerW, Time rxDuration, Ptr<Event> event)
3609 {
3610  NS_LOG_FUNCTION (this << packet << txVector << +mpdutype << rxPowerW << rxDuration);
3611  if (rxPowerW > DbmToW (GetEdThreshold ())) //checked here, no need to check in the payload reception (current implementation assumes constant rx power over the packet duration)
3612  {
3613  AmpduTag ampduTag;
3614  WifiPreamble preamble = txVector.GetPreambleType ();
3615  if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false))
3616  {
3617  m_plcpSuccess = false;
3618  m_mpdusNum = 0;
3619  NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been received");
3620  NotifyRxDrop (packet);
3622  return;
3623  }
3624  else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
3625  {
3626  //received the first MPDU in an MPDU
3627  m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3629  }
3630  else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
3631  {
3632  //received the other MPDUs that are part of the A-MPDU
3633  if (ampduTag.GetRemainingNbOfMpdus () < (m_mpdusNum - 1))
3634  {
3635  NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetRemainingNbOfMpdus ());
3636  m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3637  }
3638  else
3639  {
3640  m_mpdusNum--;
3641  }
3642  }
3643  else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
3644  {
3645  NS_LOG_DEBUG ("New A-MPDU started while " << m_mpdusNum << " MPDUs from previous are lost");
3646  m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3647  }
3648  else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 )
3649  {
3650  NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum);
3651  m_mpdusNum = 0;
3652  }
3653 
3654  NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
3655  m_currentEvent = event;
3656  m_state->SwitchToRx (rxDuration);
3658  NotifyRxBegin (packet);
3660 
3661  if (preamble != WIFI_PREAMBLE_NONE)
3662  {
3664  Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector);
3665  m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &WifiPhy::StartReceivePacket, this,
3666  packet, txVector, mpdutype, event);
3667  }
3668 
3671  packet, preamble, mpdutype, event);
3672  }
3673  else
3674  {
3675  NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
3676  rxPowerW << "<" << DbmToW (GetEdThreshold ()) << ")");
3677  NotifyRxDrop (packet);
3678  m_plcpSuccess = false;
3680  }
3681 }
3682 
3683 int64_t
3684 WifiPhy::AssignStreams (int64_t stream)
3685 {
3686  NS_LOG_FUNCTION (this << stream);
3687  m_random->SetStream (stream);
3688  return 1;
3689 }
3690 
3691 std::ostream& operator<< (std::ostream& os, WifiPhyState state)
3692 {
3693  switch (state)
3694  {
3695  case WifiPhyState::IDLE:
3696  return (os << "IDLE");
3698  return (os << "CCA_BUSY");
3699  case WifiPhyState::TX:
3700  return (os << "TX");
3701  case WifiPhyState::RX:
3702  return (os << "RX");
3704  return (os << "SWITCHING");
3705  case WifiPhyState::SLEEP:
3706  return (os << "SLEEP");
3707  case WifiPhyState::OFF:
3708  return (os << "OFF");
3709  default:
3710  NS_FATAL_ERROR ("Invalid WifiPhy state");
3711  return (os << "INVALID");
3712  }
3713 }
3714 
3715 } //namespace ns3
3716 
3717 namespace {
3718 
3722 static class Constructor
3723 {
3724 public:
3726  {
3817  }
3818 } g_constructor;
3819 
3820 }
uint8_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
Definition: wifi-phy.cc:1312
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:531
MpduInfo structure.
Definition: wifi-phy.h:53
static WifiMode GetVhtMcs6()
Return MCS 6 from VHT MCS values.
Definition: wifi-phy.cc:3339
static WifiMode GetOfdmRate9MbpsBW5MHz()
Return a WifiMode for OFDM at 9Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:2993
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
Definition: wifi-phy.h:1663
Ptr< NetDevice > m_device
Pointer to the device.
Definition: wifi-phy.h:1787
static WifiMode GetErpOfdmRate24Mbps()
Return a WifiMode for ERP-OFDM at 24Mbps.
Definition: wifi-phy.cc:2684
uint32_t m_txMpduReferenceNumber
A-MPDU reference number to identify all transmitted subframes belonging to the same received A-MPDU...
Definition: wifi-phy.h:1504
static WifiMode GetDsssRate11Mbps()
Return a WifiMode for DSSS at 11Mbps.
Definition: wifi-phy.cc:2621
uint8_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1407
uint16_t GetGuardInterval(void) const
double signal
in dBm
Definition: wifi-phy.h:48
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:3429
std::pair< uint8_t, WifiPhyStandard > ChannelNumberStandardPair
A pair of a ChannelNumber and WifiPhyStandard.
Definition: wifi-phy.h:495
static WifiMode GetErpOfdmRate36Mbps()
Return a WifiMode for ERP-OFDM at 36Mbps.
Definition: wifi-phy.cc:2696
Signal event for a packet.
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)
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
Definition: wifi-mode.cc:156
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:524
uint8_t m_channelNumber
Operating channel number.
Definition: wifi-phy.h:1780
double m_rxGainDb
Reception gain (dB)
Definition: wifi-phy.h:1759
bool DefineChannelNumber(uint8_t channelNumber, WifiPhyStandard standard, uint16_t frequency, uint16_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:1016
static WifiMode GetVhtMcs8()
Return MCS 8 from VHT MCS values.
Definition: wifi-phy.cc:3355
uint8_t FindChannelNumberForFrequencyWidth(uint16_t frequency, uint16_t width) const
Look for channel number matching the frequency and width.
Definition: wifi-phy.cc:1033
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:54
double GetTxGain(void) const
Return the transmission gain (dB).
Definition: wifi-phy.cc:544
void SetShortPlcpPreambleSupported(bool preamble)
Enable or disable short PLCP preamble.
Definition: wifi-phy.cc:629
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:3482
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:2747
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:2894
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:2918
uint8_t GetRemainingNbOfMpdus(void) const
Definition: ampdu-tag.cc:89
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:1692
double m_txGainDb
Transmission gain (dB)
Definition: wifi-phy.h:1758
#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:2957
static WifiMode GetVhtMcs0()
Return MCS 0 from VHT MCS values.
Definition: wifi-phy.cc:3291
void MaybeCcaBusyDuration(void)
Eventually switch to CCA busy.
Definition: wifi-phy.cc:2478
virtual ~WifiPhy()
Definition: wifi-phy.cc:375
void SetLdpc(bool ldpc)
Enable or disable LDPC.
Definition: wifi-phy.cc:563
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1Mbps.
Definition: wifi-phy.cc:2582
bool m_ldpc
Flag if LDPC is used.
Definition: wifi-phy.h:1764
void ResumeFromOff(void)
Resume from off mode.
Definition: wifi-phy.cc:1601
void ResumeFromSleep(void)
Resume from sleep mode.
Definition: wifi-phy.cc:1571
bool GetGreenfield(void) const
Return whether Greenfield is supported.
Definition: wifi-phy.cc:596
uint16_t GetChannelWidth(void) const
static WifiMode GetHeMcs5()
Return MCS 5 from HE MCS values.
Definition: wifi-phy.cc:3413
static WifiMode GetErpOfdmRate18Mbps()
Return a WifiMode for ERP-OFDM at 18Mbps.
Definition: wifi-phy.cc:2672
void SetTxGain(double gain)
Sets the transmission gain (dB).
Definition: wifi-phy.cc:537
void Configure80211ax(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ax standard...
Definition: wifi-phy.cc:991
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:46
static WifiMode GetHtMcs7()
Return MCS 7 from HT MCS values.
Definition: wifi-phy.cc:3088
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:3531
bool IsZero(void) const
Definition: nstime.h:288
def start()
Definition: core.py:1806
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:852
bool Is2_4Ghz(double frequency)
Definition: wifi-utils.cc:65
void SetStbc(bool stbc)
Enable or disable STBC.
Definition: wifi-phy.cc:576
static Time GetPlcpHtSigHeaderDuration(WifiPreamble preamble)
Definition: wifi-phy.cc:1697
static WifiMode GetVhtMcs5()
Return MCS 5 from VHT MCS values.
Definition: wifi-phy.cc:3331
uint8_t GetFrameComplete(void) const
Getter for frameComplete parameter.
Definition: wifi-phy-tag.cc:92
The PHY layer is sleeping.
static WifiMode GetHtMcs22()
Return MCS 22 from HT MCS values.
Definition: wifi-phy.cc:3208
static WifiMode GetHtMcs14()
Return MCS 14 from HT MCS values.
Definition: wifi-phy.cc:3144
uint8_t GetMaxSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1306
static WifiMode GetOfdmRate12Mbps()
Return a WifiMode for OFDM at 12Mbps.
Definition: wifi-phy.cc:2759
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition: wifi-phy.h:1671
#define HE_PHY
Definition: wifi-phy.h:33
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:3280
void StartRx(Ptr< Packet > packet, WifiTxVector txVector, MpduType mpdutype, double rxPowerW, Time rxDuration, Ptr< Event > event)
Starting receiving the packet after having detected the medium is idle or after a reception switch...
Definition: wifi-phy.cc:3608
static WifiMode GetHtMcs21()
Return MCS 21 from HT MCS values.
Definition: wifi-phy.cc:3200
bool IsStateCcaBusy(void) const
Definition: wifi-phy.cc:3519
#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
static WifiMode GetHtMcs30()
Return MCS 30 from HT MCS values.
Definition: wifi-phy.cc:3272
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
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:1747
HE PHY for the 2.4 GHz band (clause 26)
static WifiMode GetHtMcs10()
Return MCS 10 from HT MCS values.
Definition: wifi-phy.cc:3112
void StartReceivePreambleAndHeader(Ptr< Packet > packet, double rxPowerW, Time rxDuration)
Starting receiving the plcp of a packet (i.e.
Definition: wifi-phy.cc:2348
static WifiMode GetHtMcs26()
Return MCS 26 from HT MCS values.
Definition: wifi-phy.cc:3240
static WifiMode GetOfdmRate1_5MbpsBW5MHz()
Return a WifiMode for OFDM at 1.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:2933
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:831
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:3168
static WifiMode GetHtMcs24()
Return MCS 24 from HT MCS values.
Definition: wifi-phy.cc:3224
bool GetShortGuardInterval(void) const
Return whether short guard interval is supported.
Definition: wifi-phy.cc:609
static WifiMode GetOfdmRate4_5MbpsBW10MHz()
Return a WifiMode for OFDM at 4.5Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2846
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54Mbps.
Definition: wifi-phy.cc:2819
void SetMobility(const Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:654
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:490
#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:3405
void SendPacket(Ptr< const Packet > packet, WifiTxVector txVector, MpduType mpdutype=NORMAL_MPDU)
Definition: wifi-phy.cc:2280
void ConfigureHolland(void)
Configure WifiPhy with appropriate channel frequency and supported rates for holland.
Definition: wifi-phy.cc:873
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
bool Is5Ghz(double frequency)
Definition: wifi-utils.cc:75
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:3507
void NotifyTxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyTxDrop trace.
Definition: wifi-phy.cc:2244
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:589
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:843
HR/DSSS PHY (Clause 18)
Definition: wifi-mode.h:48
std::pair< uint16_t, uint16_t > FrequencyWidthPair
A pair of a center Frequency and a ChannelWidth.
Definition: wifi-phy.h:499
static WifiMode GetHtMcs8()
Return MCS 8 from HT MCS values.
Definition: wifi-phy.cc:3096
uint8_t m_nTxPower
Number of available transmission power levels.
Definition: wifi-phy.h:1762
static WifiMode GetHtMcs18()
Return MCS 18 from HT MCS values.
Definition: wifi-phy.cc:3176
void NotifyTxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyTxBegin trace.
Definition: wifi-phy.cc:2232
virtual void SetFrequency(uint16_t freq)
Definition: wifi-phy.cc:1178
static WifiMode GetVhtMcs4()
Return MCS 4 from VHT MCS values.
Definition: wifi-phy.cc:3323
static WifiMode GetHtMcs27()
Return MCS 27 from HT MCS values.
Definition: wifi-phy.cc:3248
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
Definition: wifi-phy.cc:680
bool IsStateSwitching(void) const
Definition: wifi-phy.cc:3543
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:1706
uint16_t GetFrequency(void) const
Definition: wifi-phy.cc:1235
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:3469
static WifiMode GetOfdmRate36Mbps()
Return a WifiMode for OFDM at 36Mbps.
Definition: wifi-phy.cc:2795
uint8_t m_initialChannelNumber
Initial channel number.
Definition: wifi-phy.h:1781
static WifiMode GetVhtMcs7()
Return MCS 7 from VHT MCS values.
Definition: wifi-phy.cc:3347
static WifiMode GetOfdmRate6MbpsBW5MHz()
Return a WifiMode for OFDM at 6Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:2981
bool GetStbc(void) const
Return whether STBC is supported.
Definition: wifi-phy.cc:583
static WifiMode GetVhtMcs3()
Return MCS 3 from VHT MCS values.
Definition: wifi-phy.cc:3315
void ConfigureDefaultsForStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:722
static Time GetPlcpSigA1Duration(WifiPreamble preamble)
Definition: wifi-phy.cc:1712
uint8_t GetTxPowerLevel(void) const
MpduType
The type of an MPDU.
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:1745
mobility
Definition: third.py:101
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:1751
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:642
static WifiMode GetHtMcs16()
Return MCS 16 from HT MCS values.
Definition: wifi-phy.cc:3160
static WifiMode GetErpOfdmRate54Mbps()
Return a WifiMode for ERP-OFDM at 54Mbps.
Definition: wifi-phy.cc:2720
bool GetLdpc(void) const
Return if LDPC is supported.
Definition: wifi-phy.cc:570
uint16_t m_mpdusNum
carries the number of expected mpdus that are part of an A-MPDU
Definition: wifi-phy.h:1502
void AddSupportedChannelWidth(uint16_t channelwidth)
Definition: wifi-phy.cc:1324
static WifiMode GetHtMcs29()
Return MCS 29 from HT MCS values.
Definition: wifi-phy.cc:3264
static WifiMode GetHtMcs11()
Return MCS 11 from HT MCS values.
Definition: wifi-phy.cc:3120
void NotifyRxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:2262
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, uint16_t frequency)
Definition: wifi-phy.cc:2226
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:1777
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:692
double GetEdThreshold(void) const
Return the energy detection threshold (dBm).
Definition: wifi-phy.cc:471
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
The MPDU is not part of an A-MPDU.
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:1727
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:1465
static WifiMode GetHtMcs2()
Return MCS 2 from HT MCS values.
Definition: wifi-phy.cc:3048
struct InterferenceHelper::SnrPer CalculatePlcpPayloadSnrPer(Ptr< Event > event) const
Calculate the SNIR at the start of the plcp payload and accumulate all SNIR changes in the snir vecto...
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:1381
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
Definition: wifi-phy.h:1788
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:1874
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:1655
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:2268
bool m_shortPreamble
Flag if short PLCP preamble is supported.
Definition: wifi-phy.h:1768
bool IsStrictlyPositive(void) const
Definition: nstime.h:308
Ptr< Event > Add(Ptr< const Packet > packet, WifiTxVector txVector, Time duration, double rxPower)
Add the packet-related signal to interference helper.
static WifiMode GetHeMcs3()
Return MCS 3 from HE MCS values.
Definition: wifi-phy.cc:3397
static Time GetPlcpSigBDuration(WifiPreamble preamble)
Definition: wifi-phy.cc:1742
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:694
uint16_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1255
EventId m_endPlcpRxEvent
the end PLCP receive event
Definition: wifi-phy.h:1508
static WifiMode GetHtMcs12()
Return MCS 12 from HT MCS values.
Definition: wifi-phy.cc:3128
Ptr< WifiRadioEnergyModel > m_wifiRadioEnergyModel
Wifi radio energy model.
Definition: wifi-phy.h:1792
static WifiMode GetErpOfdmRate48Mbps()
Return a WifiMode for ERP-OFDM at 48Mbps.
Definition: wifi-phy.cc:2708
static Time CalculatePlcpPreambleAndHeaderDuration(WifiTxVector txVector)
Definition: wifi-phy.cc:2204
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:511
uint8_t GetNess(void) const
Time GetGuardInterval(void) const
Definition: wifi-phy.cc:623
WifiMode GetMode(uint8_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3501
static WifiMode GetOfdmRate12MbpsBW10MHz()
Return a WifiMode for OFDM at 12Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2882
static WifiMode GetHeMcs11()
Return MCS 11 from HE MCS values.
Definition: wifi-phy.cc:3461
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:3561
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:478
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:463
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU...
Definition: wifi-phy.h:1505
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
Definition: wifi-phy.h:1678
double m_edThresholdW
Energy detection threshold in watts.
Definition: wifi-phy.h:1756
void Configure80211_5Mhz()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard with 5M...
Definition: wifi-phy.cc:858
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
void NotifyRxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyRxBegin trace.
Definition: wifi-phy.cc:2250
bool IsStateSleep(void) const
Definition: wifi-phy.cc:3549
static WifiMode GetOfdmRate18Mbps()
Return a WifiMode for OFDM at 18Mbps.
Definition: wifi-phy.cc:2771
void SetCapabilitiesChangedCallback(Callback< void > callback)
Definition: wifi-phy.cc:430
void SetOffMode(void)
Put in off mode.
Definition: wifi-phy.cc:1549
static WifiMode GetOfdmRate9MbpsBW10MHz()
Return a WifiMode for OFDM at 9Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2870
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:3005
void AbortCurrentReception(void)
Due to newly arrived signal, the current reception cannot be continued and has to be aborted...
Definition: wifi-phy.cc:3590
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
Definition: wifi-phy.h:1639
static WifiMode GetVhtMcs1()
Return MCS 1 from VHT MCS values.
Definition: wifi-phy.cc:3299
std::vector< uint16_t > GetSupportedChannelWidthSet(void) const
Definition: wifi-phy.cc:1339
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:2807
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:673
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:3445
The MPDU is part of an A-MPDU, but is not the last aggregate.
double f(double x, void *params)
Definition: 80211b.c:70
static WifiMode GetHtMcs0()
Return MCS 0 from HT MCS values.
Definition: wifi-phy.cc:3032
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:3513
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.
Hold objects of type Ptr<T>.
Definition: pointer.h:36
double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:518
void SetWifiRadioEnergyModel(const Ptr< WifiRadioEnergyModel > wifiRadioEnergyModel)
Sets the wifi radio energy model.
Definition: wifi-phy.cc:686
Time m_guardInterval
Supported HE guard interval.
Definition: wifi-phy.h:1770
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:2783
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
virtual void SetChannelWidth(uint16_t channelwidth)
Definition: wifi-phy.cc:1241
WifiPhyState
The state of the PHY layer.
static WifiMode GetHeMcs1()
Return MCS 1 from HE MCS values.
Definition: wifi-phy.cc:3381
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
static WifiMode GetHtMcs13()
Return MCS 13 from HT MCS values.
Definition: wifi-phy.cc:3136
void SetShortGuardInterval(bool shortGuardInterval)
Enable or disable support for HT/VHT short guard interval.
Definition: wifi-phy.cc:602
static WifiMode GetHeMcs0()
Return MCS 0 from HE MCS values.
Definition: wifi-phy.cc:3373
double CalculateSnr(WifiTxVector txVector, double ber) const
Definition: wifi-phy.cc:716
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:3453
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:3192
static WifiMode GetHeMcs2()
Return MCS 2 from HE MCS values.
Definition: wifi-phy.cc:3389
static WifiMode GetHtMcs5()
Return MCS 5 from HT MCS values.
Definition: wifi-phy.cc:3072
void SetMaxSupportedRxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1294
void SetCcaMode1Threshold(double threshold)
Sets the CCA threshold (dBm).
Definition: wifi-phy.cc:477
Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
Definition: wifi-phy.cc:3567
static WifiMode GetVhtMcs2()
Return MCS 2 from VHT MCS values.
Definition: wifi-phy.cc:3307
FrequencyWidthPair GetFrequencyWidthForChannelNumberStandard(uint8_t channelNumber, WifiPhyStandard standard) const
Lookup frequency/width pair for channelNumber/standard pair.
Definition: wifi-phy.cc:1345
virtual void SetChannelNumber(uint8_t id)
Set channel number.
Definition: wifi-phy.cc:1353
static WifiMode GetDsssRate5_5Mbps()
Return a WifiMode for DSSS at 5.5Mbps.
Definition: wifi-phy.cc:2609
void Configure80211ac(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard...
Definition: wifi-phy.cc:971
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:2945
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:53
WifiPhyStandard m_standard
WifiPhyStandard.
Definition: wifi-phy.h:1749
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
void SetGuardInterval(Time guardInterval)
Definition: wifi-phy.cc:615
static WifiMode GetErpOfdmRate9Mbps()
Return a WifiMode for ERP-OFDM at 9Mbps.
Definition: wifi-phy.cc:2648
void NotifyTxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyTxEnd trace.
Definition: wifi-phy.cc:2238
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Definition: wifi-phy.h:1499
double DbToRatio(double dB)
Convert from dB to ratio.
Definition: wifi-utils.cc:39
bool IsStateTx(void) const
Definition: wifi-phy.cc:3537
uint8_t m_txSpatialStreams
Number of supported TX spatial streams.
Definition: wifi-phy.h:1773
uint8_t GetMaxSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1288
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition: wifi-utils.cc:59
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:1791
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:1318
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:648
struct InterferenceHelper::SnrPer CalculatePlcpHeaderSnrPer(Ptr< Event > event) const
Calculate the SNIR at the start of the plcp header and accumulate all SNIR changes in the snir vector...
void SetRxGain(double gain)
Sets the reception gain (dB).
Definition: wifi-phy.cc:550
void Configure80211b(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard...
Definition: wifi-phy.cc:816
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:80
void EndReceive(Ptr< Packet > packet, WifiPreamble preamble, MpduType mpdutype, Ptr< Event > event)
The last bit of the packet has arrived.
Definition: wifi-phy.cc:2531
void SetReceiveOkCallback(RxOkCallback callback)
Definition: wifi-phy.cc:406
uint16_t m_channelWidth
Channel width.
Definition: wifi-phy.h:1754
static WifiMode GetErpOfdmRate6Mbps()
Return a WifiMode for ERP-OFDM at 6Mbps.
Definition: wifi-phy.cc:2636
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:1061
uint8_t GetNss(void) const
void SetMaxSupportedTxSpatialStreams(uint8_t streams)
Definition: wifi-phy.cc:1275
The PHY layer is sending a packet.
static WifiMode GetErpOfdmRate12Mbps()
Return a WifiMode for ERP-OFDM at 12Mbps.
Definition: wifi-phy.cc:2660
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:1503
bool m_greenfield
Flag if GreenField format is supported.
Definition: wifi-phy.h:1766
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:1507
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Definition: wifi-phy.h:1500
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:2256
void Configure80211n(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard...
Definition: wifi-phy.cc:954
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:498
double m_txPowerBaseDbm
Minimum transmission power (dBm)
Definition: wifi-phy.h:1760
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:262
SignalNoiseDbm structure.
Definition: wifi-phy.h:46
uint32_t mpduRefNumber
MPDU ref number.
Definition: wifi-phy.h:56
bool m_frequencyChannelNumberInitialized
Store initialization state.
Definition: wifi-phy.h:1753
static WifiMode GetHtMcs19()
Return MCS 19 from HT MCS values.
Definition: wifi-phy.cc:3184
InterferenceHelper m_interference
Pointer to InterferenceHelper.
Definition: wifi-phy.h:1498
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:3080
bool m_isConstructed
true when ready to set frequency
Definition: wifi-phy.h:1750
void StartReceivePacket(Ptr< Packet > packet, WifiTxVector txVector, MpduType mpdutype, Ptr< Event > event)
Starting receiving the payload of a packet (i.e.
Definition: wifi-phy.cc:2493
The MPDU is the last aggregate in an A-MPDU.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:270
void ConfigureHtDeviceMcsSet(void)
Configure the device Mcs set with the appropriate HtMcs modes for the number of available transmit sp...
Definition: wifi-phy.cc:885
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:1638
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:1785
static WifiMode GetHtMcs28()
Return MCS 28 from HT MCS values.
Definition: wifi-phy.cc:3256
bool IsStateOff(void) const
Definition: wifi-phy.cc:3555
static WifiMode GetHtMcs9()
Return MCS 9 from HT MCS values.
Definition: wifi-phy.cc:3104
Ptr< MobilityModel > GetMobility(void) const
Return the mobility model this PHY is associated with.
Definition: wifi-phy.cc:660
Time GetChannelSwitchDelay(void) const
Definition: wifi-phy.cc:710
static WifiMode GetHtMcs4()
Return MCS 4 from HT MCS values.
Definition: wifi-phy.cc:3064
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:3232
static WifiMode GetHeMcs8()
Return MCS 8 from HE MCS values.
Definition: wifi-phy.cc:3437
Tag for WifiTxVector and WifiPreamble information to be embedded in outgoing transmissions as a Packe...
Definition: wifi-phy-tag.h:36
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:827
static WifiMode GetHePlcpHeaderMode()
Definition: wifi-phy.cc:1644
The PHY layer is switching to other channel.
void SetSleepMode(void)
Put in sleep mode.
Definition: wifi-phy.cc:1517
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:1784
double noise
in dBm
Definition: wifi-phy.h:49
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1023
WifiModeList m_deviceRateSet
This vector holds the set of transmission modes that this WifiPhy(-derived class) can support...
Definition: wifi-phy.h:1744
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:2274
Time GetPayloadDuration(uint32_t size, WifiTxVector txVector, uint16_t frequency)
Definition: wifi-phy.cc:1928
void SetNumberOfAntennas(uint8_t antennas)
Definition: wifi-phy.cc:1261
second
Definition: nstime.h:114
static WifiMode GetHtMcs1()
Return MCS 1 from HT MCS values.
Definition: wifi-phy.cc:3040
static WifiMode GetHtMcs23()
Return MCS 23 from HT MCS values.
Definition: wifi-phy.cc:3216
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:2594
static WifiMode GetVhtMcs9()
Return MCS 9 from VHT MCS values.
Definition: wifi-phy.cc:3363
#define HT_PHY
Definition: wifi-phy.h:35
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1111
WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:500
static WifiMode GetOfdmRate6MbpsBW10MHz()
Return a WifiMode for OFDM at 6Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2858
WifiMode GetMode(void) const
double m_txPowerEndDbm
Maximum transmission power (dBm)
Definition: wifi-phy.h:1761
uint8_t GetNumberOfAntennas(void) const
Definition: wifi-phy.cc:1269
#define VHT_PHY
Definition: wifi-phy.h:34
bool GetShortPlcpPreambleSupported(void) const
Return whether short PLCP preamble is supported.
Definition: wifi-phy.cc:636
static WifiMode GetPlcpHeaderMode(WifiTxVector txVector)
Definition: wifi-phy.cc:1759
static Time GetPlcpTrainingSymbolDuration(WifiTxVector txVector)
Definition: wifi-phy.cc:1650
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
static WifiMode GetOfdmRate24MbpsBW10MHz()
Return a WifiMode for OFDM at 24Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2906
MpduType type
type
Definition: wifi-phy.h:55
Time m_channelSwitchDelay
Time required to switch between channel.
Definition: wifi-phy.h:1783
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
Return a WifiMode for OFDM at 13.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:3017
double m_ccaMode1ThresholdW
Clear channel assessment (CCA) threshold in watts.
Definition: wifi-phy.h:1757
double GetCcaMode1Threshold(void) const
Return the CCA threshold (dBm).
Definition: wifi-phy.cc:484
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
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:732
bool IsStateIdle(void) const
Definition: wifi-phy.cc:3525
uint8_t m_numberOfAntennas
Number of transmitters.
Definition: wifi-phy.h:1772
static Time GetPlcpHeaderDuration(WifiTxVector txVector)
Definition: wifi-phy.cc:1805
a unique identifier for an interface.
Definition: type-id.h:58
static WifiMode GetHtMcs15()
Return MCS 15 from HT MCS values.
Definition: wifi-phy.cc:3152
Ptr< Event > m_currentEvent
Hold the current event.
Definition: wifi-phy.h:1790
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
static WifiMode GetHtMcs3()
Return MCS 3 from HT MCS values.
Definition: wifi-phy.cc:3056
uint8_t m_rxSpatialStreams
Number of supported RX spatial streams.
Definition: wifi-phy.h:1774
std::vector< uint16_t > m_supportedChannelWidthSet
Supported channel width.
Definition: wifi-phy.h:1779
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6Mbps.
Definition: wifi-phy.cc:2735
void SwitchMaybeToCcaBusy(void)
Check if Phy state should move to CCA busy state based on current state of interference tracker...
Definition: wifi-phy.cc:3573
bool m_shortGuardInterval
Flag if HT/VHT short guard interval is supported.
Definition: wifi-phy.h:1767
WifiPhyStandard GetStandard(void) const
Get the configured Wi-Fi standard.
Definition: wifi-phy.cc:1172
double GetRxGain(void) const
Return the reception gain (dB).
Definition: wifi-phy.cc:557
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:3684
DSSS PHY (Clause 15)
Definition: wifi-mode.h:46
static WifiMode GetHeMcs6()
Return MCS 6 from HE MCS values.
Definition: wifi-phy.cc:3421
uint8_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:3495
static WifiMode GetHtPlcpHeaderMode()
Definition: wifi-phy.cc:1632
double GetTxPowerStart(void) const
Return the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:505
static WifiMode GetOfdmRate4_5MbpsBW5MHz()
Return a WifiMode for OFDM at 4.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:2969
bool m_stbc
Flag if STBC is used.
Definition: wifi-phy.h:1765
Callback< void > m_capabilitiesChangedCallback
Callback when PHY capabilities changed.
Definition: wifi-phy.h:1794
MpduType GetMpduType(void) const
Getter for mpduType parameter.
Definition: wifi-phy-tag.cc:86
void Configure80211a(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard...
Definition: wifi-phy.cc:801
std::map< ChannelNumberStandardPair, FrequencyWidthPair > ChannelToFrequencyWidthMap
channel to frequency width map typedef
Definition: wifi-phy.h:1776
static WifiMode GetOfdmRate3MbpsBW10MHz()
Return a WifiMode for OFDM at 3Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2834
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...
Definition: wifi-phy.h:1647
uint16_t m_initialFrequency
Store frequency until initialization.
Definition: wifi-phy.h:1752
bool DoChannelSwitch(uint8_t id)
The default implementation does nothing and returns true.
Definition: wifi-phy.cc:1413