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