A Discrete-Event Network Simulator
API
wifi-phy.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Sébastien Deronne <sebastien.deronne@gmail.com>
20  */
21 
22 #include "wifi-phy.h"
23 #include "wifi-mode.h"
24 #include "wifi-channel.h"
25 #include "wifi-preamble.h"
26 #include "wifi-phy-state-helper.h"
27 #include "ns3/simulator.h"
28 #include "ns3/assert.h"
29 #include "ns3/log.h"
30 #include "ns3/boolean.h"
31 #include "ns3/double.h"
32 #include "ns3/uinteger.h"
33 #include "ns3/enum.h"
34 #include "ns3/pointer.h"
35 #include "ns3/trace-source-accessor.h"
36 #include "ns3/fatal-error.h"
37 #include <cmath>
38 
39 namespace ns3 {
40 
41 NS_LOG_COMPONENT_DEFINE ("WifiPhy");
42 
43 /****************************************************************
44  * This destructor is needed.
45  ****************************************************************/
46 
48 {
49 }
50 
51 /****************************************************************
52  * The actual WifiPhy class
53  ****************************************************************/
54 
56 
66 {
67  // 802.11b uses width of 22, while OFDM modes use width of 20
68  { std::make_pair (1, WIFI_PHY_STANDARD_80211b), std::make_pair (2412, 22) },
69  { std::make_pair (1, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2412, 20) },
70  { std::make_pair (2, WIFI_PHY_STANDARD_80211b), std::make_pair (2417, 22) },
71  { std::make_pair (2, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2417, 20) },
72  { std::make_pair (3, WIFI_PHY_STANDARD_80211b), std::make_pair (2422, 22) },
73  { std::make_pair (3, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2422, 20) },
74  { std::make_pair (4, WIFI_PHY_STANDARD_80211b), std::make_pair (2427, 22) },
75  { std::make_pair (4, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2427, 20) },
76  { std::make_pair (5, WIFI_PHY_STANDARD_80211b), std::make_pair (2432, 22) },
77  { std::make_pair (5, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2432, 20) },
78  { std::make_pair (6, WIFI_PHY_STANDARD_80211b), std::make_pair (2437, 22) },
79  { std::make_pair (6, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2437, 20) },
80  { std::make_pair (7, WIFI_PHY_STANDARD_80211b), std::make_pair (2442, 22) },
81  { std::make_pair (7, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2442, 20) },
82  { std::make_pair (8, WIFI_PHY_STANDARD_80211b), std::make_pair (2447, 22) },
83  { std::make_pair (8, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2447, 20) },
84  { std::make_pair (9, WIFI_PHY_STANDARD_80211b), std::make_pair (2452, 22) },
85  { std::make_pair (9, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2452, 20) },
86  { std::make_pair (10, WIFI_PHY_STANDARD_80211b), std::make_pair (2457, 22) },
87  { std::make_pair (10, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2457, 20) },
88  { std::make_pair (11, WIFI_PHY_STANDARD_80211b), std::make_pair (2462, 22) },
89  { std::make_pair (11, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2462, 20) },
90  { std::make_pair (12, WIFI_PHY_STANDARD_80211b), std::make_pair (2467, 22) },
91  { std::make_pair (12, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2467, 20) },
92  { std::make_pair (13, WIFI_PHY_STANDARD_80211b), std::make_pair (2472, 22) },
93  { std::make_pair (13, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (2472, 20) },
94  // Only defined for 802.11b
95  { std::make_pair (14, WIFI_PHY_STANDARD_80211b), std::make_pair (2484, 22) },
96 
97  // Now the 5GHz channels; UNSPECIFIED for 802.11a/n channels, but limited
98  // to 802.11ac for the 80/160 MHz channels
99  // 20 MHz channels
100  { std::make_pair (36, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5180, 20) },
101  { std::make_pair (40, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5200, 20) },
102  { std::make_pair (44, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5220, 20) },
103  { std::make_pair (48, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5240, 20) },
104  { std::make_pair (52, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5260, 20) },
105  { std::make_pair (56, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5280, 20) },
106  { std::make_pair (60, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5300, 20) },
107  { std::make_pair (64, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5320, 20) },
108  { std::make_pair (100, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5500, 20) },
109  { std::make_pair (104, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5520, 20) },
110  { std::make_pair (108, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5540, 20) },
111  { std::make_pair (112, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5560, 20) },
112  { std::make_pair (116, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5580, 20) },
113  { std::make_pair (120, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5600, 20) },
114  { std::make_pair (124, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5620, 20) },
115  { std::make_pair (128, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5640, 20) },
116  { std::make_pair (132, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5660, 20) },
117  { std::make_pair (136, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5680, 20) },
118  { std::make_pair (140, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5700, 20) },
119  { std::make_pair (144, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5720, 20) },
120  { std::make_pair (149, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5745, 20) },
121  { std::make_pair (153, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5765, 20) },
122  { std::make_pair (157, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5785, 20) },
123  { std::make_pair (161, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5805, 20) },
124  { std::make_pair (165, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5825, 20) },
125  // 40 MHz channels
126  { std::make_pair (38, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5190, 40) },
127  { std::make_pair (46, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5230, 40) },
128  { std::make_pair (54, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5230, 40) },
129  { std::make_pair (62, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5310, 40) },
130  { std::make_pair (102, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5510, 40) },
131  { std::make_pair (110, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5550, 40) },
132  { std::make_pair (118, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5590, 40) },
133  { std::make_pair (126, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5590, 40) },
134  { std::make_pair (134, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5670, 40) },
135  { std::make_pair (142, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5710, 40) },
136  { std::make_pair (151, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5755, 40) },
137  { std::make_pair (159, WIFI_PHY_STANDARD_UNSPECIFIED), std::make_pair (5795, 40) },
138  // 80 MHz channels
139  { std::make_pair (42, WIFI_PHY_STANDARD_80211ac), std::make_pair (5210, 80) },
140  { std::make_pair (58, WIFI_PHY_STANDARD_80211ac), std::make_pair (5290, 80) },
141  { std::make_pair (106, WIFI_PHY_STANDARD_80211ac), std::make_pair (5530, 80) },
142  { std::make_pair (122, WIFI_PHY_STANDARD_80211ac), std::make_pair (5610, 80) },
143  { std::make_pair (138, WIFI_PHY_STANDARD_80211ac), std::make_pair (5690, 80) },
144  { std::make_pair (155, WIFI_PHY_STANDARD_80211ac), std::make_pair (5775, 80) },
145  // 160 MHz channels
146  { std::make_pair (50, WIFI_PHY_STANDARD_80211ac), std::make_pair (5250, 160) },
147  { std::make_pair (114, WIFI_PHY_STANDARD_80211ac), std::make_pair (5570, 160) },
148 
149  // 802.11p (10 MHz channels at the 5.855-5.925 band
150  { std::make_pair (172, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5860, 10) },
151  { std::make_pair (174, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5870, 10) },
152  { std::make_pair (176, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5880, 10) },
153  { std::make_pair (178, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5890, 10) },
154  { std::make_pair (180, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5900, 10) },
155  { std::make_pair (182, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5910, 10) },
156  { std::make_pair (184, WIFI_PHY_STANDARD_80211_10MHZ), std::make_pair (5920, 10) }
157 };
158 
159 TypeId
161 {
162  static TypeId tid = TypeId ("ns3::WifiPhy")
163  .SetParent<Object> ()
164  .SetGroupName ("Wifi")
165  .AddAttribute ("Frequency",
166  "The operating center frequency (MHz)",
167  UintegerValue (0),
170  MakeUintegerChecker<uint32_t> ())
171  .AddAttribute ("ChannelWidth",
172  "Whether 5MHz, 10MHz, 20MHz, 22MHz, 40MHz, 80 MHz or 160 MHz.",
173  UintegerValue (20),
176  MakeUintegerChecker<uint32_t> ())
177  .AddAttribute ("ChannelNumber",
178  "If set to non-zero defined value, will control Frequency and ChannelWidth assignment",
179  UintegerValue (0),
182  MakeUintegerChecker<uint16_t> ())
183  .AddAttribute ("EnergyDetectionThreshold",
184  "The energy of a received signal should be higher than "
185  "this threshold (dbm) to allow the PHY layer to detect the signal.",
186  DoubleValue (-96.0),
189  MakeDoubleChecker<double> ())
190  .AddAttribute ("CcaMode1Threshold",
191  "The energy of a received signal should be higher than "
192  "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.",
193  DoubleValue (-99.0),
196  MakeDoubleChecker<double> ())
197  .AddAttribute ("TxGain",
198  "Transmission gain (dB).",
199  DoubleValue (1.0),
202  MakeDoubleChecker<double> ())
203  .AddAttribute ("RxGain",
204  "Reception gain (dB).",
205  DoubleValue (1.0),
208  MakeDoubleChecker<double> ())
209  .AddAttribute ("TxPowerLevels",
210  "Number of transmission power levels available between "
211  "TxPowerStart and TxPowerEnd included.",
212  UintegerValue (1),
214  MakeUintegerChecker<uint32_t> ())
215  .AddAttribute ("TxPowerEnd",
216  "Maximum available transmission level (dbm).",
217  DoubleValue (16.0206),
220  MakeDoubleChecker<double> ())
221  .AddAttribute ("TxPowerStart",
222  "Minimum available transmission level (dbm).",
223  DoubleValue (16.0206),
226  MakeDoubleChecker<double> ())
227  .AddAttribute ("RxNoiseFigure",
228  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
229  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
230  "\"the difference in decibels (dB) between"
231  " the noise output of the actual receiver to the noise output of an "
232  " ideal receiver with the same overall gain and bandwidth when the receivers "
233  " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
234  DoubleValue (7),
237  MakeDoubleChecker<double> ())
238  .AddAttribute ("State",
239  "The state of the PHY layer.",
240  PointerValue (),
242  MakePointerChecker<WifiPhyStateHelper> ())
243  .AddAttribute ("ChannelSwitchDelay",
244  "Delay between two short frames transmitted on different frequencies.",
245  TimeValue (MicroSeconds (250)),
247  MakeTimeChecker ())
248  .AddAttribute ("TxAntennas",
249  "The number of supported Tx antennas.",
250  UintegerValue (1),
253  MakeUintegerChecker<uint32_t> ())
254  .AddAttribute ("RxAntennas",
255  "The number of supported Rx antennas.",
256  UintegerValue (1),
259  MakeUintegerChecker<uint32_t> ())
260  .AddAttribute ("ShortGuardEnabled",
261  "Whether or not short guard interval is enabled."
262  "This parameter is only valuable for 802.11n/ac STAs and APs.",
263  BooleanValue (false),
267  .AddAttribute ("LdpcEnabled",
268  "Whether or not LDPC is enabled.",
269  BooleanValue (false),
273  .AddAttribute ("STBCEnabled",
274  "Whether or not STBC is enabled.",
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  .AddTraceSource ("PhyTxBegin",
295  "Trace source indicating a packet "
296  "has begun transmitting over the channel medium",
298  "ns3::Packet::TracedCallback")
299  .AddTraceSource ("PhyTxEnd",
300  "Trace source indicating a packet "
301  "has been completely transmitted over the channel. "
302  "NOTE: the only official WifiPhy implementation "
303  "available to this date never fires "
304  "this trace source.",
306  "ns3::Packet::TracedCallback")
307  .AddTraceSource ("PhyTxDrop",
308  "Trace source indicating a packet "
309  "has been dropped by the device during transmission",
311  "ns3::Packet::TracedCallback")
312  .AddTraceSource ("PhyRxBegin",
313  "Trace source indicating a packet "
314  "has begun being received from the channel medium "
315  "by the device",
317  "ns3::Packet::TracedCallback")
318  .AddTraceSource ("PhyRxEnd",
319  "Trace source indicating a packet "
320  "has been completely received from the channel medium "
321  "by the device",
323  "ns3::Packet::TracedCallback")
324  .AddTraceSource ("PhyRxDrop",
325  "Trace source indicating a packet "
326  "has been dropped by the device during reception",
328  "ns3::Packet::TracedCallback")
329  .AddTraceSource ("MonitorSnifferRx",
330  "Trace source simulating a wifi device in monitor mode "
331  "sniffing all received frames",
333  "ns3::WifiPhy::MonitorSnifferRxTracedCallback")
334  .AddTraceSource ("MonitorSnifferTx",
335  "Trace source simulating the capability of a wifi device "
336  "in monitor mode to sniff all frames being transmitted",
338  "ns3::WifiPhy::MonitorSnifferTxTracedCallback")
339  ;
340  return tid;
341 }
342 
344  : m_mpdusNum (0),
345  m_plcpSuccess (false),
346  m_txMpduReferenceNumber (0xffffffff),
347  m_rxMpduReferenceNumber (0xffffffff),
348  m_endRxEvent (),
349  m_endPlcpRxEvent (),
350  m_standard (WIFI_PHY_STANDARD_UNSPECIFIED),
351  m_isConstructed (false),
352  m_channelCenterFrequency (0),
353  m_initialFrequency (0),
354  m_frequencyChannelNumberInitialized (false),
355  m_channelNumber (0),
356  m_initialChannelNumber (0),
357  m_totalAmpduSize (0),
358  m_totalAmpduNumSymbols (0)
359 {
360  NS_LOG_FUNCTION (this);
361  m_random = CreateObject<UniformRandomVariable> ();
362  m_state = CreateObject<WifiPhyStateHelper> ();
363 }
364 
366 {
367  NS_LOG_FUNCTION (this);
368 }
369 
370 void
372 {
373  NS_LOG_FUNCTION (this);
374  m_device = 0;
375  m_mobility = 0;
376  m_state = 0;
377  m_deviceRateSet.clear ();
378  m_deviceMcsSet.clear ();
379 }
380 
381 void
383 {
384  NS_LOG_FUNCTION (this);
385  m_isConstructed = true;
387  {
388  NS_LOG_DEBUG ("Frequency already initialized");
389  return;
390  }
392 }
393 
394 void
396 {
397  NS_LOG_FUNCTION (this);
398 
399  NS_ASSERT_MSG (m_frequencyChannelNumberInitialized == false, "Initialization called twice");
400 
401  // If frequency has been set to a non-zero value during attribute
402  // construction phase, the frequency and channel width will drive the
403  // initial configuration. If frequency has not been set, but both
404  // standard and channel number have been set, that pair will instead
405  // drive the configuration, and frequency and channel number will be
406  // aligned
407  if (m_initialFrequency != 0)
408  {
410  }
412  {
414  }
416  {
417  NS_FATAL_ERROR ("Error, ChannelNumber " << GetChannelNumber () << " was set by user, but neither a standard nor a frequency");
418  }
420 }
421 
422 void
423 WifiPhy::SetEdThreshold (double threshold)
424 {
425  NS_LOG_FUNCTION (this << threshold);
426  m_edThresholdW = DbmToW (threshold);
427 }
428 
429 double
431 {
432  return m_edThresholdW;
433 }
434 
435 double
437 {
438  return WToDbm (m_edThresholdW);
439 }
440 
441 void
443 {
444  NS_LOG_FUNCTION (this << threshold);
445  m_ccaMode1ThresholdW = DbmToW (threshold);
446 }
447 
448 double
450 {
451  return WToDbm (m_ccaMode1ThresholdW);
452 }
453 
454 void
455 WifiPhy::SetRxNoiseFigure (double noiseFigureDb)
456 {
457  NS_LOG_FUNCTION (this << noiseFigureDb);
458  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
459 }
460 
461 double
463 {
465 }
466 
467 void
469 {
470  NS_LOG_FUNCTION (this << start);
472 }
473 
474 double
476 {
477  return m_txPowerBaseDbm;
478 }
479 
480 void
482 {
483  NS_LOG_FUNCTION (this << end);
484  m_txPowerEndDbm = end;
485 }
486 
487 double
489 {
490  return m_txPowerEndDbm;
491 }
492 
493 void
495 {
496  NS_LOG_FUNCTION (this << n);
497  m_nTxPower = n;
498 }
499 
500 uint32_t
502 {
503  return m_nTxPower;
504 }
505 
506 void
507 WifiPhy::SetTxGain (double gain)
508 {
509  NS_LOG_FUNCTION (this << gain);
510  m_txGainDb = gain;
511 }
512 
513 double
514 WifiPhy::GetTxGain (void) const
515 {
516  return m_txGainDb;
517 }
518 
519 void
520 WifiPhy::SetRxGain (double gain)
521 {
522  NS_LOG_FUNCTION (this << gain);
523  m_rxGainDb = gain;
524 }
525 
526 double
527 WifiPhy::GetRxGain (void) const
528 {
529  return m_rxGainDb;
530 }
531 
532 void
533 WifiPhy::SetLdpc (bool ldpc)
534 {
535  NS_LOG_FUNCTION (this << ldpc);
536  m_ldpc = ldpc;
537 }
538 
539 bool
540 WifiPhy::GetLdpc (void) const
541 {
542  return m_ldpc;
543 }
544 
545 void
546 WifiPhy::SetStbc (bool stbc)
547 {
548  NS_LOG_FUNCTION (this << stbc);
549  m_stbc = stbc;
550 }
551 
552 bool
553 WifiPhy::GetStbc (void) const
554 {
555  return m_stbc;
556 }
557 
558 void
559 WifiPhy::SetGreenfield (bool greenfield)
560 {
561  NS_LOG_FUNCTION (this << greenfield);
562  m_greenfield = greenfield;
563 }
564 
565 bool
567 {
568  return m_greenfield;
569 }
570 
571 void
572 WifiPhy::SetGuardInterval (bool guardInterval)
573 {
574  NS_LOG_FUNCTION (this << guardInterval);
575  m_guardInterval = guardInterval;
576 }
577 
578 bool
580 {
581  return m_guardInterval;
582 }
583 
584 void
586 {
587  NS_LOG_FUNCTION (this << enable);
588  m_shortPreamble = enable;
589 }
590 
591 bool
593 {
594  return m_shortPreamble;
595 }
596 
597 void
599 {
600  m_device = device;
601 }
602 
604 WifiPhy::GetDevice (void) const
605 {
606  return m_device;
607 }
608 
609 void
611 {
613 }
614 
617 {
618  if (m_mobility != 0)
619  {
620  return m_mobility;
621  }
622  else
623  {
624  return m_device->GetNode ()->GetObject<MobilityModel> ();
625  }
626 }
627 
628 void
630 {
632 }
633 
636 {
638 }
639 
640 double
641 WifiPhy::GetPowerDbm (uint8_t power) const
642 {
644  NS_ASSERT (m_nTxPower > 0);
645  double dbm;
646  if (m_nTxPower > 1)
647  {
648  dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
649  }
650  else
651  {
652  NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
653  dbm = m_txPowerBaseDbm;
654  }
655  return dbm;
656 }
657 
658 Time
660 {
661  return m_channelSwitchDelay;
662 }
663 
664 double
665 WifiPhy::CalculateSnr (WifiTxVector txVector, double ber) const
666 {
667  return m_interference.GetErrorRateModel ()->CalculateSnr (txVector, ber);
668 }
669 
670 void
672 {
673  NS_LOG_FUNCTION (this << standard);
674  switch (standard)
675  {
677  SetChannelWidth (20);
678  SetFrequency (5180);
679  // Channel number should be aligned by SetFrequency () to 36
680  NS_ASSERT (GetChannelNumber () == 36);
681  break;
683  SetChannelWidth (22);
684  SetFrequency (2412);
685  // Channel number should be aligned by SetFrequency () to 1
686  NS_ASSERT (GetChannelNumber () == 1);
687  break;
689  SetChannelWidth (20);
690  SetFrequency (2412);
691  // Channel number should be aligned by SetFrequency () to 1
692  NS_ASSERT (GetChannelNumber () == 1);
693  break;
695  SetChannelWidth (10);
696  SetFrequency (5860);
697  // Channel number should be aligned by SetFrequency () to 172
698  NS_ASSERT (GetChannelNumber () == 172);
699  break;
701  SetChannelWidth (5);
702  SetFrequency (5860);
703  // Channel number should be aligned by SetFrequency () to 0
704  NS_ASSERT (GetChannelNumber () == 0);
705  break;
707  SetChannelWidth (20);
708  SetFrequency (5180);
709  // Channel number should be aligned by SetFrequency () to 36
710  NS_ASSERT (GetChannelNumber () == 36);
711  break;
713  SetChannelWidth (20);
714  SetFrequency (2412);
715  // Channel number should be aligned by SetFrequency () to 1
716  NS_ASSERT (GetChannelNumber () == 1);
717  break;
719  SetChannelWidth (20);
720  SetFrequency (5180);
721  // Channel number should be aligned by SetFrequency () to 36
722  NS_ASSERT (GetChannelNumber () == 36);
723  break;
725  SetChannelWidth (80);
726  SetFrequency (5210);
727  // Channel number should be aligned by SetFrequency () to 42
728  NS_ASSERT (GetChannelNumber () == 42);
729  break;
731  NS_LOG_WARN ("Configuring unspecified standard; performing no action");
732  break;
733  default:
734  NS_ASSERT (false);
735  break;
736  }
737 }
738 
739 void
741 {
742  NS_LOG_FUNCTION (this);
743 
752 }
753 
754 void
756 {
757  NS_LOG_FUNCTION (this);
758 
763 }
764 
765 void
767 {
768  NS_LOG_FUNCTION (this);
769  Configure80211b ();
770 
779 }
780 
781 void
783 {
784  NS_LOG_FUNCTION (this);
785 
794 }
795 
796 void
798 {
799  NS_LOG_FUNCTION (this);
800 
809 }
810 
811 void
813 {
814  NS_LOG_FUNCTION (this);
815 
821 }
822 
823 void
825 {
826  NS_LOG_FUNCTION (this);
827 
828  bool htFound = false;
829  for (std::vector<uint32_t>::size_type i = 0; i < m_bssMembershipSelectorSet.size (); i++)
830  {
832  {
833  htFound = true;
834  break;
835  }
836  }
837  if (htFound)
838  {
839  // erase all HtMcs modes from deviceMcsSet
840  size_t index = m_deviceMcsSet.size () - 1;
841  for (std::vector<WifiMode>::reverse_iterator rit = m_deviceMcsSet.rbegin (); rit != m_deviceMcsSet.rend(); ++rit, --index)
842  {
843  if (m_deviceMcsSet[index].GetModulationClass ()== WIFI_MOD_CLASS_HT)
844  {
845  m_deviceMcsSet.erase (m_deviceMcsSet.begin () + index);
846  }
847  }
848  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs0 ());
849  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs1 ());
850  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs2 ());
851  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs3 ());
852  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs4 ());
853  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs5 ());
854  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs6 ());
855  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs7 ());
856  if (GetSupportedTxSpatialStreams () > 1)
857  {
858  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs8 ());
859  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs9 ());
860  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs10 ());
861  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs11 ());
862  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs12 ());
863  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs13 ());
864  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs14 ());
865  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs15 ());
866  }
867  if (GetSupportedTxSpatialStreams () > 2)
868  {
869  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs16 ());
870  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs17 ());
871  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs18 ());
872  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs19 ());
873  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs20 ());
874  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs21 ());
875  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs22 ());
876  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs23 ());
877  }
878  if (GetSupportedTxSpatialStreams () > 3)
879  {
880  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs24 ());
881  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs25 ());
882  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs26 ());
883  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs27 ());
884  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs28 ());
885  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs29 ());
886  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs30 ());
887  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs31 ());
888  }
889  }
890 }
891 
892 void
894 {
895  NS_LOG_FUNCTION (this);
896  if (GetFrequency () >= 2400 && GetFrequency () <= 2500) //at 2.4 GHz
897  {
898  Configure80211b ();
899  Configure80211g ();
900  }
901  if (GetFrequency () >= 5000 && GetFrequency () <= 6000) //at 5 GHz
902  {
903  Configure80211a ();
904  }
907 }
908 
909 void
911 {
912  NS_LOG_FUNCTION (this);
913  Configure80211n ();
914 
915  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs0 ());
916  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs1 ());
917  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs2 ());
918  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs3 ());
919  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs4 ());
920  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs5 ());
921  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs6 ());
922  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs7 ());
923  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs8 ());
924  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs9 ());
925 
927 }
928 
929 bool
930 WifiPhy::DefineChannelNumber (uint16_t channelNumber, enum WifiPhyStandard standard, uint32_t frequency, uint32_t channelWidth)
931 {
932  NS_LOG_FUNCTION (this << channelNumber << standard << frequency << channelWidth);
933  ChannelNumberStandardPair p = std::make_pair (channelNumber, standard);
934  ChannelToFrequencyWidthMap::const_iterator it;
935  it = m_channelToFrequencyWidth.find (p);
936  if (it != m_channelToFrequencyWidth.end ())
937  {
938  NS_LOG_DEBUG ("channel number/standard already defined; returning false");
939  return false;
940  }
941  FrequencyWidthPair f = std::make_pair (frequency, channelWidth);
943  return true;
944 }
945 
946 uint16_t
947 WifiPhy::FindChannelNumberForFrequencyWidth (uint32_t frequency, uint32_t width) const
948 {
949  NS_LOG_FUNCTION (this << frequency << width);
950  bool found = false;
951  FrequencyWidthPair f = std::make_pair (frequency, width);
952  ChannelToFrequencyWidthMap::const_iterator it = m_channelToFrequencyWidth.begin ();
953  while (it != m_channelToFrequencyWidth.end ())
954  {
955  if (it->second == f)
956  {
957  found = true;
958  break;
959  }
960  ++it;
961  }
962  if (found)
963  {
964  NS_LOG_DEBUG ("Found, returning " << it->first.first);
965  return (it->first.first);
966  }
967  else
968  {
969  NS_LOG_DEBUG ("Not found, returning 0");
970  return 0;
971  }
972 }
973 
974 void
976 {
977  NS_LOG_FUNCTION (this << standard);
978  // If the user has configured both Frequency and ChannelNumber, Frequency
979  // takes precedence
980  if (GetFrequency () != 0)
981  {
982  // If Frequency is already set, then see whether a ChannelNumber can
983  // be found that matches Frequency and ChannelWidth. If so, configure
984  // the ChannelNumber to that channel number. If not, set
985  // ChannelNumber to zero.
986  NS_LOG_DEBUG ("Frequency set; checking whether a channel number corresponds");
987  uint32_t channelNumberSearched = FindChannelNumberForFrequencyWidth (GetFrequency (), GetChannelWidth ());
988  if (channelNumberSearched)
989  {
990  NS_LOG_DEBUG ("Channel number found; setting to " << channelNumberSearched);
991  SetChannelNumber (channelNumberSearched);
992  }
993  else
994  {
995  NS_LOG_DEBUG ("Channel number not found; setting to zero");
996  SetChannelNumber (0);
997  }
998  }
999  else if (GetChannelNumber () != 0)
1000  {
1001  // If the channel number is known for this particular standard or for
1002  // the unspecified standard, configure using the known values;
1003  // otherwise, this is a configuration error
1004  NS_LOG_DEBUG ("Configuring for channel number " << GetChannelNumber ());
1006  if (f.first == 0)
1007  {
1008  // the specific pair of number/standard is not known
1009  NS_LOG_DEBUG ("Falling back to check WIFI_PHY_STANDARD_UNSPECIFIED");
1011  }
1012  if (f.first == 0)
1013  {
1014  NS_FATAL_ERROR ("Error, ChannelNumber " << GetChannelNumber () << " is unknown for this standard");
1015  }
1016  else
1017  {
1018  NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << f.second);
1019  SetFrequency (f.first);
1020  SetChannelWidth (f.second);
1021  }
1022  }
1023 }
1024 
1025 void
1027 {
1028  NS_LOG_FUNCTION (this << standard);
1029  m_standard = standard;
1030  m_isConstructed = true;
1032  {
1034  }
1035  if (GetFrequency () == 0 && GetChannelNumber () == 0)
1036  {
1037  ConfigureDefaultsForStandard (standard);
1038  }
1039  else
1040  {
1041  // The user has configured either (or both) Frequency or ChannelNumber
1042  ConfigureChannelForStandard (standard);
1043  }
1044  switch (standard)
1045  {
1047  Configure80211a ();
1048  break;
1050  Configure80211b ();
1051  break;
1053  Configure80211g ();
1054  break;
1057  break;
1060  break;
1062  ConfigureHolland ();
1063  break;
1065  Configure80211n ();
1066  break;
1068  Configure80211n ();
1069  break;
1071  Configure80211ac ();
1072  break;
1073  default:
1074  NS_ASSERT (false);
1075  break;
1076  }
1077 }
1078 
1079 enum WifiPhyStandard
1081 {
1082  return m_standard;
1083 }
1084 
1085 void
1086 WifiPhy::SetFrequency (uint32_t frequency)
1087 {
1088  NS_LOG_FUNCTION (this << frequency);
1089  if (m_isConstructed == false)
1090  {
1091  NS_LOG_DEBUG ("Saving frequency configuration for initialization");
1092  m_initialFrequency = frequency;
1093  return;
1094  }
1095  if (GetFrequency () == frequency)
1096  {
1097  NS_LOG_DEBUG ("No frequency change requested");
1098  return;
1099  }
1100  if (frequency == 0)
1101  {
1102  DoFrequencySwitch (0);
1103  NS_LOG_DEBUG ("Setting frequency and channel number to zero");
1105  m_channelNumber = 0;
1106  return;
1107  }
1108  // If the user has configured both Frequency and ChannelNumber, Frequency
1109  // takes precedence. Lookup the channel number corresponding to the
1110  // requested frequency.
1111  uint16_t nch = FindChannelNumberForFrequencyWidth (frequency, GetChannelWidth ());
1112  if (nch != 0)
1113  {
1114  NS_LOG_DEBUG ("Setting frequency " << frequency << " corresponds to channel " << nch);
1115  if (DoFrequencySwitch (frequency))
1116  {
1117  NS_LOG_DEBUG ("Channel frequency switched to " << frequency << "; channel number to " << nch);
1118  m_channelCenterFrequency = frequency;
1119  m_channelNumber = nch;
1120  }
1121  else
1122  {
1123  NS_LOG_DEBUG ("Suppressing reassignment of frequency");
1124  }
1125  }
1126  else
1127  {
1128  NS_LOG_DEBUG ("Channel number is unknown for frequency " << frequency);
1129  if (DoFrequencySwitch (frequency))
1130  {
1131  NS_LOG_DEBUG ("Channel frequency switched to " << frequency << "; channel number to " << 0);
1132  m_channelCenterFrequency = frequency;
1133  m_channelNumber = 0;
1134  }
1135  else
1136  {
1137  NS_LOG_DEBUG ("Suppressing reassignment of frequency");
1138  }
1139  }
1140 }
1141 
1142 uint32_t
1144 {
1145  return m_channelCenterFrequency;
1146 }
1147 
1148 void
1149 WifiPhy::SetChannelWidth (uint32_t channelwidth)
1150 {
1151  NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 || channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth == 160, "wrong channel width value");
1152  m_channelWidth = channelwidth;
1153  AddSupportedChannelWidth (channelwidth);
1154 }
1155 
1156 uint32_t
1158 {
1159  return m_channelWidth;
1160 }
1161 
1162 void
1164 {
1167 }
1168 
1169 void
1171 {
1172  m_numberOfReceivers = rx;
1173 }
1174 
1175 uint32_t
1177 {
1178  return m_numberOfTransmitters;
1179 }
1180 
1181 uint32_t
1183 {
1184  return m_numberOfReceivers;
1185 }
1186 
1187 uint8_t
1189 {
1190  return (static_cast<uint8_t> (GetNumberOfReceiveAntennas ()));
1191 }
1192 
1193 uint8_t
1195 {
1196  return (static_cast<uint8_t> (GetNumberOfTransmitAntennas ()));
1197 }
1198 
1199 uint32_t
1201 {
1202  return m_bssMembershipSelectorSet.size ();
1203 }
1204 
1205 uint32_t
1206 WifiPhy::GetBssMembershipSelector (uint32_t selector) const
1207 {
1208  return m_bssMembershipSelectorSet[selector];
1209 }
1210 
1213 {
1214  uint32_t id = GetBssMembershipSelector (selector);
1215  WifiModeList supportedmodes;
1216  if (id == HT_PHY || id == VHT_PHY)
1217  {
1218  //mandatory MCS 0 to 7
1219  supportedmodes.push_back (WifiPhy::GetHtMcs0 ());
1220  supportedmodes.push_back (WifiPhy::GetHtMcs1 ());
1221  supportedmodes.push_back (WifiPhy::GetHtMcs2 ());
1222  supportedmodes.push_back (WifiPhy::GetHtMcs3 ());
1223  supportedmodes.push_back (WifiPhy::GetHtMcs4 ());
1224  supportedmodes.push_back (WifiPhy::GetHtMcs5 ());
1225  supportedmodes.push_back (WifiPhy::GetHtMcs6 ());
1226  supportedmodes.push_back (WifiPhy::GetHtMcs7 ());
1227  }
1228  if (id == VHT_PHY)
1229  {
1230  //mandatory MCS 0 to 9
1231  supportedmodes.push_back (WifiPhy::GetVhtMcs0 ());
1232  supportedmodes.push_back (WifiPhy::GetVhtMcs1 ());
1233  supportedmodes.push_back (WifiPhy::GetVhtMcs2 ());
1234  supportedmodes.push_back (WifiPhy::GetVhtMcs3 ());
1235  supportedmodes.push_back (WifiPhy::GetVhtMcs4 ());
1236  supportedmodes.push_back (WifiPhy::GetVhtMcs5 ());
1237  supportedmodes.push_back (WifiPhy::GetVhtMcs6 ());
1238  supportedmodes.push_back (WifiPhy::GetVhtMcs7 ());
1239  supportedmodes.push_back (WifiPhy::GetVhtMcs8 ());
1240  supportedmodes.push_back (WifiPhy::GetVhtMcs9 ());
1241  }
1242  return supportedmodes;
1243 }
1244 
1245 void
1247 {
1248  NS_LOG_FUNCTION (this << width);
1249  for (std::vector<uint32_t>::size_type i = 0; i != m_supportedChannelWidthSet.size (); i++)
1250  {
1251  if (m_supportedChannelWidthSet[i] == width)
1252  {
1253  return;
1254  }
1255  }
1256  NS_LOG_FUNCTION ("Adding " << width << " to supported channel width set");
1257  m_supportedChannelWidthSet.push_back (width);
1258 }
1259 
1260 std::vector<uint32_t>
1262 {
1264 }
1265 
1267 WifiPhy::GetFrequencyWidthForChannelNumberStandard (uint16_t channelNumber, enum WifiPhyStandard standard) const
1268 {
1269  ChannelNumberStandardPair p = std::make_pair (channelNumber, standard);
1271  return f;
1272 }
1273 
1274 void
1276 {
1277  NS_LOG_FUNCTION (this << nch);
1278  if (m_isConstructed == false)
1279  {
1280  NS_LOG_DEBUG ("Saving channel number configuration for initialization");
1281  m_initialChannelNumber = nch;
1282  return;
1283  }
1284  if (GetChannelNumber () == nch)
1285  {
1286  NS_LOG_DEBUG ("No channel change requested");
1287  return;
1288  }
1289  if (nch == 0)
1290  {
1291  // This case corresponds to when there is not a known channel
1292  // number for the requested frequency. There is no need to call
1293  // DoChannelSwitch () because DoFrequencySwitch () should have been
1294  // called by the client
1295  NS_LOG_DEBUG ("Setting channel number to zero");
1296  m_channelNumber = 0;
1297  return;
1298  }
1299 
1300  // First make sure that the channel number is defined for the standard
1301  // in use
1303  if (f.first == 0)
1304  {
1306  }
1307  if (f.first != 0)
1308  {
1309  if (DoChannelSwitch (nch))
1310  {
1311  NS_LOG_DEBUG ("Setting frequency to " << f.first << "; width to " << f.second);
1312  m_channelCenterFrequency = f.first;
1313  SetChannelWidth (f.second);
1314  m_channelNumber = nch;
1315  }
1316  else
1317  {
1318  // Subclass may have suppressed (e.g. waiting for state change)
1319  NS_LOG_DEBUG ("Channel switch suppressed");
1320  }
1321  }
1322  else
1323  {
1324  NS_FATAL_ERROR ("Frequency not found for channel number " << nch);
1325  }
1326 }
1327 
1328 uint16_t
1330 {
1331  return m_channelNumber;
1332 }
1333 
1334 bool
1336 {
1337  return true;
1338 }
1339 
1340 bool
1341 WifiPhy::DoFrequencySwitch (uint32_t frequency)
1342 {
1343  return true;
1344 }
1345 
1346 WifiMode
1348 {
1349  return WifiPhy::GetHtMcs0 ();
1350 }
1351 
1352 WifiMode
1354 {
1355  return WifiPhy::GetVhtMcs0 ();
1356 }
1357 
1358 Time
1360 {
1361  uint8_t Ndltf, Neltf;
1362  //We suppose here that STBC = 0.
1363  //If STBC > 0, we need a different mapping between Nss and Nltf (IEEE 802.11n-2012 standard, page 1682).
1364  if (txVector.GetNss () < 3)
1365  {
1366  Ndltf = txVector.GetNss ();
1367  }
1368  else if (txVector.GetNss () < 5)
1369  {
1370  Ndltf = 4;
1371  }
1372  else if (txVector.GetNss () < 7)
1373  {
1374  Ndltf = 6;
1375  }
1376  else
1377  {
1378  Ndltf = 8;
1379  }
1380 
1381  if (txVector.GetNess () < 3)
1382  {
1383  Neltf = txVector.GetNess ();
1384  }
1385  else
1386  {
1387  Neltf = 4;
1388  }
1389 
1390  switch (preamble)
1391  {
1392  case WIFI_PREAMBLE_HT_MF:
1393  return MicroSeconds (4 + (4 * Ndltf) + (4 * Neltf));
1394  case WIFI_PREAMBLE_HT_GF:
1395  return MicroSeconds ((4 * Ndltf) + (4 * Neltf));
1396  case WIFI_PREAMBLE_VHT:
1397  return MicroSeconds (4 + (4 * Ndltf));
1398  default:
1399  //no training for non HT
1400  return MicroSeconds (0);
1401  }
1402 }
1403 
1404 Time
1406 {
1407  switch (preamble)
1408  {
1409  case WIFI_PREAMBLE_HT_MF:
1410  case WIFI_PREAMBLE_HT_GF:
1411  //HT-SIG
1412  return MicroSeconds (8);
1413  default:
1414  //no HT-SIG for non HT
1415  return MicroSeconds (0);
1416  }
1417 }
1418 
1419 Time
1421 {
1422  switch (preamble)
1423  {
1424  case WIFI_PREAMBLE_VHT:
1425  //VHT-SIG-A1
1426  return MicroSeconds (4);
1427  default:
1428  // no VHT-SIG-A1 for non VHT
1429  return MicroSeconds (0);
1430  }
1431 }
1432 
1433 Time
1435 {
1436  switch (preamble)
1437  {
1438  case WIFI_PREAMBLE_VHT:
1439  //VHT-SIG-A2
1440  return MicroSeconds (4);
1441  default:
1442  // no VHT-SIG-A2 for non VHT
1443  return MicroSeconds (0);
1444  }
1445 }
1446 
1447 Time
1449 {
1450  switch (preamble)
1451  {
1452  case WIFI_PREAMBLE_VHT:
1453  //VHT-SIG-B
1454  return MicroSeconds (4);
1455  default:
1456  // no VHT-SIG-B for non VHT
1457  return MicroSeconds (0);
1458  }
1459 }
1460 
1461 WifiMode
1463 {
1464  switch (payloadMode.GetModulationClass ())
1465  {
1466  case WIFI_MOD_CLASS_OFDM:
1467  case WIFI_MOD_CLASS_HT:
1468  case WIFI_MOD_CLASS_VHT:
1469  switch (txVector.GetChannelWidth ())
1470  {
1471  case 5:
1473  case 10:
1475  case 20:
1476  case 40:
1477  case 80:
1478  case 160:
1479  default:
1480  //(Section 18.3.2 "PLCP frame format"; IEEE Std 802.11-2012)
1481  //actually this is only the first part of the PlcpHeader,
1482  //because the last 16 bits of the PlcpHeader are using the
1483  //same mode of the payload
1484  return WifiPhy::GetOfdmRate6Mbps ();
1485  }
1487  return WifiPhy::GetErpOfdmRate6Mbps ();
1488  case WIFI_MOD_CLASS_DSSS:
1490  if (preamble == WIFI_PREAMBLE_LONG || payloadMode == WifiPhy::GetDsssRate1Mbps ())
1491  {
1492  //(Section 16.2.3 "PLCP field definitions" and Section 17.2.2.2 "Long PPDU format"; IEEE Std 802.11-2012)
1493  return WifiPhy::GetDsssRate1Mbps ();
1494  }
1495  else //WIFI_PREAMBLE_SHORT
1496  {
1497  //(Section 17.2.2.3 "Short PPDU format"; IEEE Std 802.11-2012)
1498  return WifiPhy::GetDsssRate2Mbps ();
1499  }
1500  default:
1501  NS_FATAL_ERROR ("unsupported modulation class");
1502  return WifiMode ();
1503  }
1504 }
1505 
1506 Time
1508 {
1509  if (preamble == WIFI_PREAMBLE_NONE)
1510  {
1511  return MicroSeconds (0);
1512  }
1513  switch (txVector.GetMode ().GetModulationClass ())
1514  {
1515  case WIFI_MOD_CLASS_OFDM:
1516  {
1517  switch (txVector.GetChannelWidth ())
1518  {
1519  case 20:
1520  default:
1521  //(Section 18.3.3 "PLCP preamble (SYNC))" and Figure 18-4 "OFDM training structure"; IEEE Std 802.11-2012)
1522  //also (Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
1523  //We return the duration of the SIGNAL field only, since the
1524  //SERVICE field (which strictly speaking belongs to the PLCP
1525  //header, see Section 18.3.2 and Figure 18-1) is sent using the
1526  //payload mode.
1527  return MicroSeconds (4);
1528  case 10:
1529  //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
1530  return MicroSeconds (8);
1531  case 5:
1532  //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012)
1533  return MicroSeconds (16);
1534  }
1535  }
1536  case WIFI_MOD_CLASS_HT:
1537  {
1538  //L-SIG
1539  //IEEE 802.11n Figure 20.1
1540  switch (preamble)
1541  {
1542  case WIFI_PREAMBLE_HT_MF:
1543  default:
1544  return MicroSeconds (4);
1545  case WIFI_PREAMBLE_HT_GF:
1546  return MicroSeconds (0);
1547  }
1548  }
1549  case WIFI_MOD_CLASS_VHT:
1551  return MicroSeconds (4);
1552  case WIFI_MOD_CLASS_DSSS:
1554  if ((preamble == WIFI_PREAMBLE_SHORT) && (txVector.GetMode ().GetDataRate (22, 0, 1) > 1000000))
1555  {
1556  //(Section 17.2.2.3 "Short PPDU format" and Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
1557  return MicroSeconds (24);
1558  }
1559  else //WIFI_PREAMBLE_LONG
1560  {
1561  //(Section 17.2.2.2 "Long PPDU format" and Figure 17-1 "Short PPDU format"; IEEE Std 802.11-2012)
1562  return MicroSeconds (48);
1563  }
1564  default:
1565  NS_FATAL_ERROR ("unsupported modulation class");
1566  return MicroSeconds (0);
1567  }
1568 }
1569 
1570 Time
1572 {
1573  if (preamble == WIFI_PREAMBLE_NONE)
1574  {
1575  return MicroSeconds (0);
1576  }
1577  switch (txVector.GetMode ().GetModulationClass ())
1578  {
1579  case WIFI_MOD_CLASS_OFDM:
1580  {
1581  switch (txVector.GetChannelWidth ())
1582  {
1583  case 20:
1584  default:
1585  //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
1586  //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
1587  return MicroSeconds (16);
1588  case 10:
1589  //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
1590  //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
1591  return MicroSeconds (32);
1592  case 5:
1593  //(Section 18.3.3 "PLCP preamble (SYNC))" Figure 18-4 "OFDM training structure"
1594  //also Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
1595  return MicroSeconds (64);
1596  }
1597  }
1598  case WIFI_MOD_CLASS_VHT:
1599  case WIFI_MOD_CLASS_HT:
1600  //IEEE 802.11n Figure 20.1 the training symbols before L_SIG or HT_SIG
1601  return MicroSeconds (16);
1603  return MicroSeconds (16);
1604  case WIFI_MOD_CLASS_DSSS:
1606  if ((preamble == WIFI_PREAMBLE_SHORT) && (txVector.GetMode ().GetDataRate (22, 0, 1) > 1000000))
1607  {
1608  //(Section 17.2.2.3 "Short PPDU format)" Figure 17-2 "Short PPDU format"; IEEE Std 802.11-2012)
1609  return MicroSeconds (72);
1610  }
1611  else //WIFI_PREAMBLE_LONG
1612  {
1613  //(Section 17.2.2.2 "Long PPDU format)" Figure 17-1 "Long PPDU format"; IEEE Std 802.11-2012)
1614  return MicroSeconds (144);
1615  }
1616  default:
1617  NS_FATAL_ERROR ("unsupported modulation class");
1618  return MicroSeconds (0);
1619  }
1620 }
1621 
1622 Time
1623 WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, WifiPreamble preamble, double frequency)
1624 {
1625  return GetPayloadDuration (size, txVector, preamble, frequency, NORMAL_MPDU, 0);
1626 }
1627 
1628 Time
1629 WifiPhy::GetPayloadDuration (uint32_t size, WifiTxVector txVector, WifiPreamble preamble, double frequency, enum mpduType mpdutype, uint8_t incFlag)
1630 {
1631  WifiMode payloadMode = txVector.GetMode ();
1632  NS_LOG_FUNCTION (size << payloadMode);
1633 
1634  switch (payloadMode.GetModulationClass ())
1635  {
1636  case WIFI_MOD_CLASS_OFDM:
1638  {
1639  //(Section 18.3.2.4 "Timing related parameters" Table 18-5 "Timing-related parameters"; IEEE Std 802.11-2012
1640  //corresponds to T_{SYM} in the table)
1641  Time symbolDuration;
1642 
1643  switch (txVector.GetChannelWidth ())
1644  {
1645  case 20:
1646  default:
1647  symbolDuration = MicroSeconds (4);
1648  break;
1649  case 10:
1650  symbolDuration = MicroSeconds (8);
1651  break;
1652  case 5:
1653  symbolDuration = MicroSeconds (16);
1654  break;
1655  }
1656 
1657  //(Section 18.3.2.3 "Modulation-dependent parameters" Table 18-4 "Modulation-dependent parameters"; IEEE Std 802.11-2012)
1658  //corresponds to N_{DBPS} in the table
1659  double numDataBitsPerSymbol = payloadMode.GetDataRate (txVector.GetChannelWidth (), 0, 1) * symbolDuration.GetNanoSeconds () / 1e9;
1660  double numSymbols;
1661 
1662  if (mpdutype == MPDU_IN_AGGREGATE && preamble != WIFI_PREAMBLE_NONE)
1663  {
1664  //First packet in an A-MPDU
1665  numSymbols = ((16 + size * 8.0 + 6) / numDataBitsPerSymbol);
1666  if (incFlag == 1)
1667  {
1668  m_totalAmpduSize += size;
1669  m_totalAmpduNumSymbols += numSymbols;
1670  }
1671  }
1672  else if (mpdutype == MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE)
1673  {
1674  //consecutive packets in an A-MPDU
1675  numSymbols = ((size * 8.0) / numDataBitsPerSymbol);
1676  if (incFlag == 1)
1677  {
1678  m_totalAmpduSize += size;
1679  m_totalAmpduNumSymbols += numSymbols;
1680  }
1681  }
1682  else if (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE)
1683  {
1684  //last packet in an A-MPDU
1685  uint32_t totalAmpduSize = m_totalAmpduSize + size;
1686  numSymbols = lrint (ceil ((16 + totalAmpduSize * 8.0 + 6) / numDataBitsPerSymbol));
1687  NS_ASSERT (m_totalAmpduNumSymbols <= numSymbols);
1688  numSymbols -= m_totalAmpduNumSymbols;
1689  if (incFlag == 1)
1690  {
1691  m_totalAmpduSize = 0;
1693  }
1694  }
1695  else if (mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE)
1696  {
1697  //Not an A-MPDU
1698  numSymbols = lrint (ceil ((16 + size * 8.0 + 6.0) / numDataBitsPerSymbol));
1699  }
1700  else
1701  {
1702  NS_FATAL_ERROR ("Wrong combination of preamble and packet type");
1703  }
1704 
1705  //Add signal extension for ERP PHY
1706  if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1707  {
1708  return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ()) + MicroSeconds (6);
1709  }
1710  else
1711  {
1712  return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ());
1713  }
1714  }
1715  case WIFI_MOD_CLASS_HT:
1716  case WIFI_MOD_CLASS_VHT:
1717  {
1718  Time symbolDuration;
1719  double m_Stbc;
1720  //if short GI data rate is used then symbol duration is 3.6us else symbol duration is 4us
1721  //In the future has to create a stationmanager that only uses these data rates if sender and reciever support GI
1722  if (txVector.IsShortGuardInterval ())
1723  {
1724  symbolDuration = NanoSeconds (3600);
1725  }
1726  else
1727  {
1728  symbolDuration = MicroSeconds (4);
1729  }
1730 
1731  if (txVector.IsStbc ())
1732  {
1733  m_Stbc = 2;
1734  }
1735  else
1736  {
1737  m_Stbc = 1;
1738  }
1739 
1740  //check tables 20-35 and 20-36 in the .11n standard to get cases when nes = 2
1741  double Nes = 1;
1742  if (payloadMode.GetUniqueName () == "HtMcs21"
1743  || payloadMode.GetUniqueName () == "HtMcs22"
1744  || payloadMode.GetUniqueName () == "HtMcs23"
1745  || payloadMode.GetUniqueName () == "HtMcs28"
1746  || payloadMode.GetUniqueName () == "HtMcs29"
1747  || payloadMode.GetUniqueName () == "HtMcs30"
1748  || payloadMode.GetUniqueName () == "HtMcs31")
1749  {
1750  Nes = 2;
1751  }
1752  //check tables 22-30 to 22-61 in the .11ac standard to get cases when nes > 1
1753  //todo: improve logic to reduce the number of if cases
1754  //todo: extend to NSS > 4 for VHT rates
1755  if (txVector.GetChannelWidth () == 40
1756  && txVector.GetNss () == 3
1757  && payloadMode.GetMcsValue () >= 8)
1758  {
1759  Nes = 2;
1760  }
1761  if (txVector.GetChannelWidth () == 80
1762  && txVector.GetNss () == 2
1763  && payloadMode.GetMcsValue () >= 7)
1764  {
1765  Nes = 2;
1766  }
1767  if (txVector.GetChannelWidth () == 80
1768  && txVector.GetNss () == 3
1769  && payloadMode.GetMcsValue () >= 7)
1770  {
1771  Nes = 2;
1772  }
1773  if (txVector.GetChannelWidth () == 80
1774  && txVector.GetNss () == 3
1775  && payloadMode.GetMcsValue () == 9)
1776  {
1777  Nes = 3;
1778  }
1779  if (txVector.GetChannelWidth () == 80
1780  && txVector.GetNss () == 4
1781  && payloadMode.GetMcsValue () >= 4)
1782  {
1783  Nes = 2;
1784  }
1785  if (txVector.GetChannelWidth () == 80
1786  && txVector.GetNss () == 4
1787  && payloadMode.GetMcsValue () >= 7)
1788  {
1789  Nes = 3;
1790  }
1791  if (txVector.GetChannelWidth () == 160
1792  && payloadMode.GetMcsValue () >= 7)
1793  {
1794  Nes = 2;
1795  }
1796  if (txVector.GetChannelWidth () == 160
1797  && txVector.GetNss () == 2
1798  && payloadMode.GetMcsValue () >= 4)
1799  {
1800  Nes = 2;
1801  }
1802  if (txVector.GetChannelWidth () == 160
1803  && txVector.GetNss () == 2
1804  && payloadMode.GetMcsValue () >= 7)
1805  {
1806  Nes = 3;
1807  }
1808  if (txVector.GetChannelWidth () == 160
1809  && txVector.GetNss () == 3
1810  && payloadMode.GetMcsValue () >= 3)
1811  {
1812  Nes = 2;
1813  }
1814  if (txVector.GetChannelWidth () == 160
1815  && txVector.GetNss () == 3
1816  && payloadMode.GetMcsValue () >= 5)
1817  {
1818  Nes = 3;
1819  }
1820  if (txVector.GetChannelWidth () == 160
1821  && txVector.GetNss () == 3
1822  && payloadMode.GetMcsValue () >= 7)
1823  {
1824  Nes = 4;
1825  }
1826  if (txVector.GetChannelWidth () == 160
1827  && txVector.GetNss () == 4
1828  && payloadMode.GetMcsValue () >= 2)
1829  {
1830  Nes = 2;
1831  }
1832  if (txVector.GetChannelWidth () == 160
1833  && txVector.GetNss () == 4
1834  && payloadMode.GetMcsValue () >= 4)
1835  {
1836  Nes = 3;
1837  }
1838  if (txVector.GetChannelWidth () == 160
1839  && txVector.GetNss () == 4
1840  && payloadMode.GetMcsValue () >= 5)
1841  {
1842  Nes = 4;
1843  }
1844  if (txVector.GetChannelWidth () == 160
1845  && txVector.GetNss () == 4
1846  && payloadMode.GetMcsValue () >= 7)
1847  {
1848  Nes = 6;
1849  }
1850 
1851  //IEEE Std 802.11n, section 20.3.11, equation (20-32)
1852  double numDataBitsPerSymbol = payloadMode.GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), txVector.GetNss ()) * symbolDuration.GetNanoSeconds () / 1e9;
1853  double numSymbols;
1854 
1855  if (mpdutype == MPDU_IN_AGGREGATE && preamble != WIFI_PREAMBLE_NONE)
1856  {
1857  //First packet in an A-MPDU
1858  numSymbols = (m_Stbc * (16 + size * 8.0 + 6 * Nes) / (m_Stbc * numDataBitsPerSymbol));
1859  if (incFlag == 1)
1860  {
1861  m_totalAmpduSize += size;
1862  m_totalAmpduNumSymbols += numSymbols;
1863  }
1864  }
1865  else if (mpdutype == MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE)
1866  {
1867  //consecutive packets in an A-MPDU
1868  numSymbols = (m_Stbc * size * 8.0) / (m_Stbc * numDataBitsPerSymbol);
1869  if (incFlag == 1)
1870  {
1871  m_totalAmpduSize += size;
1872  m_totalAmpduNumSymbols += numSymbols;
1873  }
1874  }
1875  else if (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE)
1876  {
1877  //last packet in an A-MPDU
1878  uint32_t totalAmpduSize = m_totalAmpduSize + size;
1879  numSymbols = lrint (m_Stbc * ceil ((16 + totalAmpduSize * 8.0 + 6 * Nes) / (m_Stbc * numDataBitsPerSymbol)));
1880  NS_ASSERT (m_totalAmpduNumSymbols <= numSymbols);
1881  numSymbols -= m_totalAmpduNumSymbols;
1882  if (incFlag == 1)
1883  {
1884  m_totalAmpduSize = 0;
1886  }
1887  }
1888  else if (mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE)
1889  {
1890  //Not an A-MPDU
1891  numSymbols = lrint (m_Stbc * ceil ((16 + size * 8.0 + 6.0 * Nes) / (m_Stbc * numDataBitsPerSymbol)));
1892  }
1893  else
1894  {
1895  NS_FATAL_ERROR ("Wrong combination of preamble and packet type");
1896  }
1897 
1898  if (payloadMode.GetModulationClass () == WIFI_MOD_CLASS_HT && frequency >= 2400 && frequency <= 2500 && ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE) || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE))) //at 2.4 GHz
1899  {
1900  return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ()) + MicroSeconds (6);
1901  }
1902  else //at 5 GHz
1903  {
1904  return FemtoSeconds (numSymbols * symbolDuration.GetFemtoSeconds ());
1905  }
1906  }
1907  case WIFI_MOD_CLASS_DSSS:
1909  //(Section 17.2.3.6 "Long PLCP LENGTH field"; IEEE Std 802.11-2012)
1910  NS_LOG_LOGIC (" size=" << size
1911  << " mode=" << payloadMode
1912  << " rate=" << payloadMode.GetDataRate (22, 0, 1));
1913  return MicroSeconds (lrint (ceil ((size * 8.0) / (payloadMode.GetDataRate (22, 0, 1) / 1.0e6))));
1914  default:
1915  NS_FATAL_ERROR ("unsupported modulation class");
1916  return MicroSeconds (0);
1917  }
1918 }
1919 
1920 Time
1922 {
1923  Time duration = GetPlcpPreambleDuration (txVector, preamble)
1924  + GetPlcpHeaderDuration (txVector, preamble)
1925  + GetPlcpHtSigHeaderDuration (preamble)
1926  + GetPlcpVhtSigA1Duration (preamble)
1927  + GetPlcpVhtSigA2Duration (preamble)
1928  + GetPlcpHtTrainingSymbolDuration (preamble, txVector)
1929  + GetPlcpVhtSigBDuration (preamble);
1930  return duration;
1931 }
1932 
1933 Time
1934 WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txVector, WifiPreamble preamble, double frequency, enum mpduType mpdutype, uint8_t incFlag)
1935 {
1936  Time duration = CalculatePlcpPreambleAndHeaderDuration (txVector, preamble)
1937  + GetPayloadDuration (size, txVector, preamble, frequency, mpdutype, incFlag);
1938  return duration;
1939 }
1940 
1941 Time
1942 WifiPhy::CalculateTxDuration (uint32_t size, WifiTxVector txVector, WifiPreamble preamble, double frequency)
1943 {
1944  return CalculateTxDuration (size, txVector, preamble, frequency, NORMAL_MPDU, 0);
1945 }
1946 
1947 void
1949 {
1950  m_phyTxBeginTrace (packet);
1951 }
1952 
1953 void
1955 {
1956  m_phyTxEndTrace (packet);
1957 }
1958 
1959 void
1961 {
1962  m_phyTxDropTrace (packet);
1963 }
1964 
1965 void
1967 {
1968  m_phyRxBeginTrace (packet);
1969 }
1970 
1971 void
1973 {
1974  m_phyRxEndTrace (packet);
1975 }
1976 
1977 void
1979 {
1980  m_phyRxDropTrace (packet);
1981 }
1982 
1983 void
1984 WifiPhy::NotifyMonitorSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu, struct signalNoiseDbm signalNoise)
1985 {
1986  m_phyMonitorSniffRxTrace (packet, channelFreqMhz, channelNumber, rate, preamble, txVector, aMpdu, signalNoise);
1987 }
1988 
1989 void
1990 WifiPhy::NotifyMonitorSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu)
1991 {
1992  m_phyMonitorSniffTxTrace (packet, channelFreqMhz, channelNumber, rate, preamble, txVector, aMpdu);
1993 }
1994 
1995 
1996 // Clause 15 rates (DSSS)
1997 
1998 WifiMode
2000 {
2001  static WifiMode mode =
2002  WifiModeFactory::CreateWifiMode ("DsssRate1Mbps",
2004  true,
2006  2);
2007  return mode;
2008 }
2009 
2010 WifiMode
2012 {
2013  static WifiMode mode =
2014  WifiModeFactory::CreateWifiMode ("DsssRate2Mbps",
2016  true,
2018  4);
2019  return mode;
2020 }
2021 
2022 
2023 // Clause 18 rates (HR/DSSS)
2024 
2025 WifiMode
2027 {
2028  static WifiMode mode =
2029  WifiModeFactory::CreateWifiMode ("DsssRate5_5Mbps",
2031  true,
2033  16);
2034  return mode;
2035 }
2036 
2037 WifiMode
2039 {
2040  static WifiMode mode =
2041  WifiModeFactory::CreateWifiMode ("DsssRate11Mbps",
2043  true,
2045  256);
2046  return mode;
2047 }
2048 
2049 
2050 // Clause 19.5 rates (ERP-OFDM)
2051 
2052 WifiMode
2054 {
2055  static WifiMode mode =
2056  WifiModeFactory::CreateWifiMode ("ErpOfdmRate6Mbps",
2058  true,
2060  2);
2061  return mode;
2062 }
2063 
2064 WifiMode
2066 {
2067  static WifiMode mode =
2068  WifiModeFactory::CreateWifiMode ("ErpOfdmRate9Mbps",
2070  false,
2072  2);
2073  return mode;
2074 }
2075 
2076 WifiMode
2078 {
2079  static WifiMode mode =
2080  WifiModeFactory::CreateWifiMode ("ErpOfdmRate12Mbps",
2082  true,
2084  4);
2085  return mode;
2086 }
2087 
2088 WifiMode
2090 {
2091  static WifiMode mode =
2092  WifiModeFactory::CreateWifiMode ("ErpOfdmRate18Mbps",
2094  false,
2096  4);
2097  return mode;
2098 }
2099 
2100 WifiMode
2102 {
2103  static WifiMode mode =
2104  WifiModeFactory::CreateWifiMode ("ErpOfdmRate24Mbps",
2106  true,
2108  16);
2109  return mode;
2110 }
2111 
2112 WifiMode
2114 {
2115  static WifiMode mode =
2116  WifiModeFactory::CreateWifiMode ("ErpOfdmRate36Mbps",
2118  false,
2120  16);
2121  return mode;
2122 }
2123 
2124 WifiMode
2126 {
2127  static WifiMode mode =
2128  WifiModeFactory::CreateWifiMode ("ErpOfdmRate48Mbps",
2130  false,
2132  64);
2133  return mode;
2134 }
2135 
2136 WifiMode
2138 {
2139  static WifiMode mode =
2140  WifiModeFactory::CreateWifiMode ("ErpOfdmRate54Mbps",
2142  false,
2144  64);
2145  return mode;
2146 }
2147 
2148 
2149 // Clause 17 rates (OFDM)
2150 
2151 WifiMode
2153 {
2154  static WifiMode mode =
2155  WifiModeFactory::CreateWifiMode ("OfdmRate6Mbps",
2157  true,
2159  2);
2160  return mode;
2161 }
2162 
2163 WifiMode
2165 {
2166  static WifiMode mode =
2167  WifiModeFactory::CreateWifiMode ("OfdmRate9Mbps",
2169  false,
2171  2);
2172  return mode;
2173 }
2174 
2175 WifiMode
2177 {
2178  static WifiMode mode =
2179  WifiModeFactory::CreateWifiMode ("OfdmRate12Mbps",
2181  true,
2183  4);
2184  return mode;
2185 }
2186 
2187 WifiMode
2189 {
2190  static WifiMode mode =
2191  WifiModeFactory::CreateWifiMode ("OfdmRate18Mbps",
2193  false,
2195  4);
2196  return mode;
2197 }
2198 
2199 WifiMode
2201 {
2202  static WifiMode mode =
2203  WifiModeFactory::CreateWifiMode ("OfdmRate24Mbps",
2205  true,
2207  16);
2208  return mode;
2209 }
2210 
2211 WifiMode
2213 {
2214  static WifiMode mode =
2215  WifiModeFactory::CreateWifiMode ("OfdmRate36Mbps",
2217  false,
2219  16);
2220  return mode;
2221 }
2222 
2223 WifiMode
2225 {
2226  static WifiMode mode =
2227  WifiModeFactory::CreateWifiMode ("OfdmRate48Mbps",
2229  false,
2231  64);
2232  return mode;
2233 }
2234 
2235 WifiMode
2237 {
2238  static WifiMode mode =
2239  WifiModeFactory::CreateWifiMode ("OfdmRate54Mbps",
2241  false,
2243  64);
2244  return mode;
2245 }
2246 
2247 
2248 // 10 MHz channel rates
2249 
2250 WifiMode
2252 {
2253  static WifiMode mode =
2254  WifiModeFactory::CreateWifiMode ("OfdmRate3MbpsBW10MHz",
2256  true,
2258  2);
2259  return mode;
2260 }
2261 
2262 WifiMode
2264 {
2265  static WifiMode mode =
2266  WifiModeFactory::CreateWifiMode ("OfdmRate4_5MbpsBW10MHz",
2268  false,
2270  2);
2271  return mode;
2272 }
2273 
2274 WifiMode
2276 {
2277  static WifiMode mode =
2278  WifiModeFactory::CreateWifiMode ("OfdmRate6MbpsBW10MHz",
2280  true,
2282  4);
2283  return mode;
2284 }
2285 
2286 WifiMode
2288 {
2289  static WifiMode mode =
2290  WifiModeFactory::CreateWifiMode ("OfdmRate9MbpsBW10MHz",
2292  false,
2294  4);
2295  return mode;
2296 }
2297 
2298 WifiMode
2300 {
2301  static WifiMode mode =
2302  WifiModeFactory::CreateWifiMode ("OfdmRate12MbpsBW10MHz",
2304  true,
2306  16);
2307  return mode;
2308 }
2309 
2310 WifiMode
2312 {
2313  static WifiMode mode =
2314  WifiModeFactory::CreateWifiMode ("OfdmRate18MbpsBW10MHz",
2316  false,
2318  16);
2319  return mode;
2320 }
2321 
2322 WifiMode
2324 {
2325  static WifiMode mode =
2326  WifiModeFactory::CreateWifiMode ("OfdmRate24MbpsBW10MHz",
2328  false,
2330  64);
2331  return mode;
2332 }
2333 
2334 WifiMode
2336 {
2337  static WifiMode mode =
2338  WifiModeFactory::CreateWifiMode ("OfdmRate27MbpsBW10MHz",
2340  false,
2342  64);
2343  return mode;
2344 }
2345 
2346 
2347 // 5 MHz channel rates
2348 
2349 WifiMode
2351 {
2352  static WifiMode mode =
2353  WifiModeFactory::CreateWifiMode ("OfdmRate1_5MbpsBW5MHz",
2355  true,
2357  2);
2358  return mode;
2359 }
2360 
2361 WifiMode
2363 {
2364  static WifiMode mode =
2365  WifiModeFactory::CreateWifiMode ("OfdmRate2_25MbpsBW5MHz",
2367  false,
2369  2);
2370  return mode;
2371 }
2372 
2373 WifiMode
2375 {
2376  static WifiMode mode =
2377  WifiModeFactory::CreateWifiMode ("OfdmRate3MbpsBW5MHz",
2379  true,
2381  4);
2382  return mode;
2383 }
2384 
2385 WifiMode
2387 {
2388  static WifiMode mode =
2389  WifiModeFactory::CreateWifiMode ("OfdmRate4_5MbpsBW5MHz",
2391  false,
2393  4);
2394  return mode;
2395 }
2396 
2397 WifiMode
2399 {
2400  static WifiMode mode =
2401  WifiModeFactory::CreateWifiMode ("OfdmRate6MbpsBW5MHz",
2403  true,
2405  16);
2406  return mode;
2407 }
2408 
2409 WifiMode
2411 {
2412  static WifiMode mode =
2413  WifiModeFactory::CreateWifiMode ("OfdmRate9MbpsBW5MHz",
2415  false,
2417  16);
2418  return mode;
2419 }
2420 
2421 WifiMode
2423 {
2424  static WifiMode mode =
2425  WifiModeFactory::CreateWifiMode ("OfdmRate12MbpsBW5MHz",
2427  false,
2429  64);
2430  return mode;
2431 }
2432 
2433 WifiMode
2435 {
2436  static WifiMode mode =
2437  WifiModeFactory::CreateWifiMode ("OfdmRate13_5MbpsBW5MHz",
2439  false,
2441  64);
2442  return mode;
2443 }
2444 
2445 
2446 // Clause 20
2447 
2448 WifiMode
2450 {
2451  static WifiMode mcs =
2453  return mcs;
2454 }
2455 
2456 WifiMode
2458 {
2459  static WifiMode mcs =
2461  return mcs;
2462 }
2463 
2464 WifiMode
2466 {
2467  static WifiMode mcs =
2469  return mcs;
2470 }
2471 
2472 WifiMode
2474 {
2475  static WifiMode mcs =
2477  return mcs;
2478 }
2479 
2480 WifiMode
2482 {
2483  static WifiMode mcs =
2485  return mcs;
2486 }
2487 
2488 WifiMode
2490 {
2491  static WifiMode mcs =
2493  return mcs;
2494 }
2495 
2496 WifiMode
2498 {
2499  static WifiMode mcs =
2501  return mcs;
2502 }
2503 
2504 WifiMode
2506 {
2507  static WifiMode mcs =
2509  return mcs;
2510 }
2511 
2512 WifiMode
2514 {
2515  static WifiMode mcs =
2517  return mcs;
2518 }
2519 
2520 WifiMode
2522 {
2523  static WifiMode mcs =
2525  return mcs;
2526 }
2527 
2528 WifiMode
2530 {
2531  static WifiMode mcs =
2533  return mcs;
2534 }
2535 
2536 WifiMode
2538 {
2539  static WifiMode mcs =
2541  return mcs;
2542 }
2543 
2544 WifiMode
2546 {
2547  static WifiMode mcs =
2549  return mcs;
2550 }
2551 
2552 WifiMode
2554 {
2555  static WifiMode mcs =
2557  return mcs;
2558 }
2559 
2560 WifiMode
2562 {
2563  static WifiMode mcs =
2565  return mcs;
2566 }
2567 
2568 WifiMode
2570 {
2571  static WifiMode mcs =
2573  return mcs;
2574 }
2575 
2576 WifiMode
2578 {
2579  static WifiMode mcs =
2581  return mcs;
2582 }
2583 
2584 WifiMode
2586 {
2587  static WifiMode mcs =
2589  return mcs;
2590 }
2591 
2592 WifiMode
2594 {
2595  static WifiMode mcs =
2597  return mcs;
2598 }
2599 
2600 WifiMode
2602 {
2603  static WifiMode mcs =
2605  return mcs;
2606 }
2607 
2608 WifiMode
2610 {
2611  static WifiMode mcs =
2613  return mcs;
2614 }
2615 
2616 WifiMode
2618 {
2619  static WifiMode mcs =
2621  return mcs;
2622 }
2623 
2624 WifiMode
2626 {
2627  static WifiMode mcs =
2629  return mcs;
2630 }
2631 
2632 WifiMode
2634 {
2635  static WifiMode mcs =
2637  return mcs;
2638 }
2639 
2640 WifiMode
2642 {
2643  static WifiMode mcs =
2645  return mcs;
2646 }
2647 
2648 WifiMode
2650 {
2651  static WifiMode mcs =
2653  return mcs;
2654 }
2655 
2656 WifiMode
2658 {
2659  static WifiMode mcs =
2661  return mcs;
2662 }
2663 
2664 WifiMode
2666 {
2667  static WifiMode mcs =
2669  return mcs;
2670 }
2671 
2672 WifiMode
2674 {
2675  static WifiMode mcs =
2677  return mcs;
2678 }
2679 
2680 WifiMode
2682 {
2683  static WifiMode mcs =
2685  return mcs;
2686 }
2687 
2688 WifiMode
2690 {
2691  static WifiMode mcs =
2693  return mcs;
2694 }
2695 
2696 WifiMode
2698 {
2699  static WifiMode mcs =
2701  return mcs;
2702 }
2703 
2704 
2705 // Clause 22
2706 
2707 WifiMode
2709 {
2710  static WifiMode mcs =
2712  return mcs;
2713 }
2714 
2715 WifiMode
2717 {
2718  static WifiMode mcs =
2720  return mcs;
2721 }
2722 
2723 WifiMode
2725 {
2726  static WifiMode mcs =
2728  return mcs;
2729 }
2730 
2731 WifiMode
2733 {
2734  static WifiMode mcs =
2736  return mcs;
2737 }
2738 
2739 WifiMode
2741 {
2742  static WifiMode mcs =
2744  return mcs;
2745 }
2746 
2747 WifiMode
2749 {
2750  static WifiMode mcs =
2752  return mcs;
2753 }
2754 
2755 WifiMode
2757 {
2758  static WifiMode mcs =
2760  return mcs;
2761 }
2762 
2763 WifiMode
2765 {
2766  static WifiMode mcs =
2768  return mcs;
2769 }
2770 
2771 WifiMode
2773 {
2774  static WifiMode mcs =
2776  return mcs;
2777 }
2778 
2779 WifiMode
2781 {
2782  static WifiMode mcs =
2784  return mcs;
2785 }
2786 
2787 bool
2789 {
2790  uint32_t chWidth = txVector.GetChannelWidth();
2791  uint8_t nss = txVector.GetNss();
2792  std::string modeName = txVector.GetMode().GetUniqueName();
2793 
2794  if (chWidth == 20)
2795  {
2796  if (nss != 3 && nss != 6)
2797  {
2798  return (modeName != "VhtMcs9");
2799  }
2800  }
2801  else if (chWidth == 80)
2802  {
2803  if (nss == 3 || nss == 7)
2804  {
2805  return (modeName != "VhtMcs6");
2806  }
2807  else if (nss == 6)
2808  {
2809  return (modeName != "VhtMcs9");
2810  }
2811  }
2812  else if (chWidth == 160)
2813  {
2814  if (nss == 3)
2815  {
2816  return (modeName != "VhtMcs9");
2817  }
2818  }
2819 
2820  return true;
2821 }
2822 
2823 bool
2825 {
2826  for (uint32_t i = 0; i < GetNModes (); i++)
2827  {
2828  if (mode == GetMode (i))
2829  {
2830  return true;
2831  }
2832  }
2833  return false;
2834 }
2835 
2836 bool
2838 {
2839  for (uint32_t i = 0; i < GetNMcs (); i++)
2840  {
2841  if (mcs == GetMcs (i))
2842  {
2843  return true;
2844  }
2845  }
2846  return false;
2847 }
2848 
2849 uint32_t
2851 {
2852  return m_deviceRateSet.size ();
2853 }
2854 
2855 WifiMode
2856 WifiPhy::GetMode (uint32_t mode) const
2857 {
2858  return m_deviceRateSet[mode];
2859 }
2860 
2861 uint8_t
2862 WifiPhy::GetNMcs (void) const
2863 {
2864  return m_deviceMcsSet.size ();
2865 }
2866 
2867 WifiMode
2868 WifiPhy::GetMcs (uint8_t mcs) const
2869 {
2870  return m_deviceMcsSet[mcs];
2871 }
2872 
2873 double
2874 WifiPhy::DbToRatio (double dB) const
2875 {
2876  double ratio = std::pow (10.0, dB / 10.0);
2877  return ratio;
2878 }
2879 
2880 double
2881 WifiPhy::DbmToW (double dBm) const
2882 {
2883  double mW = std::pow (10.0, dBm / 10.0);
2884  return mW / 1000.0;
2885 }
2886 
2887 double
2888 WifiPhy::WToDbm (double w) const
2889 {
2890  return 10.0 * std::log10 (w * 1000.0);
2891 }
2892 
2893 double
2894 WifiPhy::RatioToDb (double ratio) const
2895 {
2896  return 10.0 * std::log10 (ratio);
2897 }
2898 
2899 bool
2901 {
2902  return m_state->IsStateCcaBusy ();
2903 }
2904 
2905 bool
2907 {
2908  return m_state->IsStateIdle ();
2909 }
2910 
2911 bool
2913 {
2914  return m_state->IsStateBusy ();
2915 }
2916 
2917 bool
2919 {
2920  return m_state->IsStateRx ();
2921 }
2922 
2923 bool
2925 {
2926  return m_state->IsStateTx ();
2927 }
2928 
2929 bool
2931 {
2932  return m_state->IsStateSwitching ();
2933 }
2934 
2935 bool
2937 {
2938  return m_state->IsStateSleep ();
2939 }
2940 
2941 Time
2943 {
2944  return m_state->GetStateDuration ();
2945 }
2946 
2947 Time
2949 {
2950  return m_state->GetDelayUntilIdle ();
2951 }
2952 
2953 Time
2955 {
2956  return m_state->GetLastRxStartTime ();
2957 }
2958 
2959 int64_t
2960 WifiPhy::AssignStreams (int64_t stream)
2961 {
2962  NS_LOG_FUNCTION (this << stream);
2963  m_random->SetStream (stream);
2964  return 1;
2965 }
2966 
2967 std::ostream& operator<< (std::ostream& os, enum WifiPhy::State state)
2968 {
2969  switch (state)
2970  {
2971  case WifiPhy::IDLE:
2972  return (os << "IDLE");
2973  case WifiPhy::CCA_BUSY:
2974  return (os << "CCA_BUSY");
2975  case WifiPhy::TX:
2976  return (os << "TX");
2977  case WifiPhy::RX:
2978  return (os << "RX");
2979  case WifiPhy::SWITCHING:
2980  return (os << "SWITCHING");
2981  case WifiPhy::SLEEP:
2982  return (os << "SLEEP");
2983  default:
2984  NS_FATAL_ERROR ("Invalid WifiPhy state");
2985  return (os << "INVALID");
2986  }
2987 }
2988 
2989 } //namespace ns3
2990 
2991 namespace {
2992 
2993 static class Constructor
2994 {
2995 public:
2997  {
3076  }
3077 } g_constructor;
3078 
3079 }
static class anonymous_namespace{wifi-phy.cc}::Constructor g_constructor
ERP-OFDM PHY (Clause 19, Section 19.5)
static WifiMode GetVhtMcs6()
Return MCS 6 from VHT MCS values.
Definition: wifi-phy.cc:2756
static WifiMode GetOfdmRate9MbpsBW5MHz()
Return a WifiMode for OFDM at 9Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:2410
TracedCallback< Ptr< const Packet > > m_phyRxBeginTrace
The trace source fired when a packet begins the reception process from the medium.
Definition: wifi-phy.h:1711
Ptr< NetDevice > m_device
Pointer to the device.
Definition: wifi-phy.h:1834
static WifiMode GetErpOfdmRate24Mbps()
Return a WifiMode for ERP-OFDM at 24Mbps.
Definition: wifi-phy.cc:2101
static WifiMode GetDsssRate11Mbps()
Return a WifiMode for DSSS at 11Mbps.
Definition: wifi-phy.cc:2038
virtual uint32_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
Definition: wifi-phy.cc:1200
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
virtual bool DoFrequencySwitch(uint32_t frequency)
The default implementation does nothing and returns true.
Definition: wifi-phy.cc:1341
void SetDevice(Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:598
std::vector< uint32_t > m_supportedChannelWidthSet
Supported channel width.
Definition: wifi-phy.h:1826
static WifiMode GetErpOfdmRate36Mbps()
Return a WifiMode for ERP-OFDM at 36Mbps.
Definition: wifi-phy.cc:2113
virtual void SetNumberOfTransmitAntennas(uint32_t tx)
Definition: wifi-phy.cc:1163
void NotifyMonitorSniffTx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu)
Public method used to fire a MonitorSniffer trace for a wifi packet being transmitted.
Definition: wifi-phy.cc:1990
virtual bool IsStateBusy(void)
Definition: wifi-phy.cc:2912
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)
double RatioToDb(double ratio) const
Convert from ratio to dB.
Definition: wifi-phy.cc:2894
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
double m_rxGainDb
Reception gain (dB)
Definition: wifi-phy.h:1809
static WifiMode GetVhtMcs8()
Return MCS 8 from VHT MCS values.
Definition: wifi-phy.cc:2772
ERP-OFDM PHY (19.5)
Definition: wifi-mode.h:58
double GetTxGain(void) const
Return the transmission gain (dB).
Definition: wifi-phy.cc:514
double GetRxNoiseFigure(void) const
Return the RX noise figure (dBm).
Definition: wifi-phy.cc:462
virtual void SetShortPlcpPreambleSupported(bool preamble)
Enable or disable short PLCP preamble.
Definition: wifi-phy.cc:585
AttributeValue implementation for Boolean.
Definition: boolean.h:34
virtual bool IsMcsSupported(WifiMode mcs) const
Check if the given WifiMode is supported by the PHY.
Definition: wifi-phy.cc:2837
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model.
uint16_t m_channelNumber
Operating channel number.
Definition: wifi-phy.h:1827
static WifiMode GetOfdmRate9Mbps()
Return a WifiMode for OFDM at 9Mbps.
Definition: wifi-phy.cc:2164
HT OFDM PHY for the 5 GHz band (clause 20)
virtual bool GetGuardInterval(void) const
Return whether guard interval is being used.
Definition: wifi-phy.cc:579
static WifiMode GetOfdmRate18MbpsBW10MHz()
Return a WifiMode for OFDM at 18Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2311
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:2335
double m_txGainDb
Transmission gain (dB)
Definition: wifi-phy.h:1808
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
static WifiMode GetOfdmRate3MbpsBW5MHz()
Return a WifiMode for OFDM at 3Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:2374
static WifiMode GetVhtMcs0()
Return MCS 0 from VHT MCS values.
Definition: wifi-phy.cc:2708
virtual ~WifiPhy()
Definition: wifi-phy.cc:365
virtual void SetLdpc(bool ldpc)
Enable or disable LDPC.
Definition: wifi-phy.cc:533
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1Mbps.
Definition: wifi-phy.cc:1999
bool m_ldpc
Flag if LDPC is used.
Definition: wifi-phy.h:1814
virtual bool GetGreenfield(void) const
Return whether Greenfield is supported.
Definition: wifi-phy.cc:566
802.11 PHY layer model
Definition: wifi-phy.h:162
static WifiMode GetErpOfdmRate18Mbps()
Return a WifiMode for ERP-OFDM at 18Mbps.
Definition: wifi-phy.cc:2089
void SetTxGain(double gain)
Sets the transmission gain (dB).
Definition: wifi-phy.cc:507
The PHY layer has sense the medium busy through the CCA mechanism.
Definition: wifi-phy.h:177
static WifiMode GetHtMcs7()
Return MCS 7 from HT MCS values.
Definition: wifi-phy.cc:2505
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:81
virtual void DoDispose(void)
Destructor implementation.
Definition: wifi-phy.cc:371
static WifiMode GetHtPlcpHeaderMode(WifiMode payloadMode)
Definition: wifi-phy.cc:1347
def start()
Definition: core.py:1482
virtual void SetStbc(bool stbc)
Enable or disable STBC.
Definition: wifi-phy.cc:546
static Time GetPlcpHtSigHeaderDuration(WifiPreamble preamble)
Definition: wifi-phy.cc:1405
static WifiMode GetVhtMcs5()
Return MCS 5 from VHT MCS values.
Definition: wifi-phy.cc:2748
static WifiMode GetHtMcs22()
Return MCS 22 from HT MCS values.
Definition: wifi-phy.cc:2625
std::vector< uint32_t > m_bssMembershipSelectorSet
Definition: wifi-phy.h:1797
static WifiMode GetHtMcs14()
Return MCS 14 from HT MCS values.
Definition: wifi-phy.cc:2561
static WifiMode GetOfdmRate12Mbps()
Return a WifiMode for OFDM at 12Mbps.
Definition: wifi-phy.cc:2176
TracedCallback< Ptr< const Packet > > m_phyRxEndTrace
The trace source fired when a packet ends the reception process from the medium.
Definition: wifi-phy.h:1719
enum WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:379
static WifiMode GetHtMcs31()
Return MCS 31 from HT MCS values.
Definition: wifi-phy.cc:2697
static WifiMode GetHtMcs21()
Return MCS 21 from HT MCS values.
Definition: wifi-phy.cc:2617
#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
uint32_t m_numberOfReceivers
Number of receivers.
Definition: wifi-phy.h:1821
static WifiMode GetHtMcs30()
Return MCS 30 from HT MCS values.
Definition: wifi-phy.cc:2689
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
static WifiMode GetHtMcs10()
Return MCS 10 from HT MCS values.
Definition: wifi-phy.cc:2529
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model this PHY is using.
Definition: wifi-phy.cc:635
static WifiMode GetHtMcs26()
Return MCS 26 from HT MCS values.
Definition: wifi-phy.cc:2657
bool IsShortGuardInterval(void) const
static WifiMode GetOfdmRate1_5MbpsBW5MHz()
Return a WifiMode for OFDM at 1.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:2350
virtual void SetNumberOfReceiveAntennas(uint32_t rx)
Definition: wifi-phy.cc:1170
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
The PHY layer is sleeping.
Definition: wifi-phy.h:193
static WifiMode GetHtMcs17()
Return MCS 17 from HT MCS values.
Definition: wifi-phy.cc:2585
static WifiMode GetHtMcs24()
Return MCS 24 from HT MCS values.
Definition: wifi-phy.cc:2641
static WifiMode GetOfdmRate4_5MbpsBW10MHz()
Return a WifiMode for OFDM at 4.5Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2263
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54Mbps.
Definition: wifi-phy.cc:2236
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:455
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
void ConfigureHolland(void)
Definition: wifi-phy.cc:812
virtual 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:2862
void NotifyTxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyTxDrop trace.
Definition: wifi-phy.cc:1960
int64_t GetFemtoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:361
HT OFDM PHY for the 2.4 GHz band (clause 20)
virtual void SetGreenfield(bool greenfield)
Enable or disable Greenfield support.
Definition: wifi-phy.cc:559
VHT PHY (Clause 22)
Definition: wifi-mode.h:64
void Configure80211_10Mhz(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard with 10...
Definition: wifi-phy.cc:782
HR/DSSS PHY (Clause 18)
Definition: wifi-mode.h:52
static WifiMode GetHtMcs8()
Return MCS 8 from HT MCS values.
Definition: wifi-phy.cc:2513
static WifiMode GetHtMcs18()
Return MCS 18 from HT MCS values.
Definition: wifi-phy.cc:2593
virtual void SetGuardInterval(bool guardInterval)
Enable or disable short/long guard interval.
Definition: wifi-phy.cc:572
void NotifyTxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyTxBegin trace.
Definition: wifi-phy.cc:1948
static WifiMode GetVhtMcs4()
Return MCS 4 from VHT MCS values.
Definition: wifi-phy.cc:2740
static WifiMode GetHtMcs27()
Return MCS 27 from HT MCS values.
Definition: wifi-phy.cc:2665
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
virtual bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
Definition: wifi-phy.cc:2824
static WifiMode GetOfdmRate36Mbps()
Return a WifiMode for OFDM at 36Mbps.
Definition: wifi-phy.cc:2212
Time GetPayloadDuration(uint32_t size, WifiTxVector txVector, WifiPreamble preamble, double frequency)
Definition: wifi-phy.cc:1623
static WifiMode CreateWifiMcs(std::string uniqueName, uint8_t mcsValue, enum WifiModulationClass modClass)
Definition: wifi-mode.cc:581
static WifiMode GetVhtMcs7()
Return MCS 7 from VHT MCS values.
Definition: wifi-phy.cc:2764
static WifiMode GetOfdmRate6MbpsBW5MHz()
Return a WifiMode for OFDM at 6Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:2398
virtual bool GetStbc(void) const
Return whether STBC is supported.
Definition: wifi-phy.cc:553
static WifiMode GetVhtMcs3()
Return MCS 3 from VHT MCS values.
Definition: wifi-phy.cc:2732
void NotifyMonitorSniffRx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu, struct signalNoiseDbm signalNoise)
Public method used to fire a MonitorSniffer trace for a wifi packet being received.
Definition: wifi-phy.cc:1984
virtual uint32_t GetBssMembershipSelector(uint32_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
Definition: wifi-phy.cc:1206
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
WifiModeList m_deviceMcsSet
Definition: wifi-phy.h:1795
static WifiMode GetVhtPlcpHeaderMode(WifiMode payloadMode)
Definition: wifi-phy.cc:1353
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
static WifiMode GetHtMcs16()
Return MCS 16 from HT MCS values.
Definition: wifi-phy.cc:2577
static WifiMode GetErpOfdmRate54Mbps()
Return a WifiMode for ERP-OFDM at 54Mbps.
Definition: wifi-phy.cc:2137
virtual bool GetLdpc(void) const
Return if LDPC is supported.
Definition: wifi-phy.cc:540
static WifiMode GetHtMcs29()
Return MCS 29 from HT MCS values.
Definition: wifi-phy.cc:2681
static WifiMode GetHtMcs11()
Return MCS 11 from HT MCS values.
Definition: wifi-phy.cc:2537
void NotifyRxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:1978
virtual uint32_t GetNumberOfReceiveAntennas(void) const
Definition: wifi-phy.cc:1182
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.
void SetNTxPower(uint32_t n)
Sets the number of transmission power levels available between the minimum level and the maximum leve...
Definition: wifi-phy.cc:494
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
static ChannelToFrequencyWidthMap m_channelToFrequencyWidth
This table maintains the mapping of valid ChannelNumber to Frequency/ChannelWidth pairs...
Definition: wifi-phy.h:1824
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:641
double GetEdThreshold(void) const
Return the energy detection threshold (dBm).
Definition: wifi-phy.cc:436
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
TracedCallback< Ptr< const Packet >, uint16_t, uint16_t, uint32_t, WifiPreamble, WifiTxVector, struct mpduInfo, struct signalNoiseDbm > m_phyMonitorSniffRxTrace
A trace source that emulates a wifi device in monitor mode sniffing a packet being received...
Definition: wifi-phy.h:1741
The MPDU is not part of an A-MPDU.
Definition: wifi-phy.h:59
static WifiMode GetHtMcs2()
Return MCS 2 from HT MCS values.
Definition: wifi-phy.cc:2465
tuple mobility
Definition: third.py:101
virtual uint16_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1329
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
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
Definition: wifi-phy.h:1835
AttributeValue implementation for Time.
Definition: nstime.h:957
Time CalculatePlcpPreambleAndHeaderDuration(WifiTxVector txVector, enum WifiPreamble preamble)
Definition: wifi-phy.cc:1921
bool DefineChannelNumber(uint16_t channelNumber, enum WifiPhyStandard standard, uint32_t frequency, uint32_t channelWidth)
Add a channel definition to the WifiPhy.
Definition: wifi-phy.cc:930
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:919
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:1703
virtual void AddSupportedChannelWidth(uint32_t channelwidth)
Definition: wifi-phy.cc:1246
bool m_shortPreamble
Flag if short PLCP preamble is supported.
Definition: wifi-phy.h:1818
virtual bool IsStateTx(void)
Definition: wifi-phy.cc:2924
virtual void SetChannelWidth(uint32_t channelwidth)
Definition: wifi-phy.cc:1149
Hold an unsigned integer type.
Definition: uinteger.h:44
static WifiMode GetPlcpHeaderMode(WifiMode payloadMode, WifiPreamble preamble, WifiTxVector txVector)
Definition: wifi-phy.cc:1462
The PHY layer is IDLE.
Definition: wifi-phy.h:173
std::pair< uint32_t, uint32_t > FrequencyWidthPair
A pair of a center Frequency and a ChannelWidth.
Definition: wifi-phy.h:617
static WifiMode GetHtMcs12()
Return MCS 12 from HT MCS values.
Definition: wifi-phy.cc:2545
static WifiMode GetErpOfdmRate48Mbps()
Return a WifiMode for ERP-OFDM at 48Mbps.
Definition: wifi-phy.cc:2125
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:481
uint8_t GetNess(void) const
static WifiMode GetOfdmRate12MbpsBW10MHz()
Return a WifiMode for OFDM at 12Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2299
uint32_t GetChannelWidth(void) const
HT PHY (Clause 20)
Definition: wifi-mode.h:62
virtual Time GetDelayUntilIdle(void)
Definition: wifi-phy.cc:2948
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:357
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:342
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, enum WifiPreamble preamble, double frequency)
Definition: wifi-phy.cc:1942
The PHY layer is receiving a packet.
Definition: wifi-phy.h:185
TracedCallback< Ptr< const Packet > > m_phyRxDropTrace
The trace source fired when the phy layer drops a packet it has received.
Definition: wifi-phy.h:1726
double m_edThresholdW
Energy detection threshold in watts.
Definition: wifi-phy.h:1806
void Configure80211_5Mhz()
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard with 5M...
Definition: wifi-phy.cc:797
virtual ~WifiPhyListener()
Definition: wifi-phy.cc:47
virtual uint32_t GetFrequency(void) const
Definition: wifi-phy.cc:1143
uint16_t FindChannelNumberForFrequencyWidth(uint32_t frequency, uint32_t width) const
Look for channel number matching the frequency and width.
Definition: wifi-phy.cc:947
void NotifyRxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyRxBegin trace.
Definition: wifi-phy.cc:1966
The PHY layer is sending a packet.
Definition: wifi-phy.h:181
static WifiMode GetOfdmRate18Mbps()
Return a WifiMode for OFDM at 18Mbps.
Definition: wifi-phy.cc:2188
virtual uint32_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:2850
static WifiMode GetOfdmRate9MbpsBW10MHz()
Return a WifiMode for OFDM at 9Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2287
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:2422
virtual void SetChannelNumber(uint16_t id)
Set channel number.
Definition: wifi-phy.cc:1275
virtual WifiModeList GetMembershipSelectorModes(uint32_t selector)
The WifiPhy::GetMembershipSelectorModes() method is used (e.g., by a WifiRemoteStationManager) to det...
Definition: wifi-phy.cc:1212
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
std::pair< uint16_t, enum WifiPhyStandard > ChannelNumberStandardPair
A pair of a ChannelNumber and WifiPhyStandard.
Definition: wifi-phy.h:613
The PHY layer is switching to other channel.
Definition: wifi-phy.h:189
virtual bool DoChannelSwitch(uint16_t id)
The default implementation does nothing and returns true.
Definition: wifi-phy.cc:1335
TracedCallback< Ptr< const Packet > > m_phyTxBeginTrace
The trace source fired when a packet begins the transmission process on the medium.
Definition: wifi-phy.h:1687
The MPDU is part of an A-MPDU, but is not the last aggregate.
Definition: wifi-phy.h:61
virtual uint32_t GetNTxPower(void) const
Return the number of available transmission power levels.
Definition: wifi-phy.cc:501
static WifiMode GetVhtMcs1()
Return MCS 1 from VHT MCS values.
Definition: wifi-phy.cc:2716
virtual void ConfigureDefaultsForStandard(enum WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:671
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:2224
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
double f(double x, void *params)
Definition: 80211b.c:60
static WifiMode GetHtMcs0()
Return MCS 0 from HT MCS values.
Definition: wifi-phy.cc:2449
virtual 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:2868
virtual uint32_t GetChannelWidth(void) const
Definition: wifi-phy.cc:1157
static TypeId GetTypeId(void)
Definition: wifi-phy.cc:160
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr.
Definition: pointer.h:36
virtual double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
Definition: wifi-phy.cc:488
VHT OFDM PHY (clause 22)
virtual bool IsStateIdle(void)
Definition: wifi-phy.cc:2906
static bool IsValidTxVector(WifiTxVector txVector)
The standard disallows certain combinations of WifiMode, number of spatial streams, and channel widths.
Definition: wifi-phy.cc:2788
TracedCallback< Ptr< const Packet >, uint16_t, uint16_t, uint32_t, WifiPreamble, WifiTxVector, struct mpduInfo > m_phyMonitorSniffTxTrace
A trace source that emulates a wifi device in monitor mode sniffing a packet being transmitted...
Definition: wifi-phy.h:1756
static WifiMode GetOfdmRate24Mbps()
Return a WifiMode for OFDM at 24Mbps.
Definition: wifi-phy.cc:2200
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
static WifiMode GetHtMcs13()
Return MCS 13 from HT MCS values.
Definition: wifi-phy.cc:2553
virtual double CalculateSnr(WifiTxVector txVector, double ber) const
Definition: wifi-phy.cc:665
static WifiMode GetHtMcs20()
Return MCS 20 from HT MCS values.
Definition: wifi-phy.cc:2609
static WifiMode GetHtMcs5()
Return MCS 5 from HT MCS values.
Definition: wifi-phy.cc:2489
void SetCcaMode1Threshold(double threshold)
Sets the CCA threshold (dBm).
Definition: wifi-phy.cc:442
virtual Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
Definition: wifi-phy.cc:2954
void SetMobility(Ptr< MobilityModel > mobility)
assign a mobility model to this device
Definition: wifi-phy.cc:610
uint64_t GetDataRate(uint32_t channelWidth, bool isShortGuardInterval, uint8_t nss) const
Definition: wifi-mode.cc:109
static WifiMode GetVhtMcs2()
Return MCS 2 from VHT MCS values.
Definition: wifi-phy.cc:2724
virtual bool IsStateCcaBusy(void)
Definition: wifi-phy.cc:2900
static WifiMode GetDsssRate5_5Mbps()
Return a WifiMode for DSSS at 5.5Mbps.
Definition: wifi-phy.cc:2026
Ptr< MobilityModel > GetMobility(void)
Return the mobility model this PHY is associated with.
Definition: wifi-phy.cc:616
void Configure80211ac(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11ac standard...
Definition: wifi-phy.cc:910
virtual void DoInitialize(void)
Initialize() implementation.
Definition: wifi-phy.cc:382
static WifiMode GetOfdmRate2_25MbpsBW5MHz()
Return a WifiMode for OFDM at 2.25Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:2362
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:958
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes...
Definition: wifi-mode.h:226
static Time GetPlcpVhtSigA1Duration(WifiPreamble preamble)
Definition: wifi-phy.cc:1420
static WifiMode GetErpOfdmRate9Mbps()
Return a WifiMode for ERP-OFDM at 9Mbps.
Definition: wifi-phy.cc:2065
void NotifyTxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyTxEnd trace.
Definition: wifi-phy.cc:1954
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Definition: wifi-phy.h:1584
virtual Time GetStateDuration(void)
Definition: wifi-phy.cc:2942
void InitializeFrequencyChannelNumber(void)
post-construction setting of frequency and/or channel number
Definition: wifi-phy.cc:395
static WifiMode CreateWifiMode(std::string uniqueName, enum WifiModulationClass modClass, bool isMandatory, enum WifiCodeRate codingRate, uint16_t constellationSize)
Definition: wifi-mode.cc:543
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:90
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
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:353
virtual void ConfigureStandard(enum WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1026
Ptr< NetDevice > GetDevice(void) const
Return the device this PHY is associated with.
Definition: wifi-phy.cc:604
void SetRxGain(double gain)
Sets the reception gain (dB).
Definition: wifi-phy.cc:520
void Configure80211b(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11b standard...
Definition: wifi-phy.cc:755
No explicit coding (e.g., DSSS rates)
Definition: wifi-mode.h:77
virtual std::vector< uint32_t > GetSupportedChannelWidthSet(void) const
Definition: wifi-phy.cc:1261
static WifiMode GetErpOfdmRate6Mbps()
Return a WifiMode for ERP-OFDM at 6Mbps.
Definition: wifi-phy.cc:2053
uint8_t GetNss(void) const
static WifiMode GetErpOfdmRate12Mbps()
Return a WifiMode for ERP-OFDM at 12Mbps.
Definition: wifi-phy.cc:2077
bool m_greenfield
Flag if GreenField format is supported.
Definition: wifi-phy.h:1816
virtual void ConfigureChannelForStandard(enum WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:975
virtual bool IsStateSleep(void)
Definition: wifi-phy.cc:2936
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Definition: wifi-phy.h:1585
void SetEdThreshold(double threshold)
Sets the energy detection threshold (dBm).
Definition: wifi-phy.cc:423
void NotifyRxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyRxEnd trace.
Definition: wifi-phy.cc:1972
void Configure80211n(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11n standard...
Definition: wifi-phy.cc:893
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:468
double m_txPowerBaseDbm
Minimum transmission power (dBm)
Definition: wifi-phy.h:1810
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:228
virtual bool IsStateSwitching(void)
Definition: wifi-phy.cc:2930
bool m_frequencyChannelNumberInitialized
Store initialization state.
Definition: wifi-phy.h:1803
static WifiMode GetHtMcs19()
Return MCS 19 from HT MCS values.
Definition: wifi-phy.cc:2601
InterferenceHelper m_interference
Pointer to InterferenceHelper.
Definition: wifi-phy.h:1583
enum WifiPhyStandard m_standard
WifiPhyStandard.
Definition: wifi-phy.h:1799
virtual uint8_t GetSupportedTxSpatialStreams(void) const
Definition: wifi-phy.cc:1194
static WifiMode GetHtMcs6()
Return MCS 6 from HT MCS values.
Definition: wifi-phy.cc:2497
bool m_isConstructed
true when ready to set frequency
Definition: wifi-phy.h:1800
virtual uint32_t GetNumberOfTransmitAntennas(void) const
Definition: wifi-phy.cc:1176
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
void ConfigureHtDeviceMcsSet(void)
Configure the device Mcs set with the appropriate HtMcs modes for the number of available transmit sp...
Definition: wifi-phy.cc:824
OFDM PHY (Clause 17)
Definition: wifi-mode.h:60
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:1832
static WifiMode GetHtMcs28()
Return MCS 28 from HT MCS values.
Definition: wifi-phy.cc:2673
FrequencyWidthPair GetFrequencyWidthForChannelNumberStandard(uint16_t channelNumber, enum WifiPhyStandard standard) const
Lookup frequency/width pair for channelNumber/standard pair.
Definition: wifi-phy.cc:1267
static WifiMode GetHtMcs9()
Return MCS 9 from HT MCS values.
Definition: wifi-phy.cc:2521
virtual void SetFrequency(uint32_t freq)
Definition: wifi-phy.cc:1086
static Time GetPlcpHeaderDuration(WifiTxVector txVector, WifiPreamble preamble)
Definition: wifi-phy.cc:1507
uint32_t m_channelCenterFrequency
Center frequency in MHz.
Definition: wifi-phy.h:1801
virtual Time GetChannelSwitchDelay(void) const
Definition: wifi-phy.cc:659
static WifiMode GetHtMcs4()
Return MCS 4 from HT MCS values.
Definition: wifi-phy.cc:2481
static WifiMode GetHtMcs25()
Return MCS 25 from HT MCS values.
Definition: wifi-phy.cc:2649
uint32_t m_initialFrequency
Store frequency until initialization.
Definition: wifi-phy.h:1802
void Configure80211g(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11g standard...
Definition: wifi-phy.cc:766
double WToDbm(double w) const
Convert from Watts to dBm.
Definition: wifi-phy.cc:2888
uint32_t m_channelWidth
Channel width.
Definition: wifi-phy.h:1804
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:1831
virtual uint8_t GetSupportedRxSpatialStreams(void) const
Definition: wifi-phy.cc:1188
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:911
WifiModeList m_deviceRateSet
This vector holds the set of transmission modes that this WifiPhy(-derived class) can support...
Definition: wifi-phy.h:1794
double DbmToW(double dbm) const
Convert from dBm to Watts.
Definition: wifi-phy.cc:2881
static WifiMode GetHtMcs1()
Return MCS 1 from HT MCS values.
Definition: wifi-phy.cc:2457
static WifiMode GetHtMcs23()
Return MCS 23 from HT MCS values.
Definition: wifi-phy.cc:2633
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:935
virtual enum WifiPhyStandard GetStandard(void) const
Get the configured Wi-Fi standard.
Definition: wifi-phy.cc:1080
static WifiMode GetDsssRate2Mbps()
Return a WifiMode for DSSS at 2Mbps.
Definition: wifi-phy.cc:2011
static WifiMode GetVhtMcs9()
Return MCS 9 from VHT MCS values.
Definition: wifi-phy.cc:2780
#define HT_PHY
Definition: wifi-phy.h:49
static WifiMode GetOfdmRate6MbpsBW10MHz()
Return a WifiMode for OFDM at 6Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2275
double GetEdThresholdW(void) const
Return the energy detection threshold.
Definition: wifi-phy.cc:430
WifiMode GetMode(void) const
double m_txPowerEndDbm
Maximum transmission power (dBm)
Definition: wifi-phy.h:1811
#define VHT_PHY
Definition: wifi-phy.h:48
virtual bool GetShortPlcpPreambleSupported(void) const
Return whether short PLCP preamble is supported.
Definition: wifi-phy.cc:592
State
The state of the PHY layer.
Definition: wifi-phy.h:168
double GetNoiseFigure(void) const
Return the noise figure.
static Time GetPlcpHtTrainingSymbolDuration(WifiPreamble preamble, WifiTxVector txVector)
Definition: wifi-phy.cc:1359
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
static WifiMode GetOfdmRate24MbpsBW10MHz()
Return a WifiMode for OFDM at 24Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2323
Time m_channelSwitchDelay
Time required to switch between channel.
Definition: wifi-phy.h:1830
static Time GetPlcpVhtSigBDuration(WifiPreamble preamble)
Definition: wifi-phy.cc:1448
virtual bool IsStateRx(void)
Definition: wifi-phy.cc:2918
uint32_t m_numberOfTransmitters
Number of transmitters.
Definition: wifi-phy.h:1820
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
Return a WifiMode for OFDM at 13.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:2434
double m_ccaMode1ThresholdW
Clear channel assessment (CCA) threshold in watts.
Definition: wifi-phy.h:1807
double GetCcaMode1Threshold(void) const
Return the CCA threshold (dBm).
Definition: wifi-phy.cc:449
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
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:2569
static Time GetPlcpPreambleDuration(WifiTxVector txVector, WifiPreamble preamble)
Definition: wifi-phy.cc:1571
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
static WifiMode GetHtMcs3()
Return MCS 3 from HT MCS values.
Definition: wifi-phy.cc:2473
uint16_t m_initialChannelNumber
Initial channel number.
Definition: wifi-phy.h:1828
double DbToRatio(double db) const
Convert from dB to ratio.
Definition: wifi-phy.cc:2874
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6Mbps.
Definition: wifi-phy.cc:2152
double GetRxGain(void) const
Return the reception gain (dB).
Definition: wifi-phy.cc:527
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:2960
DSSS PHY (Clause 15)
Definition: wifi-mode.h:50
virtual double GetTxPowerStart(void) const
Return the minimum available transmission power level (dBm).
Definition: wifi-phy.cc:475
static Time GetPlcpVhtSigA2Duration(WifiPreamble preamble)
Definition: wifi-phy.cc:1434
static WifiMode GetOfdmRate4_5MbpsBW5MHz()
Return a WifiMode for OFDM at 4.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:2386
uint32_t m_nTxPower
Number of available transmission power levels.
Definition: wifi-phy.h:1812
bool m_stbc
Flag if STBC is used.
Definition: wifi-phy.h:1815
void Configure80211a(void)
Configure WifiPhy with appropriate channel frequency and supported rates for 802.11a standard...
Definition: wifi-phy.cc:740
mpduType
This enumeration defines the type of an MPDU.
Definition: wifi-phy.h:56
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:629
std::map< ChannelNumberStandardPair, FrequencyWidthPair > ChannelToFrequencyWidthMap
Definition: wifi-phy.h:1823
static WifiMode GetOfdmRate3MbpsBW10MHz()
Return a WifiMode for OFDM at 3Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:2251
TracedCallback< Ptr< const Packet > > m_phyTxEndTrace
The trace source fired when a packet ends the transmission process on the medium. ...
Definition: wifi-phy.h:1695
bool m_guardInterval
Flag if short guard interval is used.
Definition: wifi-phy.h:1817
virtual WifiMode GetMode(uint32_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
Definition: wifi-phy.cc:2856
The MPDU is the last aggregate in an A-MPDU.
Definition: wifi-phy.h:63