A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
yans-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  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Author: Ghada Badawy <gbadawy@gmail.com>
20  */
21 
22 #include "yans-wifi-phy.h"
23 #include "yans-wifi-channel.h"
24 #include "wifi-mode.h"
25 #include "wifi-preamble.h"
26 #include "wifi-phy-state-helper.h"
27 #include "error-rate-model.h"
28 #include "ns3/simulator.h"
29 #include "ns3/packet.h"
30 #include "ns3/assert.h"
31 #include "ns3/log.h"
32 #include "ns3/double.h"
33 #include "ns3/uinteger.h"
34 #include "ns3/enum.h"
35 #include "ns3/pointer.h"
36 #include "ns3/net-device.h"
37 #include "ns3/trace-source-accessor.h"
38 #include "ns3/boolean.h"
39 #include <cmath>
40 
41 NS_LOG_COMPONENT_DEFINE ("YansWifiPhy");
42 
43 namespace ns3 {
44 
45 NS_OBJECT_ENSURE_REGISTERED (YansWifiPhy);
46 
47 TypeId
49 {
50  static TypeId tid = TypeId ("ns3::YansWifiPhy")
51  .SetParent<WifiPhy> ()
52  .AddConstructor<YansWifiPhy> ()
53  .AddAttribute ("EnergyDetectionThreshold",
54  "The energy of a received signal should be higher than "
55  "this threshold (dbm) to allow the PHY layer to detect the signal.",
56  DoubleValue (-96.0),
57  MakeDoubleAccessor (&YansWifiPhy::SetEdThreshold,
59  MakeDoubleChecker<double> ())
60  .AddAttribute ("CcaMode1Threshold",
61  "The energy of a received signal should be higher than "
62  "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state",
63  DoubleValue (-99.0),
64  MakeDoubleAccessor (&YansWifiPhy::SetCcaMode1Threshold,
66  MakeDoubleChecker<double> ())
67  .AddAttribute ("TxGain",
68  "Transmission gain (dB).",
69  DoubleValue (1.0),
70  MakeDoubleAccessor (&YansWifiPhy::SetTxGain,
72  MakeDoubleChecker<double> ())
73  .AddAttribute ("RxGain",
74  "Reception gain (dB).",
75  DoubleValue (1.0),
76  MakeDoubleAccessor (&YansWifiPhy::SetRxGain,
78  MakeDoubleChecker<double> ())
79  .AddAttribute ("TxPowerLevels",
80  "Number of transmission power levels available between "
81  "TxPowerStart and TxPowerEnd included.",
82  UintegerValue (1),
83  MakeUintegerAccessor (&YansWifiPhy::m_nTxPower),
84  MakeUintegerChecker<uint32_t> ())
85  .AddAttribute ("TxPowerEnd",
86  "Maximum available transmission level (dbm).",
87  DoubleValue (16.0206),
88  MakeDoubleAccessor (&YansWifiPhy::SetTxPowerEnd,
90  MakeDoubleChecker<double> ())
91  .AddAttribute ("TxPowerStart",
92  "Minimum available transmission level (dbm).",
93  DoubleValue (16.0206),
94  MakeDoubleAccessor (&YansWifiPhy::SetTxPowerStart,
96  MakeDoubleChecker<double> ())
97  .AddAttribute ("RxNoiseFigure",
98  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
99  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
100  "\"the difference in decibels (dB) between"
101  " the noise output of the actual receiver to the noise output of an "
102  " ideal receiver with the same overall gain and bandwidth when the receivers "
103  " are connected to sources at the standard noise temperature T0 (usually 290 K)\"."
104  " For",
105  DoubleValue (7),
106  MakeDoubleAccessor (&YansWifiPhy::SetRxNoiseFigure,
108  MakeDoubleChecker<double> ())
109  .AddAttribute ("State", "The state of the PHY layer",
110  PointerValue (),
111  MakePointerAccessor (&YansWifiPhy::m_state),
112  MakePointerChecker<WifiPhyStateHelper> ())
113  .AddAttribute ("ChannelSwitchDelay",
114  "Delay between two short frames transmitted on different frequencies.",
115  TimeValue (MicroSeconds (250)),
116  MakeTimeAccessor (&YansWifiPhy::m_channelSwitchDelay),
117  MakeTimeChecker ())
118  .AddAttribute ("ChannelNumber",
119  "Channel center frequency = Channel starting frequency + 5 MHz * nch",
120  UintegerValue (1),
121  MakeUintegerAccessor (&YansWifiPhy::SetChannelNumber,
123  MakeUintegerChecker<uint16_t> ())
124  .AddAttribute ("Frequency", "The operating frequency.",
125  UintegerValue (2407),
126  MakeUintegerAccessor (&YansWifiPhy::GetFrequency,
128  MakeUintegerChecker<uint32_t> ())
129  .AddAttribute ("Transmitters", "The number of transmitters.",
130  UintegerValue (1),
131  MakeUintegerAccessor (&YansWifiPhy::GetNumberOfTransmitAntennas,
133  MakeUintegerChecker<uint32_t> ())
134  .AddAttribute ("Recievers", "The number of recievers.",
135  UintegerValue (1),
136  MakeUintegerAccessor (&YansWifiPhy::GetNumberOfReceiveAntennas,
138  MakeUintegerChecker<uint32_t> ())
139  .AddAttribute ("ShortGuardEnabled", "Whether or not short guard interval is enabled.",
140  BooleanValue (false),
141  MakeBooleanAccessor (&YansWifiPhy::GetGuardInterval,
143  MakeBooleanChecker ())
144  .AddAttribute ("LdpcEnabled", "Whether or not LDPC is enabled.",
145  BooleanValue (false),
146  MakeBooleanAccessor (&YansWifiPhy::GetLdpc,
148  MakeBooleanChecker ())
149  .AddAttribute ("STBCEnabled", "Whether or not STBC is enabled.",
150  BooleanValue (false),
151  MakeBooleanAccessor (&YansWifiPhy::GetStbc,
153  MakeBooleanChecker ())
154  .AddAttribute ("GreenfieldEnabled", "Whether or not STBC is enabled.",
155  BooleanValue (false),
156  MakeBooleanAccessor (&YansWifiPhy::GetGreenfield,
158  MakeBooleanChecker ())
159  .AddAttribute ("ChannelBonding", "Whether 20MHz or 40MHz.",
160  BooleanValue (false),
161  MakeBooleanAccessor (&YansWifiPhy::GetChannelBonding,
163  MakeBooleanChecker ())
164 
165 
166  ;
167  return tid;
168 }
169 
171  : m_channelNumber (1),
172  m_endRxEvent (),
173  m_channelStartingFrequency (0)
174 {
175  NS_LOG_FUNCTION (this);
176  m_random = CreateObject<UniformRandomVariable> ();
177  m_state = CreateObject<WifiPhyStateHelper> ();
178 }
179 
181 {
182  NS_LOG_FUNCTION (this);
183 }
184 
185 void
187 {
188  NS_LOG_FUNCTION (this);
189  m_channel = 0;
190  m_deviceRateSet.clear ();
191  m_deviceMcsSet.clear();
192  m_device = 0;
193  m_mobility = 0;
194  m_state = 0;
195 }
196 
197 void
199 {
200  NS_LOG_FUNCTION (this << standard);
201  switch (standard)
202  {
204  Configure80211a ();
205  break;
207  Configure80211b ();
208  break;
210  Configure80211g ();
211  break;
214  break;
217  break;
219  ConfigureHolland ();
220  break;
223  Configure80211n ();
224  break;
227  Configure80211n ();
228  break;
229 
230  default:
231  NS_ASSERT (false);
232  break;
233  }
234 }
235 
236 
237 void
238 YansWifiPhy::SetRxNoiseFigure (double noiseFigureDb)
239 {
240  NS_LOG_FUNCTION (this << noiseFigureDb);
241  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
242 }
243 void
245 {
246  NS_LOG_FUNCTION (this << start);
248 }
249 void
251 {
252  NS_LOG_FUNCTION (this << end);
253  m_txPowerEndDbm = end;
254 }
255 void
257 {
258  NS_LOG_FUNCTION (this << n);
259  m_nTxPower = n;
260 }
261 void
263 {
264  NS_LOG_FUNCTION (this << gain);
265  m_txGainDb = gain;
266 }
267 void
269 {
270  NS_LOG_FUNCTION (this << gain);
271  m_rxGainDb = gain;
272 }
273 void
274 YansWifiPhy::SetEdThreshold (double threshold)
275 {
276  NS_LOG_FUNCTION (this << threshold);
277  m_edThresholdW = DbmToW (threshold);
278 }
279 void
281 {
282  NS_LOG_FUNCTION (this << threshold);
283  m_ccaMode1ThresholdW = DbmToW (threshold);
284 }
285 void
287 {
289 }
290 void
292 {
293  m_device = device;
294 }
295 void
297 {
298  m_mobility = mobility;
299 }
300 
301 double
303 {
305 }
306 double
308 {
309  return m_txPowerBaseDbm;
310 }
311 double
313 {
314  return m_txPowerEndDbm;
315 }
316 double
318 {
319  return m_txGainDb;
320 }
321 double
323 {
324  return m_rxGainDb;
325 }
326 
327 double
329 {
330  return WToDbm (m_edThresholdW);
331 }
332 
333 double
335 {
336  return WToDbm (m_ccaMode1ThresholdW);
337 }
338 
341 {
343 }
346 {
347  return m_device;
348 }
351 {
352  return m_mobility;
353 }
354 
355 double
356 YansWifiPhy::CalculateSnr (WifiMode txMode, double ber) const
357 {
358  return m_interference.GetErrorRateModel ()->CalculateSnr (txMode, ber);
359 }
360 
363 {
364  return m_channel;
365 }
366 void
368 {
369  m_channel = channel;
370  m_channel->Add (this);
371 }
372 
373 void
375 {
376  if (Simulator::Now () == Seconds (0))
377  {
378  // this is not channel switch, this is initialization
379  NS_LOG_DEBUG ("start at channel " << nch);
380  m_channelNumber = nch;
381  return;
382  }
383 
385  switch (m_state->GetState ())
386  {
387  case YansWifiPhy::RX:
388  NS_LOG_DEBUG ("drop packet because of channel switching while reception");
389  m_endRxEvent.Cancel ();
390  goto switchChannel;
391  break;
392  case YansWifiPhy::TX:
393  NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
395  break;
397  case YansWifiPhy::IDLE:
398  goto switchChannel;
399  break;
400  case YansWifiPhy::SLEEP:
401  NS_LOG_DEBUG ("channel switching ignored in sleep mode");
402  break;
403  default:
404  NS_ASSERT (false);
405  break;
406  }
407 
408  return;
409 
410 switchChannel:
411 
412  NS_LOG_DEBUG ("switching channel " << m_channelNumber << " -> " << nch);
413  m_state->SwitchToChannelSwitching (m_channelSwitchDelay);
415  /*
416  * Needed here to be able to correctly sensed the medium for the first
417  * time after the switching. The actual switching is not performed until
418  * after m_channelSwitchDelay. Packets received during the switching
419  * state are added to the event list and are employed later to figure
420  * out the state of the medium after the switching.
421  */
422  m_channelNumber = nch;
423 }
424 
425 uint16_t
427 {
428  return m_channelNumber;
429 }
430 
431 double
433 {
435 }
436 
437 void
439 {
440  NS_LOG_FUNCTION (this);
441  switch (m_state->GetState ())
442  {
443  case YansWifiPhy::TX:
444  NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmission");
446  break;
447  case YansWifiPhy::RX:
448  NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception");
450  break;
452  NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching");
454  break;
456  case YansWifiPhy::IDLE:
457  NS_LOG_DEBUG ("setting sleep mode");
458  m_state->SwitchToSleep ();
459  break;
460  case YansWifiPhy::SLEEP:
461  NS_LOG_DEBUG ("already in sleep mode");
462  break;
463  default:
464  NS_ASSERT (false);
465  break;
466  }
467 }
468 
469 void
471 {
472  NS_LOG_FUNCTION (this);
473  switch (m_state->GetState ())
474  {
475  case YansWifiPhy::TX:
476  case YansWifiPhy::RX:
477  case YansWifiPhy::IDLE:
480  NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume");
481  break;
482  case YansWifiPhy::SLEEP:
483  NS_LOG_DEBUG ("resuming from sleep mode");
485  m_state->SwitchFromSleep (delayUntilCcaEnd);
486  break;
487  }
488 }
489 
490 void
492 {
493  m_state->SetReceiveOkCallback (callback);
494 }
495 void
497 {
498  m_state->SetReceiveErrorCallback (callback);
499 }
500 void
502  double rxPowerDbm,
503  WifiTxVector txVector,
504  enum WifiPreamble preamble)
505 {
506  NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode()<< preamble);
507  rxPowerDbm += m_rxGainDb;
508  double rxPowerW = DbmToW (rxPowerDbm);
509  Time rxDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble);
510  WifiMode txMode = txVector.GetMode();
511  Time endRx = Simulator::Now () + rxDuration;
512 
514  event = m_interference.Add (packet->GetSize (),
515  txMode,
516  preamble,
517  rxDuration,
518  rxPowerW,
519  txVector); // we need it to calculate duration of HT training symbols
520 
521  switch (m_state->GetState ())
522  {
524  NS_LOG_DEBUG ("drop packet because of channel switching");
525  NotifyRxDrop (packet);
526  /*
527  * Packets received on the upcoming channel are added to the event list
528  * during the switching state. This way the medium can be correctly sensed
529  * when the device listens to the channel for the first time after the
530  * switching e.g. after channel switching, the channel may be sensed as
531  * busy due to other devices' tramissions started before the end of
532  * the switching.
533  */
534  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
535  {
536  // that packet will be noise _after_ the completion of the
537  // channel switching.
538  goto maybeCcaBusy;
539  }
540  break;
541  case YansWifiPhy::RX:
542  NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
543  rxPowerW << "W)");
544  NotifyRxDrop (packet);
545  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
546  {
547  // that packet will be noise _after_ the reception of the
548  // currently-received packet.
549  goto maybeCcaBusy;
550  }
551  break;
552  case YansWifiPhy::TX:
553  NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
554  rxPowerW << "W)");
555  NotifyRxDrop (packet);
556  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
557  {
558  // that packet will be noise _after_ the transmission of the
559  // currently-transmitted packet.
560  goto maybeCcaBusy;
561  }
562  break;
564  case YansWifiPhy::IDLE:
565  if (rxPowerW > m_edThresholdW)
566  {
567  if (IsModeSupported (txMode) || IsMcsSupported(txMode))
568  {
569  NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
570  // sync to signal
571  m_state->SwitchToRx (rxDuration);
573  NotifyRxBegin (packet);
576  packet,
577  event);
578  }
579  else
580  {
581  NS_LOG_DEBUG ("drop packet because it was sent using an unsupported mode (" << txMode << ")");
582  NotifyRxDrop (packet);
583  goto maybeCcaBusy;
584  }
585  }
586  else
587  {
588  NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
589  rxPowerW << "<" << m_edThresholdW << ")");
590  NotifyRxDrop (packet);
591  goto maybeCcaBusy;
592  }
593  break;
594  case YansWifiPhy::SLEEP:
595  NS_LOG_DEBUG ("drop packet because in sleep mode");
596  NotifyRxDrop (packet);
597  break;
598  }
599 
600  return;
601 
602 maybeCcaBusy:
603  // We are here because we have received the first bit of a packet and we are
604  // not going to be able to synchronize on it
605  // In this model, CCA becomes busy when the aggregation of all signals as
606  // tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
607 
609  if (!delayUntilCcaEnd.IsZero ())
610  {
611  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
612  }
613 }
614 
615 void
617 {
618  NS_LOG_FUNCTION (this << packet << txVector.GetMode() << preamble << (uint32_t)txVector.GetTxPowerLevel());
619  /* Transmission can happen if:
620  * - we are syncing on a packet. It is the responsability of the
621  * MAC layer to avoid doing this but the PHY does nothing to
622  * prevent it.
623  * - we are idle
624  */
625  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
626 
627  if (m_state->IsStateSleep ())
628  {
629  NS_LOG_DEBUG ("Dropping packet because in sleep mode");
630  NotifyTxDrop (packet);
631  return;
632  }
633 
634  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble);
635  if (m_state->IsStateRx ())
636  {
637  m_endRxEvent.Cancel ();
639  }
640  NotifyTxBegin (packet);
641  uint32_t dataRate500KbpsUnits = txVector.GetMode().GetDataRate () * txVector.GetNss() / 500000;
642  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
643  NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, txVector.GetTxPowerLevel());
644  m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel()), txVector, preamble);
645  m_channel->Send (this, packet, GetPowerDbm ( txVector.GetTxPowerLevel()) + m_txGainDb, txVector, preamble);
646 }
647 
648 uint32_t
650 {
651  return m_deviceRateSet.size ();
652 }
653 WifiMode
654 YansWifiPhy::GetMode (uint32_t mode) const
655 {
656  return m_deviceRateSet[mode];
657 }
658 bool
660 {
661  for (uint32_t i = 0; i < GetNModes (); i++)
662  {
663  if (mode == GetMode (i))
664  {
665  return true;
666  }
667  }
668  return false;
669 }
670 bool
672 {
673  for (uint32_t i = 0; i < GetNMcs (); i++)
674  {
675  if (mode == McsToWifiMode(GetMcs (i)))
676  {
677  return true;
678  }
679  }
680  return false;
681 }
682 uint32_t
684 {
685  return m_nTxPower;
686 }
687 
688 void
690 {
691  NS_LOG_FUNCTION (this);
692  m_channelStartingFrequency = 5e3; // 5.000 GHz
693 
702 }
703 
704 
705 void
707 {
708  NS_LOG_FUNCTION (this);
709  m_channelStartingFrequency = 2407; // 2.407 GHz
710 
715 }
716 
717 void
719 {
720  NS_LOG_FUNCTION (this);
721  m_channelStartingFrequency = 2407; // 2.407 GHz
722 
735 }
736 
737 void
739 {
740  NS_LOG_FUNCTION (this);
741  m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a
742 
751 }
752 
753 void
755 {
756  NS_LOG_FUNCTION (this);
757  m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a
758 
767 }
768 
769 void
771 {
772  NS_LOG_FUNCTION (this);
773  m_channelStartingFrequency = 5e3; // 5.000 GHz
779 }
780 
781 void
783 {
784  m_state->RegisterListener (listener);
785 }
786 
787 bool
789 {
790  return m_state->IsStateCcaBusy ();
791 }
792 
793 bool
795 {
796  return m_state->IsStateIdle ();
797 }
798 bool
800 {
801  return m_state->IsStateBusy ();
802 }
803 bool
805 {
806  return m_state->IsStateRx ();
807 }
808 bool
810 {
811  return m_state->IsStateTx ();
812 }
813 bool
815 {
816  return m_state->IsStateSwitching ();
817 }
818 bool
820 {
821  return m_state->IsStateSleep ();
822 }
823 
824 Time
826 {
827  return m_state->GetStateDuration ();
828 }
829 Time
831 {
832  return m_state->GetDelayUntilIdle ();
833 }
834 
835 Time
837 {
838  return m_state->GetLastRxStartTime ();
839 }
840 
841 double
842 YansWifiPhy::DbToRatio (double dB) const
843 {
844  double ratio = std::pow (10.0, dB / 10.0);
845  return ratio;
846 }
847 
848 double
849 YansWifiPhy::DbmToW (double dBm) const
850 {
851  double mW = std::pow (10.0, dBm / 10.0);
852  return mW / 1000.0;
853 }
854 
855 double
856 YansWifiPhy::WToDbm (double w) const
857 {
858  return 10.0 * std::log10 (w * 1000.0);
859 }
860 
861 double
862 YansWifiPhy::RatioToDb (double ratio) const
863 {
864  return 10.0 * std::log10 (ratio);
865 }
866 
867 double
869 {
870  return m_edThresholdW;
871 }
872 
873 double
874 YansWifiPhy::GetPowerDbm (uint8_t power) const
875 {
877  NS_ASSERT (m_nTxPower > 0);
878  double dbm;
879  if (m_nTxPower > 1)
880  {
881  dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
882  }
883  else
884  {
885  NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
886  dbm = m_txPowerBaseDbm;
887  }
888  return dbm;
889 }
890 
891 void
893 {
894  NS_LOG_FUNCTION (this << packet << event);
895  NS_ASSERT (IsStateRx ());
896  NS_ASSERT (event->GetEndTime () == Simulator::Now ());
897 
898  struct InterferenceHelper::SnrPer snrPer;
899  snrPer = m_interference.CalculateSnrPer (event);
901 
902  NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate ()) <<
903  ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
904  if (m_random->GetValue () > snrPer.per)
905  {
906  NotifyRxEnd (packet);
907  uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () * event->GetTxVector().GetNss()/ 500000;
908  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
909  double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
910  double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
911  NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
912  m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
913  }
914  else
915  {
916  /* failure. */
917  NotifyRxDrop (packet);
918  m_state->SwitchFromRxEndError (packet, snrPer.snr);
919  }
920 }
921 
922 int64_t
924 {
925  NS_LOG_FUNCTION (this << stream);
926  m_random->SetStream (stream);
927  return 1;
928 }
929 
930 void
932 {
934 }
935 
936 void
938 {
940 }
941 void
943 {
944  m_numberOfReceivers = rx;
945 }
946 
947 void
949 {
950  m_ldpc = Ldpc;
951 }
952 
953 void
955 {
956  m_stbc = stbc;
957 }
958 
959 void
960 YansWifiPhy::SetGreenfield (bool greenfield)
961 {
962  m_greenfield = greenfield;
963 }
964 bool
966 {
967  return m_guardInterval;
968 }
969 void
970 YansWifiPhy::SetGuardInterval (bool guardInterval)
971 {
972  m_guardInterval = guardInterval;
973 }
974 
975 uint32_t
977 {
979 }
980 
981 uint32_t
983 {
984  return m_numberOfTransmitters;
985 }
986 uint32_t
988 {
989  return m_numberOfReceivers;
990 }
991 
992 bool
994 {
995  return m_ldpc;
996 }
997 bool
999 {
1000  return m_stbc;
1001 }
1002 
1003 bool
1005 {
1006  return m_greenfield;
1007 }
1008 
1009 bool
1011 {
1012  return m_channelBonding;
1013 }
1014 
1015 void
1016 YansWifiPhy::SetChannelBonding(bool channelbonding)
1017 {
1018  m_channelBonding= channelbonding;
1019 }
1020 
1021 void
1023 {
1024  NS_LOG_FUNCTION (this);
1033  for (uint8_t i=0; i <8; i++)
1034  {
1035  m_deviceMcsSet.push_back(i);
1036  }
1037 
1038 }
1039 uint32_t
1041 {
1042  return m_bssMembershipSelectorSet.size ();
1043 }
1044 uint32_t
1045 YansWifiPhy::GetBssMembershipSelector (uint32_t selector) const
1046 {
1047  return m_bssMembershipSelectorSet[selector];
1048 }
1051 {
1052  uint32_t id=GetBssMembershipSelector(selector);
1053  WifiModeList supportedmodes;
1054  if (id == HT_PHY)
1055  {
1056  //mandatory MCS 0 to 7
1057  supportedmodes.push_back (WifiPhy::GetOfdmRate6_5MbpsBW20MHz ());
1058  supportedmodes.push_back (WifiPhy::GetOfdmRate13MbpsBW20MHz ());
1059  supportedmodes.push_back (WifiPhy::GetOfdmRate19_5MbpsBW20MHz ());
1060  supportedmodes.push_back (WifiPhy::GetOfdmRate26MbpsBW20MHz ());
1061  supportedmodes.push_back (WifiPhy::GetOfdmRate39MbpsBW20MHz ());
1062  supportedmodes.push_back (WifiPhy::GetOfdmRate52MbpsBW20MHz ());
1063  supportedmodes.push_back (WifiPhy::GetOfdmRate58_5MbpsBW20MHz ());
1064  supportedmodes.push_back (WifiPhy::GetOfdmRate65MbpsBW20MHz ());
1065  }
1066  return supportedmodes;
1067 }
1068 uint8_t
1070 {
1071  return m_deviceMcsSet.size ();
1072 }
1073 uint8_t
1074 YansWifiPhy::GetMcs (uint8_t mcs) const
1075 {
1076  return m_deviceMcsSet[mcs];
1077 }
1078 uint32_t
1080 {
1081  uint32_t mcs = 0;
1082  if (mode.GetUniqueName() == "OfdmRate135MbpsBW40MHzShGi" || mode.GetUniqueName() == "OfdmRate65MbpsBW20MHzShGi" )
1083  {
1084  mcs=6;
1085  }
1086  else
1087  {
1088  switch (mode.GetDataRate())
1089  {
1090  case 6500000:
1091  case 7200000:
1092  case 13500000:
1093  case 15000000:
1094  mcs=0;
1095  break;
1096  case 13000000:
1097  case 14400000:
1098  case 27000000:
1099  case 30000000:
1100  mcs=1;
1101  break;
1102  case 19500000:
1103  case 21700000:
1104  case 40500000:
1105  case 45000000:
1106  mcs=2;
1107  break;
1108  case 26000000:
1109  case 28900000:
1110  case 54000000:
1111  case 60000000:
1112  mcs=3;
1113  break;
1114  case 39000000:
1115  case 43300000:
1116  case 81000000:
1117  case 90000000:
1118  mcs=4;
1119  break;
1120  case 52000000:
1121  case 57800000:
1122  case 108000000:
1123  case 120000000:
1124  mcs=5;
1125  break;
1126  case 58500000:
1127  case 121500000:
1128  mcs=6;
1129  break;
1130  case 65000000:
1131  case 72200000:
1132  case 135000000:
1133  case 150000000:
1134  mcs=7;
1135  break;
1136  }
1137  }
1138  return mcs;
1139 }
1140 WifiMode
1142 {
1143  WifiMode mode;
1144  switch (mcs)
1145  {
1146  case 7:
1147  if (!GetGuardInterval() && !GetChannelBonding())
1148  {
1150  }
1151  else if(GetGuardInterval() && !GetChannelBonding())
1152  {
1154  }
1155  else if (!GetGuardInterval() && GetChannelBonding())
1156  {
1158  }
1159  else
1160  {
1162  }
1163  break;
1164  case 6:
1165  if (!GetGuardInterval() && !GetChannelBonding())
1166  {
1168 
1169  }
1170  else if(GetGuardInterval() && !GetChannelBonding())
1171  {
1173 
1174  }
1175  else if (!GetGuardInterval() && GetChannelBonding())
1176  {
1178 
1179  }
1180  else
1181  {
1183 
1184  }
1185  break;
1186  case 5:
1187  if (!GetGuardInterval() && !GetChannelBonding())
1188  {
1190 
1191  }
1192  else if(GetGuardInterval() && !GetChannelBonding())
1193  {
1195  }
1196  else if (!GetGuardInterval() && GetChannelBonding())
1197  {
1199 
1200  }
1201  else
1202  {
1204 
1205  }
1206  break;
1207  case 4:
1208  if (!GetGuardInterval() && !GetChannelBonding())
1209  {
1211  }
1212  else if(GetGuardInterval() && !GetChannelBonding())
1213  {
1215  }
1216  else if (!GetGuardInterval() && GetChannelBonding())
1217  {
1219 
1220  }
1221  else
1222  {
1224 
1225  }
1226  break;
1227  case 3:
1228  if (!GetGuardInterval() && !GetChannelBonding())
1229  {
1231 
1232  }
1233  else if(GetGuardInterval() && !GetChannelBonding())
1234  {
1236 
1237  }
1238  else if (!GetGuardInterval() && GetChannelBonding())
1239  {
1241 
1242  }
1243  else
1244  {
1246  }
1247  break;
1248  case 2:
1249  if (!GetGuardInterval() && !GetChannelBonding())
1250  {
1252 
1253  }
1254  else if(GetGuardInterval() && !GetChannelBonding())
1255  {
1257 
1258  }
1259  else if (!GetGuardInterval() && GetChannelBonding())
1260  {
1262 
1263  }
1264  else
1265  {
1267 
1268  }
1269  break;
1270  case 1:
1271  if (!GetGuardInterval() && !GetChannelBonding())
1272  {
1274 
1275  }
1276  else if(GetGuardInterval() && !GetChannelBonding())
1277  {
1279  }
1280  else if (!GetGuardInterval() && GetChannelBonding())
1281  {
1283 
1284  }
1285  else
1286  {
1288  }
1289  break;
1290  case 0:
1291  default:
1292  if (!GetGuardInterval() && !GetChannelBonding())
1293  {
1295 
1296  }
1297  else if(GetGuardInterval() && !GetChannelBonding())
1298  {
1300  }
1301  else if (!GetGuardInterval() && GetChannelBonding())
1302  {
1304 
1305  }
1306  else
1307  {
1309  }
1310  break;
1311  }
1312  return mode;
1313 }
1314 } // namespace ns3
ERP-OFDM PHY (Clause 19, Section 19.5)
uint16_t m_channelNumber
Operating channel number.
bool m_channelBonding
Flag if channel conding is used.
static WifiMode GetOfdmRate9MbpsBW5MHz()
Return a WifiMode for ODFM at 9Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:946
static WifiMode GetErpOfdmRate24Mbps()
Return a WifiMode for ERP-ODFM at 24Mbps.
Definition: wifi-phy.cc:614
static WifiMode GetDsssRate11Mbps()
Return a WifiMode for DSSS at 11Mbps.
Definition: wifi-phy.cc:546
Ptr< Object > m_mobility
Pointer to the mobility model.
virtual bool IsStateBusy(void)
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
static WifiMode GetErpOfdmRate36Mbps()
Return a WifiMode for ERP-ODFM at 36Mbps.
Definition: wifi-phy.cc:627
A struct for both SNR and PER.
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
OFDM PHY for the 5 GHz band (Clause 17 with 5 MHz channel bandwidth)
void Configure80211b(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11b standard.
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
virtual uint32_t GetFrequency(void) const
virtual bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
static WifiMode GetOfdmRate26MbpsBW20MHz()
Return a WifiMode for ODFM at 26Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1064
Hold a bool native type.
Definition: boolean.h:38
The PHY layer is sleeping.
Definition: wifi-phy.h:157
virtual WifiModeList GetMembershipSelectorModes(uint32_t selector)
The WifiPhy::GetMembershipSelectorModes() method is used (e.g., by a WifiRemoteStationManager) to det...
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model.
double DbmToW(double dbm) const
Convert from dBm to Watts.
static WifiMode GetOfdmRate9Mbps()
Return a WifiMode for ODFM at 9Mbps.
Definition: wifi-phy.cc:682
double DbToRatio(double db) const
Convert from dB to ratio.
static WifiMode GetOfdmRate7_2MbpsBW20MHz()
Return a WifiMode for ODFM at 7.2Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:999
static WifiMode GetOfdmRate18MbpsBW10MHz()
Return a WifiMode for ODFM at 18Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:840
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 ODFM at 27Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:866
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
Sets the error rate model.
virtual bool IsStateSwitching(void)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
virtual bool IsStateTx(void)
static WifiMode GetOfdmRate3MbpsBW5MHz()
Return a WifiMode for ODFM at 3Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:907
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1Mbps.
Definition: wifi-phy.cc:504
void NotifyMonitorSniffTx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, uint8_t txPower)
Public method used to fire a MonitorSniffer trace for a wifi packet being transmitted.
Definition: wifi-phy.cc:495
void Configure80211n(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11n standard.
Ptr< YansWifiChannel > m_channel
YansWifiChannel that this YansWifiPhy is connected to.
static WifiMode GetOfdmRate81MbpsBW40MHz()
Return a WifiMode for ODFM at 81Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1297
void SetTxGain(double gain)
Sets the transmission gain (dB).
802.11 PHY layer model
Definition: wifi-phy.h:126
static WifiMode GetErpOfdmRate18Mbps()
Return a WifiMode for ERP-ODFM at 18Mbps.
Definition: wifi-phy.cc:601
bool IsZero(void) const
Definition: nstime.h:264
virtual void SetGuardInterval(bool guardInterval)
Enable or disable short/long guard interval.
static WifiMode GetOfdmRate12Mbps()
Return a WifiMode for ODFM at 12Mbps.
Definition: wifi-phy.cc:695
virtual void SetLdpc(bool ldpc)
Enable or disable LDPC.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
static WifiMode GetOfdmRate43_3MbpsBW20MHz()
Return a WifiMode for ODFM at 43.3Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1103
Time GetEnergyDuration(double energyW)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
virtual void RegisterListener(WifiPhyListener *listener)
static WifiMode GetOfdmRate60MbpsBW40MHz()
Return a WifiMode for ODFM at 60Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1284
static WifiMode GetOfdmRate1_5MbpsBW5MHz()
Return a WifiMode for ODFM at 1.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:881
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:744
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
double m_txPowerBaseDbm
Minimum transmission power (dBm)
static WifiMode GetOfdmRate4_5MbpsBW10MHz()
Return a WifiMode for ODFM at 4.5Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:788
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for ODFM at 54Mbps.
Definition: wifi-phy.cc:760
virtual bool IsMcsSupported(WifiMode mode)
uint16_t GetChannelNumber() const
Return the current channel number.
void SetChannelNumber(uint16_t id)
Set the current channel number.
void NotifyTxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyTxDrop trace.
Definition: wifi-phy.cc:465
static WifiMode GetOfdmRate108MbpsBW40MHz()
Return a WifiMode for ODFM at 108Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1322
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:825
virtual bool IsStateSleep(void)
static WifiMode GetOfdmRate21_7MbpsBW20MHz()
Return a WifiMode for ODFM at 21.7Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1050
void NotifyTxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyTxBegin trace.
Definition: wifi-phy.cc:453
Ptr< Object > GetDevice(void) const
Return the device this PHY is associated with.
double m_edThresholdW
Energy detection threshold in watts.
void Configure80211_5Mhz()
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11a standard with 5MHz channel spacing.
virtual Time GetDelayUntilIdle(void)
void Configure80211a(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:91
void Configure80211g(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
static WifiMode GetOfdmRate135MbpsBW40MHz()
Return a WifiMode for ODFM at 135Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1370
static WifiMode GetOfdmRate36Mbps()
Return a WifiMode for ODFM at 36Mbps.
Definition: wifi-phy.cc:734
static WifiMode GetOfdmRate6MbpsBW5MHz()
Return a WifiMode for ODFM at 6Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:933
virtual Time GetStateDuration(void)
virtual uint32_t GetNBssMembershipSelectors(void) const
The WifiPhy::NBssMembershipSelectors() method is used (e.g., by a WifiRemoteStationManager) to determ...
double m_rxGainDb
Reception gain (dB)
uint8_t GetTxPowerLevel(void) const
double GetTxGain(void) const
Return the transmission gain (dB).
virtual bool GetChannelBonding(void) const
Return whether channel bonding is supported.
std::vector< uint32_t > m_bssMembershipSelectorSet
The PHY layer is switching to other channel.
Definition: wifi-phy.h:153
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:444
static WifiMode GetErpOfdmRate54Mbps()
Return a WifiMode for ERP-ODFM at 54Mbps.
Definition: wifi-phy.cc:653
virtual void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
void NotifyRxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:483
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:29
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
virtual uint32_t GetNModes(void) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
static WifiMode GetOfdmRate6_5MbpsBW20MHz()
Return a WifiMode for ODFM at 6.5Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:987
virtual bool IsStateRx(void)
virtual uint8_t GetNMcs(void) const
virtual double GetTxPowerStart(void) const
Return the minimum available transmission power level (dBm).
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
virtual WifiMode GetMode(uint32_t mode) const
The WifiPhy::GetNModes() and WifiPhy::GetMode() methods are used (e.g., by a WifiRemoteStationManager...
double m_channelStartingFrequency
Standard-dependent center frequency of 0-th channel in MHz.
void SetEdThreshold(double threshold)
Sets the energy detection threshold (dBm).
static WifiMode GetOfdmRate135MbpsBW40MHzShGi()
Return a WifiMode for ODFM at 135Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1358
bool m_ldpc
Flag if LDPC is used.
virtual uint8_t GetMcs(uint8_t mcs) const
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
Attribute for objects of type ns3::Time.
Definition: nstime.h:912
receive notifications about phy events.
Definition: wifi-phy.h:44
virtual bool GetStbc(void) const
Return whether STBC is supported.
bool m_stbc
Flag if STBC is used.
Hold an unsigned integer type.
Definition: uinteger.h:46
Ptr< Object > m_device
Pointer to the device.
WifiModeList m_deviceRateSet
This vector holds the set of transmission modes that this WifiPhy(-derived class) can support...
static WifiMode GetErpOfdmRate48Mbps()
Return a WifiMode for ERP-ODFM at 48Mbps.
Definition: wifi-phy.cc:640
double m_ccaMode1ThresholdW
Clear channel assessment (CCA) threshold in watts.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual void SetStbc(bool stbc)
Enable or disable STBC.
#define HT_PHY
Definition: yans-wifi-phy.h:43
static WifiMode GetOfdmRate12MbpsBW10MHz()
Return a WifiMode for ODFM at 12Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:827
virtual uint32_t GetBssMembershipSelector(uint32_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:97
double GetRxGain(void) const
Return the reception gain (dB).
Ptr< InterferenceHelper::Event > Add(uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble, Time duration, double rxPower, WifiTxVector txvector)
Add the packet-related signal to interference helper.
void NotifyRxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyRxBegin trace.
Definition: wifi-phy.cc:471
static WifiMode GetOfdmRate19_5MbpsBW20MHz()
Return a WifiMode for ODFM at 19.5Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1037
static WifiMode GetOfdmRate18Mbps()
Return a WifiMode for ODFM at 18Mbps.
Definition: wifi-phy.cc:708
double GetChannelFrequencyMhz() const
Return current center channel frequency in MHz.
static WifiMode GetOfdmRate9MbpsBW10MHz()
Return a WifiMode for ODFM at 9Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:814
static WifiMode GetOfdmRate12MbpsBW5MHz()
Return a WifiMode for ODFM at 12Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:959
static WifiMode GetOfdmRate52MbpsBW20MHz()
Return a WifiMode for ODFM at 52Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1116
double WToDbm(double w) const
Convert from Watts to dBm.
static WifiMode GetOfdmRate40_5MbpsBW40MHz()
Return a WifiMode for ODFM at 40.5Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1246
void SetChannel(Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
void SetNTxPower(uint32_t n)
Sets the number of transmission power levels available between the minimum level and the maximum leve...
virtual bool IsStateCcaBusy(void)
static WifiMode GetOfdmRate72_2MbpsBW20MHz()
Return a WifiMode for ODFM at 72.2Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1182
static WifiMode GetOfdmRate65MbpsBW20MHzShGi()
Return a WifiMode for ODFM at 65Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1156
virtual ~YansWifiPhy()
void SetDevice(Ptr< Object > device)
Sets the device this PHY is associated with.
struct InterferenceHelper::SnrPer CalculateSnrPer(Ptr< InterferenceHelper::Event > event)
Calculate the SNIR at the start of the packet and accumulate all SNIR changes in the snir vector...
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
static WifiMode GetOfdmRate48Mbps()
Return a WifiMode for ODFM at 48Mbps.
Definition: wifi-phy.cc:747
void NotifyMonitorSniffRx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
Public method used to fire a MonitorSniffer trace for a wifi packet being received.
Definition: wifi-phy.cc:489
double m_txPowerEndDbm
Maximum transmission power (dBm)
virtual void SetReceiveOkCallback(WifiPhy::RxOkCallback callback)
The PHY layer is IDLE.
Definition: wifi-phy.h:137
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
double GetCcaMode1Threshold(void) const
Return the CCA threshold (dBm).
OFDM PHY for the 5 GHz band (Clause 17)
void NotifyRxStart()
Notify that RX has started.
hold objects of type Ptr
Definition: pointer.h:33
static WifiMode GetOfdmRate57_8MbpsBW20MHz()
Return a WifiMode for ODFM at 57.8Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1129
void EraseEvents(void)
Erase all events.
static WifiMode GetOfdmRate24Mbps()
Return a WifiMode for ODFM at 24Mbps.
Definition: wifi-phy.cc:721
double GetEdThreshold(void) const
Return the energy detection threshold (dBm).
static TypeId GetTypeId(void)
static WifiMode GetOfdmRate13MbpsBW20MHz()
Return a WifiMode for ODFM at 13Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1012
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
virtual uint32_t GetNumberOfTransmitAntennas(void) const
virtual uint32_t WifiModeToMcs(WifiMode mode)
For a given WifiMode finds the corresponding MCS value and returns it as defined in the IEEE 802...
static WifiMode GetOfdmRate65MbpsBW20MHz()
Return a WifiMode for ODFM at 65Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1169
double GetValue(double min, double max)
Returns a random double from the uniform distribution with the specified range.
virtual uint32_t GetNumberOfReceiveAntennas(void) const
static WifiMode GetOfdmRate58_5MbpsBW20MHz()
Return a WifiMode for ODFM at 58.5Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1143
uint32_t m_nTxPower
Number of available transmission power levels.
virtual void SendPacket(Ptr< const Packet > packet, WifiTxVector txvector, enum WifiPreamble preamble)
void SetRxGain(double gain)
Sets the reception gain (dB).
static WifiMode GetDsssRate5_5Mbps()
Return a WifiMode for DSSS at 5.5Mbps.
Definition: wifi-phy.cc:533
static WifiMode GetOfdmRate2_25MbpsBW5MHz()
Return a WifiMode for ODFM at 2.25Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:894
virtual void SetSleepMode(void)
Put in sleep mode.
std::vector< WifiMode > WifiModeList
In various parts of the code, folk are interested in maintaining a list of transmission modes...
Definition: wifi-mode.h:188
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
static WifiMode GetErpOfdmRate9Mbps()
Return a WifiMode for ERP-ODFM at 9Mbps.
Definition: wifi-phy.cc:575
virtual WifiMode McsToWifiMode(uint8_t mcs)
For a given MCS finds the corresponding WifiMode and returns it as defined in the IEEE 802...
void SetTxPowerStart(double start)
Sets the minimum available transmission power level (dBm).
double RatioToDb(double ratio) const
Convert from ratio to dB.
virtual void SetNumberOfTransmitAntennas(uint32_t tx)
static WifiMode GetOfdmRate15MbpsBW40MHz()
Return a WifiMode for ODFM at 15Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1208
static WifiMode GetOfdmRate121_5MbpsBW40MHz()
Return a WifiMode for ODFM at 121.5Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1346
#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:84
static WifiMode GetOfdmRate28_9MbpsBW20MHz()
Return a WifiMode for ODFM at 28.9Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1077
virtual bool IsStateIdle(void)
void StartReceivePacket(Ptr< Packet > packet, double rxPowerDbm, WifiTxVector txVector, WifiPreamble preamble)
Starting receiving the packet (i.e.
virtual Time GetLastRxStartTime(void) const
Return the start time of the last received packet.
virtual double CalculateSnr(WifiMode txMode, double ber) const
virtual bool GetGreenfield(void) const
Return whether Greenfield is supported.
static WifiMode GetErpOfdmRate6Mbps()
Return a WifiMode for ERP-ODFM at 6Mbps.
Definition: wifi-phy.cc:562
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
static Time CalculateTxDuration(uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble)
Definition: wifi-phy.cc:439
uint8_t GetNss(void) const
InterferenceHelper m_interference
Pointer to InterferenceHelper.
static WifiMode GetErpOfdmRate12Mbps()
Return a WifiMode for ERP-ODFM at 12Mbps.
Definition: wifi-phy.cc:588
virtual bool GetGuardInterval(void) const
Return whether guard interval is being used.
void NotifyRxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyRxEnd trace.
Definition: wifi-phy.cc:477
void SetMobility(Ptr< Object > mobility)
Sets the mobility model.
void NotifyRxEnd()
Notify that RX has ended.
void SetNoiseFigure(double value)
Set the noise figure.
Time m_channelSwitchDelay
Time required to switch between channel.
virtual void ConfigureStandard(enum WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
static WifiMode GetOfdmRate13_5MbpsBW40MHz()
Return a WifiMode for ODFM at 13.5Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1195
static WifiMode GetOfdmRate30MbpsBW40MHz()
Return a WifiMode for ODFM at 30Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1233
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:213
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:845
static WifiMode GetOfdmRate54MbpsBW40MHz()
Return a WifiMode for ODFM at 54Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1271
virtual bool GetLdpc(void) const
Return if LDPC is supported.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
Definition: event-id.cc:47
std::vector< uint8_t > m_deviceMcsSet
double m_txGainDb
Transmission gain (dB)
bool m_greenfield
Flag if GreenField format is supported.
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
bool m_guardInterval
Flag if short guard interval is used.
void EndReceive(Ptr< Packet > packet, Ptr< InterferenceHelper::Event > event)
The last bit of the packet has arrived.
static WifiMode GetOfdmRate90MbpsBW40MHz()
Return a WifiMode for ODFM at 90Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1309
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:861
virtual void SetNumberOfReceiveAntennas(uint32_t rx)
static WifiMode GetOfdmRate45MbpsBW40MHz()
Return a WifiMode for ODFM at 45Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1258
uint32_t m_numberOfTransmitters
Number of transmitters.
static WifiMode GetOfdmRate120MbpsBW40MHz()
Return a WifiMode for ODFM at 120Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1334
double GetEdThresholdW(void) const
Return the energy detection threshold.
static WifiMode GetOfdmRate39MbpsBW20MHz()
Return a WifiMode for ODFM at 39Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1090
virtual Ptr< WifiChannel > GetChannel(void) const
Return the WifiChannel this WifiPhy is connected to.
static WifiMode GetDsssRate2Mbps()
Return a WifiMode for DSSS at 2Mbps.
Definition: wifi-phy.cc:517
void SetCcaMode1Threshold(double threshold)
Sets the CCA threshold (dBm).
static WifiMode GetOfdmRate6MbpsBW10MHz()
Return a WifiMode for ODFM at 6Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:801
WifiMode GetMode(void) const
The PHY layer is receiving a packet.
Definition: wifi-phy.h:149
void ConfigureHolland(void)
double GetNoiseFigure(void) const
Return the noise figure.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
Hold a floating point type.
Definition: double.h:41
double GetRxNoiseFigure(void) const
Return the RX noise figure (dBm).
static WifiMode GetOfdmRate24MbpsBW10MHz()
Return a WifiMode for ODFM at 24Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:853
The PHY layer has sense the medium busy through the CCA mechanism.
Definition: wifi-phy.h:141
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
Return a WifiMode for ODFM at 13.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:972
virtual double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
Definition: event-id.cc:53
a unique identifier for an interface.
Definition: type-id.h:49
uint32_t m_numberOfReceivers
Number of receivers.
virtual void ResumeFromSleep(void)
Resume from sleep mode.
The PHY layer is sending a packet.
Definition: wifi-phy.h:145
uint64_t GetDataRate(void) const
Definition: wifi-mode.cc:79
virtual void SetChannelBonding(bool channelbonding)
Enable or disable channel bonding support.
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for ODFM at 6Mbps.
Definition: wifi-phy.cc:669
static WifiMode GetOfdmRate27MbpsBW40MHz()
Return a WifiMode for ODFM at 27Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1221
virtual void SetFrequency(uint32_t freq)
static WifiMode GetOfdmRate4_5MbpsBW5MHz()
Return a WifiMode for ODFM at 4.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:920
static WifiMode GetOfdmRate14_4MbpsBW20MHz()
Return a WifiMode for ODFM at 14.4Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1025
void Configure80211_10Mhz(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11a standard with 10MHz channel spacing.
virtual uint32_t GetNTxPower(void) const
Return the number of available transmission power levels.
void SetRxNoiseFigure(double noiseFigureDb)
Sets the RX loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver.
static WifiMode GetOfdmRate3MbpsBW10MHz()
Return a WifiMode for ODFM at 3Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:775
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model this PHY is using.
Ptr< Object > GetMobility(void)
Return the mobility model this PHY is associated with.
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
static WifiMode GetOfdmRate150MbpsBW40MHz()
Return a WifiMode for ODFM at 150Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1383
virtual void SetGreenfield(bool greenfield)
Enable or disable Greenfield support.