A Discrete-Event Network Simulator
API
channel-access-manager.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 "ns3/log.h"
22 #include "ns3/simulator.h"
23 #include "channel-access-manager.h"
24 #include "txop.h"
25 #include "wifi-phy-listener.h"
26 #include "wifi-phy.h"
27 #include "mac-low.h"
28 
29 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("ChannelAccessManager");
32 
37 {
38 public:
45  : m_dcf (dcf)
46  {
47  }
48  virtual ~PhyListener ()
49  {
50  }
51  void NotifyRxStart (Time duration)
52  {
53  m_dcf->NotifyRxStartNow (duration);
54  }
55  void NotifyRxEndOk (void)
56  {
58  }
59  void NotifyRxEndError (void)
60  {
62  }
63  void NotifyTxStart (Time duration, double txPowerDbm)
64  {
65  m_dcf->NotifyTxStartNow (duration);
66  }
67  void NotifyMaybeCcaBusyStart (Time duration)
68  {
70  }
71  void NotifySwitchingStart (Time duration)
72  {
73  m_dcf->NotifySwitchingStartNow (duration);
74  }
75  void NotifySleep (void)
76  {
78  }
79  void NotifyOff (void)
80  {
81  m_dcf->NotifyOffNow ();
82  }
83  void NotifyWakeup (void)
84  {
86  }
87  void NotifyOn (void)
88  {
89  m_dcf->NotifyOnNow ();
90  }
91 
92 private:
94 };
95 
96 
97 /****************************************************************
98  * Implement the DCF manager of all DCF state holders
99  ****************************************************************/
100 
102  : m_lastAckTimeoutEnd (MicroSeconds (0)),
103  m_lastCtsTimeoutEnd (MicroSeconds (0)),
104  m_lastNavStart (MicroSeconds (0)),
105  m_lastNavDuration (MicroSeconds (0)),
106  m_lastRxStart (MicroSeconds (0)),
107  m_lastRxDuration (MicroSeconds (0)),
108  m_lastRxReceivedOk (true),
109  m_lastRxEnd (MicroSeconds (0)),
110  m_lastTxStart (MicroSeconds (0)),
111  m_lastTxDuration (MicroSeconds (0)),
112  m_lastBusyStart (MicroSeconds (0)),
113  m_lastBusyDuration (MicroSeconds (0)),
114  m_lastSwitchingStart (MicroSeconds (0)),
115  m_lastSwitchingDuration (MicroSeconds (0)),
116  m_sleeping (false),
117  m_off (false),
118  m_slot (Seconds (0.0)),
119  m_sifs (Seconds (0.0)),
120  m_phyListener (0)
121 {
122  NS_LOG_FUNCTION (this);
123 }
124 
126 {
127  NS_LOG_FUNCTION (this);
128  delete m_phyListener;
129  m_phyListener = 0;
130 }
131 
132 void
134 {
135  NS_LOG_FUNCTION (this);
136  for (Ptr<Txop> i : m_states)
137  {
138  i->Dispose ();
139  i = 0;
140  }
141  m_phy = 0;
142 }
143 
144 void
146 {
147  NS_LOG_FUNCTION (this << phy);
148  NS_ASSERT (m_phyListener == 0);
149  m_phyListener = new PhyListener (this);
150  phy->RegisterListener (m_phyListener);
151  m_phy = phy;
152 }
153 
154 void
156 {
157  NS_LOG_FUNCTION (this << phy);
158  if (m_phyListener != 0)
159  {
160  phy->UnregisterListener (m_phyListener);
161  delete m_phyListener;
162  m_phyListener = 0;
163  m_phy = 0;
164  }
165 }
166 
167 void
169 {
170  NS_LOG_FUNCTION (this << low);
171  low->RegisterDcf (this);
172 }
173 
174 void
176 {
177  NS_LOG_FUNCTION (this << slotTime);
178  m_slot = slotTime;
179 }
180 
181 void
183 {
184  NS_LOG_FUNCTION (this << sifs);
185  m_sifs = sifs;
186 }
187 
188 void
190 {
191  NS_LOG_FUNCTION (this << eifsNoDifs);
192  m_eifsNoDifs = eifsNoDifs;
193 }
194 
195 Time
197 {
198  NS_LOG_FUNCTION (this);
199  return m_eifsNoDifs;
200 }
201 
202 void
204 {
205  NS_LOG_FUNCTION (this << dcf);
206  m_states.push_back (dcf);
207 }
208 
209 Time
210 ChannelAccessManager::MostRecent (std::initializer_list<Time> list) const
211 {
212  NS_ASSERT (list.size () > 0);
213  return *std::max_element (list.begin (), list.end ());
214 }
215 
216 bool
218 {
219  NS_LOG_FUNCTION (this);
220  // PHY busy
221  if (m_lastRxEnd > Simulator::Now ())
222  {
223  return true;
224  }
225  Time lastTxEnd = m_lastTxStart + m_lastTxDuration;
226  if (lastTxEnd > Simulator::Now ())
227  {
228  return true;
229  }
230  // NAV busy
231  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
232  if (lastNavEnd > Simulator::Now ())
233  {
234  return true;
235  }
236  // CCA busy
237  Time lastCCABusyEnd = m_lastBusyStart + m_lastBusyDuration;
238  if (lastCCABusyEnd > Simulator::Now ())
239  {
240  return true;
241  }
242  return false;
243 }
244 
245 bool
247 {
248  NS_LOG_FUNCTION (this << state);
249  Time ifsEnd = GetAccessGrantStart () + (state->GetAifsn () * m_slot);
250  if (ifsEnd > Simulator::Now ())
251  {
252  NS_LOG_DEBUG ("IsWithinAifs () true; ifsEnd is at " << ifsEnd.GetSeconds ());
253  return true;
254  }
255  NS_LOG_DEBUG ("IsWithinAifs () false; ifsEnd was at " << ifsEnd.GetSeconds ());
256  return false;
257 }
258 
259 
260 void
262 {
263  NS_LOG_FUNCTION (this << state);
264  if (m_phy)
265  {
267  }
268  //Deny access if in sleep mode or off
269  if (m_sleeping || m_off)
270  {
271  return;
272  }
273  if (isCfPeriod)
274  {
275  state->NotifyAccessRequested ();
276  Time delay = (MostRecent ({GetAccessGrantStart (true), Simulator::Now ()}) - Simulator::Now ());
278  return;
279  }
280  UpdateBackoff ();
281  NS_ASSERT (!state->IsAccessRequested ());
282  state->NotifyAccessRequested ();
283  // If currently transmitting; end of transmission (ACK or no ACK) will cause
284  // a later access request if needed from EndTxNoAck, GotAck, or MissedAck
285  Time lastTxEnd = m_lastTxStart + m_lastTxDuration;
286  if (lastTxEnd > Simulator::Now ())
287  {
288  NS_LOG_DEBUG ("Internal collision (currently transmitting)");
289  state->NotifyInternalCollision ();
291  return;
292  }
297  if (state->GetBackoffSlots () == 0)
298  {
299  if (IsBusy ())
300  {
301  NS_LOG_DEBUG ("medium is busy: collision");
302  // someone else has accessed the medium; generate a backoff.
303  state->NotifyCollision ();
305  return;
306  }
307  else if (IsWithinAifs (state))
308  {
309  NS_LOG_DEBUG ("busy within AIFS");
310  state->NotifyCollision ();
312  return;
313  }
314  }
315  DoGrantDcfAccess ();
317 }
318 
319 void
321 {
322  state->NotifyAccessGranted ();
323 }
324 
325 void
327 {
328  NS_LOG_FUNCTION (this);
329  uint32_t k = 0;
330  for (States::iterator i = m_states.begin (); i != m_states.end (); k++)
331  {
332  Ptr<Txop> state = *i;
333  if (state->IsAccessRequested ()
334  && GetBackoffEndFor (state) <= Simulator::Now () )
335  {
340  NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. access granted. slots=" << state->GetBackoffSlots ());
341  i++; //go to the next item in the list.
342  k++;
343  std::vector<Ptr<Txop> > internalCollisionStates;
344  for (States::iterator j = i; j != m_states.end (); j++, k++)
345  {
346  Ptr<Txop> otherState = *j;
347  if (otherState->IsAccessRequested ()
348  && GetBackoffEndFor (otherState) <= Simulator::Now ())
349  {
350  NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision. slots=" <<
351  otherState->GetBackoffSlots ());
357  internalCollisionStates.push_back (otherState);
358  }
359  }
360 
368  state->NotifyAccessGranted ();
369  for (std::vector<Ptr<Txop> >::iterator l = internalCollisionStates.begin ();
370  l != internalCollisionStates.end (); l++)
371  {
372  (*l)->NotifyInternalCollision ();
373  }
374  break;
375  }
376  i++;
377  }
378 }
379 
380 void
382 {
383  NS_LOG_FUNCTION (this);
384  UpdateBackoff ();
385  DoGrantDcfAccess ();
387 }
388 
389 Time
391 {
392  NS_LOG_FUNCTION (this);
393  Time rxAccessStart;
394  if (m_lastRxEnd <= Simulator::Now ())
395  {
396  rxAccessStart = m_lastRxEnd + m_sifs;
397  if (!m_lastRxReceivedOk)
398  {
399  rxAccessStart += m_eifsNoDifs;
400  }
401  }
402  else
403  {
404  rxAccessStart = m_lastRxStart + m_lastRxDuration + m_sifs;
405  }
406  Time busyAccessStart = m_lastBusyStart + m_lastBusyDuration + m_sifs;
407  Time txAccessStart = m_lastTxStart + m_lastTxDuration + m_sifs;
408  Time navAccessStart = m_lastNavStart + m_lastNavDuration + m_sifs;
409  Time ackTimeoutAccessStart = m_lastAckTimeoutEnd + m_sifs;
410  Time ctsTimeoutAccessStart = m_lastCtsTimeoutEnd + m_sifs;
411  Time switchingAccessStart = m_lastSwitchingStart + m_lastSwitchingDuration + m_sifs;
412  Time accessGrantedStart;
413  if (ignoreNav)
414  {
415  accessGrantedStart = MostRecent ({rxAccessStart,
416  busyAccessStart,
417  txAccessStart,
418  ackTimeoutAccessStart,
419  ctsTimeoutAccessStart,
420  switchingAccessStart}
421  );
422  }
423  else
424  {
425  accessGrantedStart = MostRecent ({rxAccessStart,
426  busyAccessStart,
427  txAccessStart,
428  navAccessStart,
429  ackTimeoutAccessStart,
430  ctsTimeoutAccessStart,
431  switchingAccessStart}
432  );
433  }
434  NS_LOG_INFO ("access grant start=" << accessGrantedStart <<
435  ", rx access start=" << rxAccessStart <<
436  ", busy access start=" << busyAccessStart <<
437  ", tx access start=" << txAccessStart <<
438  ", nav access start=" << navAccessStart);
439  return accessGrantedStart;
440 }
441 
442 Time
444 {
445  NS_LOG_FUNCTION (this << state);
446  Time mostRecentEvent = MostRecent ({state->GetBackoffStart (),
447  GetAccessGrantStart () + (state->GetAifsn () * m_slot)});
448 
449  return mostRecentEvent;
450 }
451 
452 Time
454 {
455  NS_LOG_FUNCTION (this << state);
456  NS_LOG_DEBUG ("Backoff start: " << GetBackoffStartFor (state).As (Time::US) <<
457  " end: " << (GetBackoffStartFor (state) + state->GetBackoffSlots () * m_slot).As (Time::US));
458  return GetBackoffStartFor (state) + (state->GetBackoffSlots () * m_slot);
459 }
460 
461 void
463 {
464  NS_LOG_FUNCTION (this);
465  uint32_t k = 0;
466  for (States::iterator i = m_states.begin (); i != m_states.end (); i++, k++)
467  {
468  Ptr<Txop> state = *i;
469 
470  Time backoffStart = GetBackoffStartFor (state);
471  if (backoffStart <= Simulator::Now ())
472  {
473  uint32_t nIntSlots = ((Simulator::Now () - backoffStart) / m_slot).GetHigh ();
474  /*
475  * EDCA behaves slightly different to DCA. For EDCA we
476  * decrement once at the slot boundary at the end of AIFS as
477  * well as once at the end of each clear slot
478  * thereafter. For DCA we only decrement at the end of each
479  * clear slot after DIFS. We account for the extra backoff
480  * by incrementing the slot count here in the case of
481  * EDCA. The if statement whose body we are in has confirmed
482  * that a minimum of AIFS has elapsed since last busy
483  * medium.
484  */
485  if (state->IsQosTxop ())
486  {
487  nIntSlots++;
488  }
489  uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ());
490  NS_LOG_DEBUG ("dcf " << k << " dec backoff slots=" << n);
491  Time backoffUpdateBound = backoffStart + (n * m_slot);
492  state->UpdateBackoffSlotsNow (n, backoffUpdateBound);
493  }
494  }
495 }
496 
497 void
499 {
500  NS_LOG_FUNCTION (this);
505  bool accessTimeoutNeeded = false;
506  Time expectedBackoffEnd = Simulator::GetMaximumSimulationTime ();
507  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
508  {
509  Ptr<Txop> state = *i;
510  if (state->IsAccessRequested ())
511  {
512  Time tmp = GetBackoffEndFor (state);
513  if (tmp > Simulator::Now ())
514  {
515  accessTimeoutNeeded = true;
516  expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
517  }
518  }
519  }
520  NS_LOG_DEBUG ("Access timeout needed: " << accessTimeoutNeeded);
521  if (accessTimeoutNeeded)
522  {
523  NS_LOG_DEBUG ("expected backoff end=" << expectedBackoffEnd);
524  Time expectedBackoffDelay = expectedBackoffEnd - Simulator::Now ();
526  && Simulator::GetDelayLeft (m_accessTimeout) > expectedBackoffDelay)
527  {
529  }
530  if (m_accessTimeout.IsExpired ())
531  {
532  m_accessTimeout = Simulator::Schedule (expectedBackoffDelay,
534  }
535  }
536 }
537 
538 void
540 {
541  NS_LOG_FUNCTION (this << duration);
542  NS_LOG_DEBUG ("rx start for=" << duration);
543  UpdateBackoff ();
545  m_lastRxDuration = duration;
547 }
548 
549 void
551 {
552  NS_LOG_FUNCTION (this);
553  NS_LOG_DEBUG ("rx end ok");
556  m_lastRxReceivedOk = true;
557 }
558 
559 void
561 {
562  NS_LOG_FUNCTION (this);
563  NS_LOG_DEBUG ("rx end error");
566  m_lastRxReceivedOk = false;
567 }
568 
569 void
571 {
572  NS_LOG_FUNCTION (this << duration);
573  if (m_lastRxEnd > Simulator::Now ())
574  {
575  //this may be caused only if PHY has started to receive a packet
576  //inside SIFS, so, we check that lastRxStart was maximum a SIFS ago
580  m_lastRxReceivedOk = true;
581  }
582  NS_LOG_DEBUG ("tx start for " << duration);
583  UpdateBackoff ();
585  m_lastTxDuration = duration;
586 }
587 
588 void
590 {
591  NS_LOG_FUNCTION (this << duration);
592  NS_LOG_DEBUG ("busy start for " << duration);
593  UpdateBackoff ();
595  m_lastBusyDuration = duration;
596 }
597 
598 void
600 {
601  NS_LOG_FUNCTION (this << duration);
602  Time now = Simulator::Now ();
605 
606  if (m_lastRxEnd > Simulator::Now ())
607  {
608  //channel switching during packet reception
611  m_lastRxReceivedOk = true;
612  }
613  if (m_lastNavStart + m_lastNavDuration > now)
614  {
616  }
618  {
620  }
621  if (m_lastAckTimeoutEnd > now)
622  {
623  m_lastAckTimeoutEnd = now;
624  }
625  if (m_lastCtsTimeoutEnd > now)
626  {
627  m_lastCtsTimeoutEnd = now;
628  }
629 
630  //Cancel timeout
631  if (m_accessTimeout.IsRunning ())
632  {
634  }
635 
636  //Reset backoffs
637  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
638  {
639  Ptr<Txop> state = *i;
640  uint32_t remainingSlots = state->GetBackoffSlots ();
641  if (remainingSlots > 0)
642  {
643  state->UpdateBackoffSlotsNow (remainingSlots, now);
644  NS_ASSERT (state->GetBackoffSlots () == 0);
645  }
646  state->ResetCw ();
647  state->m_accessRequested = false;
648  state->NotifyChannelSwitching ();
649  }
650 
651  NS_LOG_DEBUG ("switching start for " << duration);
653  m_lastSwitchingDuration = duration;
654 
655 }
656 
657 void
659 {
660  NS_LOG_FUNCTION (this);
661  m_sleeping = true;
662  //Cancel timeout
663  if (m_accessTimeout.IsRunning ())
664  {
666  }
667 
668  //Reset backoffs
669  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
670  {
671  Ptr<Txop> state = *i;
672  state->NotifySleep ();
673  }
674 }
675 
676 void
678 {
679  NS_LOG_FUNCTION (this);
680  m_off = true;
681  //Cancel timeout
682  if (m_accessTimeout.IsRunning ())
683  {
685  }
686 
687  //Reset backoffs
688  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
689  {
690  Ptr<Txop> state = *i;
691  state->NotifyOff ();
692  }
693 }
694 
695 void
697 {
698  NS_LOG_FUNCTION (this);
699  m_sleeping = false;
700  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
701  {
702  Ptr<Txop> state = *i;
703  uint32_t remainingSlots = state->GetBackoffSlots ();
704  if (remainingSlots > 0)
705  {
706  state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ());
707  NS_ASSERT (state->GetBackoffSlots () == 0);
708  }
709  state->ResetCw ();
710  state->m_accessRequested = false;
711  state->NotifyWakeUp ();
712  }
713 }
714 
715 void
717 {
718  NS_LOG_FUNCTION (this);
719  m_off = false;
720  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
721  {
722  Ptr<Txop> state = *i;
723  uint32_t remainingSlots = state->GetBackoffSlots ();
724  if (remainingSlots > 0)
725  {
726  state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ());
727  NS_ASSERT (state->GetBackoffSlots () == 0);
728  }
729  state->ResetCw ();
730  state->m_accessRequested = false;
731  state->NotifyOn ();
732  }
733 }
734 
735 void
737 {
738  NS_LOG_FUNCTION (this << duration);
739  NS_LOG_DEBUG ("nav reset for=" << duration);
740  UpdateBackoff ();
742  m_lastNavDuration = duration;
750 }
751 
752 void
754 {
755  NS_LOG_FUNCTION (this << duration);
757  NS_LOG_DEBUG ("nav start for=" << duration);
758  UpdateBackoff ();
759  Time newNavEnd = Simulator::Now () + duration;
760  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
761  if (newNavEnd > lastNavEnd)
762  {
764  m_lastNavDuration = duration;
765  }
766 }
767 
768 void
770 {
771  NS_LOG_FUNCTION (this << duration);
773  m_lastAckTimeoutEnd = Simulator::Now () + duration;
774 }
775 
776 void
778 {
779  NS_LOG_FUNCTION (this);
782 }
783 
784 void
786 {
787  NS_LOG_FUNCTION (this << duration);
788  m_lastCtsTimeoutEnd = Simulator::Now () + duration;
789 }
790 
791 void
793 {
794  NS_LOG_FUNCTION (this);
797 }
798 
799 } //namespace ns3
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:202
Time GetBackoffEndFor(Ptr< Txop > state)
Return the time when the backoff procedure ended (or will ended) for the given Txop.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Time m_eifsNoDifs
EIFS no DIFS time.
microsecond
Definition: nstime.h:116
void UpdateBackoff(void)
Update backoff slots for all Txops.
bool m_off
flag whether it is in off state
uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: txop.cc:296
void NotifyMaybeCcaBusyStart(Time duration)
Time m_lastRxDuration
the last receive duration time
Time m_lastCtsTimeoutEnd
the last CTS timeout end time
#define min(a, b)
Definition: 80211b.c:42
void NotifySwitchingStart(Time duration)
void NotifyOnNow(void)
Notify the DCF that the device has been resumed from off mode.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
virtual void NotifyAccessGranted(void)
Notify the DCF that access has been granted.
Definition: txop.cc:467
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for Phy events.
#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
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
void NotifyOff(void)
Notify listeners that we went to switch off.
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
Definition: txop.cc:238
void NotifyMaybeCcaBusyStartNow(Time duration)
Time m_lastBusyStart
the last busy start time
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV or CCA busy.
EventId m_accessTimeout
the access timeout ID
Time MostRecent(std::initializer_list< Time > list) const
Return the most recent time.
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for Phy events.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:280
Manage a set of ns3::TxopHandle a set of independent ns3::Txop, each of which represents a single DCF...
bool m_sleeping
flag whether it is in sleeping state
Time m_lastTxDuration
the last transmit duration time
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
Definition: txop.cc:244
void NotifyRxStartNow(Time duration)
void NotifyRxEndError(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
Time m_lastRxStart
the last receive start time
virtual void NotifyOff(void)
When off operation occurs, the queue gets cleaned up.
Definition: txop.cc:584
Time m_lastBusyDuration
the last busy duration time
phy
Definition: third.py:86
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully.
Time m_lastNavDuration
the last NAV duration time
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Ptr< WifiPhy > m_phy
Ptr to the PHY.
PhyListener(ns3::ChannelAccessManager *dcf)
Create a PhyListener for the given ChannelAccessManager.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1389
void SetEifsNoDifs(Time eifsNoDifs)
receive notifications about phy events.
void NotifyOffNow(void)
Notify the DCF that the device has been put in off mode.
Time m_lastRxEnd
the last receive end time
void NotifyChannelAccessRequested(void)
Notify the PHY that an access to the channel was requested.
Definition: wifi-phy.cc:3150
Time m_lastSwitchingStart
the last switching start time
void NotifyWakeup(void)
Notify listeners that we woke up.
void NotifySleepNow(void)
Notify the DCF that the device has been put in sleep mode.
Listener for PHY events.
void NotifyTxStart(Time duration, double txPowerDbm)
virtual bool IsAccessRequested(void) const
Definition: txop.cc:454
virtual bool IsQosTxop() const
Check for QoS TXOP.
Definition: txop.cc:864
#define list
Time m_lastTxStart
the last transmit start time
void NotifyNavResetNow(Time duration)
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
void NotifySleep(void)
Notify listeners that we went to sleep.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
Definition: txop.cc:573
void NotifyOn(void)
Notify listeners that we went to switch on.
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Time GetAccessGrantStart(bool ignoreNav=false) const
Access will never be granted to the medium before the time returned by this method.
virtual void NotifyOn(void)
When on operation occurs, channel access will be started.
Definition: txop.cc:599
bool m_lastRxReceivedOk
the last receive OK
PhyListener * m_phyListener
the phy listener
void NotifyCtsTimeoutResetNow(void)
Notify that CTS timer has reset.
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: txop.cc:565
ns3::ChannelAccessManager * m_dcf
ChannelAccessManager to forward events to.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:193
virtual void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
Definition: txop.cc:548
void NotifyRxStart(Time duration)
void DoGrantPcfAccess(Ptr< Txop > state)
Grant access to PCF.
void DoGrantDcfAccess(void)
Grant access to DCF.
bool m_accessRequested
flag whether channel access is already requested
Definition: txop.h:514
Time m_lastNavStart
the last NAV start time
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:272
virtual void NotifyCollision(void)
Notify the DCF that collision has occurred.
Definition: txop.cc:555
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1062
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: txop.cc:232
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
void NotifySwitchingStartNow(Time duration)
void NotifyNavStartNow(Time duration)
States m_states
the DCF states
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
Time m_lastSwitchingDuration
the last switching duration time
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1078
void AccessTimeout(void)
Called when access timeout should occur (e.g.
void NotifyTxStartNow(Time duration)
virtual void NotifyAccessRequested(void)
Notify that access request has been received.
Definition: txop.cc:460
Time GetBackoffStartFor(Ptr< Txop > state)
Return the time when the backoff procedure started for the given Txop.
void SetupLow(Ptr< MacLow > low)
Set up listener for MacLow events.
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
Definition: txop.cc:217
void NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
Definition: simulator.cc:315
void NotifyWakeupNow(void)
Notify the DCF that the device has been resumed from sleep mode.
void RequestAccess(Ptr< Txop > state, bool isCfPeriod=false)
Time m_lastAckTimeoutEnd
the last ACK timeout end time
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Definition: txop.cc:592
bool IsWithinAifs(Ptr< Txop > state) const
Check if the device is between frames (in DIFS or AIFS interval)
void DoDispose(void)
Destructor implementation.
void NotifyAckTimeoutResetNow(void)
Notify that ACK timer has reset.