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  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Ghada Badawy <gbadawy@gmail.com>
20  * Sébastien Deronne <sebastien.deronne@gmail.com>
21  */
22 
23 #include "yans-wifi-phy.h"
24 #include "yans-wifi-channel.h"
25 #include "wifi-mode.h"
26 #include "wifi-preamble.h"
27 #include "wifi-phy-state-helper.h"
28 #include "error-rate-model.h"
29 #include "ns3/simulator.h"
30 #include "ns3/packet.h"
31 #include "ns3/assert.h"
32 #include "ns3/log.h"
33 #include "ns3/double.h"
34 #include "ns3/uinteger.h"
35 #include "ns3/enum.h"
36 #include "ns3/pointer.h"
37 #include "ns3/net-device.h"
38 #include "ns3/trace-source-accessor.h"
39 #include "ns3/boolean.h"
40 #include "ns3/node.h"
41 #include "ampdu-tag.h"
42 #include <cmath>
43 
44 namespace ns3 {
45 
46 NS_LOG_COMPONENT_DEFINE ("YansWifiPhy");
47 
48 NS_OBJECT_ENSURE_REGISTERED (YansWifiPhy);
49 
50 TypeId
52 {
53  static TypeId tid = TypeId ("ns3::YansWifiPhy")
54  .SetParent<WifiPhy> ()
55  .SetGroupName ("Wifi")
56  .AddConstructor<YansWifiPhy> ()
57  .AddAttribute ("EnergyDetectionThreshold",
58  "The energy of a received signal should be higher than "
59  "this threshold (dbm) to allow the PHY layer to detect the signal.",
60  DoubleValue (-96.0),
63  MakeDoubleChecker<double> ())
64  .AddAttribute ("CcaMode1Threshold",
65  "The energy of a received signal should be higher than "
66  "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.",
67  DoubleValue (-99.0),
70  MakeDoubleChecker<double> ())
71  .AddAttribute ("TxGain",
72  "Transmission gain (dB).",
73  DoubleValue (1.0),
76  MakeDoubleChecker<double> ())
77  .AddAttribute ("RxGain",
78  "Reception gain (dB).",
79  DoubleValue (1.0),
82  MakeDoubleChecker<double> ())
83  .AddAttribute ("TxPowerLevels",
84  "Number of transmission power levels available between "
85  "TxPowerStart and TxPowerEnd included.",
86  UintegerValue (1),
88  MakeUintegerChecker<uint32_t> ())
89  .AddAttribute ("TxPowerEnd",
90  "Maximum available transmission level (dbm).",
91  DoubleValue (16.0206),
94  MakeDoubleChecker<double> ())
95  .AddAttribute ("TxPowerStart",
96  "Minimum available transmission level (dbm).",
97  DoubleValue (16.0206),
100  MakeDoubleChecker<double> ())
101  .AddAttribute ("RxNoiseFigure",
102  "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
103  " According to Wikipedia (http://en.wikipedia.org/wiki/Noise_figure), this is "
104  "\"the difference in decibels (dB) between"
105  " the noise output of the actual receiver to the noise output of an "
106  " ideal receiver with the same overall gain and bandwidth when the receivers "
107  " are connected to sources at the standard noise temperature T0 (usually 290 K)\".",
108  DoubleValue (7),
111  MakeDoubleChecker<double> ())
112  .AddAttribute ("State",
113  "The state of the PHY layer.",
114  PointerValue (),
116  MakePointerChecker<WifiPhyStateHelper> ())
117  .AddAttribute ("ChannelSwitchDelay",
118  "Delay between two short frames transmitted on different frequencies.",
119  TimeValue (MicroSeconds (250)),
121  MakeTimeChecker ())
122  .AddAttribute ("ChannelNumber",
123  "Channel center frequency = Channel starting frequency + 5 MHz * nch.",
124  UintegerValue (1),
127  MakeUintegerChecker<uint16_t> ())
128  .AddAttribute ("Frequency",
129  "The operating frequency.",
130  UintegerValue (2407),
133  MakeUintegerChecker<uint32_t> ())
134  .AddAttribute ("Transmitters",
135  "The number of transmitters.",
136  UintegerValue (1),
139  MakeUintegerChecker<uint32_t> ())
140  .AddAttribute ("Receivers",
141  "The number of receivers.",
142  UintegerValue (1),
145  MakeUintegerChecker<uint32_t> ())
146  .AddAttribute ("ShortGuardEnabled",
147  "Whether or not short guard interval is enabled.",
148  BooleanValue (false),
152  .AddAttribute ("LdpcEnabled",
153  "Whether or not LDPC is enabled.",
154  BooleanValue (false),
158  .AddAttribute ("STBCEnabled",
159  "Whether or not STBC is enabled.",
160  BooleanValue (false),
164  .AddAttribute ("GreenfieldEnabled",
165  "Whether or not Greenfield is enabled.",
166  BooleanValue (false),
170  .AddAttribute ("ChannelWidth",
171  "Whether 5MHz, 10MHz, 20MHz, 22MHz, 40MHz, 80 MHz or 160 MHz.",
172  UintegerValue (20),
175  MakeUintegerChecker<uint32_t> ())
176  ;
177  return tid;
178 }
179 
181  : m_initialized (false),
182  m_channelNumber (1),
183  m_endRxEvent (),
184  m_endPlcpRxEvent (),
185  m_channelStartingFrequency (0),
186  m_mpdusNum (0),
187  m_plcpSuccess (false)
188 {
189  NS_LOG_FUNCTION (this);
190  m_random = CreateObject<UniformRandomVariable> ();
191  m_state = CreateObject<WifiPhyStateHelper> ();
192 }
193 
195 {
196  NS_LOG_FUNCTION (this);
197 }
198 
199 void
201 {
202  NS_LOG_FUNCTION (this);
203  m_channel = 0;
204  m_deviceRateSet.clear ();
205  m_deviceMcsSet.clear ();
206  m_device = 0;
207  m_mobility = 0;
208  m_state = 0;
209 }
210 
211 void
213 {
214  NS_LOG_FUNCTION (this);
215  m_initialized = true;
216 }
217 
218 void
220 {
221  NS_LOG_FUNCTION (this << standard);
222  switch (standard)
223  {
225  Configure80211a ();
226  break;
228  Configure80211b ();
229  break;
231  Configure80211g ();
232  break;
235  break;
238  break;
240  ConfigureHolland ();
241  break;
244  Configure80211n ();
245  break;
248  Configure80211n ();
249  break;
251  Configure80211ac ();
252  break;
253  default:
254  NS_ASSERT (false);
255  break;
256  }
257 }
258 
259 void
260 YansWifiPhy::SetRxNoiseFigure (double noiseFigureDb)
261 {
262  NS_LOG_FUNCTION (this << noiseFigureDb);
263  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
264 }
265 
266 void
268 {
269  NS_LOG_FUNCTION (this << start);
271 }
272 
273 void
275 {
276  NS_LOG_FUNCTION (this << end);
277  m_txPowerEndDbm = end;
278 }
279 
280 void
282 {
283  NS_LOG_FUNCTION (this << n);
284  m_nTxPower = n;
285 }
286 
287 void
289 {
290  NS_LOG_FUNCTION (this << gain);
291  m_txGainDb = gain;
292 }
293 
294 void
296 {
297  NS_LOG_FUNCTION (this << gain);
298  m_rxGainDb = gain;
299 }
300 
301 void
302 YansWifiPhy::SetEdThreshold (double threshold)
303 {
304  NS_LOG_FUNCTION (this << threshold);
305  m_edThresholdW = DbmToW (threshold);
306 }
307 
308 void
310 {
311  NS_LOG_FUNCTION (this << threshold);
312  m_ccaMode1ThresholdW = DbmToW (threshold);
313 }
314 
315 void
317 {
319 }
320 
321 void
323 {
324  m_device = device;
325 }
326 
327 void
329 {
331 }
332 
333 double
335 {
337 }
338 
339 double
341 {
342  return m_txPowerBaseDbm;
343 }
344 
345 double
347 {
348  return m_txPowerEndDbm;
349 }
350 
351 double
353 {
354  return m_txGainDb;
355 }
356 
357 double
359 {
360  return m_rxGainDb;
361 }
362 
363 double
365 {
366  return WToDbm (m_edThresholdW);
367 }
368 
369 double
371 {
372  return WToDbm (m_ccaMode1ThresholdW);
373 }
374 
377 {
379 }
380 
383 {
384  return m_device;
385 }
386 
389 {
390  if (m_mobility != 0)
391  {
392  return m_mobility;
393  }
394  else
395  {
396  return m_device->GetNode ()->GetObject<MobilityModel> ();
397  }
398 }
399 
400 double
401 YansWifiPhy::CalculateSnr (WifiMode txMode, double ber) const
402 {
403  return m_interference.GetErrorRateModel ()->CalculateSnr (txMode, ber);
404 }
405 
408 {
409  return m_channel;
410 }
411 
412 void
414 {
415  m_channel = channel;
416  m_channel->Add (this);
417 }
418 
419 void
421 {
422  if (!m_initialized)
423  {
424  //this is not channel switch, this is initialization
425  NS_LOG_DEBUG ("start at channel " << nch);
426  m_channelNumber = nch;
427  return;
428  }
429 
431  switch (m_state->GetState ())
432  {
433  case YansWifiPhy::RX:
434  NS_LOG_DEBUG ("drop packet because of channel switching while reception");
436  m_endRxEvent.Cancel ();
437  goto switchChannel;
438  break;
439  case YansWifiPhy::TX:
440  NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
442  break;
444  case YansWifiPhy::IDLE:
445  goto switchChannel;
446  break;
447  case YansWifiPhy::SLEEP:
448  NS_LOG_DEBUG ("channel switching ignored in sleep mode");
449  break;
450  default:
451  NS_ASSERT (false);
452  break;
453  }
454 
455  return;
456 
457 switchChannel:
458 
459  NS_LOG_DEBUG ("switching channel " << m_channelNumber << " -> " << nch);
460  m_state->SwitchToChannelSwitching (m_channelSwitchDelay);
462  /*
463  * Needed here to be able to correctly sensed the medium for the first
464  * time after the switching. The actual switching is not performed until
465  * after m_channelSwitchDelay. Packets received during the switching
466  * state are added to the event list and are employed later to figure
467  * out the state of the medium after the switching.
468  */
469  m_channelNumber = nch;
470 }
471 
472 uint16_t
474 {
475  return m_channelNumber;
476 }
477 
478 Time
480 {
481  return m_channelSwitchDelay;
482 }
483 
484 double
486 {
488 }
489 
490 void
492 {
493  NS_LOG_FUNCTION (this);
494  switch (m_state->GetState ())
495  {
496  case YansWifiPhy::TX:
497  NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmission");
499  break;
500  case YansWifiPhy::RX:
501  NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception");
503  break;
505  NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching");
507  break;
509  case YansWifiPhy::IDLE:
510  NS_LOG_DEBUG ("setting sleep mode");
511  m_state->SwitchToSleep ();
512  break;
513  case YansWifiPhy::SLEEP:
514  NS_LOG_DEBUG ("already in sleep mode");
515  break;
516  default:
517  NS_ASSERT (false);
518  break;
519  }
520 }
521 
522 void
524 {
525  NS_LOG_FUNCTION (this);
526  switch (m_state->GetState ())
527  {
528  case YansWifiPhy::TX:
529  case YansWifiPhy::RX:
530  case YansWifiPhy::IDLE:
533  {
534  NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume");
535  break;
536  }
537  case YansWifiPhy::SLEEP:
538  {
539  NS_LOG_DEBUG ("resuming from sleep mode");
541  m_state->SwitchFromSleep (delayUntilCcaEnd);
542  break;
543  }
544  default:
545  {
546  NS_ASSERT (false);
547  break;
548  }
549  }
550 }
551 
552 void
554 {
555  m_state->SetReceiveOkCallback (callback);
556 }
557 
558 void
560 {
561  m_state->SetReceiveErrorCallback (callback);
562 }
563 
564 void
566  double rxPowerDbm,
567  WifiTxVector txVector,
568  enum WifiPreamble preamble,
569  struct mpduInfo aMpdu, Time rxDuration)
570 {
571  //This function should be later split to check separately whether plcp preamble and plcp header can be successfully received.
572  //Note: plcp preamble reception is not yet modeled.
573  NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode () << preamble << (uint32_t)aMpdu.packetType);
574  AmpduTag ampduTag;
575  rxPowerDbm += m_rxGainDb;
576  double rxPowerW = DbmToW (rxPowerDbm);
577  Time endRx = Simulator::Now () + rxDuration;
578  Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector, preamble);
579 
581  event = m_interference.Add (packet->GetSize (),
582  txVector,
583  preamble,
584  rxDuration,
585  rxPowerW);
586 
587  switch (m_state->GetState ())
588  {
590  NS_LOG_DEBUG ("drop packet because of channel switching");
591  NotifyRxDrop (packet);
592  m_plcpSuccess = false;
593  /*
594  * Packets received on the upcoming channel are added to the event list
595  * during the switching state. This way the medium can be correctly sensed
596  * when the device listens to the channel for the first time after the
597  * switching e.g. after channel switching, the channel may be sensed as
598  * busy due to other devices' tramissions started before the end of
599  * the switching.
600  */
601  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
602  {
603  //that packet will be noise _after_ the completion of the
604  //channel switching.
605  goto maybeCcaBusy;
606  }
607  break;
608  case YansWifiPhy::RX:
609  NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
610  rxPowerW << "W)");
611  NotifyRxDrop (packet);
612  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
613  {
614  //that packet will be noise _after_ the reception of the
615  //currently-received packet.
616  goto maybeCcaBusy;
617  }
618  break;
619  case YansWifiPhy::TX:
620  NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
621  rxPowerW << "W)");
622  NotifyRxDrop (packet);
623  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
624  {
625  //that packet will be noise _after_ the transmission of the
626  //currently-transmitted packet.
627  goto maybeCcaBusy;
628  }
629  break;
631  case YansWifiPhy::IDLE:
632  if (rxPowerW > m_edThresholdW) //checked here, no need to check in the payload reception (current implementation assumes constant rx power over the packet duration)
633  {
634  if (preamble == WIFI_PREAMBLE_NONE && m_mpdusNum == 0)
635  {
636  NS_LOG_DEBUG ("drop packet because no preamble has been received");
637  NotifyRxDrop (packet);
638  goto maybeCcaBusy;
639  }
640  else if (preamble == WIFI_PREAMBLE_NONE && m_plcpSuccess == false) //A-MPDU reception fails
641  {
642  NS_LOG_DEBUG ("Drop MPDU because no plcp has been received");
643  NotifyRxDrop (packet);
644  goto maybeCcaBusy;
645  }
646  else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
647  {
648  //received the first MPDU in an MPDU
649  m_mpdusNum = ampduTag.GetNoOfMpdus () - 1;
650  }
651  else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
652  {
653  //received the other MPDUs that are part of the A-MPDU
654  if (ampduTag.GetNoOfMpdus () < m_mpdusNum)
655  {
656  NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetNoOfMpdus ());
657  m_mpdusNum = ampduTag.GetNoOfMpdus ();
658  }
659  else
660  {
661  m_mpdusNum--;
662  }
663  }
664  else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 )
665  {
666  NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum);
667  m_mpdusNum = 0;
668  }
669 
670  NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
671  //sync to signal
672  m_state->SwitchToRx (rxDuration);
674  NotifyRxBegin (packet);
676 
677  if (preamble != WIFI_PREAMBLE_NONE)
678  {
680  m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &YansWifiPhy::StartReceivePacket, this,
681  packet, txVector, preamble, aMpdu, event);
682  }
683 
686  packet, preamble, aMpdu, event);
687  }
688  else
689  {
690  NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
691  rxPowerW << "<" << m_edThresholdW << ")");
692  NotifyRxDrop (packet);
693  m_plcpSuccess = false;
694  goto maybeCcaBusy;
695  }
696  break;
697  case YansWifiPhy::SLEEP:
698  NS_LOG_DEBUG ("drop packet because in sleep mode");
699  NotifyRxDrop (packet);
700  m_plcpSuccess = false;
701  break;
702  }
703 
704  return;
705 
706 maybeCcaBusy:
707  //We are here because we have received the first bit of a packet and we are
708  //not going to be able to synchronize on it
709  //In this model, CCA becomes busy when the aggregation of all signals as
710  //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
711 
713  if (!delayUntilCcaEnd.IsZero ())
714  {
715  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
716  }
717 }
718 
719 void
721  WifiTxVector txVector,
722  enum WifiPreamble preamble,
723  struct mpduInfo aMpdu,
725 {
726  NS_LOG_FUNCTION (this << packet << txVector.GetMode () << preamble << (uint32_t)aMpdu.packetType);
727  NS_ASSERT (IsStateRx ());
729  AmpduTag ampduTag;
730  WifiMode txMode = txVector.GetMode ();
731 
732  struct InterferenceHelper::SnrPer snrPer;
733  snrPer = m_interference.CalculatePlcpHeaderSnrPer (event);
734 
735  NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per);
736 
737  if (m_random->GetValue () > snrPer.per) //plcp reception succeeded
738  {
739  if (IsModeSupported (txMode) || IsMcsSupported (txMode))
740  {
741  NS_LOG_DEBUG ("receiving plcp payload"); //endReceive is already scheduled
742  m_plcpSuccess = true;
743  }
744  else //mode is not allowed
745  {
746  NS_LOG_DEBUG ("drop packet because it was sent using an unsupported mode (" << txMode << ")");
747  NotifyRxDrop (packet);
748  m_plcpSuccess = false;
749  }
750  }
751  else //plcp reception failed
752  {
753  NS_LOG_DEBUG ("drop packet because plcp preamble/header reception failed");
754  NotifyRxDrop (packet);
755  m_plcpSuccess = false;
756  }
757 }
758 
759 void
760 YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, WifiPreamble preamble, uint8_t packetType, uint32_t mpduReferenceNumber)
761 {
762  NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) << preamble << (uint32_t)txVector.GetTxPowerLevel () << (uint32_t)packetType);
763  /* Transmission can happen if:
764  * - we are syncing on a packet. It is the responsability of the
765  * MAC layer to avoid doing this but the PHY does nothing to
766  * prevent it.
767  * - we are idle
768  */
769  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
770 
771  if (m_state->IsStateSleep ())
772  {
773  NS_LOG_DEBUG ("Dropping packet because in sleep mode");
774  NotifyTxDrop (packet);
775  return;
776  }
777 
778  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble, GetFrequency (), packetType, 1);
779  NS_ASSERT (txDuration > NanoSeconds (0));
780 
781  if (m_state->IsStateRx ())
782  {
784  m_endRxEvent.Cancel ();
786  }
787  NotifyTxBegin (packet);
788  uint32_t dataRate500KbpsUnits;
790  {
791  dataRate500KbpsUnits = 128 + txVector.GetMode ().GetMcsValue ();
792  }
793  else
794  {
795  dataRate500KbpsUnits = txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) * txVector.GetNss () / 500000;
796  }
797  struct mpduInfo aMpdu;
798  aMpdu.packetType = packetType;
799  aMpdu.referenceNumber = mpduReferenceNumber;
800  NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, preamble, txVector, aMpdu);
801  m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector, preamble);
802  m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + m_txGainDb, txVector, preamble, aMpdu, txDuration);
803 }
804 
805 uint32_t
807 {
808  return m_deviceRateSet.size ();
809 }
810 
811 WifiMode
812 YansWifiPhy::GetMode (uint32_t mode) const
813 {
814  return m_deviceRateSet[mode];
815 }
816 
817 bool
819 {
820  for (uint32_t i = 0; i < GetNModes (); i++)
821  {
822  if (mode == GetMode (i))
823  {
824  return true;
825  }
826  }
827  return false;
828 }
829 bool
831 {
832  for (uint32_t i = 0; i < GetNMcs (); i++)
833  {
834  if (mcs == GetMcs (i))
835  {
836  return true;
837  }
838  }
839  return false;
840 }
841 
842 uint32_t
844 {
845  return m_nTxPower;
846 }
847 
848 void
850 {
851  NS_LOG_FUNCTION (this);
852  m_channelStartingFrequency = 5e3; //5.000 GHz
853  SetChannelWidth (20); //20 MHz
854 
863 }
864 
865 void
867 {
868  NS_LOG_FUNCTION (this);
869  m_channelStartingFrequency = 2407; //2.407 GHz
870  SetChannelWidth (22); //22 MHz
871 
876 }
877 
878 void
880 {
881  NS_LOG_FUNCTION (this);
882  m_channelStartingFrequency = 2407; //2.407 GHz
883  SetChannelWidth (20); //20 MHz
884 
897 }
898 
899 void
901 {
902  NS_LOG_FUNCTION (this);
903  m_channelStartingFrequency = 5e3; //5.000 GHz, suppose 802.11a
904  SetChannelWidth (10); //10 MHz
905 
914 }
915 
916 void
918 {
919  NS_LOG_FUNCTION (this);
920  m_channelStartingFrequency = 5e3; //5.000 GHz, suppose 802.11a
921  SetChannelWidth (5); //5 MHz
922 
931 }
932 
933 void
935 {
936  NS_LOG_FUNCTION (this);
937  m_channelStartingFrequency = 5e3; //5.000 GHz
938  SetChannelWidth (20); //20 MHz
939 
945 }
946 
947 void
949 {
950  NS_LOG_FUNCTION (this);
951  SetChannelWidth (20); //20 MHz
952  if (m_channelStartingFrequency >= 2400 && m_channelStartingFrequency <= 2500) //at 2.4 GHz
953  {
961  }
962  if (m_channelStartingFrequency >= 5000 && m_channelStartingFrequency <= 6000) //at 5 GHz
963  {
967  }
968 
969  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs0 ());
970  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs1 ());
971  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs2 ());
972  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs3 ());
973  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs4 ());
974  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs5 ());
975  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs6 ());
976  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs7 ());
977 
979 }
980 
981 void
983 {
984  NS_LOG_FUNCTION (this);
985  m_channelStartingFrequency = 5e3; //5.000 GHz
986  SetChannelWidth (80); //80 MHz
987 
991 
992  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs0 ());
993  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs1 ());
994  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs2 ());
995  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs3 ());
996  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs4 ());
997  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs5 ());
998  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs6 ());
999  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs7 ());
1000 
1001  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs0 ());
1002  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs1 ());
1003  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs2 ());
1004  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs3 ());
1005  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs4 ());
1006  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs5 ());
1007  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs6 ());
1008  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs7 ());
1009  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs8 ());
1010  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs9 ());
1011 
1012  m_bssMembershipSelectorSet.push_back (VHT_PHY);
1013 }
1014 
1015 void
1017 {
1018  m_state->RegisterListener (listener);
1019 }
1020 
1021 void
1023 {
1024  m_state->UnregisterListener (listener);
1025 }
1026 
1027 bool
1029 {
1030  return m_state->IsStateCcaBusy ();
1031 }
1032 
1033 bool
1035 {
1036  return m_state->IsStateIdle ();
1037 }
1038 
1039 bool
1041 {
1042  return m_state->IsStateBusy ();
1043 }
1044 
1045 bool
1047 {
1048  return m_state->IsStateRx ();
1049 }
1050 
1051 bool
1053 {
1054  return m_state->IsStateTx ();
1055 }
1056 
1057 bool
1059 {
1060  return m_state->IsStateSwitching ();
1061 }
1062 
1063 bool
1065 {
1066  return m_state->IsStateSleep ();
1067 }
1068 
1069 Time
1071 {
1072  return m_state->GetStateDuration ();
1073 }
1074 
1075 Time
1077 {
1078  return m_state->GetDelayUntilIdle ();
1079 }
1080 
1081 Time
1083 {
1084  return m_state->GetLastRxStartTime ();
1085 }
1086 
1087 double
1088 YansWifiPhy::DbToRatio (double dB) const
1089 {
1090  double ratio = std::pow (10.0, dB / 10.0);
1091  return ratio;
1092 }
1093 
1094 double
1095 YansWifiPhy::DbmToW (double dBm) const
1096 {
1097  double mW = std::pow (10.0, dBm / 10.0);
1098  return mW / 1000.0;
1099 }
1100 
1101 double
1102 YansWifiPhy::WToDbm (double w) const
1103 {
1104  return 10.0 * std::log10 (w * 1000.0);
1105 }
1106 
1107 double
1108 YansWifiPhy::RatioToDb (double ratio) const
1109 {
1110  return 10.0 * std::log10 (ratio);
1111 }
1112 
1113 double
1115 {
1116  return m_edThresholdW;
1117 }
1118 
1119 double
1120 YansWifiPhy::GetPowerDbm (uint8_t power) const
1121 {
1123  NS_ASSERT (m_nTxPower > 0);
1124  double dbm;
1125  if (m_nTxPower > 1)
1126  {
1127  dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
1128  }
1129  else
1130  {
1131  NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
1132  dbm = m_txPowerBaseDbm;
1133  }
1134  return dbm;
1135 }
1136 
1137 void
1139 {
1140  NS_LOG_FUNCTION (this << packet << event);
1141  NS_ASSERT (IsStateRx ());
1142  NS_ASSERT (event->GetEndTime () == Simulator::Now ());
1143 
1144  struct InterferenceHelper::SnrPer snrPer;
1145  snrPer = m_interference.CalculatePlcpPayloadSnrPer (event);
1147 
1148  if (m_plcpSuccess == true)
1149  {
1150  NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate (event->GetTxVector ().GetChannelWidth (), event->GetTxVector ().IsShortGuardInterval (), 1)) <<
1151  ", snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
1152 
1153  if (m_random->GetValue () > snrPer.per)
1154  {
1155  NotifyRxEnd (packet);
1156  uint32_t dataRate500KbpsUnits;
1157  if ((event->GetPayloadMode ().GetModulationClass () == WIFI_MOD_CLASS_HT) || (event->GetPayloadMode ().GetModulationClass () == WIFI_MOD_CLASS_VHT))
1158  {
1159  dataRate500KbpsUnits = 128 + event->GetPayloadMode ().GetMcsValue ();
1160  }
1161  else
1162  {
1163  dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate (event->GetTxVector ().GetChannelWidth (), event->GetTxVector ().IsShortGuardInterval (), 1) * event->GetTxVector ().GetNss () / 500000;
1164  }
1165  struct signalNoiseDbm signalNoise;
1166  signalNoise.signal = RatioToDb (event->GetRxPowerW ()) + 30;
1167  signalNoise.noise = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
1168  NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, event->GetPreambleType (), event->GetTxVector (), aMpdu, signalNoise);
1169  m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ());
1170  }
1171  else
1172  {
1173  /* failure. */
1174  NotifyRxDrop (packet);
1175  m_state->SwitchFromRxEndError (packet, snrPer.snr);
1176  }
1177  }
1178  else
1179  {
1180  m_state->SwitchFromRxEndError (packet, snrPer.snr);
1181  }
1182 
1183  if (preamble == WIFI_PREAMBLE_NONE && aMpdu.packetType == 2)
1184  {
1185  m_plcpSuccess = false;
1186  }
1187 }
1188 
1189 int64_t
1191 {
1192  NS_LOG_FUNCTION (this << stream);
1193  m_random->SetStream (stream);
1194  return 1;
1195 }
1196 
1197 void
1199 {
1201 }
1202 
1203 void
1205 {
1207 }
1208 
1209 void
1211 {
1212  m_numberOfReceivers = rx;
1213 }
1214 
1215 void
1217 {
1218  m_ldpc = Ldpc;
1219 }
1220 
1221 void
1223 {
1224  m_stbc = stbc;
1225 }
1226 
1227 void
1229 {
1230  m_greenfield = greenfield;
1231 }
1232 
1233 bool
1235 {
1236  return m_guardInterval;
1237 }
1238 
1239 void
1240 YansWifiPhy::SetGuardInterval (bool guardInterval)
1241 {
1242  m_guardInterval = guardInterval;
1243 }
1244 
1245 uint32_t
1247 {
1249 }
1250 
1251 uint32_t
1253 {
1254  return m_numberOfTransmitters;
1255 }
1256 
1257 uint32_t
1259 {
1260  return m_numberOfReceivers;
1261 }
1262 
1263 bool
1265 {
1266  return m_ldpc;
1267 }
1268 
1269 bool
1271 {
1272  return m_stbc;
1273 }
1274 
1275 bool
1277 {
1278  return m_greenfield;
1279 }
1280 
1281 void
1282 YansWifiPhy::SetChannelWidth (uint32_t channelwidth)
1283 {
1284  NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 || channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth == 160, "wrong channel width value");
1285  m_channelWidth = channelwidth;
1286 }
1287 
1288 uint32_t
1290 {
1291  return m_channelWidth;
1292 }
1293 
1294 uint32_t
1296 {
1297  return m_bssMembershipSelectorSet.size ();
1298 }
1299 
1300 uint32_t
1301 YansWifiPhy::GetBssMembershipSelector (uint32_t selector) const
1302 {
1303  return m_bssMembershipSelectorSet[selector];
1304 }
1305 
1308 {
1309  uint32_t id = GetBssMembershipSelector (selector);
1310  WifiModeList supportedmodes;
1311  if (id == HT_PHY || id == VHT_PHY)
1312  {
1313  //mandatory MCS 0 to 7
1314  supportedmodes.push_back (WifiPhy::GetHtMcs0 ());
1315  supportedmodes.push_back (WifiPhy::GetHtMcs1 ());
1316  supportedmodes.push_back (WifiPhy::GetHtMcs2 ());
1317  supportedmodes.push_back (WifiPhy::GetHtMcs3 ());
1318  supportedmodes.push_back (WifiPhy::GetHtMcs4 ());
1319  supportedmodes.push_back (WifiPhy::GetHtMcs5 ());
1320  supportedmodes.push_back (WifiPhy::GetHtMcs6 ());
1321  supportedmodes.push_back (WifiPhy::GetHtMcs7 ());
1322  }
1323  if (id == VHT_PHY)
1324  {
1325  //mandatory MCS 0 to 9
1326  supportedmodes.push_back (WifiPhy::GetVhtMcs0 ());
1327  supportedmodes.push_back (WifiPhy::GetVhtMcs1 ());
1328  supportedmodes.push_back (WifiPhy::GetVhtMcs2 ());
1329  supportedmodes.push_back (WifiPhy::GetVhtMcs3 ());
1330  supportedmodes.push_back (WifiPhy::GetVhtMcs4 ());
1331  supportedmodes.push_back (WifiPhy::GetVhtMcs5 ());
1332  supportedmodes.push_back (WifiPhy::GetVhtMcs6 ());
1333  supportedmodes.push_back (WifiPhy::GetVhtMcs7 ());
1334  supportedmodes.push_back (WifiPhy::GetVhtMcs8 ());
1335  supportedmodes.push_back (WifiPhy::GetVhtMcs9 ());
1336  }
1337  return supportedmodes;
1338 }
1339 
1340 uint8_t
1342 {
1343  return m_deviceMcsSet.size ();
1344 }
1345 
1346 WifiMode
1347 YansWifiPhy::GetMcs (uint8_t mcs) const
1348 {
1349  return m_deviceMcsSet[mcs];
1350 }
1351 
1352 } //namespace ns3
ERP-OFDM PHY (Clause 19, Section 19.5)
static WifiMode GetVhtMcs6()
Return MCS 6 from VHT MCS values.
Definition: wifi-phy.cc:1421
uint16_t m_channelNumber
Operating channel number.
tuple channel
Definition: third.py:85
static WifiMode GetOfdmRate9MbpsBW5MHz()
Return a WifiMode for OFDM at 9Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1075
static WifiMode GetErpOfdmRate24Mbps()
Return a WifiMode for ERP-OFDM at 24Mbps.
Definition: wifi-phy.cc:766
static WifiMode GetDsssRate11Mbps()
Return a WifiMode for DSSS at 11Mbps.
Definition: wifi-phy.cc:703
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:778
void NotifyMonitorSniffTx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu)
Public method used to fire a MonitorSniffer trace for a wifi packet being transmitted.
Definition: wifi-phy.cc:655
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 GetVhtMcs8()
Return MCS 8 from VHT MCS values.
Definition: wifi-phy.cc:1437
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:829
double DbToRatio(double db) const
Convert from dB to ratio.
HT OFDM PHY for the 5 GHz band (clause 20)
static WifiMode GetOfdmRate18MbpsBW10MHz()
Return a WifiMode for OFDM at 18Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:976
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:1000
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:1039
static WifiMode GetVhtMcs0()
Return MCS 0 from VHT MCS values.
Definition: wifi-phy.cc:1373
static WifiMode GetDsssRate1Mbps()
Return a WifiMode for DSSS at 1Mbps.
Definition: wifi-phy.cc:664
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.
void SetTxGain(double gain)
Sets the transmission gain (dB).
802.11 PHY layer model
Definition: wifi-phy.h:138
static WifiMode GetErpOfdmRate18Mbps()
Return a WifiMode for ERP-OFDM at 18Mbps.
Definition: wifi-phy.cc:754
The PHY layer has sense the medium busy through the CCA mechanism.
Definition: wifi-phy.h:153
static WifiMode GetHtMcs7()
Return MCS 7 from HT MCS values.
Definition: wifi-phy.cc:1170
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:274
def start()
Definition: core.py:1482
static WifiMode GetVhtMcs5()
Return MCS 5 from VHT MCS values.
Definition: wifi-phy.cc:1413
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:375
void StartReceivePacket(Ptr< Packet > packet, WifiTxVector txVector, WifiPreamble preamble, struct mpduInfo aMpdu, Ptr< InterferenceHelper::Event > event)
Starting receiving the payload of a packet (i.e.
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
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)
bool IsShortGuardInterval(void) const
static WifiMode GetOfdmRate1_5MbpsBW5MHz()
Return a WifiMode for OFDM at 1.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1015
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:786
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
The PHY layer is sleeping.
Definition: wifi-phy.h:169
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:928
static WifiMode GetOfdmRate54Mbps()
Return a WifiMode for OFDM at 54Mbps.
Definition: wifi-phy.cc:901
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:625
HT OFDM PHY for the 2.4 GHz band (clause 20)
VHT PHY (Clause 22)
Definition: wifi-mode.h:62
virtual void SendPacket(Ptr< const Packet > packet, WifiTxVector txVector, enum WifiPreamble preamble, uint8_t packetType, uint32_t mpduReferenceNumber)
Ptr< MobilityModel > m_mobility
Pointer to the mobility model.
virtual bool IsStateSleep(void)
void NotifyTxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyTxBegin trace.
Definition: wifi-phy.cc:613
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)
static WifiMode GetVhtMcs4()
Return MCS 4 from VHT MCS values.
Definition: wifi-phy.cc:1405
void Configure80211a(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11a standard.
void Configure80211ac(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11ac standard.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
void Configure80211g(void)
Configure YansWifiPhy with appropriate channel frequency and supported rates for 802.11g standard.
static WifiMode GetOfdmRate36Mbps()
Return a WifiMode for OFDM at 36Mbps.
Definition: wifi-phy.cc:877
static WifiMode GetVhtMcs7()
Return MCS 7 from VHT MCS values.
Definition: wifi-phy.cc:1429
static WifiMode GetOfdmRate6MbpsBW5MHz()
Return a WifiMode for OFDM at 6Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1063
virtual Time GetStateDuration(void)
static WifiMode GetVhtMcs3()
Return MCS 3 from VHT MCS values.
Definition: wifi-phy.cc:1397
void NotifyMonitorSniffRx(Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu, struct signalNoiseDbm signalNoise)
Public method used to fire a MonitorSniffer trace for a wifi packet being received.
Definition: wifi-phy.cc:649
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).
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
void SetMobility(Ptr< MobilityModel > mobility)
assign a mobility model to this device
virtual void SetChannelWidth(uint32_t channelwidth)
Set channel width.
static WifiMode GetErpOfdmRate54Mbps()
Return a WifiMode for ERP-OFDM at 54Mbps.
Definition: wifi-phy.cc:802
virtual void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
void NotifyRxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:643
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
Keep track of the current position and velocity of an object.
void 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...
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:844
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 GetHtMcs2()
Return MCS 2 from HT MCS values.
Definition: wifi-phy.cc:1130
bool m_ldpc
Flag if LDPC is used.
tuple mobility
Definition: third.py:101
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:220
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1216
AttributeValue implementation for Time.
Definition: nstime.h:957
Time CalculatePlcpPreambleAndHeaderDuration(WifiTxVector txVector, enum WifiPreamble preamble)
Definition: wifi-phy.cc:592
#define VHT_PHY
Definition: yans-wifi-phy.h:44
uint8_t packetType
Definition: wifi-phy.h:50
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:919
receive notifications about phy events.
Definition: wifi-phy.h:57
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
The PHY layer is IDLE.
Definition: wifi-phy.h:149
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:790
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:45
static WifiMode GetOfdmRate12MbpsBW10MHz()
Return a WifiMode for OFDM at 12Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:964
uint32_t GetChannelWidth(void) const
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:60
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...
virtual WifiMode GetMcs(uint8_t mcs) const
The WifiPhy::GetMcs() method is used (e.g., by a WifiRemoteStationManager) to determine the set of tr...
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:353
The PHY layer is receiving a packet.
Definition: wifi-phy.h:161
double GetRxGain(void) const
Return the reception gain (dB).
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:36
void NotifyRxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyRxBegin trace.
Definition: wifi-phy.cc:631
The PHY layer is sending a packet.
Definition: wifi-phy.h:157
static WifiMode GetOfdmRate18Mbps()
Return a WifiMode for OFDM at 18Mbps.
Definition: wifi-phy.cc:853
double GetChannelFrequencyMhz() const
Return current center channel frequency in MHz.
static WifiMode GetOfdmRate9MbpsBW10MHz()
Return a WifiMode for OFDM at 9Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:952
static WifiMode GetOfdmRate12MbpsBW5MHz()
Return a WifiMode for OFDM at 12Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1087
The PHY layer is switching to other channel.
Definition: wifi-phy.h:165
double WToDbm(double w) const
Convert from Watts to dBm.
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 GetVhtMcs1()
Return MCS 1 from VHT MCS values.
Definition: wifi-phy.cc:1381
virtual ~YansWifiPhy()
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:889
double m_txPowerEndDbm
Maximum transmission power (dBm)
static WifiMode GetHtMcs0()
Return MCS 0 from HT MCS values.
Definition: wifi-phy.cc:1114
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
VHT OFDM PHY (clause 22)
void EraseEvents(void)
Erase all events.
802.11 PHY layer modelThis PHY implements a model of 802.11a.
Definition: yans-wifi-phy.h:66
static WifiMode GetOfdmRate24Mbps()
Return a WifiMode for OFDM at 24Mbps.
Definition: wifi-phy.cc:865
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
Ptr< InterferenceHelper::Event > Add(uint32_t size, WifiTxVector txVector, enum WifiPreamble preamble, Time duration, double rxPower)
Add the packet-related signal to interference helper.
double GetEdThreshold(void) const
Return the energy detection threshold (dBm).
static TypeId GetTypeId(void)
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
virtual uint32_t GetNumberOfTransmitAntennas(void) const
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
static WifiMode GetHtMcs5()
Return MCS 5 from HT MCS values.
Definition: wifi-phy.cc:1154
virtual uint32_t GetNumberOfReceiveAntennas(void) const
uint64_t GetDataRate(uint32_t channelWidth, bool isShortGuardInterval, uint8_t nss) const
Definition: wifi-mode.cc:100
uint32_t m_nTxPower
Number of available transmission power levels.
void StartReceivePreambleAndHeader(Ptr< Packet > packet, double rxPowerDbm, WifiTxVector txVector, WifiPreamble preamble, struct mpduInfo aMpdu, Time rxDuration)
Starting receiving the plcp of a packet (i.e.
static WifiMode GetVhtMcs2()
Return MCS 2 from VHT MCS values.
Definition: wifi-phy.cc:1389
void SetRxGain(double gain)
Sets the reception gain (dB).
WifiModeList m_deviceMcsSet
static WifiMode GetDsssRate5_5Mbps()
Return a WifiMode for DSSS at 5.5Mbps.
Definition: wifi-phy.cc:691
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, enum WifiPreamble preamble, double frequency, uint8_t packetType, uint8_t incFlag)
Definition: wifi-phy.cc:605
static WifiMode GetOfdmRate2_25MbpsBW5MHz()
Return a WifiMode for OFDM at 2.25Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1027
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:958
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:195
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:730
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)
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
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:718
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Ptr< NetDevice > m_device
Pointer to the device.
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:742
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:637
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 GetHtMcs6()
Return MCS 6 from HT MCS values.
Definition: wifi-phy.cc:1162
void EndReceive(Ptr< Packet > packet, enum WifiPreamble preamble, struct mpduInfo aMpdu, Ptr< InterferenceHelper::Event > event)
The last bit of the packet has arrived.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
uint32_t m_channelWidth
Channel width.
static WifiMode GetHtMcs4()
Return MCS 4 from HT MCS values.
Definition: wifi-phy.cc:1146
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
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.
virtual uint32_t GetChannelWidth(void) const
Return channel width.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:911
virtual void SetNumberOfReceiveAntennas(uint32_t rx)
void SetDevice(Ptr< NetDevice > device)
Sets the device this PHY is associated with.
static WifiMode GetHtMcs1()
Return MCS 1 from HT MCS values.
Definition: wifi-phy.cc:1122
uint32_t m_numberOfTransmitters
Number of transmitters.
virtual bool IsMcsSupported(WifiMode mcs)
double GetEdThresholdW(void) const
Return the energy detection threshold.
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:676
static WifiMode GetVhtMcs9()
Return MCS 9 from VHT MCS values.
Definition: wifi-phy.cc:1445
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:940
WifiMode GetMode(void) const
void ConfigureHolland(void)
Ptr< NetDevice > GetDevice(void) const
Return the device this PHY is associated with.
double GetNoiseFigure(void) const
Return the noise figure.
void SetTxPowerEnd(double end)
Sets the maximum available transmission power level (dBm).
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
double GetRxNoiseFigure(void) const
Return the RX noise figure (dBm).
static WifiMode GetOfdmRate24MbpsBW10MHz()
Return a WifiMode for OFDM at 24Mbps with 10MHz channel spacing.
Definition: wifi-phy.cc:988
static WifiMode GetOfdmRate13_5MbpsBW5MHz()
Return a WifiMode for OFDM at 13.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1099
virtual double GetTxPowerEnd(void) const
Return the maximum available transmission power level (dBm).
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
a unique identifier for an interface.
Definition: type-id.h:58
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.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:826
bool m_initialized
Flag for runtime initialization.
static WifiMode GetHtMcs3()
Return MCS 3 from HT MCS values.
Definition: wifi-phy.cc:1138
uint8_t GetNoOfMpdus(void) const
Definition: ampdu-tag.cc:95
static WifiMode GetOfdmRate6Mbps()
Return a WifiMode for OFDM at 6Mbps.
Definition: wifi-phy.cc:817
virtual void SetFrequency(uint32_t freq)
uint32_t referenceNumber
Definition: wifi-phy.h:51
static WifiMode GetOfdmRate4_5MbpsBW5MHz()
Return a WifiMode for OFDM at 4.5Mbps with 5MHz channel spacing.
Definition: wifi-phy.cc:1051
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:916
Ptr< ErrorRateModel > GetErrorRateModel(void) const
Return the error rate model this PHY is using.
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Ptr< MobilityModel > GetMobility(void)
Return the mobility model this PHY is associated with.
virtual void SetGreenfield(bool greenfield)
Enable or disable Greenfield support.