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/assert.h"
22 #include "ns3/log.h"
23 #include "ns3/simulator.h"
24 #include <cmath>
25 #include "dcf-manager.h"
26 #include "wifi-phy.h"
27 #include "wifi-mac.h"
28 #include "mac-low.h"
29 
30 #define MY_DEBUG(x) \
31  NS_LOG_DEBUG (Simulator::Now () << " " << this << " " << x)
32 
33 namespace ns3 {
34 
35 NS_LOG_COMPONENT_DEFINE ("DcfManager");
36 
37 /****************************************************************
38  * Implement the DCF state holder
39  ****************************************************************/
40 
42  : m_backoffSlots (0),
43  m_backoffStart (Seconds (0.0)),
44  m_cwMin (0),
45  m_cwMax (0),
46  m_cw (0),
47  m_accessRequested (false)
48 {
49 }
50 
52 {
53 }
54 
55 void
56 DcfState::SetAifsn (uint32_t aifsn)
57 {
58  m_aifsn = aifsn;
59 }
60 
61 void
62 DcfState::SetCwMin (uint32_t minCw)
63 {
64  bool changed = (m_cwMin != minCw);
65  m_cwMin = minCw;
66  if (changed == true)
67  {
68  ResetCw ();
69  }
70 }
71 
72 void
73 DcfState::SetCwMax (uint32_t maxCw)
74 {
75  bool changed = (m_cwMax != maxCw);
76  m_cwMax = maxCw;
77  if (changed == true)
78  {
79  ResetCw ();
80  }
81 }
82 
83 uint32_t
84 DcfState::GetAifsn (void) const
85 {
86  return m_aifsn;
87 }
88 
89 uint32_t
90 DcfState::GetCwMin (void) const
91 {
92  return m_cwMin;
93 }
94 
95 uint32_t
96 DcfState::GetCwMax (void) const
97 {
98  return m_cwMax;
99 }
100 
101 void
103 {
104  m_cw = m_cwMin;
105 }
106 
107 void
109 {
110  //see 802.11-2012, section 9.19.2.5
111  m_cw = std::min ( 2 * (m_cw + 1) - 1, m_cwMax);
112 }
113 
114 void
115 DcfState::UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound)
116 {
117  m_backoffSlots -= nSlots;
118  m_backoffStart = backoffUpdateBound;
119  MY_DEBUG ("update slots=" << nSlots << " slots, backoff=" << m_backoffSlots);
120 }
121 
122 void
123 DcfState::StartBackoffNow (uint32_t nSlots)
124 {
125  NS_ASSERT (m_backoffSlots == 0);
126  MY_DEBUG ("start backoff=" << nSlots << " slots");
127  m_backoffSlots = nSlots;
129 }
130 
131 uint32_t
132 DcfState::GetCw (void) const
133 {
134  return m_cw;
135 }
136 
137 uint32_t
139 {
140  return m_backoffSlots;
141 }
142 
143 Time
145 {
146  return m_backoffStart;
147 }
148 
149 bool
151 {
152  return m_accessRequested;
153 }
154 void
156 {
157  m_accessRequested = true;
158 }
159 
160 void
162 {
164  m_accessRequested = false;
166 }
167 
168 void
170 {
172 }
173 
174 void
176 {
178 }
179 
180 void
182 {
184 }
185 
186 void
188 {
189  DoNotifySleep ();
190 }
191 
192 void
194 {
195  DoNotifyWakeUp ();
196 }
197 
198 
203 {
204 public:
211  : m_dcf (dcf)
212  {
213  }
214  virtual ~LowDcfListener ()
215  {
216  }
217  virtual void NavStart (Time duration)
218  {
219  m_dcf->NotifyNavStartNow (duration);
220  }
221  virtual void NavReset (Time duration)
222  {
223  m_dcf->NotifyNavResetNow (duration);
224  }
225  virtual void AckTimeoutStart (Time duration)
226  {
227  m_dcf->NotifyAckTimeoutStartNow (duration);
228  }
229  virtual void AckTimeoutReset ()
230  {
232  }
233  virtual void CtsTimeoutStart (Time duration)
234  {
235  m_dcf->NotifyCtsTimeoutStartNow (duration);
236  }
237  virtual void CtsTimeoutReset ()
238  {
240  }
241 
242 private:
244 };
245 
246 
251 {
252 public:
259  : m_dcf (dcf)
260  {
261  }
262  virtual ~PhyListener ()
263  {
264  }
265  virtual void NotifyRxStart (Time duration)
266  {
267  m_dcf->NotifyRxStartNow (duration);
268  }
269  virtual void NotifyRxEndOk (void)
270  {
272  }
273  virtual void NotifyRxEndError (void)
274  {
276  }
277  virtual void NotifyTxStart (Time duration, double txPowerDbm)
278  {
279  m_dcf->NotifyTxStartNow (duration);
280  }
281  virtual void NotifyMaybeCcaBusyStart (Time duration)
282  {
283  m_dcf->NotifyMaybeCcaBusyStartNow (duration);
284  }
285  virtual void NotifySwitchingStart (Time duration)
286  {
287  m_dcf->NotifySwitchingStartNow (duration);
288  }
289  virtual void NotifySleep (void)
290  {
291  m_dcf->NotifySleepNow ();
292  }
293  virtual void NotifyWakeup (void)
294  {
296  }
297 
298 private:
300 };
301 
302 
303 /****************************************************************
304  * Implement the DCF manager of all DCF state holders
305  ****************************************************************/
306 
308  : m_lastAckTimeoutEnd (MicroSeconds (0)),
309  m_lastCtsTimeoutEnd (MicroSeconds (0)),
310  m_lastNavStart (MicroSeconds (0)),
311  m_lastNavDuration (MicroSeconds (0)),
312  m_lastRxStart (MicroSeconds (0)),
313  m_lastRxDuration (MicroSeconds (0)),
314  m_lastRxReceivedOk (true),
315  m_lastRxEnd (MicroSeconds (0)),
316  m_lastTxStart (MicroSeconds (0)),
317  m_lastTxDuration (MicroSeconds (0)),
318  m_lastBusyStart (MicroSeconds (0)),
319  m_lastBusyDuration (MicroSeconds (0)),
320  m_lastSwitchingStart (MicroSeconds (0)),
321  m_lastSwitchingDuration (MicroSeconds (0)),
322  m_rxing (false),
323  m_sleeping (false),
324  m_slotTimeUs (0),
325  m_sifs (Seconds (0.0)),
326  m_phyListener (0),
327  m_lowListener (0)
328 {
329  NS_LOG_FUNCTION (this);
330 }
331 
333 {
334  delete m_phyListener;
335  delete m_lowListener;
336  m_phyListener = 0;
337  m_lowListener = 0;
338 }
339 
340 void
342 {
343  NS_LOG_FUNCTION (this << phy);
344  if (m_phyListener != 0)
345  {
346  delete m_phyListener;
347  }
348  m_phyListener = new PhyListener (this);
350 }
351 
352 void
354 {
355  NS_LOG_FUNCTION (this << phy);
356  if (m_phyListener != 0)
357  {
359  delete m_phyListener;
360  m_phyListener = 0;
361  }
362 }
363 
364 void
366 {
367  NS_LOG_FUNCTION (this << low);
368  if (m_lowListener != 0)
369  {
370  delete m_lowListener;
371  }
372  m_lowListener = new LowDcfListener (this);
374 }
375 
376 void
378 {
379  NS_LOG_FUNCTION (this << slotTime);
380  m_slotTimeUs = slotTime.GetMicroSeconds ();
381 }
382 
383 void
385 {
386  NS_LOG_FUNCTION (this << sifs);
387  m_sifs = sifs;
388 }
389 
390 void
392 {
393  NS_LOG_FUNCTION (this << eifsNoDifs);
394  m_eifsNoDifs = eifsNoDifs;
395 }
396 
397 Time
399 {
400  NS_LOG_FUNCTION (this);
401  return m_eifsNoDifs;
402 }
403 
404 void
406 {
407  NS_LOG_FUNCTION (this << dcf);
408  m_states.push_back (dcf);
409 }
410 
411 Time
413 {
414  NS_LOG_FUNCTION (this << a << b);
415  return Max (a, b);
416 }
417 
418 Time
420 {
421  NS_LOG_FUNCTION (this << a << b << c);
422  Time retval;
423  retval = Max (a, b);
424  retval = Max (retval, c);
425  return retval;
426 }
427 
428 Time
430 {
431  NS_LOG_FUNCTION (this << a << b << c << d);
432  Time e = Max (a, b);
433  Time f = Max (c, d);
434  Time retval = Max (e, f);
435  return retval;
436 }
437 
438 Time
440 {
441  NS_LOG_FUNCTION (this << a << b << c << d << e << f);
442  Time g = Max (a, b);
443  Time h = Max (c, d);
444  Time i = Max (e, f);
445  Time k = Max (g, h);
446  Time retval = Max (k, i);
447  return retval;
448 }
449 
450 Time
452 {
453  NS_LOG_FUNCTION (this << a << b << c << d << e << f << g);
454  Time h = Max (a, b);
455  Time i = Max (c, d);
456  Time j = Max (e, f);
457  Time k = Max (h, i);
458  Time l = Max (j, g);
459  Time retval = Max (k, l);
460  return retval;
461 }
462 
463 bool
464 DcfManager::IsBusy (void) const
465 {
466  NS_LOG_FUNCTION (this);
467  // PHY busy
468  if (m_rxing)
469  {
470  return true;
471  }
472  Time lastTxEnd = m_lastTxStart + m_lastTxDuration;
473  if (lastTxEnd > Simulator::Now ())
474  {
475  return true;
476  }
477  // NAV busy
478  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
479  if (lastNavEnd > Simulator::Now ())
480  {
481  return true;
482  }
483  return false;
484 }
485 
486 void
488 {
489  NS_LOG_FUNCTION (this << state);
490  //Deny access if in sleep mode
491  if (m_sleeping)
492  {
493  return;
494  }
495  UpdateBackoff ();
496  NS_ASSERT (!state->IsAccessRequested ());
497  state->NotifyAccessRequested ();
502  if (state->GetBackoffSlots () == 0
503  && IsBusy ())
504  {
505  MY_DEBUG ("medium is busy: collision");
506  /* someone else has accessed the medium.
507  * generate a backoff.
508  */
509  state->NotifyCollision ();
510  }
511  DoGrantAccess ();
513 }
514 
515 void
517 {
518  NS_LOG_FUNCTION (this);
519  uint32_t k = 0;
520  for (States::const_iterator i = m_states.begin (); i != m_states.end (); k++)
521  {
522  DcfState *state = *i;
523  if (state->IsAccessRequested ()
524  && GetBackoffEndFor (state) <= Simulator::Now () )
525  {
530  MY_DEBUG ("dcf " << k << " needs access. backoff expired. access granted. slots=" << state->GetBackoffSlots ());
531  i++; //go to the next item in the list.
532  k++;
533  std::vector<DcfState *> internalCollisionStates;
534  for (States::const_iterator j = i; j != m_states.end (); j++, k++)
535  {
536  DcfState *otherState = *j;
537  if (otherState->IsAccessRequested ()
538  && GetBackoffEndFor (otherState) <= Simulator::Now ())
539  {
540  MY_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision. slots=" <<
541  otherState->GetBackoffSlots ());
547  internalCollisionStates.push_back (otherState);
548  }
549  }
550 
558  state->NotifyAccessGranted ();
559  for (std::vector<DcfState *>::const_iterator k = internalCollisionStates.begin ();
560  k != internalCollisionStates.end (); k++)
561  {
562  (*k)->NotifyInternalCollision ();
563  }
564  break;
565  }
566  i++;
567  }
568 }
569 
570 void
572 {
573  NS_LOG_FUNCTION (this);
574  UpdateBackoff ();
575  DoGrantAccess ();
577 }
578 
579 Time
581 {
582  NS_LOG_FUNCTION (this);
583  Time rxAccessStart;
584  if (!m_rxing)
585  {
586  rxAccessStart = m_lastRxEnd + m_sifs;
587  if (!m_lastRxReceivedOk)
588  {
589  rxAccessStart += m_eifsNoDifs;
590  }
591  }
592  else
593  {
594  rxAccessStart = m_lastRxStart + m_lastRxDuration + m_sifs;
595  }
596  Time busyAccessStart = m_lastBusyStart + m_lastBusyDuration + m_sifs;
597  Time txAccessStart = m_lastTxStart + m_lastTxDuration + m_sifs;
598  Time navAccessStart = m_lastNavStart + m_lastNavDuration + m_sifs;
599  Time ackTimeoutAccessStart = m_lastAckTimeoutEnd + m_sifs;
600  Time ctsTimeoutAccessStart = m_lastCtsTimeoutEnd + m_sifs;
601  Time switchingAccessStart = m_lastSwitchingStart + m_lastSwitchingDuration + m_sifs;
602  Time accessGrantedStart = MostRecent (rxAccessStart,
603  busyAccessStart,
604  txAccessStart,
605  navAccessStart,
606  ackTimeoutAccessStart,
607  ctsTimeoutAccessStart,
608  switchingAccessStart
609  );
610  NS_LOG_INFO ("access grant start=" << accessGrantedStart <<
611  ", rx access start=" << rxAccessStart <<
612  ", busy access start=" << busyAccessStart <<
613  ", tx access start=" << txAccessStart <<
614  ", nav access start=" << navAccessStart);
615  return accessGrantedStart;
616 }
617 
618 Time
620 {
621  NS_LOG_FUNCTION (this << state);
622  Time mostRecentEvent = MostRecent (state->GetBackoffStart (),
624 
625  return mostRecentEvent;
626 }
627 
628 Time
630 {
631  return GetBackoffStartFor (state) + MicroSeconds (state->GetBackoffSlots () * m_slotTimeUs);
632 }
633 
634 void
636 {
637  NS_LOG_FUNCTION (this);
638  uint32_t k = 0;
639  for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++, k++)
640  {
641  DcfState *state = *i;
642 
643  Time backoffStart = GetBackoffStartFor (state);
644  if (backoffStart <= Simulator::Now ())
645  {
646  uint32_t nus = (Simulator::Now () - backoffStart).GetMicroSeconds ();
647  uint32_t nIntSlots = nus / m_slotTimeUs;
648  /*
649  * EDCA behaves slightly different to DCA. For EDCA we
650  * decrement once at the slot boundary at the end of AIFS as
651  * well as once at the end of each clear slot
652  * thereafter. For DCA we only decrement at the end of each
653  * clear slot after DIFS. We account for the extra backoff
654  * by incrementing the slot count here in the case of
655  * EDCA. The if statement whose body we are in has confirmed
656  * that a minimum of AIFS has elapsed since last busy
657  * medium.
658  */
659  if (state->IsEdca ())
660  {
661  nIntSlots++;
662  }
663  uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ());
664  MY_DEBUG ("dcf " << k << " dec backoff slots=" << n);
665  Time backoffUpdateBound = backoffStart + MicroSeconds (n * m_slotTimeUs);
666  state->UpdateBackoffSlotsNow (n, backoffUpdateBound);
667  }
668  }
669 }
670 
671 void
673 {
674  NS_LOG_FUNCTION (this);
679  bool accessTimeoutNeeded = false;
680  Time expectedBackoffEnd = Simulator::GetMaximumSimulationTime ();
681  for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++)
682  {
683  DcfState *state = *i;
684  if (state->IsAccessRequested ())
685  {
686  Time tmp = GetBackoffEndFor (state);
687  if (tmp > Simulator::Now ())
688  {
689  accessTimeoutNeeded = true;
690  expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
691  }
692  }
693  }
694  if (accessTimeoutNeeded)
695  {
696  MY_DEBUG ("expected backoff end=" << expectedBackoffEnd);
697  Time expectedBackoffDelay = expectedBackoffEnd - Simulator::Now ();
699  && Simulator::GetDelayLeft (m_accessTimeout) > expectedBackoffDelay)
700  {
702  }
703  if (m_accessTimeout.IsExpired ())
704  {
705  m_accessTimeout = Simulator::Schedule (expectedBackoffDelay,
707  }
708  }
709 }
710 
711 void
713 {
714  NS_LOG_FUNCTION (this << duration);
715  MY_DEBUG ("rx start for=" << duration);
716  UpdateBackoff ();
718  m_lastRxDuration = duration;
719  m_rxing = true;
720 }
721 
722 void
724 {
725  NS_LOG_FUNCTION (this);
726  MY_DEBUG ("rx end ok");
728  m_lastRxReceivedOk = true;
729  m_rxing = false;
730 }
731 
732 void
734 {
735  NS_LOG_FUNCTION (this);
736  MY_DEBUG ("rx end error");
738  m_lastRxReceivedOk = false;
739  m_rxing = false;
740 }
741 
742 void
744 {
745  NS_LOG_FUNCTION (this << duration);
746  if (m_rxing)
747  {
748  //this may be caused only if PHY has started to receive a packet
749  //inside SIFS, so, we check that lastRxStart was maximum a SIFS ago
753  m_lastRxReceivedOk = true;
754  m_rxing = false;
755  }
756  MY_DEBUG ("tx start for " << duration);
757  UpdateBackoff ();
759  m_lastTxDuration = duration;
760 }
761 
762 void
764 {
765  NS_LOG_FUNCTION (this << duration);
766  MY_DEBUG ("busy start for " << duration);
767  UpdateBackoff ();
769  m_lastBusyDuration = duration;
770 }
771 
772 void
774 {
775  NS_LOG_FUNCTION (this << duration);
776  Time now = Simulator::Now ();
779 
780  if (m_rxing)
781  {
782  //channel switching during packet reception
785  m_lastRxReceivedOk = true;
786  m_rxing = false;
787  }
788  if (m_lastNavStart + m_lastNavDuration > now)
789  {
791  }
793  {
795  }
796  if (m_lastAckTimeoutEnd > now)
797  {
798  m_lastAckTimeoutEnd = now;
799  }
800  if (m_lastCtsTimeoutEnd > now)
801  {
802  m_lastCtsTimeoutEnd = now;
803  }
804 
805  //Cancel timeout
806  if (m_accessTimeout.IsRunning ())
807  {
809  }
810 
811  //Reset backoffs
812  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
813  {
814  DcfState *state = *i;
815  uint32_t remainingSlots = state->GetBackoffSlots ();
816  if (remainingSlots > 0)
817  {
818  state->UpdateBackoffSlotsNow (remainingSlots, now);
819  NS_ASSERT (state->GetBackoffSlots () == 0);
820  }
821  state->ResetCw ();
822  state->m_accessRequested = false;
823  state->NotifyChannelSwitching ();
824  }
825 
826  MY_DEBUG ("switching start for " << duration);
828  m_lastSwitchingDuration = duration;
829 
830 }
831 
832 void
834 {
835  NS_LOG_FUNCTION (this);
836  m_sleeping = true;
837  //Cancel timeout
838  if (m_accessTimeout.IsRunning ())
839  {
841  }
842 
843  //Reset backoffs
844  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
845  {
846  DcfState *state = *i;
847  state->NotifySleep ();
848  }
849 }
850 
851 void
853 {
854  NS_LOG_FUNCTION (this);
855  m_sleeping = false;
856  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
857  {
858  DcfState *state = *i;
859  uint32_t remainingSlots = state->GetBackoffSlots ();
860  if (remainingSlots > 0)
861  {
862  state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ());
863  NS_ASSERT (state->GetBackoffSlots () == 0);
864  }
865  state->ResetCw ();
866  state->m_accessRequested = false;
867  state->NotifyWakeUp ();
868  }
869 }
870 
871 void
873 {
874  NS_LOG_FUNCTION (this << duration);
875  MY_DEBUG ("nav reset for=" << duration);
876  UpdateBackoff ();
878  m_lastNavDuration = duration;
879  UpdateBackoff ();
887 }
888 
889 void
891 {
892  NS_LOG_FUNCTION (this << duration);
894  MY_DEBUG ("nav start for=" << duration);
895  UpdateBackoff ();
896  Time newNavEnd = Simulator::Now () + duration;
897  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
898  if (newNavEnd > lastNavEnd)
899  {
901  m_lastNavDuration = duration;
902  }
903 }
904 
905 void
907 {
908  NS_LOG_FUNCTION (this << duration);
910  m_lastAckTimeoutEnd = Simulator::Now () + duration;
911 }
912 
913 void
915 {
916  NS_LOG_FUNCTION (this);
919 }
920 
921 void
923 {
924  NS_LOG_FUNCTION (this << duration);
925  m_lastCtsTimeoutEnd = Simulator::Now () + duration;
926 }
927 
928 void
930 {
931  NS_LOG_FUNCTION (this);
934 }
935 } //namespace ns3
uint32_t m_cwMin
Definition: dcf-manager.h:240
ns3::DcfManager * m_dcf
DcfManager to forward events to.
Definition: dcf-manager.cc:299
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:232
void NotifyWakeupNow(void)
Notify the DCF that the device has been resumed from sleep mode.
Definition: dcf-manager.cc:852
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-manager.cc:187
ns3::DcfManager * m_dcf
DcfManager to forward events to.
Definition: dcf-manager.cc:243
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void NavReset(Time duration)
Notify that NAV has resetted.
Definition: dcf-manager.cc:221
void NotifyInternalCollision(void)
Notify that internal collision has occurred.
Definition: dcf-manager.cc:175
bool m_lastRxReceivedOk
Definition: dcf-manager.h:537
uint32_t GetCwMin(void) const
Return the minimum congestion window size.
Definition: dcf-manager.cc:90
#define min(a, b)
Definition: 80211b.c:44
virtual void NotifyRxStart(Time duration)
Definition: dcf-manager.cc:265
void NotifyAccessGranted(void)
Notify that access has been granted.
Definition: dcf-manager.cc:161
void RequestAccess(DcfState *state)
Definition: dcf-manager.cc:487
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
Definition: dcf-manager.cc:144
void SetupLowListener(Ptr< MacLow > low)
Set up listener for MacLow events.
Definition: dcf-manager.cc:365
#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_lastAckTimeoutEnd
Definition: dcf-manager.h:531
#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-manager.cc:193
virtual void NotifySwitchingStart(Time duration)
Definition: dcf-manager.cc:285
LowDcfListener(ns3::DcfManager *dcf)
Create a LowDcfListener for the given DcfManager.
Definition: dcf-manager.cc:210
void UpdateBackoff(void)
Update backoff slots for all DcfStates.
Definition: dcf-manager.cc:635
virtual void DoNotifyCollision(void)=0
Called by DcfManager to notify a DcfState subclass that a normal collision occured, that is, that the medium was busy when access was requested.
virtual void NotifyWakeup(void)
Notify listeners that we woke up.
Definition: dcf-manager.cc:293
Time m_lastCtsTimeoutEnd
Definition: dcf-manager.h:532
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
bool m_accessRequested
Definition: dcf-manager.h:243
void SetAifsn(uint32_t aifsn)
Definition: dcf-manager.cc:56
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-manager.cc:102
Time m_lastSwitchingDuration
Definition: dcf-manager.h:544
PhyListener(ns3::DcfManager *dcf)
Create a PhyListener for the given DcfManager.
Definition: dcf-manager.cc:258
void Add(DcfState *dcf)
Definition: dcf-manager.cc:405
virtual void NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
Definition: dcf-manager.cc:269
virtual void RegisterListener(WifiPhyListener *listener)=0
void DoGrantAccess(void)
Grant access to DCF.
Definition: dcf-manager.cc:516
void NotifyNavResetNow(Time duration)
Definition: dcf-manager.cc:872
Time GetBackoffStartFor(DcfState *state)
Return the time when the backoff procedure started for the given DcfState.
Definition: dcf-manager.cc:619
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Definition: dcf-manager.cc:922
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Definition: dcf-manager.cc:723
uint32_t m_backoffSlots
Definition: dcf-manager.h:235
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:1216
PhyListener * m_phyListener
Definition: dcf-manager.h:551
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:349
Time GetAccessGrantStart(void) const
Access will never be granted to the medium before the time returned by this method.
Definition: dcf-manager.cc:580
receive notifications about phy events.
Definition: wifi-phy.h:70
Time GetBackoffEndFor(DcfState *state)
Return the time when the backoff procedure ended (or will ended) for the given DcfState.
Definition: dcf-manager.cc:629
void NotifyTxStartNow(Time duration)
Definition: dcf-manager.cc:743
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for Phy events.
Definition: dcf-manager.cc:353
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
Definition: dcf-manager.cc:906
virtual void NavStart(Time duration)
Norify that NAV has started for the given duration.
Definition: dcf-manager.cc:217
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for Phy events.
Definition: dcf-manager.cc:341
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:262
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:209
keep track of the state needed for a single DCF function.
Definition: dcf-manager.h:46
virtual void AckTimeoutStart(Time duration)
Notify that ACK timeout has started for a given duration.
Definition: dcf-manager.cc:225
virtual void CtsTimeoutReset()
Notify that CTS timeout has resetted.
Definition: dcf-manager.cc:237
bool IsAccessRequested(void) const
Definition: dcf-manager.cc:150
Listener for PHY events.
Definition: dcf-manager.cc:250
void RegisterDcfListener(MacLowDcfListener *listener)
Definition: mac-low.cc:699
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: dcf-manager.cc:138
virtual ~DcfState()
Definition: dcf-manager.cc:51
#define MY_DEBUG(x)
Definition: dcf-manager.cc:30
uint32_t GetCwMax(void) const
Return the maximum congestion window size.
Definition: dcf-manager.cc:96
Time m_lastBusyDuration
Definition: dcf-manager.h:542
void SetCwMin(uint32_t minCw)
Set the minimum congestion window size.
Definition: dcf-manager.cc:62
double f(double x, void *params)
Definition: 80211b.c:60
virtual void NotifySleep(void)
Notify listeners that we went to sleep.
Definition: dcf-manager.cc:289
void StartBackoffNow(uint32_t nSlots)
Definition: dcf-manager.cc:123
virtual void DoNotifyWakeUp(void)=0
Called by DcfManager to notify a DcfState subclass that the device has begun to wake up...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void NotifyMaybeCcaBusyStart(Time duration)
Definition: dcf-manager.cc:281
uint32_t m_cwMax
Definition: dcf-manager.h:241
virtual void DoNotifyAccessGranted(void)=0
Called by DcfManager to notify a DcfState subclass that access to the medium is granted and can start...
virtual void UnregisterListener(WifiPhyListener *listener)=0
void NotifyAccessRequested(void)
Notify that access request has been received.
Definition: dcf-manager.cc:155
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully.
Definition: dcf-manager.cc:733
virtual void CtsTimeoutStart(Time duration)
Notify that CTS timeout has started for a given duration.
Definition: dcf-manager.cc:233
uint32_t m_cw
Definition: dcf-manager.h:242
Time m_lastSwitchingStart
Definition: dcf-manager.h:543
void SetEifsNoDifs(Time eifsNoDifs)
Definition: dcf-manager.cc:391
virtual void DoNotifyInternalCollision(void)=0
Called by DcfManager to notify a DcfState subclass that an 'internal' collision occured, that is, that the backoff timer of a higher priority DcfState expired at the same time and that access was granted to this higher priority DcfState.
listen to NAV eventsThis class is typically connected to an instance of ns3::Dcf and calls to its met...
Definition: mac-low.h:156
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
void NotifyMaybeCcaBusyStartNow(Time duration)
Definition: dcf-manager.cc:763
void AccessTimeout(void)
Called when access timeout should occur (e.g.
Definition: dcf-manager.cc:571
Time m_lastNavDuration
Definition: dcf-manager.h:534
void SetSlot(Time slotTime)
Definition: dcf-manager.cc:377
void SetCwMax(uint32_t maxCw)
Set the maximum congestion window size.
Definition: dcf-manager.cc:73
void NotifyAckTimeoutResetNow()
Notify that ACK timer has resetted.
Definition: dcf-manager.cc:914
LowDcfListener * m_lowListener
Definition: dcf-manager.h:552
void NotifyNavStartNow(Time duration)
Definition: dcf-manager.cc:890
void NotifyChannelSwitching(void)
Notify that the device is switching channel.
Definition: dcf-manager.cc:181
uint32_t GetCw(void) const
Definition: dcf-manager.cc:132
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dcf-manager.cc:84
uint32_t m_aifsn
Definition: dcf-manager.h:234
virtual void DoNotifyChannelSwitching(void)=0
Called by DcfManager to notify a DcfState subclass that a channel switching occured.
void NotifyRxStartNow(Time duration)
Definition: dcf-manager.cc:712
virtual void DoNotifySleep(void)=0
Called by DcfManager to notify a DcfState subclass that the device has begun to sleep.
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
Definition: dcf-manager.cc:115
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
virtual ~PhyListener()
Definition: dcf-manager.cc:262
Time GetEifsNoDifs() const
Definition: dcf-manager.cc:398
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
virtual void NotifyRxEndError(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
Definition: dcf-manager.cc:273
void NotifySleepNow(void)
Notify the DCF that the device has been put in sleep mode.
Definition: dcf-manager.cc:833
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has resetted.
Definition: dcf-manager.cc:929
void NotifyCollision(void)
Notify that collision has occurred.
Definition: dcf-manager.cc:169
virtual void NotifyTxStart(Time duration, double txPowerDbm)
Definition: dcf-manager.cc:277
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV busy.
Definition: dcf-manager.cc:464
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:911
Time m_backoffStart
Definition: dcf-manager.h:239
void DoRestartAccessTimeoutIfNeeded(void)
Definition: dcf-manager.cc:672
EventId m_accessTimeout
Definition: dcf-manager.h:548
virtual ~LowDcfListener()
Definition: dcf-manager.cc:214
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Definition: dcf-manager.cc:108
Listener for NAV events.
Definition: dcf-manager.cc:202
void NotifySwitchingStartNow(Time duration)
Definition: dcf-manager.cc:773
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
virtual bool IsEdca(void) const =0
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
Definition: simulator.cc:336
uint32_t m_slotTimeUs
Definition: dcf-manager.h:549
Time MostRecent(Time a, Time b) const
Return the most recent time.
Definition: dcf-manager.cc:412
void SetSifs(Time sifs)
Definition: dcf-manager.cc:384
virtual void AckTimeoutReset()
Notify that ACK timeout has resetted.
Definition: dcf-manager.cc:229