A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
26 #include "dcf-manager.h"
27 #include "wifi-phy.h"
28 #include "wifi-mac.h"
29 #include "mac-low.h"
30 
31 NS_LOG_COMPONENT_DEFINE ("DcfManager");
32 
33 #define MY_DEBUG(x) \
34  NS_LOG_DEBUG (Simulator::Now () << " " << this << " " << x)
35 
36 namespace ns3 {
37 
38 /****************************************************************
39  * Implement the DCF state holder
40  ****************************************************************/
41 
43  : m_backoffSlots (0),
44  m_backoffStart (Seconds (0.0)),
45  m_cwMin (0),
46  m_cwMax (0),
47  m_cw (0),
48  m_accessRequested (false)
49 {
50 }
51 
53 {
54 }
55 
56 void
57 DcfState::SetAifsn (uint32_t aifsn)
58 {
59  m_aifsn = aifsn;
60 }
61 void
62 DcfState::SetCwMin (uint32_t minCw)
63 {
64  m_cwMin = minCw;
65  ResetCw ();
66 }
67 void
68 DcfState::SetCwMax (uint32_t maxCw)
69 {
70  m_cwMax = maxCw;
71  ResetCw ();
72 }
73 uint32_t
74 DcfState::GetAifsn (void) const
75 {
76  return m_aifsn;
77 }
78 uint32_t
79 DcfState::GetCwMin (void) const
80 {
81  return m_cwMin;
82 }
83 uint32_t
84 DcfState::GetCwMax (void) const
85 {
86  return m_cwMax;
87 }
88 
89 void
91 {
92  m_cw = m_cwMin;
93 }
94 void
96 {
97  // see 802.11-2012, section 9.19.2.5
98  m_cw = std::min ( 2 * (m_cw + 1) - 1, m_cwMax);
99 }
100 void
101 DcfState::UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound)
102 {
103  m_backoffSlots -= nSlots;
104  m_backoffStart = backoffUpdateBound;
105  MY_DEBUG ("update slots=" << nSlots << " slots, backoff=" << m_backoffSlots);
106 }
107 
108 void
109 DcfState::StartBackoffNow (uint32_t nSlots)
110 {
111  NS_ASSERT (m_backoffSlots == 0);
112  MY_DEBUG ("start backoff=" << nSlots << " slots");
113  m_backoffSlots = nSlots;
115 }
116 
117 uint32_t
118 DcfState::GetCw (void) const
119 {
120  return m_cw;
121 }
122 uint32_t
124 {
125  return m_backoffSlots;
126 }
127 Time
129 {
130  return m_backoffStart;
131 }
132 bool
134 {
135  return m_accessRequested;
136 }
137 void
139 {
140  m_accessRequested = true;
141 }
142 void
144 {
146  m_accessRequested = false;
148 }
149 void
151 {
153 }
154 void
156 {
158 }
159 void
161 {
163 }
164 
165 
170 {
171 public:
178  : m_dcf (dcf)
179  {
180  }
181  virtual ~LowDcfListener ()
182  {
183  }
184  virtual void NavStart (Time duration)
185  {
186  m_dcf->NotifyNavStartNow (duration);
187  }
188  virtual void NavReset (Time duration)
189  {
190  m_dcf->NotifyNavResetNow (duration);
191  }
192  virtual void AckTimeoutStart (Time duration)
193  {
194  m_dcf->NotifyAckTimeoutStartNow (duration);
195  }
196  virtual void AckTimeoutReset ()
197  {
199  }
200  virtual void CtsTimeoutStart (Time duration)
201  {
202  m_dcf->NotifyCtsTimeoutStartNow (duration);
203  }
204  virtual void CtsTimeoutReset ()
205  {
207  }
208 private:
210 };
211 
216 {
217 public:
224  : m_dcf (dcf)
225  {
226  }
227  virtual ~PhyListener ()
228  {
229  }
230  virtual void NotifyRxStart (Time duration)
231  {
232  m_dcf->NotifyRxStartNow (duration);
233  }
234  virtual void NotifyRxEndOk (void)
235  {
237  }
238  virtual void NotifyRxEndError (void)
239  {
241  }
242  virtual void NotifyTxStart (Time duration, double txPowerDbm)
243  {
244  m_dcf->NotifyTxStartNow (duration);
245  }
246  virtual void NotifyMaybeCcaBusyStart (Time duration)
247  {
248  m_dcf->NotifyMaybeCcaBusyStartNow (duration);
249  }
250  virtual void NotifySwitchingStart (Time duration)
251  {
252  m_dcf->NotifySwitchingStartNow (duration);
253  }
254  virtual void NotifySleep (void)
255  {
256  m_dcf->NotifySleepNow ();
257  }
258  virtual void NotifyWakeup (void)
259  {
261  }
262 private:
264 };
265 
266 /****************************************************************
267  * Implement the DCF manager of all DCF state holders
268  ****************************************************************/
269 
271  : m_lastAckTimeoutEnd (MicroSeconds (0)),
272  m_lastCtsTimeoutEnd (MicroSeconds (0)),
273  m_lastNavStart (MicroSeconds (0)),
274  m_lastNavDuration (MicroSeconds (0)),
275  m_lastRxStart (MicroSeconds (0)),
276  m_lastRxDuration (MicroSeconds (0)),
277  m_lastRxReceivedOk (true),
278  m_lastRxEnd (MicroSeconds (0)),
279  m_lastTxStart (MicroSeconds (0)),
280  m_lastTxDuration (MicroSeconds (0)),
281  m_lastBusyStart (MicroSeconds (0)),
282  m_lastBusyDuration (MicroSeconds (0)),
283  m_lastSwitchingStart (MicroSeconds (0)),
284  m_lastSwitchingDuration (MicroSeconds (0)),
285  m_rxing (false),
286  m_sleeping (false),
287  m_slotTimeUs (0),
288  m_sifs (Seconds (0.0)),
289  m_phyListener (0),
290  m_lowListener (0)
291 {
292  NS_LOG_FUNCTION (this);
293 }
294 
296 {
297  delete m_phyListener;
298  delete m_lowListener;
299  m_phyListener = 0;
300  m_lowListener = 0;
301 }
302 
303 void
305 {
306  NS_LOG_FUNCTION (this << phy);
307  if (m_phyListener != 0)
308  {
309  delete m_phyListener;
310  }
311  m_phyListener = new PhyListener (this);
313 }
314 void
316 {
317  NS_LOG_FUNCTION (this << low);
318  if (m_lowListener != 0)
319  {
320  delete m_lowListener;
321  }
322  m_lowListener = new LowDcfListener (this);
323  low->RegisterDcfListener (m_lowListener);
324 }
325 
326 void
328 {
329  NS_LOG_FUNCTION (this << slotTime);
330  m_slotTimeUs = slotTime.GetMicroSeconds ();
331 }
332 void
334 {
335  NS_LOG_FUNCTION (this << sifs);
336  m_sifs = sifs;
337 }
338 void
340 {
341  NS_LOG_FUNCTION (this << eifsNoDifs);
342  m_eifsNoDifs = eifsNoDifs;
343 }
344 Time
346 {
347  NS_LOG_FUNCTION (this);
348  return m_eifsNoDifs;
349 }
350 
351 void
353 {
354  NS_LOG_FUNCTION (this << dcf);
355  m_states.push_back (dcf);
356 }
357 
358 Time
360 {
361  NS_LOG_FUNCTION (this << a << b);
362  return Max (a, b);
363 }
364 Time
366 {
367  NS_LOG_FUNCTION (this << a << b << c);
368  Time retval;
369  retval = Max (a, b);
370  retval = Max (retval, c);
371  return retval;
372 }
373 Time
375 {
376  NS_LOG_FUNCTION (this << a << b << c << d);
377  Time e = Max (a, b);
378  Time f = Max (c, d);
379  Time retval = Max (e, f);
380  return retval;
381 }
382 Time
384 {
385  NS_LOG_FUNCTION (this << a << b << c << d << e << f);
386  Time g = Max (a, b);
387  Time h = Max (c, d);
388  Time i = Max (e, f);
389  Time k = Max (g, h);
390  Time retval = Max (k, i);
391  return retval;
392 }
393 
394 Time
395 DcfManager::MostRecent (Time a, Time b, Time c, Time d, Time e, Time f, Time g) const
396 {
397  NS_LOG_FUNCTION (this << a << b << c << d << e << f << g);
398  Time h = Max (a, b);
399  Time i = Max (c, d);
400  Time j = Max (e, f);
401  Time k = Max (h, i);
402  Time l = Max (j, g);
403  Time retval = Max (k, l);
404  return retval;
405 }
406 
407 bool
408 DcfManager::IsBusy (void) const
409 {
410  NS_LOG_FUNCTION (this);
411  // PHY busy
412  if (m_rxing)
413  {
414  return true;
415  }
416  Time lastTxEnd = m_lastTxStart + m_lastTxDuration;
417  if (lastTxEnd > Simulator::Now ())
418  {
419  return true;
420  }
421  // NAV busy
422  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
423  if (lastNavEnd > Simulator::Now ())
424  {
425  return true;
426  }
427  return false;
428 }
429 
430 
431 void
433 {
434  NS_LOG_FUNCTION (this << state);
435  // Deny access if in sleep mode
436  if (m_sleeping)
437  return;
438  UpdateBackoff ();
439  NS_ASSERT (!state->IsAccessRequested ());
440  state->NotifyAccessRequested ();
445  if (state->GetBackoffSlots () == 0
446  && IsBusy ())
447  {
448  MY_DEBUG ("medium is busy: collision");
449  /* someone else has accessed the medium.
450  * generate a backoff.
451  */
452  state->NotifyCollision ();
453  }
454  DoGrantAccess ();
456 }
457 
458 void
460 {
461  NS_LOG_FUNCTION (this);
462  uint32_t k = 0;
463  for (States::const_iterator i = m_states.begin (); i != m_states.end (); k++)
464  {
465  DcfState *state = *i;
466  if (state->IsAccessRequested ()
467  && GetBackoffEndFor (state) <= Simulator::Now () )
468  {
473  MY_DEBUG ("dcf " << k << " needs access. backoff expired. access granted. slots=" << state->GetBackoffSlots ());
474  i++; // go to the next item in the list.
475  k++;
476  std::vector<DcfState *> internalCollisionStates;
477  for (States::const_iterator j = i; j != m_states.end (); j++, k++)
478  {
479  DcfState *otherState = *j;
480  if (otherState->IsAccessRequested ()
481  && GetBackoffEndFor (otherState) <= Simulator::Now ())
482  {
483  MY_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision. slots=" <<
484  otherState->GetBackoffSlots ());
490  internalCollisionStates.push_back (otherState);
491  }
492  }
493 
501  state->NotifyAccessGranted ();
502  for (std::vector<DcfState *>::const_iterator k = internalCollisionStates.begin ();
503  k != internalCollisionStates.end (); k++)
504  {
505  (*k)->NotifyInternalCollision ();
506  }
507  break;
508  }
509  i++;
510  }
511 }
512 
513 void
515 {
516  NS_LOG_FUNCTION (this);
517  UpdateBackoff ();
518  DoGrantAccess ();
520 }
521 
522 Time
524 {
525  NS_LOG_FUNCTION (this);
526  Time rxAccessStart;
527  if (!m_rxing)
528  {
529  rxAccessStart = m_lastRxEnd + m_sifs;
530  if (!m_lastRxReceivedOk)
531  {
532  rxAccessStart += m_eifsNoDifs;
533  }
534  }
535  else
536  {
537  rxAccessStart = m_lastRxStart + m_lastRxDuration + m_sifs;
538  }
539  Time busyAccessStart = m_lastBusyStart + m_lastBusyDuration + m_sifs;
540  Time txAccessStart = m_lastTxStart + m_lastTxDuration + m_sifs;
541  Time navAccessStart = m_lastNavStart + m_lastNavDuration + m_sifs;
542  Time ackTimeoutAccessStart = m_lastAckTimeoutEnd + m_sifs;
543  Time ctsTimeoutAccessStart = m_lastCtsTimeoutEnd + m_sifs;
544  Time switchingAccessStart = m_lastSwitchingStart + m_lastSwitchingDuration + m_sifs;
545  Time accessGrantedStart = MostRecent (rxAccessStart,
546  busyAccessStart,
547  txAccessStart,
548  navAccessStart,
549  ackTimeoutAccessStart,
550  ctsTimeoutAccessStart,
551  switchingAccessStart
552  );
553  NS_LOG_INFO ("access grant start=" << accessGrantedStart <<
554  ", rx access start=" << rxAccessStart <<
555  ", busy access start=" << busyAccessStart <<
556  ", tx access start=" << txAccessStart <<
557  ", nav access start=" << navAccessStart);
558  return accessGrantedStart;
559 }
560 
561 Time
563 {
564  NS_LOG_FUNCTION (this << state);
565  Time mostRecentEvent = MostRecent (state->GetBackoffStart (),
567 
568  return mostRecentEvent;
569 }
570 
571 Time
573 {
574  return GetBackoffStartFor (state) + MicroSeconds (state->GetBackoffSlots () * m_slotTimeUs);
575 }
576 
577 void
579 {
580  NS_LOG_FUNCTION (this);
581  uint32_t k = 0;
582  for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++, k++)
583  {
584  DcfState *state = *i;
585 
586  Time backoffStart = GetBackoffStartFor (state);
587  if (backoffStart <= Simulator::Now ())
588  {
589  uint32_t nus = (Simulator::Now () - backoffStart).GetMicroSeconds ();
590  uint32_t nIntSlots = nus / m_slotTimeUs;
591  uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ());
592  MY_DEBUG ("dcf " << k << " dec backoff slots=" << n);
593  Time backoffUpdateBound = backoffStart + MicroSeconds (n * m_slotTimeUs);
594  state->UpdateBackoffSlotsNow (n, backoffUpdateBound);
595  }
596  }
597 }
598 
599 void
601 {
602  NS_LOG_FUNCTION (this);
607  bool accessTimeoutNeeded = false;
608  Time expectedBackoffEnd = Simulator::GetMaximumSimulationTime ();
609  for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++)
610  {
611  DcfState *state = *i;
612  if (state->IsAccessRequested ())
613  {
614  Time tmp = GetBackoffEndFor (state);
615  if (tmp > Simulator::Now ())
616  {
617  accessTimeoutNeeded = true;
618  expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
619  }
620  }
621  }
622  if (accessTimeoutNeeded)
623  {
624  MY_DEBUG ("expected backoff end=" << expectedBackoffEnd);
625  Time expectedBackoffDelay = expectedBackoffEnd - Simulator::Now ();
627  && Simulator::GetDelayLeft (m_accessTimeout) > expectedBackoffDelay)
628  {
630  }
631  if (m_accessTimeout.IsExpired ())
632  {
633  m_accessTimeout = Simulator::Schedule (expectedBackoffDelay,
635  }
636  }
637 }
638 
639 void
641 {
642  NS_LOG_FUNCTION (this << duration);
643  MY_DEBUG ("rx start for=" << duration);
644  UpdateBackoff ();
646  m_lastRxDuration = duration;
647  m_rxing = true;
648 }
649 void
651 {
652  NS_LOG_FUNCTION (this);
653  MY_DEBUG ("rx end ok");
655  m_lastRxReceivedOk = true;
656  m_rxing = false;
657 }
658 void
660 {
661  NS_LOG_FUNCTION (this);
662  MY_DEBUG ("rx end error");
664  m_lastRxReceivedOk = false;
665  m_rxing = false;
666 }
667 void
669 {
670  NS_LOG_FUNCTION (this << duration);
671  if (m_rxing)
672  {
673  //this may be caused only if PHY has started to receive a packet
674  //inside SIFS, so, we check that lastRxStart was maximum a SIFS
675  //ago
679  m_lastRxReceivedOk = true;
680  m_rxing = false;
681  }
682  MY_DEBUG ("tx start for " << duration);
683  UpdateBackoff ();
685  m_lastTxDuration = duration;
686 }
687 void
689 {
690  NS_LOG_FUNCTION (this << duration);
691  MY_DEBUG ("busy start for " << duration);
692  UpdateBackoff ();
694  m_lastBusyDuration = duration;
695 }
696 
697 
698 void
700 {
701  NS_LOG_FUNCTION (this << duration);
702  Time now = Simulator::Now ();
705 
706  if (m_rxing)
707  {
708  // channel switching during packet reception
711  m_lastRxReceivedOk = true;
712  m_rxing = false;
713  }
714  if (m_lastNavStart + m_lastNavDuration > now)
715  {
717  }
719  {
721  }
722  if (m_lastAckTimeoutEnd > now)
723  {
724  m_lastAckTimeoutEnd = now;
725  }
726  if (m_lastCtsTimeoutEnd > now)
727  {
728  m_lastCtsTimeoutEnd = now;
729  }
730 
731  // Cancel timeout
732  if (m_accessTimeout.IsRunning ())
733  {
735  }
736 
737  // Reset backoffs
738  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
739  {
740  DcfState *state = *i;
741  uint32_t remainingSlots = state->GetBackoffSlots ();
742  if (remainingSlots > 0)
743  {
744  state->UpdateBackoffSlotsNow (remainingSlots, now);
745  NS_ASSERT (state->GetBackoffSlots () == 0);
746  }
747  state->ResetCw ();
748  state->m_accessRequested = false;
749  state->NotifyChannelSwitching ();
750  }
751 
752  MY_DEBUG ("switching start for " << duration);
754  m_lastSwitchingDuration = duration;
755 
756 }
757 
758 void
760 {
761  NS_LOG_FUNCTION (this);
762  m_sleeping = true;
763  // Cancel timeout
764  if (m_accessTimeout.IsRunning ())
765  {
767  }
768 }
769 
770 void
772 {
773  NS_LOG_FUNCTION (this);
774  m_sleeping = false;
775  // Reset backoffs
776  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
777  {
778  DcfState *state = *i;
779  uint32_t remainingSlots = state->GetBackoffSlots ();
780  if (remainingSlots > 0)
781  {
782  state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ());
783  NS_ASSERT (state->GetBackoffSlots () == 0);
784  }
785  state->ResetCw ();
786  state->m_accessRequested = false;
787  }
788 }
789 
790 void
792 {
793  NS_LOG_FUNCTION (this << duration);
794  MY_DEBUG ("nav reset for=" << duration);
795  UpdateBackoff ();
797  m_lastNavDuration = duration;
798  UpdateBackoff ();
806 }
807 void
809 {
810  NS_LOG_FUNCTION (this << duration);
812  MY_DEBUG ("nav start for=" << duration);
813  UpdateBackoff ();
814  Time newNavEnd = Simulator::Now () + duration;
815  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
816  if (newNavEnd > lastNavEnd)
817  {
819  m_lastNavDuration = duration;
820  }
821 }
822 void
824 {
825  NS_LOG_FUNCTION (this << duration);
827  m_lastAckTimeoutEnd = Simulator::Now () + duration;
828 }
829 void
831 {
832  NS_LOG_FUNCTION (this);
835 }
836 void
838 {
839  NS_LOG_FUNCTION (this << duration);
840  m_lastCtsTimeoutEnd = Simulator::Now () + duration;
841 }
842 void
844 {
845  NS_LOG_FUNCTION (this);
848 }
849 } // namespace ns3
uint32_t m_cwMin
Definition: dcf-manager.h:208
ns3::DcfManager * m_dcf
DcfManager to forward events to.
Definition: dcf-manager.cc:263
static Time GetDelayLeft(const EventId &id)
Definition: simulator.cc:189
void NotifyWakeupNow(void)
Notify the DCF that the device has been resumed from sleep mode.
Definition: dcf-manager.cc:771
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
ns3::DcfManager * m_dcf
DcfManager to forward events to.
Definition: dcf-manager.cc:209
#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:188
void NotifyInternalCollision(void)
Notify that internal collision has occurred.
Definition: dcf-manager.cc:155
bool m_lastRxReceivedOk
Definition: dcf-manager.h:489
uint32_t GetCwMin(void) const
Return the minimum congestion window size.
Definition: dcf-manager.cc:79
virtual void NotifyRxStart(Time duration)
Definition: dcf-manager.cc:230
void NotifyAccessGranted(void)
Notify that access has been granted.
Definition: dcf-manager.cc:143
void RequestAccess(DcfState *state)
Definition: dcf-manager.cc:432
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
Definition: dcf-manager.cc:128
void SetupLowListener(Ptr< MacLow > low)
Set up listener for MacLow events.
Definition: dcf-manager.cc:315
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
Time m_lastAckTimeoutEnd
Definition: dcf-manager.h:483
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
virtual void NotifySwitchingStart(Time duration)
Definition: dcf-manager.cc:250
LowDcfListener(ns3::DcfManager *dcf)
Create a LowDcfListener for the given DcfManager.
Definition: dcf-manager.cc:177
void UpdateBackoff(void)
Update backoff slots for all DcfStates.
Definition: dcf-manager.cc:578
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:258
Time m_lastCtsTimeoutEnd
Definition: dcf-manager.h:484
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:223
bool m_accessRequested
Definition: dcf-manager.h:211
void SetAifsn(uint32_t aifsn)
Definition: dcf-manager.cc:57
bool IsRunning(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
Definition: event-id.cc:59
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:90
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition: simulator.h:825
Time m_lastSwitchingDuration
Definition: dcf-manager.h:496
PhyListener(ns3::DcfManager *dcf)
Create a PhyListener for the given DcfManager.
Definition: dcf-manager.cc:223
void Add(DcfState *dcf)
Definition: dcf-manager.cc:352
virtual void NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
Definition: dcf-manager.cc:234
virtual void RegisterListener(WifiPhyListener *listener)=0
void DoGrantAccess(void)
Grant access to DCF.
Definition: dcf-manager.cc:459
void NotifyNavResetNow(Time duration)
Definition: dcf-manager.cc:791
Time GetBackoffStartFor(DcfState *state)
Return the time when the backoff procedure started for the given DcfState.
Definition: dcf-manager.cc:562
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Definition: dcf-manager.cc:837
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Definition: dcf-manager.cc:650
uint32_t m_backoffSlots
Definition: dcf-manager.h:203
PhyListener * m_phyListener
Definition: dcf-manager.h:503
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:330
Time GetAccessGrantStart(void) const
Access will never be granted to the medium before the time returned by this method.
Definition: dcf-manager.cc:523
receive notifications about phy events.
Definition: wifi-phy.h:44
Time GetBackoffEndFor(DcfState *state)
Return the time when the backoff procedure ended (or will ended) for the given DcfState.
Definition: dcf-manager.cc:572
void NotifyTxStartNow(Time duration)
Definition: dcf-manager.cc:668
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
Definition: dcf-manager.cc:823
virtual void NavStart(Time duration)
Norify that NAV has started for the given duration.
Definition: dcf-manager.cc:184
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for Phy events.
Definition: dcf-manager.cc:304
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:229
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:204
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:192
virtual void CtsTimeoutReset()
Notify that CTS timeout has resetted.
Definition: dcf-manager.cc:204
bool IsAccessRequested(void) const
Definition: dcf-manager.cc:133
Listener for PHY events.
Definition: dcf-manager.cc:215
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: dcf-manager.cc:123
virtual ~DcfState()
Definition: dcf-manager.cc:52
#define MY_DEBUG(x)
Definition: dcf-manager.cc:33
uint32_t GetCwMax(void) const
Return the maximum congestion window size.
Definition: dcf-manager.cc:84
Time m_lastBusyDuration
Definition: dcf-manager.h:494
void SetCwMin(uint32_t minCw)
Set the minimum congestion window size.
Definition: dcf-manager.cc:62
virtual void NotifySleep(void)
Notify listeners that we went to sleep.
Definition: dcf-manager.cc:254
void StartBackoffNow(uint32_t nSlots)
Definition: dcf-manager.cc:109
virtual void NotifyMaybeCcaBusyStart(Time duration)
Definition: dcf-manager.cc:246
uint32_t m_cwMax
Definition: dcf-manager.h:209
virtual void DoNotifyAccessGranted(void)=0
Called by DcfManager to notify a DcfState subclass that access to the medium is granted and can start...
void NotifyAccessRequested(void)
Notify that access request has been received.
Definition: dcf-manager.cc:138
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully.
Definition: dcf-manager.cc:659
virtual void CtsTimeoutStart(Time duration)
Notify that CTS timeout has started for a given duration.
Definition: dcf-manager.cc:200
uint32_t m_cw
Definition: dcf-manager.h:210
Time m_lastSwitchingStart
Definition: dcf-manager.h:495
void SetEifsNoDifs(Time eifsNoDifs)
Definition: dcf-manager.cc:339
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:147
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
void NotifyMaybeCcaBusyStartNow(Time duration)
Definition: dcf-manager.cc:688
void AccessTimeout(void)
Called when access timeout should occur (e.g.
Definition: dcf-manager.cc:514
virtual void DoNotifyChannelSwitching()=0
Called by DcfManager to notify a DcfState subclass that a channel switching occured.
Time m_lastNavDuration
Definition: dcf-manager.h:486
void SetSlot(Time slotTime)
Definition: dcf-manager.cc:327
void SetCwMax(uint32_t maxCw)
Set the maximum congestion window size.
Definition: dcf-manager.cc:68
void NotifyAckTimeoutResetNow()
Notify that ACK timer has resetted.
Definition: dcf-manager.cc:830
LowDcfListener * m_lowListener
Definition: dcf-manager.h:504
void NotifyNavStartNow(Time duration)
Definition: dcf-manager.cc:808
void NotifyChannelSwitching(void)
Notify that the device is switching channel.
Definition: dcf-manager.cc:160
uint32_t GetCw(void) const
Definition: dcf-manager.cc:118
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dcf-manager.cc:74
uint32_t m_aifsn
Definition: dcf-manager.h:202
void NotifyRxStartNow(Time duration)
Definition: dcf-manager.cc:640
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
Definition: dcf-manager.cc:101
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:845
virtual ~PhyListener()
Definition: dcf-manager.cc:227
Time GetEifsNoDifs() const
Definition: dcf-manager.cc:345
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
Definition: event-id.cc:47
virtual void NotifyRxEndError(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
Definition: dcf-manager.cc:238
void NotifySleepNow(void)
Notify the DCF that the device has been put in sleep mode.
Definition: dcf-manager.cc:759
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has resetted.
Definition: dcf-manager.cc:843
void NotifyCollision(void)
Notify that collision has occurred.
Definition: dcf-manager.cc:150
virtual void NotifyTxStart(Time duration, double txPowerDbm)
Definition: dcf-manager.cc:242
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV busy.
Definition: dcf-manager.cc:408
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:861
Time m_backoffStart
Definition: dcf-manager.h:207
void DoRestartAccessTimeoutIfNeeded(void)
Definition: dcf-manager.cc:600
EventId m_accessTimeout
Definition: dcf-manager.h:500
virtual ~LowDcfListener()
Definition: dcf-manager.cc:181
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Definition: dcf-manager.cc:95
Listener for NAV events.
Definition: dcf-manager.cc:169
void NotifySwitchingStartNow(Time duration)
Definition: dcf-manager.cc:699
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
Definition: event-id.cc:53
static Time GetMaximumSimulationTime(void)
Definition: simulator.cc:293
uint32_t m_slotTimeUs
Definition: dcf-manager.h:501
Time MostRecent(Time a, Time b) const
Return the most recent time.
Definition: dcf-manager.cc:359
void SetSifs(Time sifs)
Definition: dcf-manager.cc:333
virtual void AckTimeoutReset()
Notify that ACK timeout has resetted.
Definition: dcf-manager.cc:196