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-phy-state-helper.h"
26 #include "ns3/simulator.h"
27 #include "ns3/packet.h"
28 #include "ns3/assert.h"
29 #include "ns3/log.h"
30 #include "ns3/double.h"
31 #include "ampdu-tag.h"
32 #include <cmath>
33 
34 namespace ns3 {
35 
36 NS_LOG_COMPONENT_DEFINE ("YansWifiPhy");
37 
38 NS_OBJECT_ENSURE_REGISTERED (YansWifiPhy);
39 
40 TypeId
42 {
43  static TypeId tid = TypeId ("ns3::YansWifiPhy")
44  .SetParent<WifiPhy> ()
45  .SetGroupName ("Wifi")
46  .AddConstructor<YansWifiPhy> ()
47  ;
48  return tid;
49 }
50 
52 {
53  NS_LOG_FUNCTION (this);
54 }
55 
57 {
58  NS_LOG_FUNCTION (this);
59 }
60 
61 void
63 {
64  NS_LOG_FUNCTION (this);
65  m_channel = 0;
66 }
67 
68 bool
70 {
71  if (!IsInitialized ())
72  {
73  //this is not channel switch, this is initialization
74  NS_LOG_DEBUG ("initialize to channel " << nch);
75  return true;
76  }
77 
79  switch (m_state->GetState ())
80  {
81  case YansWifiPhy::RX:
82  NS_LOG_DEBUG ("drop packet because of channel switching while reception");
85  goto switchChannel;
86  break;
87  case YansWifiPhy::TX:
88  NS_LOG_DEBUG ("channel switching postponed until end of current transmission");
90  break;
92  case YansWifiPhy::IDLE:
93  goto switchChannel;
94  break;
95  case YansWifiPhy::SLEEP:
96  NS_LOG_DEBUG ("channel switching ignored in sleep mode");
97  break;
98  default:
99  NS_ASSERT (false);
100  break;
101  }
102 
103  return false;
104 
105 switchChannel:
106 
107  NS_LOG_DEBUG ("switching channel " << GetChannelNumber () << " -> " << nch);
108  m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ());
110  /*
111  * Needed here to be able to correctly sensed the medium for the first
112  * time after the switching. The actual switching is not performed until
113  * after m_channelSwitchDelay. Packets received during the switching
114  * state are added to the event list and are employed later to figure
115  * out the state of the medium after the switching.
116  */
117  return true;
118 }
119 
120 bool
121 YansWifiPhy::DoFrequencySwitch (uint32_t frequency)
122 {
123  if (!IsInitialized ())
124  {
125  //this is not channel switch, this is initialization
126  NS_LOG_DEBUG ("start at frequency " << frequency);
127  return true;
128  }
129 
131  switch (m_state->GetState ())
132  {
133  case YansWifiPhy::RX:
134  NS_LOG_DEBUG ("drop packet because of channel/frequency switching while reception");
136  m_endRxEvent.Cancel ();
137  goto switchFrequency;
138  break;
139  case YansWifiPhy::TX:
140  NS_LOG_DEBUG ("channel/frequency switching postponed until end of current transmission");
142  break;
144  case YansWifiPhy::IDLE:
145  goto switchFrequency;
146  break;
147  case YansWifiPhy::SLEEP:
148  NS_LOG_DEBUG ("frequency switching ignored in sleep mode");
149  break;
150  default:
151  NS_ASSERT (false);
152  break;
153  }
154 
155  return false;
156 
157 switchFrequency:
158 
159  NS_LOG_DEBUG ("switching frequency " << GetFrequency () << " -> " << frequency);
160  m_state->SwitchToChannelSwitching (GetChannelSwitchDelay ());
162  /*
163  * Needed here to be able to correctly sensed the medium for the first
164  * time after the switching. The actual switching is not performed until
165  * after m_channelSwitchDelay. Packets received during the switching
166  * state are added to the event list and are employed later to figure
167  * out the state of the medium after the switching.
168  */
169  return true;
170 }
171 
174 {
175  return m_channel;
176 }
177 
178 void
180 {
181  m_channel = channel;
182  m_channel->Add (this);
183 }
184 
185 void
187 {
188  NS_LOG_FUNCTION (this);
189  switch (m_state->GetState ())
190  {
191  case YansWifiPhy::TX:
192  NS_LOG_DEBUG ("setting sleep mode postponed until end of current transmission");
194  break;
195  case YansWifiPhy::RX:
196  NS_LOG_DEBUG ("setting sleep mode postponed until end of current reception");
198  break;
200  NS_LOG_DEBUG ("setting sleep mode postponed until end of channel switching");
202  break;
204  case YansWifiPhy::IDLE:
205  NS_LOG_DEBUG ("setting sleep mode");
206  m_state->SwitchToSleep ();
207  break;
208  case YansWifiPhy::SLEEP:
209  NS_LOG_DEBUG ("already in sleep mode");
210  break;
211  default:
212  NS_ASSERT (false);
213  break;
214  }
215 }
216 
217 void
219 {
220  NS_LOG_FUNCTION (this);
221  switch (m_state->GetState ())
222  {
223  case YansWifiPhy::TX:
224  case YansWifiPhy::RX:
225  case YansWifiPhy::IDLE:
228  {
229  NS_LOG_DEBUG ("not in sleep mode, there is nothing to resume");
230  break;
231  }
232  case YansWifiPhy::SLEEP:
233  {
234  NS_LOG_DEBUG ("resuming from sleep mode");
236  m_state->SwitchFromSleep (delayUntilCcaEnd);
237  break;
238  }
239  default:
240  {
241  NS_ASSERT (false);
242  break;
243  }
244  }
245 }
246 
247 void
249 {
250  m_state->SetReceiveOkCallback (callback);
251 }
252 
253 void
255 {
256  m_state->SetReceiveErrorCallback (callback);
257 }
258 
259 void
261  double rxPowerDbm,
262  WifiTxVector txVector,
263  enum WifiPreamble preamble,
264  enum mpduType mpdutype,
265  Time rxDuration)
266 {
267  //This function should be later split to check separately whether plcp preamble and plcp header can be successfully received.
268  //Note: plcp preamble reception is not yet modeled.
269  NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode () << preamble << (uint32_t)mpdutype);
270  AmpduTag ampduTag;
271  rxPowerDbm += GetRxGain ();
272  double rxPowerW = DbmToW (rxPowerDbm);
273  Time endRx = Simulator::Now () + rxDuration;
274  Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector, preamble);
275 
277  event = m_interference.Add (packet->GetSize (),
278  txVector,
279  preamble,
280  rxDuration,
281  rxPowerW);
282 
283  switch (m_state->GetState ())
284  {
286  NS_LOG_DEBUG ("drop packet because of channel switching");
287  NotifyRxDrop (packet);
288  m_plcpSuccess = false;
289  /*
290  * Packets received on the upcoming channel are added to the event list
291  * during the switching state. This way the medium can be correctly sensed
292  * when the device listens to the channel for the first time after the
293  * switching e.g. after channel switching, the channel may be sensed as
294  * busy due to other devices' tramissions started before the end of
295  * the switching.
296  */
297  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
298  {
299  //that packet will be noise _after_ the completion of the
300  //channel switching.
301  goto maybeCcaBusy;
302  }
303  break;
304  case YansWifiPhy::RX:
305  NS_LOG_DEBUG ("drop packet because already in Rx (power=" <<
306  rxPowerW << "W)");
307  NotifyRxDrop (packet);
308  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
309  {
310  //that packet will be noise _after_ the reception of the
311  //currently-received packet.
312  goto maybeCcaBusy;
313  }
314  break;
315  case YansWifiPhy::TX:
316  NS_LOG_DEBUG ("drop packet because already in Tx (power=" <<
317  rxPowerW << "W)");
318  NotifyRxDrop (packet);
319  if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
320  {
321  //that packet will be noise _after_ the transmission of the
322  //currently-transmitted packet.
323  goto maybeCcaBusy;
324  }
325  break;
327  case YansWifiPhy::IDLE:
328  if (rxPowerW > GetEdThresholdW ()) //checked here, no need to check in the payload reception (current implementation assumes constant rx power over the packet duration)
329  {
330  if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false))
331  {
332  m_plcpSuccess = false;
333  m_mpdusNum = 0;
334  NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been received");
335  NotifyRxDrop (packet);
336  goto maybeCcaBusy;
337  }
338  else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
339  {
340  //received the first MPDU in an MPDU
341  m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
343  }
344  else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
345  {
346  //received the other MPDUs that are part of the A-MPDU
347  if (ampduTag.GetRemainingNbOfMpdus () < (m_mpdusNum - 1))
348  {
349  NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetRemainingNbOfMpdus ());
350  m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
351  }
352  else
353  {
354  m_mpdusNum--;
355  }
356  }
357  else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
358  {
359  NS_LOG_DEBUG ("New A-MPDU started while " << m_mpdusNum << " MPDUs from previous are lost");
360  m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
361  }
362  else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 )
363  {
364  NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum);
365  m_mpdusNum = 0;
366  }
367 
368  NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
369  //sync to signal
370  m_state->SwitchToRx (rxDuration);
372  NotifyRxBegin (packet);
374 
375  if (preamble != WIFI_PREAMBLE_NONE)
376  {
378  m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &YansWifiPhy::StartReceivePacket, this,
379  packet, txVector, preamble, mpdutype, event);
380  }
381 
384  packet, preamble, mpdutype, event);
385  }
386  else
387  {
388  NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
389  rxPowerW << "<" << GetEdThresholdW () << ")");
390  NotifyRxDrop (packet);
391  m_plcpSuccess = false;
392  goto maybeCcaBusy;
393  }
394  break;
395  case YansWifiPhy::SLEEP:
396  NS_LOG_DEBUG ("drop packet because in sleep mode");
397  NotifyRxDrop (packet);
398  m_plcpSuccess = false;
399  break;
400  }
401 
402  return;
403 
404 maybeCcaBusy:
405  //We are here because we have received the first bit of a packet and we are
406  //not going to be able to synchronize on it
407  //In this model, CCA becomes busy when the aggregation of all signals as
408  //tracked by the InterferenceHelper class is higher than the CcaBusyThreshold
409 
411  if (!delayUntilCcaEnd.IsZero ())
412  {
413  m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
414  }
415 }
416 
417 void
419  WifiTxVector txVector,
420  enum WifiPreamble preamble,
421  enum mpduType mpdutype,
423 {
424  NS_LOG_FUNCTION (this << packet << txVector.GetMode () << preamble << (uint32_t)mpdutype);
425  NS_ASSERT (IsStateRx ());
427  WifiMode txMode = txVector.GetMode ();
428 
429  struct InterferenceHelper::SnrPer snrPer;
430  snrPer = m_interference.CalculatePlcpHeaderSnrPer (event);
431 
432  NS_LOG_DEBUG ("snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per);
433 
434  if (m_random->GetValue () > snrPer.per) //plcp reception succeeded
435  {
436  if (IsModeSupported (txMode) || IsMcsSupported (txMode))
437  {
438  NS_LOG_DEBUG ("receiving plcp payload"); //endReceive is already scheduled
439  m_plcpSuccess = true;
440  }
441  else //mode is not allowed
442  {
443  NS_LOG_DEBUG ("drop packet because it was sent using an unsupported mode (" << txMode << ")");
444  NotifyRxDrop (packet);
445  m_plcpSuccess = false;
446  }
447  }
448  else //plcp reception failed
449  {
450  NS_LOG_DEBUG ("drop packet because plcp preamble/header reception failed");
451  NotifyRxDrop (packet);
452  m_plcpSuccess = false;
453  }
454 }
455 
456 void
458 {
459  SendPacket (packet, txVector, preamble, NORMAL_MPDU);
460 }
461 
462 void
464 {
465  NS_LOG_FUNCTION (this << packet << txVector.GetMode ()
466  << txVector.GetMode ().GetDataRate (txVector)
467  << preamble << (uint32_t)txVector.GetTxPowerLevel () << (uint32_t)mpdutype);
468  /* Transmission can happen if:
469  * - we are syncing on a packet. It is the responsability of the
470  * MAC layer to avoid doing this but the PHY does nothing to
471  * prevent it.
472  * - we are idle
473  */
474  NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
475 
476  if (m_state->IsStateSleep ())
477  {
478  NS_LOG_DEBUG ("Dropping packet because in sleep mode");
479  NotifyTxDrop (packet);
480  return;
481  }
482 
483  Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble, GetFrequency (), mpdutype, 1);
484  NS_ASSERT (txDuration > NanoSeconds (0));
485 
486  if (m_state->IsStateRx ())
487  {
489  m_endRxEvent.Cancel ();
491  }
492  NotifyTxBegin (packet);
493  uint32_t dataRate500KbpsUnits;
495  {
496  dataRate500KbpsUnits = 128 + txVector.GetMode ().GetMcsValue ();
497  }
498  else
499  {
500  dataRate500KbpsUnits = txVector.GetMode ().GetDataRate (txVector.GetChannelWidth (), txVector.IsShortGuardInterval (), 1) * txVector.GetNss () / 500000;
501  }
502  if (mpdutype == MPDU_IN_AGGREGATE && preamble != WIFI_PREAMBLE_NONE)
503  {
504  //send the first MPDU in an MPDU
506  }
507  struct mpduInfo aMpdu;
508  aMpdu.type = mpdutype;
510  NotifyMonitorSniffTx (packet, (uint16_t)GetFrequency (), GetChannelNumber (), dataRate500KbpsUnits, preamble, txVector, aMpdu);
511  m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector, preamble);
512  m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + GetTxGain (), txVector, preamble, mpdutype, txDuration);
513 }
514 
515 void
517 {
518  m_state->RegisterListener (listener);
519 }
520 
521 void
523 {
524  m_state->UnregisterListener (listener);
525 }
526 
527 void
529 {
530  NS_LOG_FUNCTION (this << packet << event);
531  NS_ASSERT (IsStateRx ());
532  NS_ASSERT (event->GetEndTime () == Simulator::Now ());
533 
534  struct InterferenceHelper::SnrPer snrPer;
537 
538  if (m_plcpSuccess == true)
539  {
540  NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate (event->GetTxVector ())) <<
541  ", snr(dB)=" << RatioToDb (snrPer.snr) << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
542 
543  if (m_random->GetValue () > snrPer.per)
544  {
545  NotifyRxEnd (packet);
546  uint32_t dataRate500KbpsUnits;
547  if ((event->GetPayloadMode ().GetModulationClass () == WIFI_MOD_CLASS_HT) || (event->GetPayloadMode ().GetModulationClass () == WIFI_MOD_CLASS_VHT))
548  {
549  dataRate500KbpsUnits = 128 + event->GetPayloadMode ().GetMcsValue ();
550  }
551  else
552  {
553  dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate (event->GetTxVector ().GetChannelWidth (), event->GetTxVector ().IsShortGuardInterval (), 1) * event->GetTxVector ().GetNss () / 500000;
554  }
555  struct signalNoiseDbm signalNoise;
556  signalNoise.signal = RatioToDb (event->GetRxPowerW ()) + 30;
557  signalNoise.noise = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
558  struct mpduInfo aMpdu;
559  aMpdu.type = mpdutype;
561  NotifyMonitorSniffRx (packet, (uint16_t)GetFrequency (), GetChannelNumber (), dataRate500KbpsUnits, event->GetPreambleType (), event->GetTxVector (), aMpdu, signalNoise);
562  m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ());
563  }
564  else
565  {
566  /* failure. */
567  NotifyRxDrop (packet);
568  m_state->SwitchFromRxEndError (packet, snrPer.snr);
569  }
570  }
571  else
572  {
573  m_state->SwitchFromRxEndError (packet, snrPer.snr);
574  }
575 
576  if (preamble == WIFI_PREAMBLE_NONE && mpdutype == LAST_MPDU_IN_AGGREGATE)
577  {
578  m_plcpSuccess = false;
579  }
580 }
581 
582 } //namespace ns3
tuple channel
Definition: third.py:85
uint32_t m_txMpduReferenceNumber
A-MPDU reference number to identify all transmitted subframes belonging to the same received A-MPDU...
Definition: wifi-phy.h:1589
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
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:1990
A struct for both SNR and PER.
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 "...
double RatioToDb(double ratio) const
Convert from ratio to dB.
Definition: wifi-phy.cc:2894
double GetTxGain(void) const
Return the transmission gain (dB).
Definition: wifi-phy.cc:514
double GetRxNoiseFigure(void) const
Return the RX noise figure (dBm).
Definition: wifi-phy.cc:462
virtual bool IsMcsSupported(WifiMode mcs) const
Check if the given WifiMode is supported by the PHY.
Definition: wifi-phy.cc:2837
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint8_t GetRemainingNbOfMpdus(void) const
Definition: ampdu-tag.cc:110
virtual void SendPacket(Ptr< const Packet > packet, WifiTxVector txVector, enum WifiPreamble preamble)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
Ptr< YansWifiChannel > m_channel
YansWifiChannel that this YansWifiPhy is connected to.
enum mpduType type
Definition: wifi-phy.h:74
802.11 PHY layer model
Definition: wifi-phy.h:162
The PHY layer has sense the medium busy through the CCA mechanism.
Definition: wifi-phy.h:177
bool IsZero(void) const
Definition: nstime.h:274
enum WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:379
#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
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:792
The PHY layer is sleeping.
Definition: wifi-phy.h:193
void NotifyTxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyTxDrop trace.
Definition: wifi-phy.cc:1960
VHT PHY (Clause 22)
Definition: wifi-mode.h:64
void NotifyTxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyTxBegin trace.
Definition: wifi-phy.cc:1948
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
virtual bool IsModeSupported(WifiMode mode) const
Check if the given WifiMode is supported by the PHY.
Definition: wifi-phy.cc:2824
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:1984
uint8_t GetTxPowerLevel(void) const
virtual bool DoFrequencySwitch(uint32_t frequency)
The default implementation does nothing and returns true.
uint16_t m_mpdusNum
carries the number of expected mpdus that are part of an A-MPDU
Definition: wifi-phy.h:1587
virtual void SetReceiveErrorCallback(WifiPhy::RxErrorCallback callback)
void NotifyRxDrop(Ptr< const Packet > packet)
Public method used to fire a PhyRxDrop trace.
Definition: wifi-phy.cc:1978
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
double GetPowerDbm(uint8_t power) const
Get the power of the given power level in dBm.
Definition: wifi-phy.cc:641
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Definition: packet.cc:846
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.
The MPDU is not part of an A-MPDU.
Definition: wifi-phy.h:59
virtual uint16_t GetChannelNumber(void) const
Return current channel number.
Definition: wifi-phy.cc:1329
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1238
Time CalculatePlcpPreambleAndHeaderDuration(WifiTxVector txVector, enum WifiPreamble preamble)
Definition: wifi-phy.cc:1921
uint32_t mpduRefNumber
Definition: wifi-phy.h:75
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:81
The PHY layer is IDLE.
Definition: wifi-phy.h:173
EventId m_endPlcpRxEvent
Definition: wifi-phy.h:1593
virtual void DoDispose(void)
Destructor implementation.
uint32_t GetChannelWidth(void) const
HT PHY (Clause 20)
Definition: wifi-mode.h:62
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 Time GetDelayUntilIdle(void)
Definition: wifi-phy.cc:2948
uint8_t GetMcsValue(void) const
Definition: wifi-mode.cc:357
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, enum WifiPreamble preamble, double frequency)
Definition: wifi-phy.cc:1942
uint32_t m_rxMpduReferenceNumber
A-MPDU reference number to identify all received subframes belonging to the same received A-MPDU...
Definition: wifi-phy.h:1590
The PHY layer is receiving a packet.
Definition: wifi-phy.h:185
virtual uint32_t GetFrequency(void) const
Definition: wifi-phy.cc:1143
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:38
void NotifyRxBegin(Ptr< const Packet > packet)
Public method used to fire a PhyRxBegin trace.
Definition: wifi-phy.cc:1966
The PHY layer is sending a packet.
Definition: wifi-phy.h:181
virtual void SetChannelNumber(uint16_t id)
Set channel number.
Definition: wifi-phy.cc:1275
The PHY layer is switching to other channel.
Definition: wifi-phy.h:189
void SetChannel(Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
The MPDU is part of an A-MPDU, but is not the last aggregate.
Definition: wifi-phy.h:61
virtual ~YansWifiPhy()
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)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void NotifyRxStart()
Notify that RX has started.
void EraseEvents(void)
Erase all events.
802.11 PHY layer modelThis PHY implements a model of 802.11a.
Definition: yans-wifi-phy.h:47
Ptr< InterferenceHelper::Event > Add(uint32_t size, WifiTxVector txVector, enum WifiPreamble preamble, Time duration, double rxPower)
Add the packet-related signal to interference helper.
static TypeId GetTypeId(void)
bool IsInitialized(void) const
Check if the object has been initialized.
Definition: object.cc:208
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
uint64_t GetDataRate(uint32_t channelWidth, bool isShortGuardInterval, uint8_t nss) const
Definition: wifi-mode.cc:109
virtual void SetSleepMode(void)
Put in sleep mode.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:224
Ptr< UniformRandomVariable > m_random
Provides uniform random variables.
Definition: wifi-phy.h:1584
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
bool m_plcpSuccess
Flag if the PLCP of the packet or the first MPDU in an A-MPDU has been received.
Definition: wifi-phy.h:1588
EventId m_endRxEvent
Definition: wifi-phy.h:1592
Ptr< WifiPhyStateHelper > m_state
Pointer to WifiPhyStateHelper.
Definition: wifi-phy.h:1585
void NotifyRxEnd(Ptr< const Packet > packet)
Public method used to fire a PhyRxEnd trace.
Definition: wifi-phy.cc:1972
void NotifyRxEnd()
Notify that RX has ended.
virtual bool IsStateSwitching(void)
Definition: wifi-phy.cc:2930
InterferenceHelper m_interference
Pointer to InterferenceHelper.
Definition: wifi-phy.h:1583
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
virtual void SetFrequency(uint32_t freq)
Definition: wifi-phy.cc:1086
virtual Time GetChannelSwitchDelay(void) const
Definition: wifi-phy.cc:659
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
double DbmToW(double dbm) const
Convert from dBm to Watts.
Definition: wifi-phy.cc:2881
virtual Ptr< WifiChannel > GetChannel(void) const
Return the WifiChannel this WifiPhy is connected to.
double GetEdThresholdW(void) const
Return the energy detection threshold.
Definition: wifi-phy.cc:430
WifiMode GetMode(void) const
virtual bool IsStateRx(void)
Definition: wifi-phy.cc:2918
double GetCcaMode1Threshold(void) const
Return the CCA threshold (dBm).
Definition: wifi-phy.cc:449
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.
a unique identifier for an interface.
Definition: type-id.h:58
virtual void ResumeFromSleep(void)
Resume from sleep mode.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
double GetRxGain(void) const
Return the reception gain (dB).
Definition: wifi-phy.cc:527
mpduType
This enumeration defines the type of an MPDU.
Definition: wifi-phy.h:56
virtual bool DoChannelSwitch(uint16_t id)
The default implementation does nothing and returns true.
The MPDU is the last aggregate in an A-MPDU.
Definition: wifi-phy.h:63