This documentation is not the Latest Release.
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 ("ShortPlcpPreambleEnabled",
171  "Whether or not short PLCP preamble is enabled.",
172  BooleanValue (false),
176  .AddAttribute ("ChannelWidth",
177  "Whether 5MHz, 10MHz, 20MHz, 22MHz, 40MHz, 80 MHz or 160 MHz.",
178  UintegerValue (20),
181  MakeUintegerChecker<uint32_t> ())
182  ;
183  return tid;
184 }
185 
187  : m_initialized (false),
188  m_channelNumber (1),
189  m_endRxEvent (),
190  m_endPlcpRxEvent (),
191  m_channelStartingFrequency (0),
192  m_mpdusNum (0),
193  m_plcpSuccess (false),
194  m_txMpduReferenceNumber (0xffffffff),
195  m_rxMpduReferenceNumber (0xffffffff)
196 {
197  NS_LOG_FUNCTION (this);
198  m_random = CreateObject<UniformRandomVariable> ();
199  m_state = CreateObject<WifiPhyStateHelper> ();
200 }
201 
203 {
204  NS_LOG_FUNCTION (this);
205 }
206 
207 void
209 {
210  NS_LOG_FUNCTION (this);
211  m_channel = 0;
212  m_deviceRateSet.clear ();
213  m_deviceMcsSet.clear ();
214  m_device = 0;
215  m_mobility = 0;
216  m_state = 0;
217 }
218 
219 void
221 {
222  NS_LOG_FUNCTION (this);
223  m_initialized = true;
224 }
225 
226 void
228 {
229  NS_LOG_FUNCTION (this << standard);
230  switch (standard)
231  {
233  Configure80211a ();
234  break;
236  Configure80211b ();
237  break;
239  Configure80211g ();
240  break;
243  break;
246  break;
248  ConfigureHolland ();
249  break;
252  Configure80211n ();
253  break;
256  Configure80211n ();
257  break;
259  Configure80211ac ();
260  break;
261  default:
262  NS_ASSERT (false);
263  break;
264  }
265 }
266 
267 void
268 YansWifiPhy::SetRxNoiseFigure (double noiseFigureDb)
269 {
270  NS_LOG_FUNCTION (this << noiseFigureDb);
271  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
272 }
273 
274 void
276 {
277  NS_LOG_FUNCTION (this << start);
279 }
280 
281 void
283 {
284  NS_LOG_FUNCTION (this << end);
285  m_txPowerEndDbm = end;
286 }
287 
288 void
290 {
291  NS_LOG_FUNCTION (this << n);
292  m_nTxPower = n;
293 }
294 
295 void
297 {
298  NS_LOG_FUNCTION (this << gain);
299  m_txGainDb = gain;
300 }
301 
302 void
304 {
305  NS_LOG_FUNCTION (this << gain);
306  m_rxGainDb = gain;
307 }
308 
309 void
310 YansWifiPhy::SetEdThreshold (double threshold)
311 {
312  NS_LOG_FUNCTION (this << threshold);
313  m_edThresholdW = DbmToW (threshold);
314 }
315 
316 void
318 {
319  NS_LOG_FUNCTION (this << threshold);
320  m_ccaMode1ThresholdW = DbmToW (threshold);
321 }
322 
323 void
325 {
327 }
328 
329 void
331 {
332  m_device = device;
333 }
334 
335 void
337 {
339 }
340 
341 double
343 {
345 }
346 
347 double
349 {
350  return m_txPowerBaseDbm;
351 }
352 
353 double
355 {
356  return m_txPowerEndDbm;
357 }
358 
359 double
361 {
362  return m_txGainDb;
363 }
364 
365 double
367 {
368  return m_rxGainDb;
369 }
370 
371 double
373 {
374  return WToDbm (m_edThresholdW);
375 }
376 
377 double
379 {
380  return WToDbm (m_ccaMode1ThresholdW);
381 }
382 
385 {
387 }
388 
391 {
392  return m_device;
393 }
394 
397 {
398  if (m_mobility != 0)
399  {
400  return m_mobility;
401  }
402  else
403  {
404  return m_device->GetNode ()->GetObject<MobilityModel> ();
405  }
406 }
407 
408 double
409 YansWifiPhy::CalculateSnr (WifiMode txMode, double ber) const
410 {
411  return m_interference.GetErrorRateModel ()->CalculateSnr (txMode, ber);
412 }
413 
416 {
417  return m_channel;
418 }
419 
420 void
422 {
423  m_channel = channel;
424  m_channel->Add (this);
425 }
426 
427 void
429 {
430  if (!m_initialized)
431  {
432  //this is not channel switch, this is initialization
433  NS_LOG_DEBUG ("start at channel " << nch);
434  m_channelNumber = nch;
435  return;
436  }
437 
439  switch (m_state->GetState ())
440  {
441  case YansWifiPhy::RX:
442  NS_LOG_DEBUG ("drop packet because of channel switching while reception");
444  m_endRxEvent.Cancel ();
445  goto switchChannel;
446  break;
447  case YansWifiPhy::TX:
448  NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
450  break;
452  case YansWifiPhy::IDLE:
453  goto switchChannel;
454  break;
455  case YansWifiPhy::SLEEP:
456  NS_LOG_DEBUG ("channel switching ignored in sleep mode");
457  break;
458  default:
459  NS_ASSERT (false);
460  break;
461  }
462 
463  return;
464 
465 switchChannel:
466 
467  NS_LOG_DEBUG ("switching channel " << m_channelNumber << " -> " << nch);
468  m_state->SwitchToChannelSwitching (m_channelSwitchDelay);
470  /*
471  * Needed here to be able to correctly sensed the medium for the first
472  * time after the switching. The actual switching is not performed until
473  * after m_channelSwitchDelay. Packets received during the switching
474  * state are added to the event list and are employed later to figure
475  * out the state of the medium after the switching.
476  */
477  m_channelNumber = nch;
478 }
479 
480 uint16_t
482 {
483  return m_channelNumber;
484 }
485 
486 Time
488 {
489  return m_channelSwitchDelay;
490 }
491 
492 double
494 {
496 }
497 
498 void
500 {
501  NS_LOG_FUNCTION (this);
502  switch (m_state->GetState ())
503  {
504  case YansWifiPhy::TX:
505  NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmission");
507  break;
508  case YansWifiPhy::RX:
509  NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception");
511  break;
513  NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching");
515  break;
517  case YansWifiPhy::IDLE:
518  NS_LOG_DEBUG ("setting sleep mode");
519  m_state->SwitchToSleep ();
520  break;
521  case YansWifiPhy::SLEEP:
522  NS_LOG_DEBUG ("already in sleep mode");
523  break;
524  default:
525  NS_ASSERT (false);
526  break;
527  }
528 }
529 
530 void
532 {
533  NS_LOG_FUNCTION (this);
534  switch (m_state->GetState ())
535  {
536  case YansWifiPhy::TX:
537  case YansWifiPhy::RX:
538  case YansWifiPhy::IDLE:
541  {
542  NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume");
543  break;
544  }
545  case YansWifiPhy::SLEEP:
546  {
547  NS_LOG_DEBUG ("resuming from sleep mode");
549  m_state->SwitchFromSleep (delayUntilCcaEnd);
550  break;
551  }
552  default:
553  {
554  NS_ASSERT (false);
555  break;
556  }
557  }
558 }
559 
560 void
562 {
563  m_state->SetReceiveOkCallback (callback);
564 }
565 
566 void
568 {
569  m_state->SetReceiveErrorCallback (callback);
570 }
571 
572 void
574  double rxPowerDbm,
575  WifiTxVector txVector,
576  enum WifiPreamble preamble,
577  enum mpduType mpdutype,
578  Time rxDuration)
579 {
580  //This function should be later split to check separately whether plcp preamble and plcp header can be successfully received.
581  //Note: plcp preamble reception is not yet modeled.
582  NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode () << preamble << (uint32_t)mpdutype);
583  AmpduTag ampduTag;
584  rxPowerDbm += m_rxGainDb;
585  double rxPowerW = DbmToW (rxPowerDbm);
586  Time endRx = Simulator::Now () + rxDuration;
587  Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector, preamble);
588 
590  event = m_interference.Add (packet->GetSize (),
591  txVector,
592  preamble,
593  rxDuration,
594  rxPowerW);
595 
596  switch (m_state->GetState ())
597  {
599  NS_LOG_DEBUG ("drop packet because of channel switching");
600  NotifyRxDrop (packet);
601  m_plcpSuccess = false;
602  /*
603  * Packets received on the upcoming channel are added to the event list
604  * during the switching state. This way the medium can be correctly sensed
605  * when the device listens to the channel for the first time after the
606  * switching e.g. after channel switching, the channel may be sensed as
607  * busy due to other devices' tramissions started before the end of
608  * the switching.
609  */
610  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
611  {
612  //that packet will be noise _after_ the completion of the
613  //channel switching.
614  goto maybeCcaBusy;
615  }
616  break;
617  case YansWifiPhy::RX:
618  NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
619  rxPowerW << "W)");
620  NotifyRxDrop (packet);
621  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
622  {
623  //that packet will be noise _after_ the reception of the
624  //currently-received packet.
625  goto maybeCcaBusy;
626  }
627  break;
628  case YansWifiPhy::TX:
629  NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
630  rxPowerW << "W)");
631  NotifyRxDrop (packet);
632  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
633  {
634  //that packet will be noise _after_ the transmission of the
635  //currently-transmitted packet.
636  goto maybeCcaBusy;
637  }
638  break;
640  case YansWifiPhy::IDLE:
641  if (rxPowerW > m_edThresholdW) //checked here, no need to check in the payload reception (current implementation assumes constant rx power over the packet duration)
642  {
643  if (preamble == WIFI_PREAMBLE_NONE && m_mpdusNum == 0)
644  {
645  NS_LOG_DEBUG ("drop packet because no preamble has been received");
646  NotifyRxDrop (packet);
647  goto maybeCcaBusy;
648  }
649  else if (preamble == WIFI_PREAMBLE_NONE && m_plcpSuccess == false) //A-MPDU reception fails
650  {
651  NS_LOG_DEBUG ("Drop MPDU because no plcp has been received");
652  NotifyRxDrop (packet);
653  goto maybeCcaBusy;
654  }
655  else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
656  {
657  //received the first MPDU in an MPDU
658  m_mpdusNum = ampduTag.GetNoOfMpdus () - 1;
660  }
661  else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
662  {
663  //received the other MPDUs that are part of the A-MPDU
664  if (ampduTag.GetNoOfMpdus () < m_mpdusNum)
665  {
666  NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetNoOfMpdus ());
667  m_mpdusNum = ampduTag.GetNoOfMpdus ();
668  }
669  else
670  {
671  m_mpdusNum--;
672  }
673  }
674  else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 )
675  {
676  NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum);
677  m_mpdusNum = 0;
678  }
679 
680  NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
681  //sync to signal
682  m_state->SwitchToRx (rxDuration);
684  NotifyRxBegin (packet);
686 
687  if (preamble != WIFI_PREAMBLE_NONE)
688  {
690  m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &YansWifiPhy::StartReceivePacket, this,
691  packet, txVector, preamble, mpdutype, event);
692  }
693 
696  packet, preamble, mpdutype, event);
697  }
698  else
699  {
700  NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
701  rxPowerW << "<" << m_edThresholdW << ")");
702  NotifyRxDrop (packet);
703  m_plcpSuccess = false;
704  goto maybeCcaBusy;
705  }
706  break;
707  case YansWifiPhy::SLEEP:
708  NS_LOG_DEBUG ("drop packet because in sleep mode");
709  NotifyRxDrop (packet);
710  m_plcpSuccess = false;
711  break;
712  }
713 
714  return;
715 
716 maybeCcaBusy:
717  //We are here because we have received the first bit of a packet and we are
718  //not going to be able to synchronize on it
719  //In this model, CCA becomes busy when the aggregation of all signals as
720  //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
721 
723  if (!delayUntilCcaEnd.IsZero ())
724  {
725  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
726  }
727 }
728 
729 void
731  WifiTxVector txVector,
732  enum WifiPreamble preamble,
733  enum mpduType mpdutype,
735 {
736  NS_LOG_FUNCTION (this << packet << txVector.GetMode () << preamble << (uint32_t)mpdutype);
737  NS_ASSERT (IsStateRx ());
739  AmpduTag ampduTag;
740  WifiMode txMode = txVector.GetMode ();
741 
742  struct InterferenceHelper::SnrPer snrPer;
743  snrPer = m_interference.CalculatePlcpHeaderSnrPer (event);
744 
745  NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per);
746 
747  if (m_random->GetValue () > snrPer.per) //plcp reception succeeded
748  {
749  if (IsModeSupported (txMode) || IsMcsSupported (txMode))
750  {
751  NS_LOG_DEBUG ("receiving plcp payload"); //endReceive is already scheduled
752  m_plcpSuccess = true;
753  }
754  else //mode is not allowed
755  {
756  NS_LOG_DEBUG ("drop packet because it was sent using an unsupported mode (" << txMode << ")");
757  NotifyRxDrop (packet);
758  m_plcpSuccess = false;
759  }
760  }
761  else //plcp reception failed
762  {
763  NS_LOG_DEBUG ("drop packet because plcp preamble/header reception failed");
764  NotifyRxDrop (packet);
765  m_plcpSuccess = false;
766  }
767 }
768 
769 void
771 {
772  NS_LOG_FUNCTION (this << packet << txVector.GetMode () << txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) << preamble << (uint32_t)txVector.GetTxPowerLevel () << (uint32_t)mpdutype);
773  /* Transmission can happen if:
774  * - we are syncing on a packet. It is the responsability of the
775  * MAC layer to avoid doing this but the PHY does nothing to
776  * prevent it.
777  * - we are idle
778  */
779  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
780 
781  if (m_state->IsStateSleep ())
782  {
783  NS_LOG_DEBUG ("Dropping packet because in sleep mode");
784  NotifyTxDrop (packet);
785  return;
786  }
787 
788  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble, GetFrequency (), mpdutype, 1);
789  NS_ASSERT (txDuration > NanoSeconds (0));
790 
791  if (m_state->IsStateRx ())
792  {
794  m_endRxEvent.Cancel ();
796  }
797  NotifyTxBegin (packet);
798  uint32_t dataRate500KbpsUnits;
800  {
801  dataRate500KbpsUnits = 128 + txVector.GetMode ().GetMcsValue ();
802  }
803  else
804  {
805  dataRate500KbpsUnits = txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) * txVector.GetNss () / 500000;
806  }
807  if (mpdutype == MPDU_IN_AGGREGATE && preamble != WIFI_PREAMBLE_NONE)
808  {
809  //send the first MPDU in an MPDU
811  }
812  struct mpduInfo aMpdu;
813  aMpdu.type = mpdutype;
815  NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, preamble, txVector, aMpdu);
816  m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector, preamble);
817  m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + m_txGainDb, txVector, preamble, mpdutype, txDuration);
818 }
819 
820 uint32_t
822 {
823  return m_deviceRateSet.size ();
824 }
825 
826 WifiMode
827 YansWifiPhy::GetMode (uint32_t mode) const
828 {
829  return m_deviceRateSet[mode];
830 }
831 
832 bool
834 {
835  for (uint32_t i = 0; i < GetNModes (); i++)
836  {
837  if (mode == GetMode (i))
838  {
839  return true;
840  }
841  }
842  return false;
843 }
844 bool
846 {
847  for (uint32_t i = 0; i < GetNMcs (); i++)
848  {
849  if (mcs == GetMcs (i))
850  {
851  return true;
852  }
853  }
854  return false;
855 }
856 
857 uint32_t
859 {
860  return m_nTxPower;
861 }
862 
863 void
865 {
866  NS_LOG_FUNCTION (this);
867  m_channelStartingFrequency = 5e3; //5.000 GHz
868  SetChannelWidth (20); //20 MHz
869 
878 }
879 
880 void
882 {
883  NS_LOG_FUNCTION (this);
884  m_channelStartingFrequency = 2407; //2.407 GHz
885  SetChannelWidth (22); //22 MHz
886 
891 }
892 
893 void
895 {
896  NS_LOG_FUNCTION (this);
897  m_channelStartingFrequency = 2407; //2.407 GHz
898  SetChannelWidth (20); //20 MHz
899 
912 }
913 
914 void
916 {
917  NS_LOG_FUNCTION (this);
918  m_channelStartingFrequency = 5e3; //5.000 GHz, suppose 802.11a
919  SetChannelWidth (10); //10 MHz
920 
929 }
930 
931 void
933 {
934  NS_LOG_FUNCTION (this);
935  m_channelStartingFrequency = 5e3; //5.000 GHz, suppose 802.11a
936  SetChannelWidth (5); //5 MHz
937 
946 }
947 
948 void
950 {
951  NS_LOG_FUNCTION (this);
952  m_channelStartingFrequency = 5e3; //5.000 GHz
953  SetChannelWidth (20); //20 MHz
954 
960 }
961 
962 void
964 {
965  NS_LOG_FUNCTION (this);
966  SetChannelWidth (20); //20 MHz
967  if (m_channelStartingFrequency >= 2400 && m_channelStartingFrequency <= 2500) //at 2.4 GHz
968  {
976  }
977  if (m_channelStartingFrequency >= 5000 && m_channelStartingFrequency <= 6000) //at 5 GHz
978  {
982  }
983 
984  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs0 ());
985  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs1 ());
986  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs2 ());
987  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs3 ());
988  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs4 ());
989  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs5 ());
990  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs6 ());
991  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs7 ());
992 
994 }
995 
996 void
998 {
999  NS_LOG_FUNCTION (this);
1000  m_channelStartingFrequency = 5e3; //5.000 GHz
1001  SetChannelWidth (80); //80 MHz
1002 
1006 
1007  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs0 ());
1008  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs1 ());
1009  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs2 ());
1010  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs3 ());
1011  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs4 ());
1012  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs5 ());
1013  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs6 ());
1014  m_deviceMcsSet.push_back (WifiPhy::GetHtMcs7 ());
1015 
1016  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs0 ());
1017  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs1 ());
1018  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs2 ());
1019  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs3 ());
1020  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs4 ());
1021  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs5 ());
1022  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs6 ());
1023  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs7 ());
1024  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs8 ());
1025  m_deviceMcsSet.push_back (WifiPhy::GetVhtMcs9 ());
1026 
1027  m_bssMembershipSelectorSet.push_back (VHT_PHY);
1028 }
1029 
1030 void
1032 {
1033  m_state->RegisterListener (listener);
1034 }
1035 
1036 void
1038 {
1039  m_state->UnregisterListener (listener);
1040 }
1041 
1042 bool
1044 {
1045  return m_state->IsStateCcaBusy ();
1046 }
1047 
1048 bool
1050 {
1051  return m_state->IsStateIdle ();
1052 }
1053 
1054 bool
1056 {
1057  return m_state->IsStateBusy ();
1058 }
1059 
1060 bool
1062 {
1063  return m_state->IsStateRx ();
1064 }
1065 
1066 bool
1068 {
1069  return m_state->IsStateTx ();
1070 }
1071 
1072 bool
1074 {
1075  return m_state->IsStateSwitching ();
1076 }
1077 
1078 bool
1080 {
1081  return m_state->IsStateSleep ();
1082 }
1083 
1084 Time
1086 {
1087  return m_state->GetStateDuration ();
1088 }
1089 
1090 Time
1092 {
1093  return m_state->GetDelayUntilIdle ();
1094 }
1095 
1096 Time
1098 {
1099  return m_state->GetLastRxStartTime ();
1100 }
1101 
1102 double
1103 YansWifiPhy::DbToRatio (double dB) const
1104 {
1105  double ratio = std::pow (10.0, dB / 10.0);
1106  return ratio;
1107 }
1108 
1109 double
1110 YansWifiPhy::DbmToW (double dBm) const
1111 {
1112  double mW = std::pow (10.0, dBm / 10.0);
1113  return mW / 1000.0;
1114 }
1115 
1116 double
1117 YansWifiPhy::WToDbm (double w) const
1118 {
1119  return 10.0 * std::log10 (w * 1000.0);
1120 }
1121 
1122 double
1123 YansWifiPhy::RatioToDb (double ratio) const
1124 {
1125  return 10.0 * std::log10 (ratio);
1126 }
1127 
1128 double
1130 {
1131  return m_edThresholdW;
1132 }
1133 
1134 double
1135 YansWifiPhy::GetPowerDbm (uint8_t power) const
1136 {
1138  NS_ASSERT (m_nTxPower > 0);
1139  double dbm;
1140  if (m_nTxPower > 1)
1141  {
1142  dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
1143  }
1144  else
1145  {
1146  NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
1147  dbm = m_txPowerBaseDbm;
1148  }
1149  return dbm;
1150 }
1151 
1152 void
1154 {
1155  NS_LOG_FUNCTION (this << packet << event);
1156  NS_ASSERT (IsStateRx ());
1157  NS_ASSERT (event->GetEndTime () == Simulator::Now ());
1158 
1159  struct InterferenceHelper::SnrPer snrPer;
1160  snrPer = m_interference.CalculatePlcpPayloadSnrPer (event);
1162 
1163  if (m_plcpSuccess == true)
1164  {
1165  NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate (event->GetTxVector ().GetChannelWidth (), event->GetTxVector ().IsShortGuardInterval (), 1)) <<
1166  ", snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
1167 
1168  if (m_random->GetValue () > snrPer.per)
1169  {
1170  NotifyRxEnd (packet);
1171  uint32_t dataRate500KbpsUnits;
1172  if ((event->GetPayloadMode ().GetModulationClass () == WIFI_MOD_CLASS_HT) || (event->GetPayloadMode ().GetModulationClass () == WIFI_MOD_CLASS_VHT))
1173  {
1174  dataRate500KbpsUnits = 128 + event->GetPayloadMode ().GetMcsValue ();
1175  }
1176  else
1177  {
1178  dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate (event->GetTxVector ().GetChannelWidth (), event->GetTxVector ().IsShortGuardInterval (), 1) * event->GetTxVector ().GetNss () / 500000;
1179  }
1180  struct signalNoiseDbm signalNoise;
1181  signalNoise.signal = RatioToDb (event->GetRxPowerW ()) + 30;
1182  signalNoise.noise = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
1183  struct mpduInfo aMpdu;
1184  aMpdu.type = mpdutype;
1186  NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, event->GetPreambleType (), event->GetTxVector (), aMpdu, signalNoise);
1187  m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ());
1188  }
1189  else
1190  {
1191  /* failure. */
1192  NotifyRxDrop (packet);
1193  bool isEndOfFrame = ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE) || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE));
1194  m_state->SwitchFromRxEndError (packet, snrPer.snr, isEndOfFrame);
1195  }
1196  }
1197  else
1198  {
1199  bool isEndOfFrame = ((mpdutype == NORMAL_MPDU && preamble != WIFI_PREAMBLE_NONE) || (mpdutype == LAST_MPDU_IN_AGGREGATE && preamble == WIFI_PREAMBLE_NONE));
1200  m_state->SwitchFromRxEndError (packet, snrPer.snr, isEndOfFrame);
1201  }
1202 
1203  if (preamble == WIFI_PREAMBLE_NONE && mpdutype == LAST_MPDU_IN_AGGREGATE)
1204  {
1205  m_plcpSuccess = false;
1206  }
1207 }
1208 
1209 int64_t
1211 {
1212  NS_LOG_FUNCTION (this << stream);
1213  m_random->SetStream (stream);
1214  return 1;
1215 }
1216 
1217 void
1219 {
1221 }
1222 
1223 void
1225 {
1227 }
1228 
1229 void
1231 {
1232  m_numberOfReceivers = rx;
1233 }
1234 
1235 void
1237 {
1238  m_ldpc = Ldpc;
1239 }
1240 
1241 void
1243 {
1244  m_stbc = stbc;
1245 }
1246 
1247 void
1249 {
1250  m_greenfield = greenfield;
1251 }
1252 
1253 bool
1255 {
1256  return m_guardInterval;
1257 }
1258 
1259 void
1260 YansWifiPhy::SetGuardInterval (bool guardInterval)
1261 {
1262  m_guardInterval = guardInterval;
1263 }
1264 
1265 uint32_t
1267 {
1269 }
1270 
1271 uint32_t
1273 {
1274  return m_numberOfTransmitters;
1275 }
1276 
1277 uint32_t
1279 {
1280  return m_numberOfReceivers;
1281 }
1282 
1283 bool
1285 {
1286  return m_ldpc;
1287 }
1288 
1289 bool
1291 {
1292  return m_stbc;
1293 }
1294 
1295 bool
1297 {
1298  return m_greenfield;
1299 }
1300 
1301 bool
1303 {
1304  return m_plcpPreamble;
1305 }
1306 
1307 void
1309 {
1310  m_plcpPreamble = preamble;
1311 }
1312 
1313 void
1314 YansWifiPhy::SetChannelWidth (uint32_t channelwidth)
1315 {
1316  NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 || channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth == 160, "wrong channel width value");
1317  m_channelWidth = channelwidth;
1318 }
1319 
1320 uint32_t
1322 {
1323  return m_channelWidth;
1324 }
1325 
1326 uint32_t
1328 {
1329  return m_bssMembershipSelectorSet.size ();
1330 }
1331 
1332 uint32_t
1333 YansWifiPhy::GetBssMembershipSelector (uint32_t selector) const
1334 {
1335  return m_bssMembershipSelectorSet[selector];
1336 }
1337 
1340 {
1341  uint32_t id = GetBssMembershipSelector (selector);
1342  WifiModeList supportedmodes;
1343  if (id == HT_PHY || id == VHT_PHY)
1344  {
1345  //mandatory MCS 0 to 7
1346  supportedmodes.push_back (WifiPhy::GetHtMcs0 ());
1347  supportedmodes.push_back (WifiPhy::GetHtMcs1 ());
1348  supportedmodes.push_back (WifiPhy::GetHtMcs2 ());
1349  supportedmodes.push_back (WifiPhy::GetHtMcs3 ());
1350  supportedmodes.push_back (WifiPhy::GetHtMcs4 ());
1351  supportedmodes.push_back (WifiPhy::GetHtMcs5 ());
1352  supportedmodes.push_back (WifiPhy::GetHtMcs6 ());
1353  supportedmodes.push_back (WifiPhy::GetHtMcs7 ());
1354  }
1355  if (id == VHT_PHY)
1356  {
1357  //mandatory MCS 0 to 9
1358  supportedmodes.push_back (WifiPhy::GetVhtMcs0 ());
1359  supportedmodes.push_back (WifiPhy::GetVhtMcs1 ());
1360  supportedmodes.push_back (WifiPhy::GetVhtMcs2 ());
1361  supportedmodes.push_back (WifiPhy::GetVhtMcs3 ());
1362  supportedmodes.push_back (WifiPhy::GetVhtMcs4 ());
1363  supportedmodes.push_back (WifiPhy::GetVhtMcs5 ());
1364  supportedmodes.push_back (WifiPhy::GetVhtMcs6 ());
1365  supportedmodes.push_back (WifiPhy::GetVhtMcs7 ());
1366  supportedmodes.push_back (WifiPhy::GetVhtMcs8 ());
1367  supportedmodes.push_back (WifiPhy::GetVhtMcs9 ());
1368  }
1369  return supportedmodes;
1370 }
1371 
1372 uint8_t
1374 {
1375  return m_deviceMcsSet.size ();
1376 }
1377 
1378 WifiMode
1379 YansWifiPhy::GetMcs (uint8_t mcs) const
1380 {
1381  return m_deviceMcsSet[mcs];
1382 }
1383 
1384 } //namespace ns3
ERP-OFDM PHY (Clause 19, Section 19.5)
bool m_plcpPreamble
Flag if short PLCP preamble is used.
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 void SetShortPlcpPreamble(bool preamble)
Enable or disable short PLCP preamble.
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).
enum mpduType type
Definition: wifi-phy.h:63
802.11 PHY layer model
Definition: wifi-phy.h:151
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:166
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
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:182
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
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
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, enum WifiPreamble preamble, double frequency, enum mpduType mpdutype, uint8_t incFlag)
Definition: wifi-phy.cc:605
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)
virtual void SendPacket(Ptr< const Packet > packet, WifiTxVector txVector, enum WifiPreamble preamble, enum mpduType mpdutype)
static WifiMode GetVhtMcs4()
Return MCS 4 from VHT MCS values.
Definition: wifi-phy.cc:1405
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU...
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 StartReceivePacket(Ptr< Packet > packet, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype, Ptr< InterferenceHelper::Event > event)
Starting receiving the payload of a packet (i.e.
void SetEdThreshold(double threshold)
Sets the energy detection threshold (dBm).
The MPDU is not part of an A-MPDU.
Definition: wifi-phy.h:48
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
uint32_t mpduRefNumber
Definition: wifi-phy.h:64
#define VHT_PHY
Definition: yans-wifi-phy.h:44
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:70
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:162
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:174
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
uint32_t m_txMpduReferenceNumber
A-MPDU reference number to identify all transmitted subframes belonging to the same received A-MPDU...
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:170
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:178
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)
The MPDU is part of an A-MPDU, but is not the last aggregate.
Definition: wifi-phy.h:50
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)
virtual bool GetShortPlcpPreamble(void) const
Return whether short PLCP preamble is supported.
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.
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
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.
void StartReceivePreambleAndHeader(Ptr< Packet > packet, double rxPowerDbm, WifiTxVector txVector, WifiPreamble preamble, enum mpduType mpdutype, Time rxDuration)
Starting receiving the plcp of a packet (i.e.
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
#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
void EndReceive(Ptr< Packet > packet, enum WifiPreamble preamble, enum mpduType mpdutype, 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: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)
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.
mpduType
This enumeration defines the type of an MPDU.
Definition: wifi-phy.h:45
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.
The MPDU is the last aggregate in an A-MPDU.
Definition: wifi-phy.h:52
Ptr< MobilityModel > GetMobility(void)
Return the mobility model this PHY is associated with.
virtual void SetGreenfield(bool greenfield)
Enable or disable Greenfield support.