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  .SetGroupName ("Wifi")
54  .AddConstructor<YansWifiPhy> ()
55  .AddAttribute ("EnergyDetectionThreshold",
56  "The energy of a received signal should be higher than "
57  "this threshold (dbm) to allow the PHY layer to detect the signal.",
58  DoubleValue (-96.0),
61  MakeDoubleChecker<double> ())
62  .AddAttribute ("CcaMode1Threshold",
63  "The energy of a received signal should be higher than "
64  "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state",
65  DoubleValue (-99.0),
68  MakeDoubleChecker<double> ())
69  .AddAttribute ("TxGain",
70  "Transmission gain (dB).",
71  DoubleValue (1.0),
74  MakeDoubleChecker<double> ())
75  .AddAttribute ("RxGain",
76  "Reception gain (dB).",
77  DoubleValue (1.0),
80  MakeDoubleChecker<double> ())
81  .AddAttribute ("TxPowerLevels",
82  "Number of transmission power levels available between "
83  "TxPowerStart and TxPowerEnd included.",
84  UintegerValue (1),
86  MakeUintegerChecker<uint32_t> ())
87  .AddAttribute ("TxPowerEnd",
88  "Maximum available transmission level (dbm).",
89  DoubleValue (16.0206),
92  MakeDoubleChecker<double> ())
93  .AddAttribute ("TxPowerStart",
94  "Minimum available transmission level (dbm).",
95  DoubleValue (16.0206),
98  MakeDoubleChecker<double> ())
99  .AddAttribute ("RxNoiseFigure",
100  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
101  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
102  "\"the difference in decibels (dB) between"
103  " the noise output of the actual receiver to the noise output of an "
104  " ideal receiver with the same overall gain and bandwidth when the receivers "
105  " are connected to sources at the standard noise temperature T0 (usually 290 K)\"."
106  " For",
107  DoubleValue (7),
110  MakeDoubleChecker<double> ())
111  .AddAttribute ("State", "The state of the PHY layer",
112  PointerValue (),
114  MakePointerChecker<WifiPhyStateHelper> ())
115  .AddAttribute ("ChannelSwitchDelay",
116  "Delay between two short frames transmitted on different frequencies.",
117  TimeValue (MicroSeconds (250)),
119  MakeTimeChecker ())
120  .AddAttribute ("ChannelNumber",
121  "Channel center frequency = Channel starting frequency + 5 MHz * nch",
122  UintegerValue (1),
125  MakeUintegerChecker<uint16_t> ())
126  .AddAttribute ("Frequency", "The operating frequency.",
127  UintegerValue (2407),
130  MakeUintegerChecker<uint32_t> ())
131  .AddAttribute ("Transmitters", "The number of transmitters.",
132  UintegerValue (1),
135  MakeUintegerChecker<uint32_t> ())
136  .AddAttribute ("Receivers", "The number of receivers.",
137  UintegerValue (1),
140  MakeUintegerChecker<uint32_t> ())
141  .AddAttribute ("ShortGuardEnabled", "Whether or not short guard interval is enabled.",
142  BooleanValue (false),
146  .AddAttribute ("LdpcEnabled", "Whether or not LDPC is enabled.",
147  BooleanValue (false),
151  .AddAttribute ("STBCEnabled", "Whether or not STBC is enabled.",
152  BooleanValue (false),
156  .AddAttribute ("GreenfieldEnabled", "Whether or not STBC is enabled.",
157  BooleanValue (false),
161  .AddAttribute ("ChannelBonding", "Whether 20MHz or 40MHz.",
162  BooleanValue (false),
166 
167 
168  ;
169  return tid;
170 }
171 
173  : m_initialized (false),
174  m_channelNumber (1),
175  m_endRxEvent (),
176  m_endPlcpRxEvent(),
177  m_channelStartingFrequency (0),
178  m_mpdusNum(0),
179  m_plcpSuccess (false)
180 {
181  NS_LOG_FUNCTION (this);
182  m_random = CreateObject<UniformRandomVariable> ();
183  m_state = CreateObject<WifiPhyStateHelper> ();
184 }
185 
187 {
188  NS_LOG_FUNCTION (this);
189 }
190 
191 void
193 {
194  NS_LOG_FUNCTION (this);
195  m_channel = 0;
196  m_deviceRateSet.clear ();
197  m_deviceMcsSet.clear();
198  m_device = 0;
199  m_mobility = 0;
200  m_state = 0;
201 }
202 
203 void
205 {
206  NS_LOG_FUNCTION (this);
207  m_initialized = true;
208 }
209 
210 void
212 {
213  NS_LOG_FUNCTION (this << standard);
214  switch (standard)
215  {
217  Configure80211a ();
218  break;
220  Configure80211b ();
221  break;
223  Configure80211g ();
224  break;
227  break;
230  break;
232  ConfigureHolland ();
233  break;
236  Configure80211n ();
237  break;
240  Configure80211n ();
241  break;
242 
243  default:
244  NS_ASSERT (false);
245  break;
246  }
247 }
248 
249 
250 void
251 YansWifiPhy::SetRxNoiseFigure (double noiseFigureDb)
252 {
253  NS_LOG_FUNCTION (this << noiseFigureDb);
254  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
255 }
256 void
258 {
259  NS_LOG_FUNCTION (this << start);
261 }
262 void
264 {
265  NS_LOG_FUNCTION (this << end);
266  m_txPowerEndDbm = end;
267 }
268 void
270 {
271  NS_LOG_FUNCTION (this << n);
272  m_nTxPower = n;
273 }
274 void
276 {
277  NS_LOG_FUNCTION (this << gain);
278  m_txGainDb = gain;
279 }
280 void
282 {
283  NS_LOG_FUNCTION (this << gain);
284  m_rxGainDb = gain;
285 }
286 void
287 YansWifiPhy::SetEdThreshold (double threshold)
288 {
289  NS_LOG_FUNCTION (this << threshold);
290  m_edThresholdW = DbmToW (threshold);
291 }
292 void
294 {
295  NS_LOG_FUNCTION (this << threshold);
296  m_ccaMode1ThresholdW = DbmToW (threshold);
297 }
298 void
300 {
302 }
303 void
305 {
306  m_device = device;
307 }
308 void
310 {
311  m_mobility = mobility;
312 }
313 
314 double
316 {
318 }
319 double
321 {
322  return m_txPowerBaseDbm;
323 }
324 double
326 {
327  return m_txPowerEndDbm;
328 }
329 double
331 {
332  return m_txGainDb;
333 }
334 double
336 {
337  return m_rxGainDb;
338 }
339 
340 double
342 {
343  return WToDbm (m_edThresholdW);
344 }
345 
346 double
348 {
349  return WToDbm (m_ccaMode1ThresholdW);
350 }
351 
354 {
356 }
359 {
360  return m_device;
361 }
364 {
365  return m_mobility;
366 }
367 
368 double
369 YansWifiPhy::CalculateSnr (WifiMode txMode, double ber) const
370 {
371  return m_interference.GetErrorRateModel ()->CalculateSnr (txMode, ber);
372 }
373 
376 {
377  return m_channel;
378 }
379 void
381 {
382  m_channel = channel;
383  m_channel->Add (this);
384 }
385 
386 void
388 {
389  if (!m_initialized)
390  {
391  // this is not channel switch, this is initialization
392  NS_LOG_DEBUG ("start at channel " << nch);
393  m_channelNumber = nch;
394  return;
395  }
396 
398  switch (m_state->GetState ())
399  {
400  case YansWifiPhy::RX:
401  NS_LOG_DEBUG ("drop packet because of channel switching while reception");
403  m_endRxEvent.Cancel ();
404  goto switchChannel;
405  break;
406  case YansWifiPhy::TX:
407  NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
409  break;
411  case YansWifiPhy::IDLE:
412  goto switchChannel;
413  break;
414  case YansWifiPhy::SLEEP:
415  NS_LOG_DEBUG ("channel switching ignored in sleep mode");
416  break;
417  default:
418  NS_ASSERT (false);
419  break;
420  }
421 
422  return;
423 
424 switchChannel:
425 
426  NS_LOG_DEBUG ("switching channel " << m_channelNumber << " -> " << nch);
427  m_state->SwitchToChannelSwitching (m_channelSwitchDelay);
429  /*
430  * Needed here to be able to correctly sensed the medium for the first
431  * time after the switching. The actual switching is not performed until
432  * after m_channelSwitchDelay. Packets received during the switching
433  * state are added to the event list and are employed later to figure
434  * out the state of the medium after the switching.
435  */
436  m_channelNumber = nch;
437 }
438 
439 uint16_t
441 {
442  return m_channelNumber;
443 }
444 
445 Time
447 {
448  return m_channelSwitchDelay;
449 }
450 
451 double
453 {
455 }
456 
457 void
459 {
460  NS_LOG_FUNCTION (this);
461  switch (m_state->GetState ())
462  {
463  case YansWifiPhy::TX:
464  NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmission");
466  break;
467  case YansWifiPhy::RX:
468  NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception");
470  break;
472  NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching");
474  break;
476  case YansWifiPhy::IDLE:
477  NS_LOG_DEBUG ("setting sleep mode");
478  m_state->SwitchToSleep ();
479  break;
480  case YansWifiPhy::SLEEP:
481  NS_LOG_DEBUG ("already in sleep mode");
482  break;
483  default:
484  NS_ASSERT (false);
485  break;
486  }
487 }
488 
489 void
491 {
492  NS_LOG_FUNCTION (this);
493  switch (m_state->GetState ())
494  {
495  case YansWifiPhy::TX:
496  case YansWifiPhy::RX:
497  case YansWifiPhy::IDLE:
500  NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume");
501  break;
502  case YansWifiPhy::SLEEP:
503  NS_LOG_DEBUG ("resuming from sleep mode");
505  m_state->SwitchFromSleep (delayUntilCcaEnd);
506  break;
507  }
508 }
509 
510 void
512 {
513  m_state->SetReceiveOkCallback (callback);
514 }
515 void
517 {
518  m_state->SetReceiveErrorCallback (callback);
519 }
520 
521 void
523  double rxPowerDbm,
524  WifiTxVector txVector,
525  enum WifiPreamble preamble,
526  uint8_t packetType, Time rxDuration)
527 {
528  // This function should be later split to check separately wether plcp preamble and plcp header can be successfully received.
529  // Note: plcp preamble reception is not yet modeled.
530  NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode()<< preamble << (uint32_t)packetType);
531  AmpduTag ampduTag;
532 
533  rxPowerDbm += m_rxGainDb;
534  double rxPowerW = DbmToW (rxPowerDbm);
535  Time endRx = Simulator::Now () + rxDuration;
536  Time plcpDuration = CalculatePlcpDuration (txVector, preamble);
537 
539  event = m_interference.Add (packet->GetSize (),
540  txVector,
541  preamble,
542  rxDuration,
543  rxPowerW);
544 
545  switch (m_state->GetState ())
546  {
548  NS_LOG_DEBUG ("drop packet because of channel switching");
549  NotifyRxDrop (packet);
550  m_plcpSuccess = false;
551  /*
552  * Packets received on the upcoming channel are added to the event list
553  * during the switching state. This way the medium can be correctly sensed
554  * when the device listens to the channel for the first time after the
555  * switching e.g. after channel switching, the channel may be sensed as
556  * busy due to other devices' tramissions started before the end of
557  * the switching.
558  */
559  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
560  {
561  // that packet will be noise _after_ the completion of the
562  // channel switching.
563  goto maybeCcaBusy;
564  }
565  break;
566  case YansWifiPhy::RX:
567  NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
568  rxPowerW << "W)");
569  NotifyRxDrop (packet);
570  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
571  {
572  // that packet will be noise _after_ the reception of the
573  // currently-received packet.
574  goto maybeCcaBusy;
575  }
576  break;
577  case YansWifiPhy::TX:
578  NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
579  rxPowerW << "W)");
580  NotifyRxDrop (packet);
581  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
582  {
583  // that packet will be noise _after_ the transmission of the
584  // currently-transmitted packet.
585  goto maybeCcaBusy;
586  }
587  break;
589  case YansWifiPhy::IDLE:
590  if (rxPowerW > m_edThresholdW) //checked here, no need to check in the payload reception (current implementation assumes constant rx power over the packet duration)
591  {
592  if (preamble == WIFI_PREAMBLE_NONE && m_mpdusNum == 0)
593  {
594  NS_LOG_DEBUG ("drop packet because no preamble has been received");
595  NotifyRxDrop (packet);
596  goto maybeCcaBusy;
597  }
598  else if (preamble == WIFI_PREAMBLE_NONE && m_plcpSuccess == false) // A-MPDU reception fails
599  {
600  NS_LOG_DEBUG ("Drop MPDU because no plcp has been received");
601  NotifyRxDrop (packet);
602  goto maybeCcaBusy;
603  }
604  else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
605  {
606  //received the first MPDU in an MPDU
607  m_mpdusNum = ampduTag.GetNoOfMpdus()-1;
608  }
609  else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
610  {
611  //received the other MPDUs that are part of the A-MPDU
612  if (ampduTag.GetNoOfMpdus() < m_mpdusNum)
613  {
614  NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetNoOfMpdus());
615  m_mpdusNum = ampduTag.GetNoOfMpdus();
616  }
617  else
618  m_mpdusNum--;
619  }
620  else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 )
621  {
622  NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum);
623  m_mpdusNum = 0;
624  }
625 
626  NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
627  // sync to signal
628  m_state->SwitchToRx (rxDuration);
630  NotifyRxBegin (packet);
632 
633  if (preamble != WIFI_PREAMBLE_NONE)
634  {
637  packet, txVector, preamble, packetType, event);
638  }
639 
642  packet, preamble, packetType, event);
643  }
644  else
645  {
646  NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
647  rxPowerW << "<" << m_edThresholdW << ")");
648  NotifyRxDrop (packet);
649  m_plcpSuccess = false;
650  goto maybeCcaBusy;
651  }
652  break;
653  case YansWifiPhy::SLEEP:
654  NS_LOG_DEBUG ("drop packet because in sleep mode");
655  NotifyRxDrop (packet);
656  m_plcpSuccess = false;
657  break;
658  }
659 
660  return;
661 
662  maybeCcaBusy:
663  // We are here because we have received the first bit of a packet and we are
664  // not going to be able to synchronize on it
665  // In this model, CCA becomes busy when the aggregation of all signals as
666  // tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
667 
669  if (!delayUntilCcaEnd.IsZero ())
670  {
671  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
672  }
673 }
674 void
676  WifiTxVector txVector,
677  enum WifiPreamble preamble,
678  uint8_t packetType,
680 {
681  NS_LOG_FUNCTION (this << packet << txVector.GetMode()<< preamble << (uint32_t)packetType);
682  NS_ASSERT (IsStateRx ());
684  AmpduTag ampduTag;
685  WifiMode txMode = txVector.GetMode();
686 
687  struct InterferenceHelper::SnrPer snrPer;
688  snrPer = m_interference.CalculatePlcpHeaderSnrPer (event);
689 
690  NS_LOG_DEBUG ("snr=" << snrPer.snr << ", per=" << snrPer.per);
691 
692  if (m_random->GetValue () > snrPer.per) //plcp reception succeeded
693  {
694  if (IsModeSupported (txMode) || IsMcsSupported(txMode))
695  {
696  NS_LOG_DEBUG ("receiving plcp payload"); //endReceive is already scheduled
697  m_plcpSuccess = true;
698  }
699  else //mode is not allowed
700  {
701  NS_LOG_DEBUG ("drop packet because it was sent using an unsupported mode (" << txMode << ")");
702  NotifyRxDrop (packet);
703  m_plcpSuccess = false;
704  }
705  }
706  else //plcp reception failed
707  {
708  NS_LOG_DEBUG ("drop packet because plcp reception failed");
709  NotifyRxDrop (packet);
710  m_plcpSuccess = false;
711  }
712 }
713 
714 void
715 YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType)
716 {
717  NS_LOG_FUNCTION (this << packet << txVector.GetMode() << preamble << (uint32_t)txVector.GetTxPowerLevel() << (uint32_t)packetType);
718  /* Transmission can happen if:
719  * - we are syncing on a packet. It is the responsability of the
720  * MAC layer to avoid doing this but the PHY does nothing to
721  * prevent it.
722  * - we are idle
723  */
724  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
725 
726  if (m_state->IsStateSleep ())
727  {
728  NS_LOG_DEBUG ("Dropping packet because in sleep mode");
729  NotifyTxDrop (packet);
730  return;
731  }
732 
733  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble, GetFrequency(), packetType, 1);
734  if (m_state->IsStateRx ())
735  {
737  m_endRxEvent.Cancel ();
739  }
740  NotifyTxBegin (packet);
741  uint32_t dataRate500KbpsUnits;
742  if (txVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
743  {
744  dataRate500KbpsUnits = 128 + WifiModeToMcs (txVector.GetMode());
745  }
746  else
747  {
748  dataRate500KbpsUnits = txVector.GetMode().GetDataRate () * txVector.GetNss() / 500000;
749  }
750  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
751  NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, txVector.GetTxPowerLevel());
752  m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel()), txVector, preamble);
753  m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel()) + m_txGainDb, txVector, preamble, packetType, txDuration);
754 }
755 
756 uint32_t
758 {
759  return m_deviceRateSet.size ();
760 }
761 WifiMode
762 YansWifiPhy::GetMode (uint32_t mode) const
763 {
764  return m_deviceRateSet[mode];
765 }
766 bool
768 {
769  for (uint32_t i = 0; i < GetNModes (); i++)
770  {
771  if (mode == GetMode (i))
772  {
773  return true;
774  }
775  }
776  return false;
777 }
778 bool
780 {
781  for (uint32_t i = 0; i < GetNMcs (); i++)
782  {
783  if (mode == McsToWifiMode(GetMcs (i)))
784  {
785  return true;
786  }
787  }
788  return false;
789 }
790 uint32_t
792 {
793  return m_nTxPower;
794 }
795 
796 void
798 {
799  NS_LOG_FUNCTION (this);
800  m_channelStartingFrequency = 5e3; // 5.000 GHz
801 
810 }
811 
812 
813 void
815 {
816  NS_LOG_FUNCTION (this);
817  m_channelStartingFrequency = 2407; // 2.407 GHz
818 
823 }
824 
825 void
827 {
828  NS_LOG_FUNCTION (this);
829  m_channelStartingFrequency = 2407; // 2.407 GHz
830 
843 }
844 
845 void
847 {
848  NS_LOG_FUNCTION (this);
849  m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a
850 
859 }
860 
861 void
863 {
864  NS_LOG_FUNCTION (this);
865  m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a
866 
875 }
876 
877 void
879 {
880  NS_LOG_FUNCTION (this);
881  m_channelStartingFrequency = 5e3; // 5.000 GHz
887 }
888 
889 void
891 {
892  m_state->RegisterListener (listener);
893 }
894 
895 void
897 {
898  m_state->UnregisterListener (listener);
899 }
900 
901 bool
903 {
904  return m_state->IsStateCcaBusy ();
905 }
906 
907 bool
909 {
910  return m_state->IsStateIdle ();
911 }
912 bool
914 {
915  return m_state->IsStateBusy ();
916 }
917 bool
919 {
920  return m_state->IsStateRx ();
921 }
922 bool
924 {
925  return m_state->IsStateTx ();
926 }
927 bool
929 {
930  return m_state->IsStateSwitching ();
931 }
932 bool
934 {
935  return m_state->IsStateSleep ();
936 }
937 
938 Time
940 {
941  return m_state->GetStateDuration ();
942 }
943 Time
945 {
946  return m_state->GetDelayUntilIdle ();
947 }
948 
949 Time
951 {
952  return m_state->GetLastRxStartTime ();
953 }
954 
955 double
956 YansWifiPhy::DbToRatio (double dB) const
957 {
958  double ratio = std::pow (10.0, dB / 10.0);
959  return ratio;
960 }
961 
962 double
963 YansWifiPhy::DbmToW (double dBm) const
964 {
965  double mW = std::pow (10.0, dBm / 10.0);
966  return mW / 1000.0;
967 }
968 
969 double
970 YansWifiPhy::WToDbm (double w) const
971 {
972  return 10.0 * std::log10 (w * 1000.0);
973 }
974 
975 double
976 YansWifiPhy::RatioToDb (double ratio) const
977 {
978  return 10.0 * std::log10 (ratio);
979 }
980 
981 double
983 {
984  return m_edThresholdW;
985 }
986 
987 double
988 YansWifiPhy::GetPowerDbm (uint8_t power) const
989 {
991  NS_ASSERT (m_nTxPower > 0);
992  double dbm;
993  if (m_nTxPower > 1)
994  {
995  dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
996  }
997  else
998  {
999  NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
1000  dbm = m_txPowerBaseDbm;
1001  }
1002  return dbm;
1003 }
1004 
1005 void
1006 YansWifiPhy::EndReceive (Ptr<Packet> packet, enum WifiPreamble preamble, uint8_t packetType, Ptr<InterferenceHelper::Event> event)
1007 {
1008  NS_LOG_FUNCTION (this << packet << event);
1009  NS_ASSERT (IsStateRx ());
1010  NS_ASSERT (event->GetEndTime () == Simulator::Now ());
1011 
1012  struct InterferenceHelper::SnrPer snrPer;
1013  snrPer = m_interference.CalculatePlcpPayloadSnrPer (event);
1015 
1016  if (m_plcpSuccess == true)
1017  {
1018  NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate ()) <<
1019  ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
1020 
1021  if (m_random->GetValue () > snrPer.per)
1022  {
1023  NotifyRxEnd (packet);
1024  uint32_t dataRate500KbpsUnits;
1025  if ((event->GetPayloadMode ().GetModulationClass () == WIFI_MOD_CLASS_HT))
1026  {
1027  dataRate500KbpsUnits = 128 + WifiModeToMcs (event->GetPayloadMode ());
1028  }
1029  else
1030  {
1031  dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () * event->GetTxVector().GetNss()/ 500000;
1032  }
1033  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
1034  double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
1035  double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
1036  NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
1037  m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ());
1038  }
1039  else
1040  {
1041  /* failure. */
1042  NotifyRxDrop (packet);
1043  m_state->SwitchFromRxEndError (packet, snrPer.snr);
1044  }
1045  }
1046  else
1047  {
1048  m_state->SwitchFromRxEndError (packet, snrPer.snr); //notify rx end
1049  }
1050 
1051  if (preamble == WIFI_PREAMBLE_NONE && packetType == 2)
1052  {
1053  m_plcpSuccess = false;
1054  }
1055 
1056 }
1057 
1058 int64_t
1060 {
1061  NS_LOG_FUNCTION (this << stream);
1062  m_random->SetStream (stream);
1063  return 1;
1064 }
1065 
1066 void
1068 {
1070 }
1071 
1072 void
1074 {
1076 }
1077 void
1079 {
1080  m_numberOfReceivers = rx;
1081 }
1082 
1083 void
1085 {
1086  m_ldpc = Ldpc;
1087 }
1088 
1089 void
1091 {
1092  m_stbc = stbc;
1093 }
1094 
1095 void
1097 {
1098  m_greenfield = greenfield;
1099 }
1100 bool
1102 {
1103  return m_guardInterval;
1104 }
1105 void
1106 YansWifiPhy::SetGuardInterval (bool guardInterval)
1107 {
1108  m_guardInterval = guardInterval;
1109 }
1110 
1111 uint32_t
1113 {
1115 }
1116 
1117 uint32_t
1119 {
1120  return m_numberOfTransmitters;
1121 }
1122 uint32_t
1124 {
1125  return m_numberOfReceivers;
1126 }
1127 
1128 bool
1130 {
1131  return m_ldpc;
1132 }
1133 bool
1135 {
1136  return m_stbc;
1137 }
1138 
1139 bool
1141 {
1142  return m_greenfield;
1143 }
1144 
1145 bool
1147 {
1148  return m_channelBonding;
1149 }
1150 
1151 void
1152 YansWifiPhy::SetChannelBonding(bool channelbonding)
1153 {
1154  m_channelBonding= channelbonding;
1155 }
1156 
1157 void
1159 {
1160  NS_LOG_FUNCTION (this);
1161  if (m_channelStartingFrequency>=2400 && m_channelStartingFrequency<=2500) //@ 2.4 GHz
1162  {
1170  }
1171  if (m_channelStartingFrequency>=5000 && m_channelStartingFrequency<=6000) //@ 5 GHz
1172  {
1176  }
1178  for (uint8_t i=0; i <8; i++)
1179  {
1180  m_deviceMcsSet.push_back(i);
1181  }
1182 
1183 }
1184 uint32_t
1186 {
1187  return m_bssMembershipSelectorSet.size ();
1188 }
1189 uint32_t
1190 YansWifiPhy::GetBssMembershipSelector (uint32_t selector) const
1191 {
1192  return m_bssMembershipSelectorSet[selector];
1193 }
1196 {
1197  uint32_t id=GetBssMembershipSelector(selector);
1198  WifiModeList supportedmodes;
1199  if (id == HT_PHY)
1200  {
1201  //mandatory MCS 0 to 7
1202  supportedmodes.push_back (WifiPhy::GetOfdmRate6_5MbpsBW20MHz ());
1203  supportedmodes.push_back (WifiPhy::GetOfdmRate13MbpsBW20MHz ());
1204  supportedmodes.push_back (WifiPhy::GetOfdmRate19_5MbpsBW20MHz ());
1205  supportedmodes.push_back (WifiPhy::GetOfdmRate26MbpsBW20MHz ());
1206  supportedmodes.push_back (WifiPhy::GetOfdmRate39MbpsBW20MHz ());
1207  supportedmodes.push_back (WifiPhy::GetOfdmRate52MbpsBW20MHz ());
1208  supportedmodes.push_back (WifiPhy::GetOfdmRate58_5MbpsBW20MHz ());
1209  supportedmodes.push_back (WifiPhy::GetOfdmRate65MbpsBW20MHz ());
1210  }
1211  return supportedmodes;
1212 }
1213 uint8_t
1215 {
1216  return m_deviceMcsSet.size ();
1217 }
1218 uint8_t
1219 YansWifiPhy::GetMcs (uint8_t mcs) const
1220 {
1221  return m_deviceMcsSet[mcs];
1222 }
1223 uint32_t
1225 {
1226  uint32_t mcs = 0;
1227  if (mode.GetUniqueName() == "OfdmRate135MbpsBW40MHzShGi" || mode.GetUniqueName() == "OfdmRate65MbpsBW20MHzShGi" )
1228  {
1229  mcs=6;
1230  }
1231  else
1232  {
1233  switch (mode.GetDataRate())
1234  {
1235  case 6500000:
1236  case 7200000:
1237  case 13500000:
1238  case 15000000:
1239  mcs=0;
1240  break;
1241  case 13000000:
1242  case 14400000:
1243  case 27000000:
1244  case 30000000:
1245  mcs=1;
1246  break;
1247  case 19500000:
1248  case 21700000:
1249  case 40500000:
1250  case 45000000:
1251  mcs=2;
1252  break;
1253  case 26000000:
1254  case 28900000:
1255  case 54000000:
1256  case 60000000:
1257  mcs=3;
1258  break;
1259  case 39000000:
1260  case 43300000:
1261  case 81000000:
1262  case 90000000:
1263  mcs=4;
1264  break;
1265  case 52000000:
1266  case 57800000:
1267  case 108000000:
1268  case 120000000:
1269  mcs=5;
1270  break;
1271  case 58500000:
1272  case 121500000:
1273  mcs=6;
1274  break;
1275  case 65000000:
1276  case 72200000:
1277  case 135000000:
1278  case 150000000:
1279  mcs=7;
1280  break;
1281  }
1282  }
1283  return mcs;
1284 }
1285 WifiMode
1287 {
1288  WifiMode mode;
1289  switch (mcs)
1290  {
1291  case 7:
1292  if (!GetGuardInterval() && !GetChannelBonding())
1293  {
1295  }
1296  else if(GetGuardInterval() && !GetChannelBonding())
1297  {
1299  }
1300  else if (!GetGuardInterval() && GetChannelBonding())
1301  {
1303  }
1304  else
1305  {
1307  }
1308  break;
1309  case 6:
1310  if (!GetGuardInterval() && !GetChannelBonding())
1311  {
1313 
1314  }
1315  else if(GetGuardInterval() && !GetChannelBonding())
1316  {
1318 
1319  }
1320  else if (!GetGuardInterval() && GetChannelBonding())
1321  {
1323 
1324  }
1325  else
1326  {
1328 
1329  }
1330  break;
1331  case 5:
1332  if (!GetGuardInterval() && !GetChannelBonding())
1333  {
1335 
1336  }
1337  else if(GetGuardInterval() && !GetChannelBonding())
1338  {
1340  }
1341  else if (!GetGuardInterval() && GetChannelBonding())
1342  {
1344 
1345  }
1346  else
1347  {
1349 
1350  }
1351  break;
1352  case 4:
1353  if (!GetGuardInterval() && !GetChannelBonding())
1354  {
1356  }
1357  else if(GetGuardInterval() && !GetChannelBonding())
1358  {
1360  }
1361  else if (!GetGuardInterval() && GetChannelBonding())
1362  {
1364 
1365  }
1366  else
1367  {
1369 
1370  }
1371  break;
1372  case 3:
1373  if (!GetGuardInterval() && !GetChannelBonding())
1374  {
1376 
1377  }
1378  else if(GetGuardInterval() && !GetChannelBonding())
1379  {
1381 
1382  }
1383  else if (!GetGuardInterval() && GetChannelBonding())
1384  {
1386 
1387  }
1388  else
1389  {
1391  }
1392  break;
1393  case 2:
1394  if (!GetGuardInterval() && !GetChannelBonding())
1395  {
1397 
1398  }
1399  else if(GetGuardInterval() && !GetChannelBonding())
1400  {
1402 
1403  }
1404  else if (!GetGuardInterval() && GetChannelBonding())
1405  {
1407 
1408  }
1409  else
1410  {
1412 
1413  }
1414  break;
1415  case 1:
1416  if (!GetGuardInterval() && !GetChannelBonding())
1417  {
1419 
1420  }
1421  else if(GetGuardInterval() && !GetChannelBonding())
1422  {
1424  }
1425  else if (!GetGuardInterval() && GetChannelBonding())
1426  {
1428 
1429  }
1430  else
1431  {
1433  }
1434  break;
1435  case 0:
1436  default:
1437  if (!GetGuardInterval() && !GetChannelBonding())
1438  {
1440 
1441  }
1442  else if(GetGuardInterval() && !GetChannelBonding())
1443  {
1445  }
1446  else if (!GetGuardInterval() && GetChannelBonding())
1447  {
1449 
1450  }
1451  else
1452  {
1454  }
1455  break;
1456  }
1457  return mode;
1458 }
1459 } // 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:1092
static WifiMode GetErpOfdmRate24Mbps()
Return a WifiMode for ERP-OFDM at 24Mbps.
Definition: wifi-phy.cc:760
static WifiMode GetDsssRate11Mbps()
Return a WifiMode for DSSS at 11Mbps.
Definition: wifi-phy.cc:692
Ptr< Object > m_mobility
Pointer to the mobility model.
virtual bool IsStateBusy(void)
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
static WifiMode GetErpOfdmRate36Mbps()
Return a WifiMode for ERP-OFDM at 36Mbps.
Definition: wifi-phy.cc:773
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:1210
AttributeValue implementation for Boolean.
Definition: boolean.h:34
EventId m_endPlcpRxEvent
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:828
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:1145
static WifiMode GetOfdmRate18MbpsBW10MHz()
Return a WifiMode for OFDM at 18Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:986
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:1012
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:1053
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1Mbps.
Definition: wifi-phy.cc:650
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:641
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:1443
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:747
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:276
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:841
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:67
static WifiMode GetOfdmRate43_3MbpsBW20MHz()
Return a WifiMode for OFDM at 43.3Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1249
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:1430
static WifiMode GetOfdmRate1_5MbpsBW5MHz()
Return a WifiMode for OFDM at 1.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1027
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:934
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54Mbps.
Definition: wifi-phy.cc:906
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:611
static WifiMode GetOfdmRate108MbpsBW40MHz()
Return a WifiMode for OFDM at 108Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1468
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
void StartReceivePlcp(Ptr< Packet > packet, double rxPowerDbm, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType, Time rxDuration)
Starting receiving the plcp of a packet (i.e.
virtual bool IsStateSleep(void)
static WifiMode GetOfdmRate21_7MbpsBW20MHz()
Return a WifiMode for OFDM at 21.7Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1196
void NotifyTxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyTxBegin trace.
Definition: wifi-phy.cc:599
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:1516
static WifiMode GetOfdmRate36Mbps()
Return a WifiMode for OFDM at 36Mbps.
Definition: wifi-phy.cc:880
static WifiMode GetOfdmRate6MbpsBW5MHz()
Return a WifiMode for OFDM at 6Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1079
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:446
static WifiMode GetErpOfdmRate54Mbps()
Return a WifiMode for ERP-OFDM at 54Mbps.
Definition: wifi-phy.cc:799
virtual void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
void NotifyRxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:629
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:1133
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:1504
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:928
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:786
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:973
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
struct InterferenceHelper::SnrPer CalculatePlcpHeaderSnrPer(Ptr< InterferenceHelper::Event > event)
Calculate the SNIR at the start of the plcp header and accumulate all SNIR changes in the snir vector...
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).
void StartReceivePacket(Ptr< Packet > packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType, Ptr< InterferenceHelper::Event > event)
Starting receiving the payload of a packet (i.e.
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:617
static WifiMode GetOfdmRate19_5MbpsBW20MHz()
Return a WifiMode for OFDM at 19.5Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1183
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:854
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:577
static WifiMode GetOfdmRate9MbpsBW10MHz()
Return a WifiMode for OFDM at 9Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:960
static WifiMode GetOfdmRate12MbpsBW5MHz()
Return a WifiMode for OFDM at 12Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1105
static WifiMode GetOfdmRate52MbpsBW20MHz()
Return a WifiMode for OFDM at 52Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1262
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:1392
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:1328
static WifiMode GetOfdmRate65MbpsBW20MHzShGi()
Return a WifiMode for OFDM at 65Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1302
virtual ~YansWifiPhy()
void SetDevice(Ptr< Object > device)
Sets the device this PHY is associated with.
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:893
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:635
double m_txPowerEndDbm
Maximum transmission power (dBm)
virtual void SetReceiveOkCallback(WifiPhy::RxOkCallback callback)
struct InterferenceHelper::SnrPer CalculatePlcpPayloadSnrPer(Ptr< InterferenceHelper::Event > event)
Calculate the SNIR at the start of the plcp payload and accumulate all SNIR changes in the snir vecto...
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:1275
void EraseEvents(void)
Erase all events.
802.11 PHY layer modelThis PHY implements a model of 802.11a.
Definition: yans-wifi-phy.h:64
static WifiMode GetOfdmRate24Mbps()
Return a WifiMode for OFDM at 24Mbps.
Definition: wifi-phy.cc:867
Ptr< InterferenceHelper::Event > Add(uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble, Time duration, double rxPower)
Add the packet-related signal to interference helper.
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:1158
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:1315
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:1289
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:679
static WifiMode GetOfdmRate2_25MbpsBW5MHz()
Return a WifiMode for OFDM at 2.25Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1040
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:929
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:721
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:1354
static WifiMode GetOfdmRate121_5MbpsBW40MHz()
Return a WifiMode for OFDM at 121.5Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1492
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:90
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
static WifiMode GetOfdmRate28_9MbpsBW20MHz()
Return a WifiMode for OFDM at 28.9Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1223
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:708
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:734
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:623
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:1341
static WifiMode GetOfdmRate30MbpsBW40MHz()
Return a WifiMode for OFDM at 30Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1379
#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:1417
Time CalculatePlcpDuration(WifiTxVector txvector, enum WifiPreamble preamble)
Definition: wifi-phy.cc:588
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.
static WifiMode GetOfdmRate90MbpsBW40MHz()
Return a WifiMode for OFDM at 90Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1455
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:882
virtual void SetNumberOfReceiveAntennas(uint32_t rx)
static WifiMode GetOfdmRate45MbpsBW40MHz()
Return a WifiMode for OFDM at 45Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1404
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:1480
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:1236
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:663
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:947
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:999
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
Return a WifiMode for OFDM at 13.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1118
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
void EndReceive(Ptr< Packet > packet, enum WifiPreamble preamble, uint8_t packetType, Ptr< InterferenceHelper::Event > event)
The last bit of the packet has arrived.
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:57
uint32_t m_numberOfReceivers
Number of receivers.
virtual void ResumeFromSleep(void)
Resume from sleep mode.
bool m_plcpSuccess
Flag if the PLCP of the packet or the first MPDU in an A-MPDU has been received.
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:638
bool m_initialized
Flag for runtime initialization.
uint8_t GetNoOfMpdus(void) const
Definition: ampdu-tag.cc:94
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6Mbps.
Definition: wifi-phy.cc:815
static WifiMode GetOfdmRate27MbpsBW40MHz()
Return a WifiMode for OFDM at 27Mbps with 40MHz channel spacing.
Definition: wifi-phy.cc:1367
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:1066
static WifiMode GetOfdmRate14_4MbpsBW20MHz()
Return a WifiMode for OFDM at 14.4Mbps with 20MHz channel spacing.
Definition: wifi-phy.cc:1171
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:921
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:1529
virtual void SetGreenfield(bool greenfield)
Enable or disable Greenfield support.