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_rxing (false),
117  m_sleeping (false),
118  m_off (false),
119  m_slot (Seconds (0.0)),
120  m_sifs (Seconds (0.0)),
121  m_phyListener (0)
122 {
123  NS_LOG_FUNCTION (this);
124 }
125 
127 {
128  NS_LOG_FUNCTION (this);
129  delete m_phyListener;
130  m_phyListener = 0;
131 }
132 
133 void
135 {
136  NS_LOG_FUNCTION (this);
137  for (Ptr<Txop> i : m_states)
138  {
139  i->Dispose ();
140  i = 0;
141  }
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 }
152 
153 void
155 {
156  NS_LOG_FUNCTION (this << phy);
157  if (m_phyListener != 0)
158  {
159  phy->UnregisterListener (m_phyListener);
160  delete m_phyListener;
161  m_phyListener = 0;
162  }
163 }
164 
165 void
167 {
168  NS_LOG_FUNCTION (this << low);
169  low->RegisterDcf (this);
170 }
171 
172 void
174 {
175  NS_LOG_FUNCTION (this << slotTime);
176  m_slot = slotTime;
177 }
178 
179 void
181 {
182  NS_LOG_FUNCTION (this << sifs);
183  m_sifs = sifs;
184 }
185 
186 void
188 {
189  NS_LOG_FUNCTION (this << eifsNoDifs);
190  m_eifsNoDifs = eifsNoDifs;
191 }
192 
193 Time
195 {
196  NS_LOG_FUNCTION (this);
197  return m_eifsNoDifs;
198 }
199 
200 void
202 {
203  NS_LOG_FUNCTION (this << dcf);
204  m_states.push_back (dcf);
205 }
206 
207 Time
209 {
210  return Max (a, b);
211 }
212 
213 Time
215 {
216  Time g = MostRecent (a, b);
217  Time h = MostRecent (c, d);
218  Time i = MostRecent (e, f);
219  Time k = MostRecent (g, h);
220  Time retval = MostRecent (k, i);
221  return retval;
222 }
223 
224 Time
226 {
227  Time h = MostRecent (a, b);
228  Time i = MostRecent (c, d);
229  Time j = MostRecent (e, f);
230  Time k = MostRecent (h, i);
231  Time l = MostRecent (j, g);
232  Time retval = MostRecent (k, l);
233  return retval;
234 }
235 
236 bool
238 {
239  NS_LOG_FUNCTION (this);
240  // PHY busy
241  if (m_rxing)
242  {
243  return true;
244  }
245  Time lastTxEnd = m_lastTxStart + m_lastTxDuration;
246  if (lastTxEnd > Simulator::Now ())
247  {
248  return true;
249  }
250  // NAV busy
251  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
252  if (lastNavEnd > Simulator::Now ())
253  {
254  return true;
255  }
256  // CCA busy
257  Time lastCCABusyEnd = m_lastBusyStart + m_lastBusyDuration;
258  if (lastCCABusyEnd > Simulator::Now ())
259  {
260  return true;
261  }
262  return false;
263 }
264 
265 bool
267 {
268  NS_LOG_FUNCTION (this << state);
269  Time ifsEnd = GetAccessGrantStart () + (state->GetAifsn () * m_slot);
270  if (ifsEnd > Simulator::Now ())
271  {
272  NS_LOG_DEBUG ("IsWithinAifs () true; ifsEnd is at " << ifsEnd.GetSeconds ());
273  return true;
274  }
275  NS_LOG_DEBUG ("IsWithinAifs () false; ifsEnd was at " << ifsEnd.GetSeconds ());
276  return false;
277 }
278 
279 
280 void
282 {
283  NS_LOG_FUNCTION (this << state);
284  //Deny access if in sleep mode or off
285  if (m_sleeping || m_off)
286  {
287  return;
288  }
289  if (isCfPeriod)
290  {
291  state->NotifyAccessRequested ();
294  return;
295  }
296  UpdateBackoff ();
297  NS_ASSERT (!state->IsAccessRequested ());
298  state->NotifyAccessRequested ();
299  // If currently transmitting; end of transmission (ACK or no ACK) will cause
300  // a later access request if needed from EndTxNoAck, GotAck, or MissedAck
301  Time lastTxEnd = m_lastTxStart + m_lastTxDuration;
302  if (lastTxEnd > Simulator::Now ())
303  {
304  NS_LOG_DEBUG ("Internal collision (currently transmitting)");
305  state->NotifyInternalCollision ();
307  return;
308  }
313  if (state->GetBackoffSlots () == 0)
314  {
315  if (IsBusy ())
316  {
317  NS_LOG_DEBUG ("medium is busy: collision");
318  // someone else has accessed the medium; generate a backoff.
319  state->NotifyCollision ();
321  return;
322  }
323  else if (IsWithinAifs (state))
324  {
325  NS_LOG_DEBUG ("busy within AIFS");
326  state->NotifyCollision ();
328  return;
329  }
330  }
331  DoGrantAccess ();
333 }
334 
335 void
337 {
338  state->NotifyAccessGranted ();
339 }
340 
341 void
343 {
344  NS_LOG_FUNCTION (this);
345  uint32_t k = 0;
346  for (States::iterator i = m_states.begin (); i != m_states.end (); k++)
347  {
348  Ptr<Txop> state = *i;
349  if (state->IsAccessRequested ()
350  && GetBackoffEndFor (state) <= Simulator::Now () )
351  {
356  NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. access granted. slots=" << state->GetBackoffSlots ());
357  i++; //go to the next item in the list.
358  k++;
359  std::vector<Ptr<Txop> > internalCollisionStates;
360  for (States::iterator j = i; j != m_states.end (); j++, k++)
361  {
362  Ptr<Txop> otherState = *j;
363  if (otherState->IsAccessRequested ()
364  && GetBackoffEndFor (otherState) <= Simulator::Now ())
365  {
366  NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision. slots=" <<
367  otherState->GetBackoffSlots ());
373  internalCollisionStates.push_back (otherState);
374  }
375  }
376 
384  state->NotifyAccessGranted ();
385  for (std::vector<Ptr<Txop> >::iterator l = internalCollisionStates.begin ();
386  l != internalCollisionStates.end (); l++)
387  {
388  (*l)->NotifyInternalCollision ();
389  }
390  break;
391  }
392  i++;
393  }
394 }
395 
396 void
398 {
399  NS_LOG_FUNCTION (this);
400  UpdateBackoff ();
401  DoGrantAccess ();
403 }
404 
405 Time
407 {
408  NS_LOG_FUNCTION (this);
409  Time rxAccessStart;
410  if (!m_rxing)
411  {
412  rxAccessStart = m_lastRxEnd + m_sifs;
413  if (!m_lastRxReceivedOk)
414  {
415  rxAccessStart += m_eifsNoDifs;
416  }
417  }
418  else
419  {
420  rxAccessStart = m_lastRxStart + m_lastRxDuration + m_sifs;
421  }
422  Time busyAccessStart = m_lastBusyStart + m_lastBusyDuration + m_sifs;
423  Time txAccessStart = m_lastTxStart + m_lastTxDuration + m_sifs;
424  Time navAccessStart = m_lastNavStart + m_lastNavDuration + m_sifs;
425  Time ackTimeoutAccessStart = m_lastAckTimeoutEnd + m_sifs;
426  Time ctsTimeoutAccessStart = m_lastCtsTimeoutEnd + m_sifs;
427  Time switchingAccessStart = m_lastSwitchingStart + m_lastSwitchingDuration + m_sifs;
428  Time accessGrantedStart;
429  if (ignoreNav)
430  {
431  accessGrantedStart = MostRecent (rxAccessStart,
432  busyAccessStart,
433  txAccessStart,
434  ackTimeoutAccessStart,
435  ctsTimeoutAccessStart,
436  switchingAccessStart
437  );
438  }
439  else
440  {
441  accessGrantedStart = MostRecent (rxAccessStart,
442  busyAccessStart,
443  txAccessStart,
444  navAccessStart,
445  ackTimeoutAccessStart,
446  ctsTimeoutAccessStart,
447  switchingAccessStart
448  );
449  }
450  NS_LOG_INFO ("access grant start=" << accessGrantedStart <<
451  ", rx access start=" << rxAccessStart <<
452  ", busy access start=" << busyAccessStart <<
453  ", tx access start=" << txAccessStart <<
454  ", nav access start=" << navAccessStart);
455  return accessGrantedStart;
456 }
457 
458 Time
460 {
461  NS_LOG_FUNCTION (this << state);
462  Time mostRecentEvent = MostRecent (state->GetBackoffStart (),
463  GetAccessGrantStart () + (state->GetAifsn () * m_slot));
464 
465  return mostRecentEvent;
466 }
467 
468 Time
470 {
471  NS_LOG_FUNCTION (this << state);
472  NS_LOG_DEBUG ("Backoff start: " << GetBackoffStartFor (state).As (Time::US) <<
473  " end: " << (GetBackoffStartFor (state) + state->GetBackoffSlots () * m_slot).As (Time::US));
474  return GetBackoffStartFor (state) + (state->GetBackoffSlots () * m_slot);
475 }
476 
477 void
479 {
480  NS_LOG_FUNCTION (this);
481  uint32_t k = 0;
482  for (States::iterator i = m_states.begin (); i != m_states.end (); i++, k++)
483  {
484  Ptr<Txop> state = *i;
485 
486  Time backoffStart = GetBackoffStartFor (state);
487  if (backoffStart <= Simulator::Now ())
488  {
489  uint32_t nIntSlots = (Simulator::Now () - backoffStart) / m_slot;
490  /*
491  * EDCA behaves slightly different to DCA. For EDCA we
492  * decrement once at the slot boundary at the end of AIFS as
493  * well as once at the end of each clear slot
494  * thereafter. For DCA we only decrement at the end of each
495  * clear slot after DIFS. We account for the extra backoff
496  * by incrementing the slot count here in the case of
497  * EDCA. The if statement whose body we are in has confirmed
498  * that a minimum of AIFS has elapsed since last busy
499  * medium.
500  */
501  if (state->IsQosTxop ())
502  {
503  nIntSlots++;
504  }
505  uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ());
506  NS_LOG_DEBUG ("dcf " << k << " dec backoff slots=" << n);
507  Time backoffUpdateBound = backoffStart + (n * m_slot);
508  state->UpdateBackoffSlotsNow (n, backoffUpdateBound);
509  }
510  }
511 }
512 
513 void
515 {
516  NS_LOG_FUNCTION (this);
521  bool accessTimeoutNeeded = false;
522  Time expectedBackoffEnd = Simulator::GetMaximumSimulationTime ();
523  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
524  {
525  Ptr<Txop> state = *i;
526  if (state->IsAccessRequested ())
527  {
528  Time tmp = GetBackoffEndFor (state);
529  if (tmp > Simulator::Now ())
530  {
531  accessTimeoutNeeded = true;
532  expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
533  }
534  }
535  }
536  NS_LOG_DEBUG ("Access timeout needed: " << accessTimeoutNeeded);
537  if (accessTimeoutNeeded)
538  {
539  NS_LOG_DEBUG ("expected backoff end=" << expectedBackoffEnd);
540  Time expectedBackoffDelay = expectedBackoffEnd - Simulator::Now ();
542  && Simulator::GetDelayLeft (m_accessTimeout) > expectedBackoffDelay)
543  {
545  }
546  if (m_accessTimeout.IsExpired ())
547  {
548  m_accessTimeout = Simulator::Schedule (expectedBackoffDelay,
550  }
551  }
552 }
553 
554 void
556 {
557  NS_LOG_FUNCTION (this << duration);
558  NS_LOG_DEBUG ("rx start for=" << duration);
559  UpdateBackoff ();
561  m_lastRxDuration = duration;
562  m_rxing = true;
563 }
564 
565 void
567 {
568  NS_LOG_FUNCTION (this);
569  NS_LOG_DEBUG ("rx end ok");
571  m_lastRxReceivedOk = true;
572  m_rxing = false;
573 }
574 
575 void
577 {
578  NS_LOG_FUNCTION (this);
579  NS_LOG_DEBUG ("rx end error");
581  m_lastRxReceivedOk = false;
582  m_rxing = false;
583 }
584 
585 void
587 {
588  NS_LOG_FUNCTION (this << duration);
589  if (m_rxing)
590  {
591  //this may be caused only if PHY has started to receive a packet
592  //inside SIFS, so, we check that lastRxStart was maximum a SIFS ago
596  m_lastRxReceivedOk = true;
597  m_rxing = false;
598  }
599  NS_LOG_DEBUG ("tx start for " << duration);
600  UpdateBackoff ();
602  m_lastTxDuration = duration;
603 }
604 
605 void
607 {
608  NS_LOG_FUNCTION (this << duration);
609  NS_LOG_DEBUG ("busy start for " << duration);
610  UpdateBackoff ();
612  m_lastBusyDuration = duration;
613 }
614 
615 void
617 {
618  NS_LOG_FUNCTION (this << duration);
619  Time now = Simulator::Now ();
622 
623  if (m_rxing)
624  {
625  //channel switching during packet reception
628  m_lastRxReceivedOk = true;
629  m_rxing = false;
630  }
631  if (m_lastNavStart + m_lastNavDuration > now)
632  {
634  }
636  {
638  }
639  if (m_lastAckTimeoutEnd > now)
640  {
641  m_lastAckTimeoutEnd = now;
642  }
643  if (m_lastCtsTimeoutEnd > now)
644  {
645  m_lastCtsTimeoutEnd = now;
646  }
647 
648  //Cancel timeout
649  if (m_accessTimeout.IsRunning ())
650  {
652  }
653 
654  //Reset backoffs
655  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
656  {
657  Ptr<Txop> state = *i;
658  uint32_t remainingSlots = state->GetBackoffSlots ();
659  if (remainingSlots > 0)
660  {
661  state->UpdateBackoffSlotsNow (remainingSlots, now);
662  NS_ASSERT (state->GetBackoffSlots () == 0);
663  }
664  state->ResetCw ();
665  state->m_accessRequested = false;
666  state->NotifyChannelSwitching ();
667  }
668 
669  NS_LOG_DEBUG ("switching start for " << duration);
671  m_lastSwitchingDuration = duration;
672 
673 }
674 
675 void
677 {
678  NS_LOG_FUNCTION (this);
679  m_sleeping = true;
680  //Cancel timeout
681  if (m_accessTimeout.IsRunning ())
682  {
684  }
685 
686  //Reset backoffs
687  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
688  {
689  Ptr<Txop> state = *i;
690  state->NotifySleep ();
691  }
692 }
693 
694 void
696 {
697  NS_LOG_FUNCTION (this);
698  m_off = true;
699  //Cancel timeout
700  if (m_accessTimeout.IsRunning ())
701  {
703  }
704 
705  //Reset backoffs
706  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
707  {
708  Ptr<Txop> state = *i;
709  state->NotifyOff ();
710  }
711 }
712 
713 void
715 {
716  NS_LOG_FUNCTION (this);
717  m_sleeping = false;
718  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
719  {
720  Ptr<Txop> state = *i;
721  uint32_t remainingSlots = state->GetBackoffSlots ();
722  if (remainingSlots > 0)
723  {
724  state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ());
725  NS_ASSERT (state->GetBackoffSlots () == 0);
726  }
727  state->ResetCw ();
728  state->m_accessRequested = false;
729  state->NotifyWakeUp ();
730  }
731 }
732 
733 void
735 {
736  NS_LOG_FUNCTION (this);
737  m_off = false;
738  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
739  {
740  Ptr<Txop> state = *i;
741  uint32_t remainingSlots = state->GetBackoffSlots ();
742  if (remainingSlots > 0)
743  {
744  state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ());
745  NS_ASSERT (state->GetBackoffSlots () == 0);
746  }
747  state->ResetCw ();
748  state->m_accessRequested = false;
749  state->NotifyOn ();
750  }
751 }
752 
753 void
755 {
756  NS_LOG_FUNCTION (this << duration);
757  NS_LOG_DEBUG ("nav reset for=" << duration);
758  UpdateBackoff ();
760  m_lastNavDuration = duration;
768 }
769 
770 void
772 {
773  NS_LOG_FUNCTION (this << duration);
775  NS_LOG_DEBUG ("nav start for=" << duration);
776  UpdateBackoff ();
777  Time newNavEnd = Simulator::Now () + duration;
778  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
779  if (newNavEnd > lastNavEnd)
780  {
782  m_lastNavDuration = duration;
783  }
784 }
785 
786 void
788 {
789  NS_LOG_FUNCTION (this << duration);
791  m_lastAckTimeoutEnd = Simulator::Now () + duration;
792 }
793 
794 void
796 {
797  NS_LOG_FUNCTION (this);
800 }
801 
802 void
804 {
805  NS_LOG_FUNCTION (this << duration);
806  m_lastCtsTimeoutEnd = Simulator::Now () + duration;
807 }
808 
809 void
811 {
812  NS_LOG_FUNCTION (this);
815 }
816 
817 } //namespace ns3
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:258
Time GetBackoffEndFor(Ptr< Txop > state)
Return the time when the backoff procedure ended (or will ended) for the given Txop.
void GrantPcfAccess(Ptr< Txop > state)
Grant access to PCF.
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:284
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:448
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:202
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:226
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
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:278
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:232
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:546
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.
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:1381
void SetEifsNoDifs(Time eifsNoDifs)
receive notifications about phy events.
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has reset.
void NotifyOffNow(void)
Notify the DCF that the device has been put in off mode.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:209
Time m_lastRxEnd
the last receive end time
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:435
virtual bool IsQosTxop() const
Check for QoS TXOP.
Definition: txop.cc:810
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.
void DoGrantAccess(void)
Grant access to DCF.
double f(double x, void *params)
Definition: 80211b.c:70
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void RegisterDcf(Ptr< ChannelAccessManager > dcf)
Definition: mac-low.cc:456
virtual void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
Definition: txop.cc:535
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:561
bool m_lastRxReceivedOk
the last receive OK
PhyListener * m_phyListener
the phy listener
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: txop.cc:527
ns3::ChannelAccessManager * m_dcf
ChannelAccessManager to forward events to.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
virtual void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
Definition: txop.cc:512
void NotifyRxStart(Time duration)
void NotifyAckTimeoutResetNow()
Notify that ACK timer has reset.
bool m_accessRequested
flag whether channel access is already requested
Definition: txop.h:509
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:270
virtual void NotifyCollision(void)
Notify the DCF that collision has occurred.
Definition: txop.cc:519
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: txop.cc:220
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:1030
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:441
bool m_rxing
flag whether it is in receiving state
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:205
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:371
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:554
bool IsWithinAifs(Ptr< Txop > state) const
Check if the device is between frames (in DIFS or AIFS interval)
Time MostRecent(Time a, Time b) const
Return the most recent time.
void DoDispose(void)
Destructor implementation.