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  default:
401  NS_ASSERT (false);
402  break;
403  }
404 
405  return;
406 
407 switchChannel:
408 
409  NS_LOG_DEBUG ("switching channel " << m_channelNumber << " -> " << nch);
410  m_state->SwitchToChannelSwitching (m_channelSwitchDelay);
412  /*
413  * Needed here to be able to correctly sensed the medium for the first
414  * time after the switching. The actual switching is not performed until
415  * after m_channelSwitchDelay. Packets received during the switching
416  * state are added to the event list and are employed later to figure
417  * out the state of the medium after the switching.
418  */
419  m_channelNumber = nch;
420 }
421 
422 uint16_t
424 {
425  return m_channelNumber;
426 }
427 
428 double
430 {
432 }
433 
434 void
436 {
437  m_state->SetReceiveOkCallback (callback);
438 }
439 void
441 {
442  m_state->SetReceiveErrorCallback (callback);
443 }
444 void
446  double rxPowerDbm,
447  WifiTxVector txVector,
448  enum WifiPreamble preamble)
449 {
450  NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode()<< preamble);
451  rxPowerDbm += m_rxGainDb;
452  double rxPowerW = DbmToW (rxPowerDbm);
453  Time rxDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble);
454 WifiMode txMode=txVector.GetMode();
455  Time endRx = Simulator::Now () + rxDuration;
456 
458  event = m_interference.Add (packet->GetSize (),
459  txMode,
460  preamble,
461  rxDuration,
462  rxPowerW,
463  txVector); // we need it to calculate duration of HT training symbols
464 
465  switch (m_state->GetState ())
466  {
468  NS_LOG_DEBUG ("drop packet because of channel switching");
469  NotifyRxDrop (packet);
470  /*
471  * Packets received on the upcoming channel are added to the event list
472  * during the switching state. This way the medium can be correctly sensed
473  * when the device listens to the channel for the first time after the
474  * switching e.g. after channel switching, the channel may be sensed as
475  * busy due to other devices' tramissions started before the end of
476  * the switching.
477  */
478  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
479  {
480  // that packet will be noise _after_ the completion of the
481  // channel switching.
482  goto maybeCcaBusy;
483  }
484  break;
485  case YansWifiPhy::RX:
486  NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
487  rxPowerW << "W)");
488  NotifyRxDrop (packet);
489  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
490  {
491  // that packet will be noise _after_ the reception of the
492  // currently-received packet.
493  goto maybeCcaBusy;
494  }
495  break;
496  case YansWifiPhy::TX:
497  NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
498  rxPowerW << "W)");
499  NotifyRxDrop (packet);
500  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
501  {
502  // that packet will be noise _after_ the transmission of the
503  // currently-transmitted packet.
504  goto maybeCcaBusy;
505  }
506  break;
508  case YansWifiPhy::IDLE:
509  if (rxPowerW > m_edThresholdW)
510  {
511  NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
512  // sync to signal
513  m_state->SwitchToRx (rxDuration);
515  NotifyRxBegin (packet);
518  packet,
519  event);
520  }
521  else
522  {
523  NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
524  rxPowerW << "<" << m_edThresholdW << ")");
525  NotifyRxDrop (packet);
526  goto maybeCcaBusy;
527  }
528  break;
529  }
530 
531  return;
532 
533 maybeCcaBusy:
534  // We are here because we have received the first bit of a packet and we are
535  // not going to be able to synchronize on it
536  // In this model, CCA becomes busy when the aggregation of all signals as
537  // tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
538 
540  if (!delayUntilCcaEnd.IsZero ())
541  {
542  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
543  }
544 }
545 
546 void
548 {
549  NS_LOG_FUNCTION (this << packet << txMode << preamble << (uint32_t)txVector.GetTxPowerLevel());
550  /* Transmission can happen if:
551  * - we are syncing on a packet. It is the responsability of the
552  * MAC layer to avoid doing this but the PHY does nothing to
553  * prevent it.
554  * - we are idle
555  */
556  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
557 
558  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble);
559  if (m_state->IsStateRx ())
560  {
561  m_endRxEvent.Cancel ();
563  }
564  NotifyTxBegin (packet);
565  uint32_t dataRate500KbpsUnits = txVector.GetMode().GetDataRate () * txVector.GetNss() / 500000;
566  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
567  NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, txVector.GetTxPowerLevel());
568  m_state->SwitchToTx (txDuration, packet, txVector.GetMode(), preamble, txVector.GetTxPowerLevel());
569  m_channel->Send (this, packet, GetPowerDbm ( txVector.GetTxPowerLevel()) + m_txGainDb, txVector, preamble);
570 }
571 
572 uint32_t
574 {
575  return m_deviceRateSet.size ();
576 }
577 WifiMode
578 YansWifiPhy::GetMode (uint32_t mode) const
579 {
580  return m_deviceRateSet[mode];
581 }
582 uint32_t
584 {
585  return m_nTxPower;
586 }
587 
588 void
590 {
591  NS_LOG_FUNCTION (this);
592  m_channelStartingFrequency = 5e3; // 5.000 GHz
593 
602 }
603 
604 
605 void
607 {
608  NS_LOG_FUNCTION (this);
609  m_channelStartingFrequency = 2407; // 2.407 GHz
610 
615 }
616 
617 void
619 {
620  NS_LOG_FUNCTION (this);
621  m_channelStartingFrequency = 2407; // 2.407 GHz
622 
635 }
636 
637 void
639 {
640  NS_LOG_FUNCTION (this);
641  m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a
642 
651 }
652 
653 void
655 {
656  NS_LOG_FUNCTION (this);
657  m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a
658 
667 }
668 
669 void
671 {
672  NS_LOG_FUNCTION (this);
673  m_channelStartingFrequency = 5e3; // 5.000 GHz
679 }
680 
681 void
683 {
684  m_state->RegisterListener (listener);
685 }
686 
687 bool
689 {
690  return m_state->IsStateCcaBusy ();
691 }
692 
693 bool
695 {
696  return m_state->IsStateIdle ();
697 }
698 bool
700 {
701  return m_state->IsStateBusy ();
702 }
703 bool
705 {
706  return m_state->IsStateRx ();
707 }
708 bool
710 {
711  return m_state->IsStateTx ();
712 }
713 bool
715 {
716  return m_state->IsStateSwitching ();
717 }
718 
719 Time
721 {
722  return m_state->GetStateDuration ();
723 }
724 Time
726 {
727  return m_state->GetDelayUntilIdle ();
728 }
729 
730 Time
732 {
733  return m_state->GetLastRxStartTime ();
734 }
735 
736 double
737 YansWifiPhy::DbToRatio (double dB) const
738 {
739  double ratio = std::pow (10.0, dB / 10.0);
740  return ratio;
741 }
742 
743 double
744 YansWifiPhy::DbmToW (double dBm) const
745 {
746  double mW = std::pow (10.0, dBm / 10.0);
747  return mW / 1000.0;
748 }
749 
750 double
751 YansWifiPhy::WToDbm (double w) const
752 {
753  return 10.0 * std::log10 (w * 1000.0);
754 }
755 
756 double
757 YansWifiPhy::RatioToDb (double ratio) const
758 {
759  return 10.0 * std::log10 (ratio);
760 }
761 
762 double
764 {
765  return m_edThresholdW;
766 }
767 
768 double
769 YansWifiPhy::GetPowerDbm (uint8_t power) const
770 {
772  NS_ASSERT (m_nTxPower > 0);
773  double dbm;
774  if (m_nTxPower > 1)
775  {
776  dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
777  }
778  else
779  {
780  NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
781  dbm = m_txPowerBaseDbm;
782  }
783  return dbm;
784 }
785 
786 void
788 {
789  NS_LOG_FUNCTION (this << packet << event);
790  NS_ASSERT (IsStateRx ());
791  NS_ASSERT (event->GetEndTime () == Simulator::Now ());
792 
793  struct InterferenceHelper::SnrPer snrPer;
794  snrPer = m_interference.CalculateSnrPer (event);
796 
797  NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate ()) <<
798  ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
799  if (m_random->GetValue () > snrPer.per)
800  {
801  NotifyRxEnd (packet);
802  uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () * event->GetTxVector().GetNss()/ 500000;
803  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
804  double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
805  double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
806  NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
807  m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
808  }
809  else
810  {
811  /* failure. */
812  NotifyRxDrop (packet);
813  m_state->SwitchFromRxEndError (packet, snrPer.snr);
814  }
815 }
816 
817 int64_t
819 {
820  NS_LOG_FUNCTION (this << stream);
821  m_random->SetStream (stream);
822  return 1;
823 }
824 
825 void
827 {
829 }
830 
831 void
833 {
835 }
836 void
838 {
839  m_numberOfReceivers = rx;
840 }
841 
842 void
844 {
845  m_ldpc = Ldpc;
846 }
847 
848 void
850 {
851  m_stbc = stbc;
852 }
853 
854 void
855 YansWifiPhy::SetGreenfield (bool greenfield)
856 {
857  m_greenfield = greenfield;
858 }
859 bool
861 {
862  return m_guardInterval;
863 }
864 void
865 YansWifiPhy::SetGuardInterval (bool GuardInterval)
866 {
867  m_guardInterval = GuardInterval;
868 }
869 
870 uint32_t
872 {
874 }
875 
876 uint32_t
878 {
879  return m_numberOfTransmitters;
880 }
881 uint32_t
883 {
884  return m_numberOfReceivers;
885 }
886 
887 bool
889 {
890  return m_ldpc;
891 }
892 bool
894 {
895  return m_stbc;
896 }
897 
898 bool
900 {
901  return m_greenfield;
902 }
903 
904 bool
906 {
907  return m_channelBonding;
908 }
909 
910 void
911 YansWifiPhy::SetChannelBonding(bool channelbonding)
912 {
913  m_channelBonding= channelbonding;
914 }
915 
916 void
918 {
919  NS_LOG_FUNCTION (this);
928  for (uint8_t i=0; i <8; i++)
929  {
930  m_deviceMcsSet.push_back(i);
931  }
932 
933 }
934 uint32_t
936 {
937  return m_bssMembershipSelectorSet.size ();
938 }
939 uint32_t
940 YansWifiPhy::GetBssMembershipSelector (uint32_t selector) const
941 {
942  return m_bssMembershipSelectorSet[selector];
943 }
946 {
947  uint32_t id=GetBssMembershipSelector(selector);
948  WifiModeList supportedmodes;
949  if (id == HT_PHY)
950  {
951  //mandatory MCS 0 to 7
952  supportedmodes.push_back (WifiPhy::GetOfdmRate6_5MbpsBW20MHz ());
953  supportedmodes.push_back (WifiPhy::GetOfdmRate13MbpsBW20MHz ());
954  supportedmodes.push_back (WifiPhy::GetOfdmRate19_5MbpsBW20MHz ());
955  supportedmodes.push_back (WifiPhy::GetOfdmRate26MbpsBW20MHz ());
956  supportedmodes.push_back (WifiPhy::GetOfdmRate39MbpsBW20MHz ());
957  supportedmodes.push_back (WifiPhy::GetOfdmRate52MbpsBW20MHz ());
958  supportedmodes.push_back (WifiPhy::GetOfdmRate58_5MbpsBW20MHz ());
959  supportedmodes.push_back (WifiPhy::GetOfdmRate65MbpsBW20MHz ());
960  }
961  return supportedmodes;
962 }
963 uint8_t
965 {
966  return m_deviceMcsSet.size ();
967 }
968 uint8_t
969 YansWifiPhy::GetMcs (uint8_t mcs) const
970 {
971  return m_deviceMcsSet[mcs];
972 }
973 uint32_t
975 {
976  uint32_t mcs = 0;
977  if (mode.GetUniqueName() == "OfdmRate135MbpsBW40MHzShGi" || mode.GetUniqueName() == "OfdmRate65MbpsBW20MHzShGi" )
978  {
979  mcs=6;
980  }
981  else
982  {
983  switch (mode.GetDataRate())
984  {
985  case 6500000:
986  case 7200000:
987  case 13500000:
988  case 15000000:
989  mcs=0;
990  break;
991  case 13000000:
992  case 14400000:
993  case 27000000:
994  case 30000000:
995  mcs=1;
996  break;
997  case 19500000:
998  case 21700000:
999  case 40500000:
1000  case 45000000:
1001  mcs=2;
1002  break;
1003  case 26000000:
1004  case 28900000:
1005  case 54000000:
1006  case 60000000:
1007  mcs=3;
1008  break;
1009  case 39000000:
1010  case 43300000:
1011  case 81000000:
1012  case 90000000:
1013  mcs=4;
1014  break;
1015  case 52000000:
1016  case 57800000:
1017  case 108000000:
1018  case 120000000:
1019  mcs=5;
1020  break;
1021  case 58500000:
1022  case 121500000:
1023  mcs=6;
1024  break;
1025  case 65000000:
1026  case 72200000:
1027  case 135000000:
1028  case 150000000:
1029  mcs=7;
1030  break;
1031  }
1032  }
1033  return mcs;
1034 }
1035 WifiMode
1037 {
1038  WifiMode mode;
1039  switch (mcs)
1040  {
1041  case 7:
1042  if (!GetGuardInterval() && !GetChannelBonding())
1043  {
1045  }
1046  else if(GetGuardInterval() && !GetChannelBonding())
1047  {
1049  }
1050  else if (!GetGuardInterval() && GetChannelBonding())
1051  {
1053  }
1054  else
1055  {
1057  }
1058  break;
1059  case 6:
1060  if (!GetGuardInterval() && !GetChannelBonding())
1061  {
1063 
1064  }
1065  else if(GetGuardInterval() && !GetChannelBonding())
1066  {
1068 
1069  }
1070  else if (!GetGuardInterval() && GetChannelBonding())
1071  {
1073 
1074  }
1075  else
1076  {
1078 
1079  }
1080  break;
1081  case 5:
1082  if (!GetGuardInterval() && !GetChannelBonding())
1083  {
1085 
1086  }
1087  else if(GetGuardInterval() && !GetChannelBonding())
1088  {
1090  }
1091  else if (!GetGuardInterval() && GetChannelBonding())
1092  {
1094 
1095  }
1096  else
1097  {
1099 
1100  }
1101  break;
1102  case 4:
1103  if (!GetGuardInterval() && !GetChannelBonding())
1104  {
1106  }
1107  else if(GetGuardInterval() && !GetChannelBonding())
1108  {
1110  }
1111  else if (!GetGuardInterval() && GetChannelBonding())
1112  {
1114 
1115  }
1116  else
1117  {
1119 
1120  }
1121  break;
1122  case 3:
1123  if (!GetGuardInterval() && !GetChannelBonding())
1124  {
1126 
1127  }
1128  else if(GetGuardInterval() && !GetChannelBonding())
1129  {
1131 
1132  }
1133  else if (!GetGuardInterval() && GetChannelBonding())
1134  {
1136 
1137  }
1138  else
1139  {
1141  }
1142  break;
1143  case 2:
1144  if (!GetGuardInterval() && !GetChannelBonding())
1145  {
1147 
1148  }
1149  else if(GetGuardInterval() && !GetChannelBonding())
1150  {
1152 
1153  }
1154  else if (!GetGuardInterval() && GetChannelBonding())
1155  {
1157 
1158  }
1159  else
1160  {
1162 
1163  }
1164  break;
1165  case 1:
1166  if (!GetGuardInterval() && !GetChannelBonding())
1167  {
1169 
1170  }
1171  else if(GetGuardInterval() && !GetChannelBonding())
1172  {
1174  }
1175  else if (!GetGuardInterval() && GetChannelBonding())
1176  {
1178 
1179  }
1180  else
1181  {
1183  }
1184  break;
1185  case 0:
1186  default:
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  break;
1206  }
1207  return mode;
1208 }
1209 } // namespace ns3
uint16_t m_channelNumber
static WifiMode GetOfdmRate9MbpsBW5MHz()
Definition: wifi-phy.cc:949
static WifiMode GetErpOfdmRate24Mbps()
Definition: wifi-phy.cc:618
static WifiMode GetDsssRate11Mbps()
Definition: wifi-phy.cc:549
Ptr< Object > m_mobility
virtual bool IsStateBusy(void)
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
static WifiMode GetErpOfdmRate36Mbps()
Definition: wifi-phy.cc:631
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
void Configure80211b(void)
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
virtual uint32_t GetFrequency(void) const
static WifiMode GetOfdmRate26MbpsBW20MHz()
Definition: wifi-phy.cc:1067
Hold a bool native type.
Definition: boolean.h:38
virtual WifiModeList GetMembershipSelectorModes(uint32_t selector)
Ptr< ErrorRateModel > GetErrorRateModel(void) const
double DbmToW(double dbm) const
static WifiMode GetOfdmRate9Mbps()
Definition: wifi-phy.cc:687
double DbToRatio(double db) const
static WifiMode GetOfdmRate7_2MbpsBW20MHz()
Definition: wifi-phy.cc:1002
static WifiMode GetOfdmRate18MbpsBW10MHz()
Definition: wifi-phy.cc:844
static WifiMode GetOfdmRate27MbpsBW10MHz()
Definition: wifi-phy.cc:870
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
virtual bool IsStateSwitching(void)
virtual bool IsStateTx(void)
static WifiMode GetOfdmRate3MbpsBW5MHz()
Definition: wifi-phy.cc:910
static WifiMode GetDsssRate1Mbps()
Definition: wifi-phy.cc:506
void NotifyMonitorSniffTx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, uint8_t txPower)
Definition: wifi-phy.cc:495
void Configure80211n(void)
Ptr< YansWifiChannel > m_channel
static WifiMode GetOfdmRate81MbpsBW40MHz()
Definition: wifi-phy.cc:1300
void SetTxGain(double gain)
802.11 PHY layer model
Definition: wifi-phy.h:117
static WifiMode GetErpOfdmRate18Mbps()
Definition: wifi-phy.cc:605
bool IsZero(void) const
Definition: nstime.h:222
static WifiMode GetOfdmRate12Mbps()
Definition: wifi-phy.cc:700
#define NS_ASSERT(condition)
Definition: assert.h:64
static WifiMode GetOfdmRate43_3MbpsBW20MHz()
Definition: wifi-phy.cc:1106
Time GetEnergyDuration(double energyW)
virtual void RegisterListener(WifiPhyListener *listener)
static WifiMode GetOfdmRate60MbpsBW40MHz()
Definition: wifi-phy.cc:1287
static WifiMode GetOfdmRate1_5MbpsBW5MHz()
Definition: wifi-phy.cc:884
uint32_t GetSize(void) const
Definition: packet.h:650
static WifiMode GetOfdmRate4_5MbpsBW10MHz()
Definition: wifi-phy.cc:792
static WifiMode GetOfdmRate54Mbps()
Definition: wifi-phy.cc:765
uint16_t GetChannelNumber() const
Return current channel number, see SetChannelNumber()
void SetChannelNumber(uint16_t id)
Set channel number.
virtual void SendPacket(Ptr< const Packet > packet, WifiMode mode, enum WifiPreamble preamble, WifiTxVector txvector)
static WifiMode GetOfdmRate108MbpsBW40MHz()
Definition: wifi-phy.cc:1325
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Definition: simulator.h:824
static WifiMode GetOfdmRate21_7MbpsBW20MHz()
Definition: wifi-phy.cc:1053
void NotifyTxBegin(Ptr< const Packet > packet)
Definition: wifi-phy.cc:453
Ptr< Object > GetDevice(void) const
void Configure80211_5Mhz()
virtual Time GetDelayUntilIdle(void)
void Configure80211a(void)
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)
static WifiMode GetOfdmRate135MbpsBW40MHz()
Definition: wifi-phy.cc:1373
static WifiMode GetOfdmRate36Mbps()
Definition: wifi-phy.cc:739
static WifiMode GetOfdmRate6MbpsBW5MHz()
Definition: wifi-phy.cc:936
virtual Time GetStateDuration(void)
virtual uint32_t GetNBssMembershipSelectors(void) const
uint8_t GetTxPowerLevel(void) const
double GetTxGain(void) const
virtual bool GetChannelBonding(void) const
std::vector< uint32_t > m_bssMembershipSelectorSet
static WifiMode GetErpOfdmRate54Mbps()
Definition: wifi-phy.cc:657
virtual void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
void NotifyRxDrop(Ptr< const Packet > packet)
Definition: wifi-phy.cc:483
WifiPreamble
Definition: wifi-preamble.h:29
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
virtual uint32_t GetNModes(void) const
static WifiMode GetOfdmRate6_5MbpsBW20MHz()
Definition: wifi-phy.cc:990
virtual bool IsStateRx(void)
virtual uint8_t GetNMcs(void) const
virtual double GetTxPowerStart(void) const
virtual WifiMode GetMode(uint32_t mode) const
double m_channelStartingFrequency
Standard-dependent center frequency of 0-th channel, MHz.
void SetEdThreshold(double threshold)
static WifiMode GetOfdmRate135MbpsBW40MHzShGi()
Definition: wifi-phy.cc:1361
virtual uint8_t GetMcs(uint8_t mcs) const
hold objects of type ns3::Time
Definition: nstime.h:828
virtual void SetGuardInterval(bool GuardInterval)
receive notifications about phy events.
Definition: wifi-phy.h:44
virtual bool GetStbc(void) const
Hold an unsigned integer type.
Definition: uinteger.h:46
Ptr< Object > m_device
WifiModeList m_deviceRateSet
static WifiMode GetErpOfdmRate48Mbps()
Definition: wifi-phy.cc:644
double m_ccaMode1ThresholdW
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
virtual void DoDispose(void)
virtual void SetStbc(bool stbc)
#define HT_PHY
Definition: yans-wifi-phy.h:43
static WifiMode GetOfdmRate12MbpsBW10MHz()
Definition: wifi-phy.cc:831
virtual uint32_t GetBssMembershipSelector(uint32_t selector) const
std::string GetUniqueName(void) const
Definition: wifi-mode.cc:75
double GetRxGain(void) const
Ptr< InterferenceHelper::Event > Add(uint32_t size, WifiMode payloadMode, enum WifiPreamble preamble, Time duration, double rxPower, WifiTxVector txvector)
void NotifyRxBegin(Ptr< const Packet > packet)
Definition: wifi-phy.cc:471
static WifiMode GetOfdmRate19_5MbpsBW20MHz()
Definition: wifi-phy.cc:1040
static WifiMode GetOfdmRate18Mbps()
Definition: wifi-phy.cc:713
double GetChannelFrequencyMhz() const
Return current center channel frequency in MHz, see SetChannelNumber()
static WifiMode GetOfdmRate9MbpsBW10MHz()
Definition: wifi-phy.cc:818
static WifiMode GetOfdmRate12MbpsBW5MHz()
Definition: wifi-phy.cc:962
static WifiMode GetOfdmRate52MbpsBW20MHz()
Definition: wifi-phy.cc:1119
double WToDbm(double w) const
static WifiMode GetOfdmRate40_5MbpsBW40MHz()
Definition: wifi-phy.cc:1249
void SetChannel(Ptr< YansWifiChannel > channel)
void SetNTxPower(uint32_t n)
virtual bool IsStateCcaBusy(void)
static WifiMode GetOfdmRate72_2MbpsBW20MHz()
Definition: wifi-phy.cc:1185
static WifiMode GetOfdmRate65MbpsBW20MHzShGi()
Definition: wifi-phy.cc:1159
virtual ~YansWifiPhy()
void SetDevice(Ptr< Object > device)
struct InterferenceHelper::SnrPer CalculateSnrPer(Ptr< InterferenceHelper::Event > event)
static WifiMode GetOfdmRate48Mbps()
Definition: wifi-phy.cc:752
void NotifyMonitorSniffRx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
Definition: wifi-phy.cc:489
virtual void SetReceiveOkCallback(WifiPhy::RxOkCallback callback)
int64_t AssignStreams(int64_t stream)
double GetCcaMode1Threshold(void) const
hold objects of type Ptr
Definition: pointer.h:33
static WifiMode GetOfdmRate57_8MbpsBW20MHz()
Definition: wifi-phy.cc:1132
static WifiMode GetOfdmRate24Mbps()
Definition: wifi-phy.cc:726
double GetEdThreshold(void) const
static TypeId GetTypeId(void)
static WifiMode GetOfdmRate13MbpsBW20MHz()
Definition: wifi-phy.cc:1015
virtual uint32_t GetNumberOfTransmitAntennas(void) const
virtual uint32_t WifiModeToMcs(WifiMode mode)
static WifiMode GetOfdmRate65MbpsBW20MHz()
Definition: wifi-phy.cc:1172
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()
Definition: wifi-phy.cc:1146
void SetRxGain(double gain)
static WifiMode GetDsssRate5_5Mbps()
Definition: wifi-phy.cc:536
static WifiMode GetOfdmRate2_25MbpsBW5MHz()
Definition: wifi-phy.cc:897
std::vector< WifiMode > WifiModeList
Definition: wifi-mode.h:177
static Time Now(void)
Definition: simulator.cc:180
static WifiMode GetErpOfdmRate9Mbps()
Definition: wifi-phy.cc:579
virtual WifiMode McsToWifiMode(uint8_t mcs)
void SetTxPowerStart(double start)
double RatioToDb(double ratio) const
virtual void SetNumberOfTransmitAntennas(uint32_t tx)
static WifiMode GetOfdmRate15MbpsBW40MHz()
Definition: wifi-phy.cc:1211
static WifiMode GetOfdmRate121_5MbpsBW40MHz()
Definition: wifi-phy.cc:1349
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
static WifiMode GetOfdmRate28_9MbpsBW20MHz()
Definition: wifi-phy.cc:1080
virtual bool IsStateIdle(void)
void StartReceivePacket(Ptr< Packet > packet, double rxPowerDbm, WifiTxVector txVector, WifiPreamble preamble)
virtual Time GetLastRxStartTime(void) const
virtual double CalculateSnr(WifiMode txMode, double ber) const
virtual bool GetGreenfield(void) const
static WifiMode GetErpOfdmRate6Mbps()
Definition: wifi-phy.cc:566
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
static WifiMode GetErpOfdmRate12Mbps()
Definition: wifi-phy.cc:592
virtual bool GetGuardInterval(void) const
void NotifyRxEnd(Ptr< const Packet > packet)
Definition: wifi-phy.cc:477
void SetMobility(Ptr< Object > mobility)
void SetNoiseFigure(double value)
virtual void ConfigureStandard(enum WifiPhyStandard standard)
static WifiMode GetOfdmRate13_5MbpsBW40MHz()
Definition: wifi-phy.cc:1198
static WifiMode GetOfdmRate30MbpsBW40MHz()
Definition: wifi-phy.cc:1236
#define NS_LOG_DEBUG(msg)
Definition: log.h:255
static WifiMode GetOfdmRate54MbpsBW40MHz()
Definition: wifi-phy.cc:1274
virtual bool GetLdpc(void) const
void Cancel(void)
Definition: event-id.cc:47
std::vector< uint8_t > m_deviceMcsSet
double GetPowerDbm(uint8_t power) const
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive.
Definition: time.cc:404
void EndReceive(Ptr< Packet > packet, Ptr< InterferenceHelper::Event > event)
static WifiMode GetOfdmRate90MbpsBW40MHz()
Definition: wifi-phy.cc:1312
virtual void SetNumberOfReceiveAntennas(uint32_t rx)
static WifiMode GetOfdmRate45MbpsBW40MHz()
Definition: wifi-phy.cc:1261
uint32_t m_numberOfTransmitters
static WifiMode GetOfdmRate120MbpsBW40MHz()
Definition: wifi-phy.cc:1337
double GetEdThresholdW(void) const
static WifiMode GetOfdmRate39MbpsBW20MHz()
Definition: wifi-phy.cc:1093
virtual Ptr< WifiChannel > GetChannel(void) const
static WifiMode GetDsssRate2Mbps()
Definition: wifi-phy.cc:519
void SetCcaMode1Threshold(double threshold)
static WifiMode GetOfdmRate6MbpsBW10MHz()
Definition: wifi-phy.cc:805
WifiMode GetMode(void) const
void ConfigureHolland(void)
double GetNoiseFigure(void) const
virtual void SetLdpc(bool Ldpc)
void SetTxPowerEnd(double end)
Hold an floating point type.
Definition: double.h:41
double GetRxNoiseFigure(void) const
static WifiMode GetOfdmRate24MbpsBW10MHz()
Definition: wifi-phy.cc:857
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
Definition: wifi-phy.cc:975
virtual double GetTxPowerEnd(void) const
bool IsExpired(void) const
Definition: event-id.cc:53
a unique identifier for an interface.
Definition: type-id.h:49
uint32_t m_numberOfReceivers
uint64_t GetDataRate(void) const
Definition: wifi-mode.cc:57
virtual void SetChannelBonding(bool channelbonding)
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
static WifiMode GetOfdmRate6Mbps()
Definition: wifi-phy.cc:674
static WifiMode GetOfdmRate27MbpsBW40MHz()
Definition: wifi-phy.cc:1224
virtual void SetFrequency(uint32_t freq)
static WifiMode GetOfdmRate4_5MbpsBW5MHz()
Definition: wifi-phy.cc:923
static WifiMode GetOfdmRate14_4MbpsBW20MHz()
Definition: wifi-phy.cc:1028
void Configure80211_10Mhz(void)
virtual uint32_t GetNTxPower(void) const
void SetRxNoiseFigure(double noiseFigureDb)
static WifiMode GetOfdmRate3MbpsBW10MHz()
Definition: wifi-phy.cc:779
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Ptr< Object > GetMobility(void)
Ptr< WifiPhyStateHelper > m_state
NS_LOG_COMPONENT_DEFINE("YansWifiPhy")
static WifiMode GetOfdmRate150MbpsBW40MHz()
Definition: wifi-phy.cc:1386
virtual void SetGreenfield(bool greenfield)