A Discrete-Event Network Simulator
API
wifi-phy-state-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include <algorithm>
22 #include "ns3/log.h"
23 #include "ns3/simulator.h"
24 #include "ns3/packet.h"
25 #include "wifi-phy-state-helper.h"
26 #include "wifi-tx-vector.h"
27 #include "wifi-phy-listener.h"
28 #include "wifi-psdu.h"
29 #include "wifi-phy.h"
30 
31 namespace ns3 {
32 
33 NS_LOG_COMPONENT_DEFINE ("WifiPhyStateHelper");
34 
35 NS_OBJECT_ENSURE_REGISTERED (WifiPhyStateHelper);
36 
37 TypeId
39 {
40  static TypeId tid = TypeId ("ns3::WifiPhyStateHelper")
41  .SetParent<Object> ()
42  .SetGroupName ("Wifi")
43  .AddConstructor<WifiPhyStateHelper> ()
44  .AddTraceSource ("State",
45  "The state of the PHY layer",
47  "ns3::WifiPhyStateHelper::StateTracedCallback")
48  .AddTraceSource ("RxOk",
49  "A packet has been received successfully.",
51  "ns3::WifiPhyStateHelper::RxOkTracedCallback")
52  .AddTraceSource ("RxError",
53  "A packet has been received unsuccessfully.",
55  "ns3::WifiPhyStateHelper::RxEndErrorTracedCallback")
56  .AddTraceSource ("Tx", "Packet transmission is starting.",
58  "ns3::WifiPhyStateHelper::TxTracedCallback")
59  ;
60  return tid;
61 }
62 
64  : m_sleeping (false),
65  m_isOff (false),
66  m_endTx (Seconds (0)),
67  m_endRx (Seconds (0)),
68  m_endCcaBusy (Seconds (0)),
69  m_endSwitching (Seconds (0)),
70  m_startTx (Seconds (0)),
71  m_startRx (Seconds (0)),
72  m_startCcaBusy (Seconds (0)),
73  m_startSwitching (Seconds (0)),
74  m_startSleep (Seconds (0)),
75  m_previousStateChangeTime (Seconds (0))
76 {
77  NS_LOG_FUNCTION (this);
78 }
79 
80 void
82 {
83  m_rxOkCallback = callback;
84 }
85 
86 void
88 {
89  m_rxErrorCallback = callback;
90 }
91 
92 void
94 {
95  m_listeners.push_back (listener);
96 }
97 
98 void
100 {
101  ListenersI i = find (m_listeners.begin (), m_listeners.end (), listener);
102  if (i != m_listeners.end ())
103  {
104  m_listeners.erase (i);
105  }
106 }
107 
108 bool
110 {
111  return (GetState () == WifiPhyState::IDLE);
112 }
113 
114 bool
116 {
117  return (GetState () == WifiPhyState::CCA_BUSY);
118 }
119 
120 bool
122 {
123  return (GetState () == WifiPhyState::RX);
124 }
125 
126 bool
128 {
129  return (GetState () == WifiPhyState::TX);
130 }
131 
132 bool
134 {
135  return (GetState () == WifiPhyState::SWITCHING);
136 }
137 
138 bool
140 {
141  return (GetState () == WifiPhyState::SLEEP);
142 }
143 
144 bool
146 {
147  return (GetState () == WifiPhyState::OFF);
148 }
149 
150 Time
152 {
153  Time retval;
154 
155  switch (GetState ())
156  {
157  case WifiPhyState::RX:
158  retval = m_endRx - Simulator::Now ();
159  break;
160  case WifiPhyState::TX:
161  retval = m_endTx - Simulator::Now ();
162  break;
164  retval = m_endCcaBusy - Simulator::Now ();
165  break;
167  retval = m_endSwitching - Simulator::Now ();
168  break;
169  case WifiPhyState::IDLE:
170  case WifiPhyState::SLEEP:
171  case WifiPhyState::OFF:
172  retval = Seconds (0);
173  break;
174  default:
175  NS_FATAL_ERROR ("Invalid WifiPhy state.");
176  retval = Seconds (0);
177  break;
178  }
179  retval = Max (retval, Seconds (0));
180  return retval;
181 }
182 
183 Time
185 {
186  return m_startRx;
187 }
188 
189 Time
191 {
192  return m_endRx;
193 }
194 
197 {
198  if (m_isOff)
199  {
200  return WifiPhyState::OFF;
201  }
202  if (m_sleeping)
203  {
204  return WifiPhyState::SLEEP;
205  }
206  else if (m_endTx > Simulator::Now ())
207  {
208  return WifiPhyState::TX;
209  }
210  else if (m_endRx > Simulator::Now ())
211  {
212  return WifiPhyState::RX;
213  }
214  else if (m_endSwitching > Simulator::Now ())
215  {
217  }
218  else if (m_endCcaBusy > Simulator::Now ())
219  {
220  return WifiPhyState::CCA_BUSY;
221  }
222  else
223  {
224  return WifiPhyState::IDLE;
225  }
226 }
227 
228 void
229 WifiPhyStateHelper::NotifyTxStart (Time duration, double txPowerDbm)
230 {
231  NS_LOG_FUNCTION (this);
232  for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++)
233  {
234  (*i)->NotifyTxStart (duration, txPowerDbm);
235  }
236 }
237 
238 void
240 {
241  NS_LOG_FUNCTION (this);
242  for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++)
243  {
244  (*i)->NotifyRxStart (duration);
245  }
246 }
247 
248 void
250 {
251  NS_LOG_FUNCTION (this);
252  for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++)
253  {
254  (*i)->NotifyRxEndOk ();
255  }
256 }
257 
258 void
260 {
261  NS_LOG_FUNCTION (this);
262  for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++)
263  {
264  (*i)->NotifyRxEndError ();
265  }
266 }
267 
268 void
270 {
271  NS_LOG_FUNCTION (this);
272  for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++)
273  {
274  (*i)->NotifyMaybeCcaBusyStart (duration);
275  }
276 }
277 
278 void
280 {
281  NS_LOG_FUNCTION (this);
282  for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++)
283  {
284  (*i)->NotifySwitchingStart (duration);
285  }
286 }
287 
288 void
290 {
291  NS_LOG_FUNCTION (this);
292  for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++)
293  {
294  (*i)->NotifySleep ();
295  }
296 }
297 
298 void
300 {
301  NS_LOG_FUNCTION (this);
302  for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++)
303  {
304  (*i)->NotifyOff ();
305  }
306 }
307 
308 void
310 {
311  NS_LOG_FUNCTION (this);
312  for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++)
313  {
314  (*i)->NotifyWakeup ();
315  }
316 }
317 
318 void
320 {
321  NS_LOG_FUNCTION (this);
322  for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++)
323  {
324  (*i)->NotifyOn ();
325  }
326 }
327 
328 void
330 {
331  NS_LOG_FUNCTION (this);
332  Time now = Simulator::Now ();
333  Time idleStart = Max (m_endCcaBusy, m_endRx);
334  idleStart = Max (idleStart, m_endTx);
335  idleStart = Max (idleStart, m_endSwitching);
336  NS_ASSERT (idleStart <= now);
337  if (m_endCcaBusy > m_endRx
339  && m_endCcaBusy > m_endTx)
340  {
341  Time ccaBusyStart = Max (m_endTx, m_endRx);
342  ccaBusyStart = Max (ccaBusyStart, m_startCcaBusy);
343  ccaBusyStart = Max (ccaBusyStart, m_endSwitching);
344  Time ccaBusyDuration = idleStart - ccaBusyStart;
345  if (ccaBusyDuration.IsStrictlyPositive ())
346  {
347  m_stateLogger (ccaBusyStart, ccaBusyDuration, WifiPhyState::CCA_BUSY);
348  }
349  }
350  Time idleDuration = now - idleStart;
351  if (idleDuration.IsStrictlyPositive ())
352  {
353  m_stateLogger (idleStart, idleDuration, WifiPhyState::IDLE);
354  }
355 }
356 
357 void
358 WifiPhyStateHelper::SwitchToTx (Time txDuration, WifiConstPsduMap psdus, double txPowerDbm, WifiTxVector txVector)
359 {
360  NS_LOG_FUNCTION (this << txDuration << psdus << txPowerDbm << txVector);
361  if (!m_txTrace.IsEmpty ())
362  {
363  for (auto const& psdu : psdus)
364  {
365  m_txTrace (psdu.second->GetPacket (), txVector.GetMode (psdu.first),
366  txVector.GetPreambleType (), txVector.GetTxPowerLevel ());
367  }
368  }
369  Time now = Simulator::Now ();
370  switch (GetState ())
371  {
372  case WifiPhyState::RX:
373  /* The packet which is being received as well
374  * as its endRx event are cancelled by the caller.
375  */
377  m_endRx = now;
378  break;
380  {
381  Time ccaStart = Max (m_endRx, m_endTx);
382  ccaStart = Max (ccaStart, m_startCcaBusy);
383  ccaStart = Max (ccaStart, m_endSwitching);
384  m_stateLogger (ccaStart, now - ccaStart, WifiPhyState::CCA_BUSY);
385  } break;
386  case WifiPhyState::IDLE:
388  break;
389  default:
390  NS_FATAL_ERROR ("Invalid WifiPhy state.");
391  break;
392  }
393  m_stateLogger (now, txDuration, WifiPhyState::TX);
395  m_endTx = now + txDuration;
396  m_startTx = now;
397  NotifyTxStart (txDuration, txPowerDbm);
398 }
399 
400 void
402 {
403  NS_LOG_FUNCTION (this << rxDuration);
405  Time now = Simulator::Now ();
406  switch (GetState ())
407  {
408  case WifiPhyState::IDLE:
410  break;
412  {
413  Time ccaStart = Max (m_endRx, m_endTx);
414  ccaStart = Max (ccaStart, m_startCcaBusy);
415  ccaStart = Max (ccaStart, m_endSwitching);
416  m_stateLogger (ccaStart, now - ccaStart, WifiPhyState::CCA_BUSY);
417  } break;
418  default:
419  NS_FATAL_ERROR ("Invalid WifiPhy state " << GetState ());
420  break;
421  }
423  m_startRx = now;
424  m_endRx = now + rxDuration;
425  NotifyRxStart (rxDuration);
426  NS_ASSERT (IsStateRx ());
427 }
428 
429 void
431 {
432  NS_LOG_FUNCTION (this << switchingDuration);
433  Time now = Simulator::Now ();
434  switch (GetState ())
435  {
436  case WifiPhyState::RX:
437  /* The packet which is being received as well
438  * as its endRx event are cancelled by the caller.
439  */
441  m_endRx = now;
442  break;
444  {
445  Time ccaStart = Max (m_endRx, m_endTx);
446  ccaStart = Max (ccaStart, m_startCcaBusy);
447  ccaStart = Max (ccaStart, m_endSwitching);
448  m_stateLogger (ccaStart, now - ccaStart, WifiPhyState::CCA_BUSY);
449  } break;
450  case WifiPhyState::IDLE:
452  break;
453  default:
454  NS_FATAL_ERROR ("Invalid WifiPhy state.");
455  break;
456  }
457 
458  if (now < m_endCcaBusy)
459  {
460  m_endCcaBusy = now;
461  }
462 
463  m_stateLogger (now, switchingDuration, WifiPhyState::SWITCHING);
465  m_startSwitching = now;
466  m_endSwitching = now + switchingDuration;
467  NotifySwitchingStart (switchingDuration);
469 }
470 
471 void
473 {
474  NS_LOG_FUNCTION (this << *psdu << rxSignalInfo << txVector);
475  std::vector<bool> statusPerMpdu;
476  if (!m_rxOkCallback.IsNull ())
477  {
478  m_rxOkCallback (psdu, rxSignalInfo, txVector, statusPerMpdu);
479  }
480 }
481 
482 void
483 WifiPhyStateHelper::SwitchFromRxEndOk (Ptr<WifiPsdu> psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, uint16_t staId, std::vector<bool> statusPerMpdu)
484 {
485  NS_LOG_FUNCTION (this << *psdu << rxSignalInfo << txVector << staId << statusPerMpdu.size () <<
486  std::all_of(statusPerMpdu.begin(), statusPerMpdu.end(), [](bool v) { return v; })); //returns true if all true
487  NS_ASSERT (statusPerMpdu.size () != 0);
488  NS_ASSERT (Abs (m_endRx - Simulator::Now ()) < MicroSeconds (1)); //1us corresponds to the maximum propagation delay (delay spread)
489  //TODO: a better fix would be to call the function once all HE TB PPDUs are received
490  if (!m_rxOkTrace.IsEmpty ())
491  {
492  m_rxOkTrace (psdu->GetPacket (), rxSignalInfo.snr, txVector.GetMode (staId),
493  txVector.GetPreambleType ());
494  }
495  NotifyRxEndOk ();
496  DoSwitchFromRx ();
497  if (!m_rxOkCallback.IsNull ())
498  {
499  m_rxOkCallback (psdu, rxSignalInfo, txVector, statusPerMpdu);
500  }
501 }
502 
503 void
505 {
506  NS_LOG_FUNCTION (this << *psdu << snr);
507  NS_ASSERT (Abs (m_endRx - Simulator::Now ()) < MicroSeconds (1)); //1us corresponds to the maximum propagation delay (delay spread)
508  //TODO: a better fix would be to call the function once all HE TB PPDUs are received
509  if (!m_rxErrorTrace.IsEmpty ())
510  {
511  m_rxErrorTrace (psdu->GetPacket (), snr);
512  }
513  NotifyRxEndError ();
514  DoSwitchFromRx ();
515  if (!m_rxErrorCallback.IsNull ())
516  {
517  m_rxErrorCallback (psdu);
518  }
519 }
520 
521 void
523 {
524  NS_LOG_FUNCTION (this);
525  Time now = Simulator::Now ();
528  m_endRx = Simulator::Now ();
530 }
531 
532 void
534 {
535  NS_LOG_FUNCTION (this << duration);
536  if (GetState () != WifiPhyState::RX)
537  {
538  NotifyMaybeCcaBusyStart (duration);
539  }
540  Time now = Simulator::Now ();
541  switch (GetState ())
542  {
543  case WifiPhyState::IDLE:
545  break;
546  case WifiPhyState::RX:
547  return;
548  default:
549  break;
550  }
552  {
553  m_startCcaBusy = now;
554  }
555  m_endCcaBusy = std::max (m_endCcaBusy, now + duration);
556 }
557 
558 void
560 {
561  NS_LOG_FUNCTION (this);
562  Time now = Simulator::Now ();
563  switch (GetState ())
564  {
565  case WifiPhyState::IDLE:
567  break;
569  {
570  Time ccaStart = Max (m_endRx, m_endTx);
571  ccaStart = Max (ccaStart, m_startCcaBusy);
572  ccaStart = Max (ccaStart, m_endSwitching);
573  m_stateLogger (ccaStart, now - ccaStart, WifiPhyState::CCA_BUSY);
574  } break;
575  default:
576  NS_FATAL_ERROR ("Invalid WifiPhy state.");
577  break;
578  }
580  m_sleeping = true;
581  m_startSleep = now;
582  NotifySleep ();
583  NS_ASSERT (IsStateSleep ());
584 }
585 
586 void
588 {
589  NS_LOG_FUNCTION (this << duration);
590  NS_ASSERT (IsStateSleep ());
591  Time now = Simulator::Now ();
594  m_sleeping = false;
595  NotifyWakeup ();
596  //update m_endCcaBusy after the sleep period
597  m_endCcaBusy = std::max (m_endCcaBusy, now + duration);
598  if (m_endCcaBusy > now)
599  {
601  }
602 }
603 
604 void
606 {
607  NS_LOG_FUNCTION (this);
608  NS_ASSERT (IsStateCcaBusy ()); //abort is called (with OBSS_PD_CCA_RESET reason) before RX is set by payload start
609  NotifyRxEndOk ();
610  DoSwitchFromRx ();
613  NS_ASSERT (IsStateIdle ());
614 }
615 
616 void
618 {
619  NS_LOG_FUNCTION (this);
620  Time now = Simulator::Now ();
621  switch (GetState ())
622  {
623  case WifiPhyState::RX:
624  /* The packet which is being received as well
625  * as its endRx event are cancelled by the caller.
626  */
628  m_endRx = now;
629  break;
630  case WifiPhyState::TX:
631  /* The packet which is being transmitted as well
632  * as its endTx event are cancelled by the caller.
633  */
635  m_endTx = now;
636  break;
637  case WifiPhyState::IDLE:
639  break;
641  {
642  Time ccaStart = Max (m_endRx, m_endTx);
643  ccaStart = Max (ccaStart, m_startCcaBusy);
644  ccaStart = Max (ccaStart, m_endSwitching);
645  m_stateLogger (ccaStart, now - ccaStart, WifiPhyState::CCA_BUSY);
646  } break;
647  default:
648  NS_FATAL_ERROR ("Invalid WifiPhy state.");
649  break;
650  }
652  m_isOff = true;
653  NotifyOff ();
654  NS_ASSERT (IsStateOff ());
655 }
656 
657 void
659 {
660  NS_LOG_FUNCTION (this << duration);
661  NS_ASSERT (IsStateOff ());
662  Time now = Simulator::Now ();
664  m_isOff = false;
665  NotifyOn ();
666  //update m_endCcaBusy after the off period
667  m_endCcaBusy = std::max (m_endCcaBusy, now + duration);
668  if (m_endCcaBusy > now)
669  {
671  }
672 }
673 
674 } //namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::WifiPhyStateHelper::IsStateSwitching
bool IsStateSwitching(void) const
Check whether the current state is SWITCHING.
Definition: wifi-phy-state-helper.cc:133
ns3::WifiPhyStateHelper::LogPreviousIdleAndCcaBusyStates
void LogPreviousIdleAndCcaBusyStates(void)
Log the ideal and CCA states.
Definition: wifi-phy-state-helper.cc:329
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
NS_ASSERT
#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
ns3::WifiPhyStateHelper::IsStateSleep
bool IsStateSleep(void) const
Check whether the current state is SLEEP.
Definition: wifi-phy-state-helper.cc:139
ns3::WifiPhyStateHelper::SwitchFromOff
void SwitchFromOff(Time duration)
Switch from off mode.
Definition: wifi-phy-state-helper.cc:658
ns3::WifiPhyStateHelper::m_rxErrorTrace
TracedCallback< Ptr< const Packet >, double > m_rxErrorTrace
receive error trace callback
Definition: wifi-phy-state-helper.h:375
ns3::Callback< void, Ptr< WifiPsdu >, RxSignalInfo, WifiTxVector, std::vector< bool > >
ns3::WifiPhyStateHelper::m_txTrace
TracedCallback< Ptr< const Packet >, WifiMode, WifiPreamble, uint8_t > m_txTrace
transmit trace callback
Definition: wifi-phy-state-helper.h:376
ns3::Simulator::Now
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
RX
@ RX
The PHY layer is receiving a packet.
Definition: wifi-phy-state.h:48
ns3::WifiPhyStateHelper::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: wifi-phy-state-helper.cc:38
ns3::WifiPhyStateHelper::SwitchToSleep
void SwitchToSleep(void)
Switch to sleep mode.
Definition: wifi-phy-state-helper.cc:559
ns3::Callback::IsNull
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1386
ns3::WifiPhyStateHelper::SetReceiveErrorCallback
void SetReceiveErrorCallback(RxErrorCallback callback)
Set a callback for a failed reception.
Definition: wifi-phy-state-helper.cc:87
ns3::WifiPhyStateHelper::m_endRx
Time m_endRx
end receive
Definition: wifi-phy-state-helper.h:363
ns3::WifiPhyStateHelper::IsStateCcaBusy
bool IsStateCcaBusy(void) const
Check whether the current state is CCA busy.
Definition: wifi-phy-state-helper.cc:115
ns3::WifiPhyStateHelper::m_rxOkTrace
TracedCallback< Ptr< const Packet >, double, WifiMode, WifiPreamble > m_rxOkTrace
receive OK trace callback
Definition: wifi-phy-state-helper.h:374
ns3::MicroSeconds
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1305
ns3::WifiPhyListener
receive notifications about PHY events.
Definition: wifi-phy-listener.h:33
IDLE
@ IDLE
The PHY layer is IDLE.
Definition: wifi-phy-state.h:36
ns3::WifiPhyStateHelper::GetState
WifiPhyState GetState(void) const
Return the current state of WifiPhy.
Definition: wifi-phy-state-helper.cc:196
ns3::WifiPhyStateHelper::m_sleeping
bool m_sleeping
sleeping
Definition: wifi-phy-state-helper.h:360
ns3::WifiPhyStateHelper::m_listeners
Listeners m_listeners
listeners
Definition: wifi-phy-state-helper.h:373
ns3::Time::IsStrictlyPositive
bool IsStrictlyPositive(void) const
Exactly equivalent to t > 0.
Definition: nstime.h:333
ns3::WifiPhyStateHelper::NotifyRxEndOk
void NotifyRxEndOk(void)
Notify all WifiPhyListener that the reception was successful.
Definition: wifi-phy-state-helper.cc:249
OFF
@ OFF
The PHY layer is switched off.
Definition: wifi-phy-state.h:60
wifi-phy-listener.h
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
wifi-phy.h
ns3::WifiConstPsduMap
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Definition: he-frame-exchange-manager.h:43
ns3::WifiPhyStateHelper::m_startSwitching
Time m_startSwitching
start switching
Definition: wifi-phy-state-helper.h:369
ns3::WifiPhyStateHelper::RegisterListener
void RegisterListener(WifiPhyListener *listener)
Register WifiPhyListener to this WifiPhyStateHelper.
Definition: wifi-phy-state-helper.cc:93
CCA_BUSY
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
Definition: wifi-phy-state.h:40
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::WifiPhyStateHelper::SwitchToOff
void SwitchToOff(void)
Switch to off mode.
Definition: wifi-phy-state-helper.cc:617
ns3::WifiPhyStateHelper::SwitchToRx
void SwitchToRx(Time rxDuration)
Switch state to RX for the given duration.
Definition: wifi-phy-state-helper.cc:401
ns3::WifiPhyStateHelper::UnregisterListener
void UnregisterListener(WifiPhyListener *listener)
Remove WifiPhyListener from this WifiPhyStateHelper.
Definition: wifi-phy-state-helper.cc:99
ns3::WifiPhyStateHelper::NotifyOff
void NotifyOff(void)
Notify all WifiPhyListener that we are going to switch off.
Definition: wifi-phy-state-helper.cc:299
ns3::MakeTraceSourceAccessor
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Definition: trace-source-accessor.h:202
ns3::WifiPhyStateHelper::IsStateIdle
bool IsStateIdle(void) const
Check whether the current state is IDLE.
Definition: wifi-phy-state-helper.cc:109
wifi-psdu.h
ns3::WifiPhyStateHelper::SetReceiveOkCallback
void SetReceiveOkCallback(RxOkCallback callback)
Set a callback for a successful reception.
Definition: wifi-phy-state-helper.cc:81
ns3::Ptr< WifiPsdu >
ns3::WifiPhyStateHelper::m_startTx
Time m_startTx
start transmit
Definition: wifi-phy-state-helper.h:366
ns3::Max
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:230
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
ns3::WifiPhyStateHelper
This objects implements the PHY state machine of the Wifi device.
Definition: wifi-phy-state-helper.h:66
ns3::WifiPhyStateHelper::NotifyTxStart
void NotifyTxStart(Time duration, double txPowerDbm)
Notify all WifiPhyListener that the transmission has started for the given duration.
Definition: wifi-phy-state-helper.cc:229
ns3::WifiPhyStateHelper::SwitchMaybeToCcaBusy
void SwitchMaybeToCcaBusy(Time duration)
Switch to CCA busy.
Definition: wifi-phy-state-helper.cc:533
ns3::WifiPhyStateHelper::SwitchFromSleep
void SwitchFromSleep(Time duration)
Switch from sleep mode.
Definition: wifi-phy-state-helper.cc:587
ns3::WifiPhyStateHelper::GetDelayUntilIdle
Time GetDelayUntilIdle(void) const
Return the time before the state is back to IDLE.
Definition: wifi-phy-state-helper.cc:151
ns3::WifiPhyStateHelper::m_startSleep
Time m_startSleep
start sleep
Definition: wifi-phy-state-helper.h:370
max
#define max(a, b)
Definition: 80211b.c:43
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::WifiPhyStateHelper::SwitchFromRxAbort
void SwitchFromRxAbort(void)
Abort current reception.
Definition: wifi-phy-state-helper.cc:605
ns3::WifiPhyStateHelper::ListenersI
std::vector< WifiPhyListener * >::iterator ListenersI
typedef for a list of WifiPhyListeners iterator
Definition: wifi-phy-state-helper.h:293
ns3::Abs
int64x64_t Abs(const int64x64_t &value)
Absolute value.
Definition: int64x64.h:205
ns3::WifiPhyStateHelper::DoSwitchFromRx
void DoSwitchFromRx(void)
Switch the state from RX.
Definition: wifi-phy-state-helper.cc:522
ns3::WifiPhyStateHelper::m_startCcaBusy
Time m_startCcaBusy
start CCA busy
Definition: wifi-phy-state-helper.h:368
wifi-tx-vector.h
ns3::WifiPhyStateHelper::m_isOff
bool m_isOff
switched off
Definition: wifi-phy-state-helper.h:361
ns3::WifiPhyStateHelper::SwitchFromRxEndError
void SwitchFromRxEndError(Ptr< WifiPsdu > psdu, double snr)
Switch from RX after the reception failed.
Definition: wifi-phy-state-helper.cc:504
ns3::WifiPhyStateHelper::m_stateLogger
TracedCallback< Time, Time, WifiPhyState > m_stateLogger
The trace source fired when state is changed.
Definition: wifi-phy-state-helper.h:358
ns3::WifiTxVector::GetPreambleType
WifiPreamble GetPreambleType(void) const
Definition: wifi-tx-vector.cc:148
ns3::WifiPhyStateHelper::m_rxOkCallback
RxOkCallback m_rxOkCallback
receive OK callback
Definition: wifi-phy-state-helper.h:377
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::WifiPhyStateHelper::m_endCcaBusy
Time m_endCcaBusy
end CCA busy
Definition: wifi-phy-state-helper.h:364
ns3::WifiPhyStateHelper::SwitchToTx
void SwitchToTx(Time txDuration, WifiConstPsduMap psdus, double txPowerDbm, WifiTxVector txVector)
Switch state to TX for the given duration.
Definition: wifi-phy-state-helper.cc:358
ns3::WifiPhyStateHelper::m_previousStateChangeTime
Time m_previousStateChangeTime
previous state change time
Definition: wifi-phy-state-helper.h:371
SLEEP
@ SLEEP
The PHY layer is sleeping.
Definition: wifi-phy-state.h:56
ns3::WifiPhyStateHelper::NotifySleep
void NotifySleep(void)
Notify all WifiPhyListener that we are going to sleep.
Definition: wifi-phy-state-helper.cc:289
WifiPhyState
WifiPhyState
The state of the PHY layer.
Definition: wifi-phy-state.h:32
ns3::WifiPhyStateHelper::IsStateOff
bool IsStateOff(void) const
Check whether the current state is OFF.
Definition: wifi-phy-state-helper.cc:145
ns3::RxSignalInfo::snr
double snr
SNR in linear scale.
Definition: phy-entity.h:68
SWITCHING
@ SWITCHING
The PHY layer is switching to other channel.
Definition: wifi-phy-state.h:52
ns3::WifiPhyStateHelper::NotifyOn
void NotifyOn(void)
Notify all WifiPhyListener that we are going to switch on.
Definition: wifi-phy-state-helper.cc:319
ns3::WifiPsdu::GetPacket
Ptr< const Packet > GetPacket(void) const
Get the PSDU as a single packet.
Definition: wifi-psdu.cc:87
ns3::RxSignalInfo
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:67
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::WifiPhyStateHelper::NotifyMaybeCcaBusyStart
void NotifyMaybeCcaBusyStart(Time duration)
Notify all WifiPhyListener that the CCA has started for the given duration.
Definition: wifi-phy-state-helper.cc:269
ns3::WifiPhyStateHelper::NotifyRxStart
void NotifyRxStart(Time duration)
Notify all WifiPhyListener that the reception has started for the given duration.
Definition: wifi-phy-state-helper.cc:239
ns3::WifiTxVector::GetTxPowerLevel
uint8_t GetTxPowerLevel(void) const
Definition: wifi-tx-vector.cc:142
ns3::WifiPhyStateHelper::SwitchFromRxEndOk
void SwitchFromRxEndOk(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, uint16_t staId, std::vector< bool > statusPerMpdu)
Switch from RX after the reception was successful.
Definition: wifi-phy-state-helper.cc:483
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::WifiPhyStateHelper::IsStateTx
bool IsStateTx(void) const
Check whether the current state is TX.
Definition: wifi-phy-state-helper.cc:127
wifi-phy-state-helper.h
ns3::WifiPhyStateHelper::SwitchToChannelSwitching
void SwitchToChannelSwitching(Time switchingDuration)
Switch state to channel switching for the given duration.
Definition: wifi-phy-state-helper.cc:430
ns3::WifiPhyStateHelper::NotifyWakeup
void NotifyWakeup(void)
Notify all WifiPhyListener that we woke up.
Definition: wifi-phy-state-helper.cc:309
ns3::WifiPhyStateHelper::WifiPhyStateHelper
WifiPhyStateHelper()
Definition: wifi-phy-state-helper.cc:63
ns3::WifiPhyStateHelper::ContinueRxNextMpdu
void ContinueRxNextMpdu(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector)
Continue RX after the reception of an MPDU in an A-MPDU was successful.
Definition: wifi-phy-state-helper.cc:472
ns3::WifiPhyStateHelper::m_startRx
Time m_startRx
start receive
Definition: wifi-phy-state-helper.h:367
ns3::WifiPhyStateHelper::GetLastRxStartTime
Time GetLastRxStartTime(void) const
Return the time the last RX start.
Definition: wifi-phy-state-helper.cc:184
ns3::WifiPhyStateHelper::IsStateRx
bool IsStateRx(void) const
Check whether the current state is RX.
Definition: wifi-phy-state-helper.cc:121
TX
@ TX
The PHY layer is sending a packet.
Definition: wifi-phy-state.h:44
ns3::WifiPhyStateHelper::NotifyRxEndError
void NotifyRxEndError(void)
Notify all WifiPhyListener that the reception was not successful.
Definition: wifi-phy-state-helper.cc:259
ns3::WifiPhyStateHelper::GetLastRxEndTime
Time GetLastRxEndTime(void) const
Return the time the last RX end.
Definition: wifi-phy-state-helper.cc:190
ns3::WifiPhyStateHelper::m_endSwitching
Time m_endSwitching
end switching
Definition: wifi-phy-state-helper.h:365
ns3::WifiPhyStateHelper::m_rxErrorCallback
RxErrorCallback m_rxErrorCallback
receive error callback
Definition: wifi-phy-state-helper.h:378
ns3::WifiPhyStateHelper::NotifySwitchingStart
void NotifySwitchingStart(Time duration)
Notify all WifiPhyListener that we are switching channel with the given channel switching delay.
Definition: wifi-phy-state-helper.cc:279
ns3::WifiTxVector::GetMode
WifiMode GetMode(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the selected payload transmission mode.
Definition: wifi-tx-vector.cc:112
ns3::WifiPhyStateHelper::m_endTx
Time m_endTx
end transmit
Definition: wifi-phy-state-helper.h:362