A Discrete-Event Network Simulator
API
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 "ampdu-tag.h"
40 #include <cmath>
41 
42 namespace ns3 {
43 
44 NS_LOG_COMPONENT_DEFINE ("YansWifiPhy");
45 
46 NS_OBJECT_ENSURE_REGISTERED (YansWifiPhy);
47 
48 TypeId
50 {
51  static TypeId tid = TypeId ("ns3::YansWifiPhy")
52  .SetParent<WifiPhy> ()
53  .AddConstructor<YansWifiPhy> ()
54  .AddAttribute ("EnergyDetectionThreshold",
55  "The energy of a received signal should be higher than "
56  "this threshold (dbm) to allow the PHY layer to detect the signal.",
57  DoubleValue (-96.0),
60  MakeDoubleChecker<double> ())
61  .AddAttribute ("CcaMode1Threshold",
62  "The energy of a received signal should be higher than "
63  "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state",
64  DoubleValue (-99.0),
67  MakeDoubleChecker<double> ())
68  .AddAttribute ("TxGain",
69  "Transmission gain (dB).",
70  DoubleValue (1.0),
73  MakeDoubleChecker<double> ())
74  .AddAttribute ("RxGain",
75  "Reception gain (dB).",
76  DoubleValue (1.0),
79  MakeDoubleChecker<double> ())
80  .AddAttribute ("TxPowerLevels",
81  "Number of transmission power levels available between "
82  "TxPowerStart and TxPowerEnd included.",
83  UintegerValue (1),
85  MakeUintegerChecker<uint32_t> ())
86  .AddAttribute ("TxPowerEnd",
87  "Maximum available transmission level (dbm).",
88  DoubleValue (16.0206),
91  MakeDoubleChecker<double> ())
92  .AddAttribute ("TxPowerStart",
93  "Minimum available transmission level (dbm).",
94  DoubleValue (16.0206),
97  MakeDoubleChecker<double> ())
98  .AddAttribute ("RxNoiseFigure",
99  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
100  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
101  "\"the difference in decibels (dB) between"
102  " the noise output of the actual receiver to the noise output of an "
103  " ideal receiver with the same overall gain and bandwidth when the receivers "
104  " are connected to sources at the standard noise temperature T0 (usually 290 K)\"."
105  " For",
106  DoubleValue (7),
109  MakeDoubleChecker<double> ())
110  .AddAttribute ("State", "The state of the PHY layer",
111  PointerValue (),
113  MakePointerChecker<WifiPhyStateHelper> ())
114  .AddAttribute ("ChannelSwitchDelay",
115  "Delay between two short frames transmitted on different frequencies.",
116  TimeValue (MicroSeconds (250)),
118  MakeTimeChecker ())
119  .AddAttribute ("ChannelNumber",
120  "Channel center frequency = Channel starting frequency + 5 MHz * nch",
121  UintegerValue (1),
124  MakeUintegerChecker<uint16_t> ())
125  .AddAttribute ("Frequency", "The operating frequency.",
126  UintegerValue (2407),
129  MakeUintegerChecker<uint32_t> ())
130  .AddAttribute ("Transmitters", "The number of transmitters.",
131  UintegerValue (1),
134  MakeUintegerChecker<uint32_t> ())
135  .AddAttribute ("Receivers", "The number of receivers.",
136  UintegerValue (1),
139  MakeUintegerChecker<uint32_t> ())
140  .AddAttribute ("ShortGuardEnabled", "Whether or not short guard interval is enabled.",
141  BooleanValue (false),
145  .AddAttribute ("LdpcEnabled", "Whether or not LDPC is enabled.",
146  BooleanValue (false),
150  .AddAttribute ("STBCEnabled", "Whether or not STBC is enabled.",
151  BooleanValue (false),
155  .AddAttribute ("GreenfieldEnabled", "Whether or not STBC is enabled.",
156  BooleanValue (false),
160  .AddAttribute ("ChannelBonding", "Whether 20MHz or 40MHz.",
161  BooleanValue (false),
165 
166 
167  ;
168  return tid;
169 }
170 
172  : m_initialized (false),
173  m_channelNumber (1),
174  m_endRxEvent (),
175  m_channelStartingFrequency (0),
176  m_mpdusNum(0)
177 {
178  NS_LOG_FUNCTION (this);
179  m_random = CreateObject<UniformRandomVariable> ();
180  m_state = CreateObject<WifiPhyStateHelper> ();
181 }
182 
184 {
185  NS_LOG_FUNCTION (this);
186 }
187 
188 void
190 {
191  NS_LOG_FUNCTION (this);
192  m_channel = 0;
193  m_deviceRateSet.clear ();
194  m_deviceMcsSet.clear();
195  m_device = 0;
196  m_mobility = 0;
197  m_state = 0;
198 }
199 
200 void
202 {
203  NS_LOG_FUNCTION (this);
204  m_initialized = true;
205 }
206 
207 void
209 {
210  NS_LOG_FUNCTION (this << standard);
211  switch (standard)
212  {
214  Configure80211a ();
215  break;
217  Configure80211b ();
218  break;
220  Configure80211g ();
221  break;
224  break;
227  break;
229  ConfigureHolland ();
230  break;
233  Configure80211n ();
234  break;
237  Configure80211n ();
238  break;
239 
240  default:
241  NS_ASSERT (false);
242  break;
243  }
244 }
245 
246 
247 void
248 YansWifiPhy::SetRxNoiseFigure (double noiseFigureDb)
249 {
250  NS_LOG_FUNCTION (this << noiseFigureDb);
251  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
252 }
253 void
255 {
256  NS_LOG_FUNCTION (this << start);
258 }
259 void
261 {
262  NS_LOG_FUNCTION (this << end);
263  m_txPowerEndDbm = end;
264 }
265 void
267 {
268  NS_LOG_FUNCTION (this << n);
269  m_nTxPower = n;
270 }
271 void
273 {
274  NS_LOG_FUNCTION (this << gain);
275  m_txGainDb = gain;
276 }
277 void
279 {
280  NS_LOG_FUNCTION (this << gain);
281  m_rxGainDb = gain;
282 }
283 void
284 YansWifiPhy::SetEdThreshold (double threshold)
285 {
286  NS_LOG_FUNCTION (this << threshold);
287  m_edThresholdW = DbmToW (threshold);
288 }
289 void
291 {
292  NS_LOG_FUNCTION (this << threshold);
293  m_ccaMode1ThresholdW = DbmToW (threshold);
294 }
295 void
297 {
299 }
300 void
302 {
303  m_device = device;
304 }
305 void
307 {
308  m_mobility = mobility;
309 }
310 
311 double
313 {
315 }
316 double
318 {
319  return m_txPowerBaseDbm;
320 }
321 double
323 {
324  return m_txPowerEndDbm;
325 }
326 double
328 {
329  return m_txGainDb;
330 }
331 double
333 {
334  return m_rxGainDb;
335 }
336 
337 double
339 {
340  return WToDbm (m_edThresholdW);
341 }
342 
343 double
345 {
346  return WToDbm (m_ccaMode1ThresholdW);
347 }
348 
351 {
353 }
356 {
357  return m_device;
358 }
361 {
362  return m_mobility;
363 }
364 
365 double
366 YansWifiPhy::CalculateSnr (WifiMode txMode, double ber) const
367 {
368  return m_interference.GetErrorRateModel ()->CalculateSnr (txMode, ber);
369 }
370 
373 {
374  return m_channel;
375 }
376 void
378 {
379  m_channel = channel;
380  m_channel->Add (this);
381 }
382 
383 void
385 {
386  if (!m_initialized)
387  {
388  // this is not channel switch, this is initialization
389  NS_LOG_DEBUG ("start at channel " << nch);
390  m_channelNumber = nch;
391  return;
392  }
393 
395  switch (m_state->GetState ())
396  {
397  case YansWifiPhy::RX:
398  NS_LOG_DEBUG ("drop packet because of channel switching while reception");
399  m_endRxEvent.Cancel ();
400  goto switchChannel;
401  break;
402  case YansWifiPhy::TX:
403  NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
405  break;
407  case YansWifiPhy::IDLE:
408  goto switchChannel;
409  break;
410  case YansWifiPhy::SLEEP:
411  NS_LOG_DEBUG ("channel switching ignored in sleep mode");
412  break;
413  default:
414  NS_ASSERT (false);
415  break;
416  }
417 
418  return;
419 
420 switchChannel:
421 
422  NS_LOG_DEBUG ("switching channel " << m_channelNumber << " -> " << nch);
423  m_state->SwitchToChannelSwitching (m_channelSwitchDelay);
425  /*
426  * Needed here to be able to correctly sensed the medium for the first
427  * time after the switching. The actual switching is not performed until
428  * after m_channelSwitchDelay. Packets received during the switching
429  * state are added to the event list and are employed later to figure
430  * out the state of the medium after the switching.
431  */
432  m_channelNumber = nch;
433 }
434 
435 uint16_t
437 {
438  return m_channelNumber;
439 }
440 
441 Time
443 {
444  return m_channelSwitchDelay;
445 }
446 
447 double
449 {
451 }
452 
453 void
455 {
456  NS_LOG_FUNCTION (this);
457  switch (m_state->GetState ())
458  {
459  case YansWifiPhy::TX:
460  NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmission");
462  break;
463  case YansWifiPhy::RX:
464  NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception");
466  break;
468  NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching");
470  break;
472  case YansWifiPhy::IDLE:
473  NS_LOG_DEBUG ("setting sleep mode");
474  m_state->SwitchToSleep ();
475  break;
476  case YansWifiPhy::SLEEP:
477  NS_LOG_DEBUG ("already in sleep mode");
478  break;
479  default:
480  NS_ASSERT (false);
481  break;
482  }
483 }
484 
485 void
487 {
488  NS_LOG_FUNCTION (this);
489  switch (m_state->GetState ())
490  {
491  case YansWifiPhy::TX:
492  case YansWifiPhy::RX:
493  case YansWifiPhy::IDLE:
496  NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume");
497  break;
498  case YansWifiPhy::SLEEP:
499  NS_LOG_DEBUG ("resuming from sleep mode");
501  m_state->SwitchFromSleep (delayUntilCcaEnd);
502  break;
503  }
504 }
505 
506 void
508 {
509  m_state->SetReceiveOkCallback (callback);
510 }
511 void
513 {
514  m_state->SetReceiveErrorCallback (callback);
515 }
516 void
518  double rxPowerDbm,
519  WifiTxVector txVector,
520  enum WifiPreamble preamble,
521  uint8_t packetType, Time rxDuration)
522 {
523  NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode()<< preamble << (uint32_t)packetType);
524  AmpduTag ampduTag;
525  rxPowerDbm += m_rxGainDb;
526  double rxPowerW = DbmToW (rxPowerDbm);
527  WifiMode txMode = txVector.GetMode();
528  Time endRx = Simulator::Now () + rxDuration;
529 
531  event = m_interference.Add (packet->GetSize (),
532  txMode,
533  preamble,
534  rxDuration,
535  rxPowerW,
536  txVector); // we need it to calculate duration of HT training symbols
537 
538  switch (m_state->GetState ())
539  {
541  NS_LOG_DEBUG ("drop packet because of channel switching");
542  NotifyRxDrop (packet);
543  /*
544  * Packets received on the upcoming channel are added to the event list
545  * during the switching state. This way the medium can be correctly sensed
546  * when the device listens to the channel for the first time after the
547  * switching e.g. after channel switching, the channel may be sensed as
548  * busy due to other devices' tramissions started before the end of
549  * the switching.
550  */
551  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
552  {
553  // that packet will be noise _after_ the completion of the
554  // channel switching.
555  goto maybeCcaBusy;
556  }
557  break;
558  case YansWifiPhy::RX:
559  NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
560  rxPowerW << "W)");
561  NotifyRxDrop (packet);
562  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
563  {
564  // that packet will be noise _after_ the reception of the
565  // currently-received packet.
566  goto maybeCcaBusy;
567  }
568  break;
569  case YansWifiPhy::TX:
570  NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
571  rxPowerW << "W)");
572  NotifyRxDrop (packet);
573  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
574  {
575  // that packet will be noise _after_ the transmission of the
576  // currently-transmitted packet.
577  goto maybeCcaBusy;
578  }
579  break;
581  case YansWifiPhy::IDLE:
582  if (rxPowerW > m_edThresholdW)
583  {
584  if (IsModeSupported (txMode) || IsMcsSupported(txMode))
585  {
586  if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
587  {
588  //received the first MPDU in an MPDU
589  m_mpdusNum = ampduTag.GetNoOfMpdus()-1;
590  }
591  else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
592  {
593  //received the other MPDUs that are part of the A-MPDU
594  if (ampduTag.GetNoOfMpdus() < m_mpdusNum)
595  {
596  NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetNoOfMpdus());
597  m_mpdusNum = ampduTag.GetNoOfMpdus();
598  }
599  else
600  m_mpdusNum--;
601  }
602  else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 )
603  {
604  NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum);
605  m_mpdusNum = 0;
606  }
607  else if (preamble == WIFI_PREAMBLE_NONE && m_mpdusNum == 0)
608  {
609  NS_LOG_DEBUG ("drop packet because no preamble has been received");
610  NotifyRxDrop (packet);
611  goto maybeCcaBusy;
612  }
613  NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
614  // sync to signal
615  m_state->SwitchToRx (rxDuration);
617  NotifyRxBegin (packet);
620  packet,
621  event);
622  }
623  else
624  {
625  NS_LOG_DEBUG ("drop packet because it was sent using an unsupported mode (" << txMode << ")");
626  NotifyRxDrop (packet);
627  goto maybeCcaBusy;
628  }
629  }
630  else
631  {
632  NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
633  rxPowerW << "<" << m_edThresholdW << ")");
634  NotifyRxDrop (packet);
635  goto maybeCcaBusy;
636  }
637  break;
638  case YansWifiPhy::SLEEP:
639  NS_LOG_DEBUG ("drop packet because in sleep mode");
640  NotifyRxDrop (packet);
641  break;
642  }
643 
644  return;
645 
646 maybeCcaBusy:
647  // We are here because we have received the first bit of a packet and we are
648  // not going to be able to synchronize on it
649  // In this model, CCA becomes busy when the aggregation of all signals as
650  // tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
651 
653  if (!delayUntilCcaEnd.IsZero ())
654  {
655  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
656  }
657 }
658 
659 void
660 YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType)
661 {
662  NS_LOG_FUNCTION (this << packet << txVector.GetMode() << preamble << (uint32_t)txVector.GetTxPowerLevel() << (uint32_t)packetType);
663  /* Transmission can happen if:
664  * - we are syncing on a packet. It is the responsability of the
665  * MAC layer to avoid doing this but the PHY does nothing to
666  * prevent it.
667  * - we are idle
668  */
669  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
670 
671  if (m_state->IsStateSleep ())
672  {
673  NS_LOG_DEBUG ("Dropping packet because in sleep mode");
674  NotifyTxDrop (packet);
675  return;
676  }
677 
678  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble, GetFrequency(), packetType, 1);
679  if (m_state->IsStateRx ())
680  {
681  m_endRxEvent.Cancel ();
683  }
684  NotifyTxBegin (packet);
685  uint32_t dataRate500KbpsUnits;
686  if (txVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
687  {
688  dataRate500KbpsUnits = 128 + WifiModeToMcs (txVector.GetMode());
689  }
690  else
691  {
692  dataRate500KbpsUnits = txVector.GetMode().GetDataRate () * txVector.GetNss() / 500000;
693  }
694  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
695  NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, txVector.GetTxPowerLevel());
696  m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel()), txVector, preamble);
697  m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel()) + m_txGainDb, txVector, preamble, packetType, txDuration);
698 }
699 
700 uint32_t
702 {
703  return m_deviceRateSet.size ();
704 }
705 WifiMode
706 YansWifiPhy::GetMode (uint32_t mode) const
707 {
708  return m_deviceRateSet[mode];
709 }
710 bool
712 {
713  for (uint32_t i = 0; i < GetNModes (); i++)
714  {
715  if (mode == GetMode (i))
716  {
717  return true;
718  }
719  }
720  return false;
721 }
722 bool
724 {
725  for (uint32_t i = 0; i < GetNMcs (); i++)
726  {
727  if (mode == McsToWifiMode(GetMcs (i)))
728  {
729  return true;
730  }
731  }
732  return false;
733 }
734 uint32_t
736 {
737  return m_nTxPower;
738 }
739 
740 void
742 {
743  NS_LOG_FUNCTION (this);
744  m_channelStartingFrequency = 5e3; // 5.000 GHz
745 
754 }
755 
756 
757 void
759 {
760  NS_LOG_FUNCTION (this);
761  m_channelStartingFrequency = 2407; // 2.407 GHz
762 
767 }
768 
769 void
771 {
772  NS_LOG_FUNCTION (this);
773  m_channelStartingFrequency = 2407; // 2.407 GHz
774 
787 }
788 
789 void
791 {
792  NS_LOG_FUNCTION (this);
793  m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a
794 
803 }
804 
805 void
807 {
808  NS_LOG_FUNCTION (this);
809  m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a
810 
819 }
820 
821 void
823 {
824  NS_LOG_FUNCTION (this);
825  m_channelStartingFrequency = 5e3; // 5.000 GHz
831 }
832 
833 void
835 {
836  m_state->RegisterListener (listener);
837 }
838 
839 void
841 {
842  m_state->UnregisterListener (listener);
843 }
844 
845 bool
847 {
848  return m_state->IsStateCcaBusy ();
849 }
850 
851 bool
853 {
854  return m_state->IsStateIdle ();
855 }
856 bool
858 {
859  return m_state->IsStateBusy ();
860 }
861 bool
863 {
864  return m_state->IsStateRx ();
865 }
866 bool
868 {
869  return m_state->IsStateTx ();
870 }
871 bool
873 {
874  return m_state->IsStateSwitching ();
875 }
876 bool
878 {
879  return m_state->IsStateSleep ();
880 }
881 
882 Time
884 {
885  return m_state->GetStateDuration ();
886 }
887 Time
889 {
890  return m_state->GetDelayUntilIdle ();
891 }
892 
893 Time
895 {
896  return m_state->GetLastRxStartTime ();
897 }
898 
899 double
900 YansWifiPhy::DbToRatio (double dB) const
901 {
902  double ratio = std::pow (10.0, dB / 10.0);
903  return ratio;
904 }
905 
906 double
907 YansWifiPhy::DbmToW (double dBm) const
908 {
909  double mW = std::pow (10.0, dBm / 10.0);
910  return mW / 1000.0;
911 }
912 
913 double
914 YansWifiPhy::WToDbm (double w) const
915 {
916  return 10.0 * std::log10 (w * 1000.0);
917 }
918 
919 double
920 YansWifiPhy::RatioToDb (double ratio) const
921 {
922  return 10.0 * std::log10 (ratio);
923 }
924 
925 double
927 {
928  return m_edThresholdW;
929 }
930 
931 double
932 YansWifiPhy::GetPowerDbm (uint8_t power) const
933 {
935  NS_ASSERT (m_nTxPower > 0);
936  double dbm;
937  if (m_nTxPower > 1)
938  {
939  dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
940  }
941  else
942  {
943  NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
944  dbm = m_txPowerBaseDbm;
945  }
946  return dbm;
947 }
948 
949 void
951 {
952  NS_LOG_FUNCTION (this << packet << event);
953  NS_ASSERT (IsStateRx ());
954  NS_ASSERT (event->GetEndTime () == Simulator::Now ());
955 
956  struct InterferenceHelper::SnrPer snrPer;
957  snrPer = m_interference.CalculateSnrPer (event);
959 
960  NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate ()) <<
961  ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
962  if (m_random->GetValue () > snrPer.per)
963  {
964  NotifyRxEnd (packet);
965  uint32_t dataRate500KbpsUnits;
966  if ((event->GetPayloadMode ().GetModulationClass () == WIFI_MOD_CLASS_HT))
967  {
968  dataRate500KbpsUnits = 128 + WifiModeToMcs (event->GetPayloadMode ());
969  }
970  else
971  {
972  dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () * event->GetTxVector().GetNss()/ 500000;
973  }
974  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
975  double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
976  double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
977  NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
978  m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
979  }
980  else
981  {
982  /* failure. */
983  NotifyRxDrop (packet);
984  m_state->SwitchFromRxEndError (packet, snrPer.snr);
985  }
986 }
987 
988 int64_t
990 {
991  NS_LOG_FUNCTION (this << stream);
992  m_random->SetStream (stream);
993  return 1;
994 }
995 
996 void
998 {
1000 }
1001 
1002 void
1004 {
1006 }
1007 void
1009 {
1010  m_numberOfReceivers = rx;
1011 }
1012 
1013 void
1015 {
1016  m_ldpc = Ldpc;
1017 }
1018 
1019 void
1021 {
1022  m_stbc = stbc;
1023 }
1024 
1025 void
1027 {
1028  m_greenfield = greenfield;
1029 }
1030 bool
1032 {
1033  return m_guardInterval;
1034 }
1035 void
1036 YansWifiPhy::SetGuardInterval (bool guardInterval)
1037 {
1038  m_guardInterval = guardInterval;
1039 }
1040 
1041 uint32_t
1043 {
1045 }
1046 
1047 uint32_t
1049 {
1050  return m_numberOfTransmitters;
1051 }
1052 uint32_t
1054 {
1055  return m_numberOfReceivers;
1056 }
1057 
1058 bool
1060 {
1061  return m_ldpc;
1062 }
1063 bool
1065 {
1066  return m_stbc;
1067 }
1068 
1069 bool
1071 {
1072  return m_greenfield;
1073 }
1074 
1075 bool
1077 {
1078  return m_channelBonding;
1079 }
1080 
1081 void
1082 YansWifiPhy::SetChannelBonding(bool channelbonding)
1083 {
1084  m_channelBonding= channelbonding;
1085 }
1086 
1087 void
1089 {
1090  NS_LOG_FUNCTION (this);
1091  if (m_channelStartingFrequency>=2400 && m_channelStartingFrequency<=2500) //@ 2.4 GHz
1092  {
1100  }
1101  if (m_channelStartingFrequency>=5000 && m_channelStartingFrequency<=6000) //@ 5 GHz
1102  {
1106  }
1108  for (uint8_t i=0; i <8; i++)
1109  {
1110  m_deviceMcsSet.push_back(i);
1111  }
1112 
1113 }
1114 uint32_t
1116 {
1117  return m_bssMembershipSelectorSet.size ();
1118 }
1119 uint32_t
1120 YansWifiPhy::GetBssMembershipSelector (uint32_t selector) const
1121 {
1122  return m_bssMembershipSelectorSet[selector];
1123 }
1126 {
1127  uint32_t id=GetBssMembershipSelector(selector);
1128  WifiModeList supportedmodes;
1129  if (id == HT_PHY)
1130  {
1131  //mandatory MCS 0 to 7
1132  supportedmodes.push_back (WifiPhy::GetOfdmRate6_5MbpsBW20MHz ());
1133  supportedmodes.push_back (WifiPhy::GetOfdmRate13MbpsBW20MHz ());
1134  supportedmodes.push_back (WifiPhy::GetOfdmRate19_5MbpsBW20MHz ());
1135  supportedmodes.push_back (WifiPhy::GetOfdmRate26MbpsBW20MHz ());
1136  supportedmodes.push_back (WifiPhy::GetOfdmRate39MbpsBW20MHz ());
1137  supportedmodes.push_back (WifiPhy::GetOfdmRate52MbpsBW20MHz ());
1138  supportedmodes.push_back (WifiPhy::GetOfdmRate58_5MbpsBW20MHz ());
1139  supportedmodes.push_back (WifiPhy::GetOfdmRate65MbpsBW20MHz ());
1140  }
1141  return supportedmodes;
1142 }
1143 uint8_t
1145 {
1146  return m_deviceMcsSet.size ();
1147 }
1148 uint8_t
1149 YansWifiPhy::GetMcs (uint8_t mcs) const
1150 {
1151  return m_deviceMcsSet[mcs];
1152 }
1153 uint32_t
1155 {
1156  uint32_t mcs = 0;
1157  if (mode.GetUniqueName() == "OfdmRate135MbpsBW40MHzShGi" || mode.GetUniqueName() == "OfdmRate65MbpsBW20MHzShGi" )
1158  {
1159  mcs=6;
1160  }
1161  else
1162  {
1163  switch (mode.GetDataRate())
1164  {
1165  case 6500000:
1166  case 7200000:
1167  case 13500000:
1168  case 15000000:
1169  mcs=0;
1170  break;
1171  case 13000000:
1172  case 14400000:
1173  case 27000000:
1174  case 30000000:
1175  mcs=1;
1176  break;
1177  case 19500000:
1178  case 21700000:
1179  case 40500000:
1180  case 45000000:
1181  mcs=2;
1182  break;
1183  case 26000000:
1184  case 28900000:
1185  case 54000000:
1186  case 60000000:
1187  mcs=3;
1188  break;
1189  case 39000000:
1190  case 43300000:
1191  case 81000000:
1192  case 90000000:
1193  mcs=4;
1194  break;
1195  case 52000000:
1196  case 57800000:
1197  case 108000000:
1198  case 120000000:
1199  mcs=5;
1200  break;
1201  case 58500000:
1202  case 121500000:
1203  mcs=6;
1204  break;
1205  case 65000000:
1206  case 72200000:
1207  case 135000000:
1208  case 150000000:
1209  mcs=7;
1210  break;
1211  }
1212  }
1213  return mcs;
1214 }
1215 WifiMode
1217 {
1218  WifiMode mode;
1219  switch (mcs)
1220  {
1221  case 7:
1222  if (!GetGuardInterval() && !GetChannelBonding())
1223  {
1225  }
1226  else if(GetGuardInterval() && !GetChannelBonding())
1227  {
1229  }
1230  else if (!GetGuardInterval() && GetChannelBonding())
1231  {
1233  }
1234  else
1235  {
1237  }
1238  break;
1239  case 6:
1240  if (!GetGuardInterval() && !GetChannelBonding())
1241  {
1243 
1244  }
1245  else if(GetGuardInterval() && !GetChannelBonding())
1246  {
1248 
1249  }
1250  else if (!GetGuardInterval() && GetChannelBonding())
1251  {
1253 
1254  }
1255  else
1256  {
1258 
1259  }
1260  break;
1261  case 5:
1262  if (!GetGuardInterval() && !GetChannelBonding())
1263  {
1265 
1266  }
1267  else if(GetGuardInterval() && !GetChannelBonding())
1268  {
1270  }
1271  else if (!GetGuardInterval() && GetChannelBonding())
1272  {
1274 
1275  }
1276  else
1277  {
1279 
1280  }
1281  break;
1282  case 4:
1283  if (!GetGuardInterval() && !GetChannelBonding())
1284  {
1286  }
1287  else if(GetGuardInterval() && !GetChannelBonding())
1288  {
1290  }
1291  else if (!GetGuardInterval() && GetChannelBonding())
1292  {
1294 
1295  }
1296  else
1297  {
1299 
1300  }
1301  break;
1302  case 3:
1303  if (!GetGuardInterval() && !GetChannelBonding())
1304  {
1306 
1307  }
1308  else if(GetGuardInterval() && !GetChannelBonding())
1309  {
1311 
1312  }
1313  else if (!GetGuardInterval() && GetChannelBonding())
1314  {
1316 
1317  }
1318  else
1319  {
1321  }
1322  break;
1323  case 2:
1324  if (!GetGuardInterval() && !GetChannelBonding())
1325  {
1327 
1328  }
1329  else if(GetGuardInterval() && !GetChannelBonding())
1330  {
1332 
1333  }
1334  else if (!GetGuardInterval() && GetChannelBonding())
1335  {
1337 
1338  }
1339  else
1340  {
1342 
1343  }
1344  break;
1345  case 1:
1346  if (!GetGuardInterval() && !GetChannelBonding())
1347  {
1349 
1350  }
1351  else if(GetGuardInterval() && !GetChannelBonding())
1352  {
1354  }
1355  else if (!GetGuardInterval() && GetChannelBonding())
1356  {
1358 
1359  }
1360  else
1361  {
1363  }
1364  break;
1365  case 0:
1366  default:
1367  if (!GetGuardInterval() && !GetChannelBonding())
1368  {
1370 
1371  }
1372  else if(GetGuardInterval() && !GetChannelBonding())
1373  {
1375  }
1376  else if (!GetGuardInterval() && GetChannelBonding())
1377  {
1379 
1380  }
1381  else
1382  {
1384  }
1385  break;
1386  }
1387  return mode;
1388 }
1389 } // namespace ns3
ERP-OFDM PHY (Clause 19, Section 19.5)
uint16_t m_channelNumber
Operating channel number.
bool m_channelBonding
Flag if channel bonding is used.
static WifiMode GetOfdmRate9MbpsBW5MHz()
Return a WifiMode for OFDM at 9Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1081
static WifiMode GetErpOfdmRate24Mbps()
Return a WifiMode for ERP-OFDM at 24Mbps.
Definition: wifi-phy.cc:749
static WifiMode GetDsssRate11Mbps()
Return a WifiMode for DSSS at 11Mbps.
Definition: wifi-phy.cc:681
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-OFDM at 36Mbps.
Definition: wifi-phy.cc:762
A struct for both SNR and PER.
uint16_t GetChannelNumber(void) const
Return the current channel number.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
OFDM PHY for the 5 GHz band (Clause 17 with 5 MHz channel bandwidth)
void 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 OFDM at 26Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1199
AttributeValue implementation for Boolean.
Definition: boolean.h:34
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 OFDM at 9Mbps.
Definition: wifi-phy.cc:817
double DbToRatio(double db) const
Convert from dB to ratio.
static WifiMode GetOfdmRate7_2MbpsBW20MHz()
Return a WifiMode for OFDM at 7.2Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1134
static WifiMode GetOfdmRate18MbpsBW10MHz()
Return a WifiMode for OFDM at 18Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:975
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:1001
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
Sets the error rate model.
virtual bool IsStateSwitching(void)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
virtual bool IsStateTx(void)
static WifiMode GetOfdmRate3MbpsBW5MHz()
Return a WifiMode for OFDM at 3Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1042
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1Mbps.
Definition: wifi-phy.cc:639
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:630
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 OFDM at 81Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1432
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-OFDM at 18Mbps.
Definition: wifi-phy.cc:736
The PHY layer has sense the medium busy through the CCA mechanism.
Definition: wifi-phy.h:141
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
bool IsZero(void) const
Definition: nstime.h:269
def start()
Definition: core.py:1482
virtual void SetGuardInterval(bool guardInterval)
Enable or disable short/long guard interval.
static WifiMode GetOfdmRate12Mbps()
Return a WifiMode for OFDM at 12Mbps.
Definition: wifi-phy.cc:830
enum WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:115
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 OFDM at 43.3Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1238
Time GetEnergyDuration(double energyW)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
virtual void RegisterListener(WifiPhyListener *listener)
static WifiMode GetOfdmRate60MbpsBW40MHz()
Return a WifiMode for OFDM at 60Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1419
static WifiMode GetOfdmRate1_5MbpsBW5MHz()
Return a WifiMode for OFDM at 1.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1016
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:766
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
The PHY layer is sleeping.
Definition: wifi-phy.h:157
double m_txPowerBaseDbm
Minimum transmission power (dBm)
static WifiMode GetOfdmRate4_5MbpsBW10MHz()
Return a WifiMode for OFDM at 4.5Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:923
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54Mbps.
Definition: wifi-phy.cc:895
virtual bool IsMcsSupported(WifiMode mode)
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:600
static WifiMode GetOfdmRate108MbpsBW40MHz()
Return a WifiMode for OFDM at 108Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1457
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:819
virtual bool IsStateSleep(void)
static WifiMode GetOfdmRate21_7MbpsBW20MHz()
Return a WifiMode for OFDM at 21.7Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1185
void NotifyTxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyTxBegin trace.
Definition: wifi-phy.cc:588
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:93
void Configure80211g(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
static WifiMode GetOfdmRate135MbpsBW40MHz()
Return a WifiMode for OFDM at 135Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1505
static WifiMode GetOfdmRate36Mbps()
Return a WifiMode for OFDM at 36Mbps.
Definition: wifi-phy.cc:869
static WifiMode GetOfdmRate6MbpsBW5MHz()
Return a WifiMode for OFDM at 6Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1068
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
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:439
static WifiMode GetErpOfdmRate54Mbps()
Return a WifiMode for ERP-OFDM at 54Mbps.
Definition: wifi-phy.cc:788
virtual void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
void NotifyRxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:618
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 OFDM at 6.5Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1122
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.
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:858
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 OFDM at 135Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1493
bool m_ldpc
Flag if LDPC is used.
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:210
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...
AttributeValue implementation for Time.
Definition: nstime.h:921
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:44
Ptr< Object > m_device
Pointer to the device.
The PHY layer is IDLE.
Definition: wifi-phy.h:137
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-OFDM at 48Mbps.
Definition: wifi-phy.cc:775
double m_ccaMode1ThresholdW
Clear channel assessment (CCA) threshold in watts.
virtual void DoDispose(void)
Destructor implementation.
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 OFDM at 12Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:962
virtual uint32_t GetBssMembershipSelector(uint32_t selector) const
The WifiPhy::BssMembershipSelector() method is used (e.g., by a WifiRemoteStationManager) to determin...
HT PHY (Clause 20)
Definition: wifi-mode.h:56
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:97
The PHY layer is receiving a packet.
Definition: wifi-phy.h:149
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.
The aim of the AmpduTag is to provide means for a MAC to specify that a packet includes A-MPDU since ...
Definition: ampdu-tag.h:35
void NotifyRxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyRxBegin trace.
Definition: wifi-phy.cc:606
static WifiMode GetOfdmRate19_5MbpsBW20MHz()
Return a WifiMode for OFDM at 19.5Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1172
The PHY layer is sending a packet.
Definition: wifi-phy.h:145
static WifiMode GetOfdmRate18Mbps()
Return a WifiMode for OFDM at 18Mbps.
Definition: wifi-phy.cc:843
double GetChannelFrequencyMhz() const
Return current center channel frequency in MHz.
Time CalculateTxDuration(uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble, double frequency, uint8_t packetType, uint8_t incFlag)
Definition: wifi-phy.cc:576
static WifiMode GetOfdmRate9MbpsBW10MHz()
Return a WifiMode for OFDM at 9Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:949
static WifiMode GetOfdmRate12MbpsBW5MHz()
Return a WifiMode for OFDM at 12Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1094
static WifiMode GetOfdmRate52MbpsBW20MHz()
Return a WifiMode for OFDM at 52Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1251
The PHY layer is switching to other channel.
Definition: wifi-phy.h:153
double WToDbm(double w) const
Convert from Watts to dBm.
static WifiMode GetOfdmRate40_5MbpsBW40MHz()
Return a WifiMode for OFDM at 40.5Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1381
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 OFDM at 72.2Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1317
static WifiMode GetOfdmRate65MbpsBW20MHzShGi()
Return a WifiMode for OFDM at 65Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1291
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 OFDM at 48Mbps.
Definition: wifi-phy.cc:882
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:624
double m_txPowerEndDbm
Maximum transmission power (dBm)
virtual void SetReceiveOkCallback(WifiPhy::RxOkCallback callback)
virtual void UnregisterListener(WifiPhyListener *listener)
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)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void NotifyRxStart()
Notify that RX has started.
Hold objects of type Ptr.
Definition: pointer.h:36
static WifiMode GetOfdmRate57_8MbpsBW20MHz()
Return a WifiMode for OFDM at 57.8Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1264
void EraseEvents(void)
Erase all events.
static WifiMode GetOfdmRate24Mbps()
Return a WifiMode for OFDM at 24Mbps.
Definition: wifi-phy.cc:856
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
double GetEdThreshold(void) const
Return the energy detection threshold (dBm).
static TypeId GetTypeId(void)
static WifiMode GetOfdmRate13MbpsBW20MHz()
Return a WifiMode for OFDM at 13Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1147
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 OFDM at 65Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1304
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 OFDM at 58.5Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1278
uint32_t m_nTxPower
Number of available transmission power levels.
virtual void SendPacket(Ptr< const Packet > packet, WifiTxVector txvector, enum WifiPreamble preamble, uint8_t packetType)
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:668
static WifiMode GetOfdmRate2_25MbpsBW5MHz()
Return a WifiMode for OFDM at 2.25Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1029
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:922
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:177
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
static WifiMode GetErpOfdmRate9Mbps()
Return a WifiMode for ERP-OFDM at 9Mbps.
Definition: wifi-phy.cc:710
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 OFDM at 15Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1343
static WifiMode GetOfdmRate121_5MbpsBW40MHz()
Return a WifiMode for OFDM at 121.5Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1481
virtual void DoInitialize(void)
Initialize() implementation.
Time GetChannelSwitchDelay(void) const
#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
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
static WifiMode GetOfdmRate28_9MbpsBW20MHz()
Return a WifiMode for OFDM at 28.9Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1212
virtual bool IsStateIdle(void)
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-OFDM at 6Mbps.
Definition: wifi-phy.cc:697
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
uint8_t GetNss(void) const
InterferenceHelper m_interference
Pointer to InterferenceHelper.
static WifiMode GetErpOfdmRate12Mbps()
Return a WifiMode for ERP-OFDM at 12Mbps.
Definition: wifi-phy.cc:723
virtual bool GetGuardInterval(void) const
Return whether guard interval is being used.
void StartReceivePacket(Ptr< Packet > packet, double rxPowerDbm, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType, Time rxDuration)
Starting receiving the packet (i.e.
void NotifyRxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyRxEnd trace.
Definition: wifi-phy.cc:612
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 OFDM at 13.5Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1330
static WifiMode GetOfdmRate30MbpsBW40MHz()
Return a WifiMode for OFDM at 30Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1368
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
static WifiMode GetOfdmRate54MbpsBW40MHz()
Return a WifiMode for OFDM at 54Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1406
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:53
uint16_t m_mpdusNum
carries the number of expected mpdus that are part of an A-MPDU
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 OFDM at 90Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1444
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:875
virtual void SetNumberOfReceiveAntennas(uint32_t rx)
static WifiMode GetOfdmRate45MbpsBW40MHz()
Return a WifiMode for OFDM at 45Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1393
uint32_t m_numberOfTransmitters
Number of transmitters.
static WifiMode GetOfdmRate120MbpsBW40MHz()
Return a WifiMode for OFDM at 120Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1469
double GetEdThresholdW(void) const
Return the energy detection threshold.
static WifiMode GetOfdmRate39MbpsBW20MHz()
Return a WifiMode for OFDM at 39Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1225
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:652
void SetCcaMode1Threshold(double threshold)
Sets the CCA threshold (dBm).
static WifiMode GetOfdmRate6MbpsBW10MHz()
Return a WifiMode for OFDM at 6Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:936
WifiMode GetMode(void) const
void ConfigureHolland(void)
double GetNoiseFigure(void) const
Return the noise figure.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
double GetRxNoiseFigure(void) const
Return the RX noise figure (dBm).
static WifiMode GetOfdmRate24MbpsBW10MHz()
Return a WifiMode for OFDM at 24Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:988
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
Return a WifiMode for OFDM at 13.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1107
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:59
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
a unique identifier for an interface.
Definition: type-id.h:51
uint32_t m_numberOfReceivers
Number of receivers.
virtual void ResumeFromSleep(void)
Resume from sleep mode.
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:631
bool m_initialized
Flag for runtime initialization.
uint8_t GetNoOfMpdus(void) const
Definition: ampdu-tag.cc:93
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6Mbps.
Definition: wifi-phy.cc:804
static WifiMode GetOfdmRate27MbpsBW40MHz()
Return a WifiMode for OFDM at 27Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1356
virtual void SetFrequency(uint32_t freq)
static WifiMode GetOfdmRate4_5MbpsBW5MHz()
Return a WifiMode for OFDM at 4.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1055
static WifiMode GetOfdmRate14_4MbpsBW20MHz()
Return a WifiMode for OFDM at 14.4Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1160
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 OFDM at 3Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:910
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 OFDM at 150Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1518
virtual void SetGreenfield(bool greenfield)
Enable or disable Greenfield support.