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-2007, section 9.9.1.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)
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 private:
256 };
257 
258 /****************************************************************
259  * Implement the DCF manager of all DCF state holders
260  ****************************************************************/
261 
263  : m_lastAckTimeoutEnd (MicroSeconds (0)),
264  m_lastCtsTimeoutEnd (MicroSeconds (0)),
265  m_lastNavStart (MicroSeconds (0)),
266  m_lastNavDuration (MicroSeconds (0)),
267  m_lastRxStart (MicroSeconds (0)),
268  m_lastRxDuration (MicroSeconds (0)),
269  m_lastRxReceivedOk (true),
270  m_lastRxEnd (MicroSeconds (0)),
271  m_lastTxStart (MicroSeconds (0)),
272  m_lastTxDuration (MicroSeconds (0)),
273  m_lastBusyStart (MicroSeconds (0)),
274  m_lastBusyDuration (MicroSeconds (0)),
275  m_lastSwitchingStart (MicroSeconds (0)),
276  m_lastSwitchingDuration (MicroSeconds (0)),
277  m_rxing (false),
278  m_slotTimeUs (0),
279  m_sifs (Seconds (0.0)),
280  m_phyListener (0),
281  m_lowListener (0)
282 {
283  NS_LOG_FUNCTION (this);
284 }
285 
287 {
288  delete m_phyListener;
289  delete m_lowListener;
290  m_phyListener = 0;
291  m_lowListener = 0;
292 }
293 
294 void
296 {
297  NS_LOG_FUNCTION (this << phy);
298  if (m_phyListener != 0)
299  {
300  delete m_phyListener;
301  }
302  m_phyListener = new PhyListener (this);
304 }
305 void
307 {
308  NS_LOG_FUNCTION (this << low);
309  if (m_lowListener != 0)
310  {
311  delete m_lowListener;
312  }
313  m_lowListener = new LowDcfListener (this);
314  low->RegisterDcfListener (m_lowListener);
315 }
316 
317 void
319 {
320  NS_LOG_FUNCTION (this << slotTime);
321  m_slotTimeUs = slotTime.GetMicroSeconds ();
322 }
323 void
325 {
326  NS_LOG_FUNCTION (this << sifs);
327  m_sifs = sifs;
328 }
329 void
331 {
332  NS_LOG_FUNCTION (this << eifsNoDifs);
333  m_eifsNoDifs = eifsNoDifs;
334 }
335 Time
337 {
338  NS_LOG_FUNCTION (this);
339  return m_eifsNoDifs;
340 }
341 
342 void
344 {
345  NS_LOG_FUNCTION (this << dcf);
346  m_states.push_back (dcf);
347 }
348 
349 Time
351 {
352  NS_LOG_FUNCTION (this << a << b);
353  return Max (a, b);
354 }
355 Time
357 {
358  NS_LOG_FUNCTION (this << a << b << c);
359  Time retval;
360  retval = Max (a, b);
361  retval = Max (retval, c);
362  return retval;
363 }
364 Time
366 {
367  NS_LOG_FUNCTION (this << a << b << c << d);
368  Time e = Max (a, b);
369  Time f = Max (c, d);
370  Time retval = Max (e, f);
371  return retval;
372 }
373 Time
375 {
376  NS_LOG_FUNCTION (this << a << b << c << d << e << f);
377  Time g = Max (a, b);
378  Time h = Max (c, d);
379  Time i = Max (e, f);
380  Time k = Max (g, h);
381  Time retval = Max (k, i);
382  return retval;
383 }
384 
385 Time
386 DcfManager::MostRecent (Time a, Time b, Time c, Time d, Time e, Time f, Time g) const
387 {
388  NS_LOG_FUNCTION (this << a << b << c << d << e << f << g);
389  Time h = Max (a, b);
390  Time i = Max (c, d);
391  Time j = Max (e, f);
392  Time k = Max (h, i);
393  Time l = Max (j, g);
394  Time retval = Max (k, l);
395  return retval;
396 }
397 
398 bool
399 DcfManager::IsBusy (void) const
400 {
401  NS_LOG_FUNCTION (this);
402  // PHY busy
403  if (m_rxing)
404  {
405  return true;
406  }
407  Time lastTxEnd = m_lastTxStart + m_lastTxDuration;
408  if (lastTxEnd > Simulator::Now ())
409  {
410  return true;
411  }
412  // NAV busy
413  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
414  if (lastNavEnd > Simulator::Now ())
415  {
416  return true;
417  }
418  return false;
419 }
420 
421 
422 void
424 {
425  NS_LOG_FUNCTION (this << state);
426  UpdateBackoff ();
427  NS_ASSERT (!state->IsAccessRequested ());
428  state->NotifyAccessRequested ();
433  if (state->GetBackoffSlots () == 0
434  && IsBusy ())
435  {
436  MY_DEBUG ("medium is busy: collision");
437  /* someone else has accessed the medium.
438  * generate a backoff.
439  */
440  state->NotifyCollision ();
441  }
442  DoGrantAccess ();
444 }
445 
446 void
448 {
449  NS_LOG_FUNCTION (this);
450  uint32_t k = 0;
451  for (States::const_iterator i = m_states.begin (); i != m_states.end (); k++)
452  {
453  DcfState *state = *i;
454  if (state->IsAccessRequested ()
455  && GetBackoffEndFor (state) <= Simulator::Now () )
456  {
461  MY_DEBUG ("dcf " << k << " needs access. backoff expired. access granted. slots=" << state->GetBackoffSlots ());
462  i++; // go to the next item in the list.
463  k++;
464  std::vector<DcfState *> internalCollisionStates;
465  for (States::const_iterator j = i; j != m_states.end (); j++, k++)
466  {
467  DcfState *otherState = *j;
468  if (otherState->IsAccessRequested ()
469  && GetBackoffEndFor (otherState) <= Simulator::Now ())
470  {
471  MY_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision. slots=" <<
472  otherState->GetBackoffSlots ());
478  internalCollisionStates.push_back (otherState);
479  }
480  }
481 
489  state->NotifyAccessGranted ();
490  for (std::vector<DcfState *>::const_iterator k = internalCollisionStates.begin ();
491  k != internalCollisionStates.end (); k++)
492  {
493  (*k)->NotifyInternalCollision ();
494  }
495  break;
496  }
497  i++;
498  }
499 }
500 
501 void
503 {
504  NS_LOG_FUNCTION (this);
505  UpdateBackoff ();
506  DoGrantAccess ();
508 }
509 
510 Time
512 {
513  NS_LOG_FUNCTION (this);
514  Time rxAccessStart;
515  if (!m_rxing)
516  {
517  rxAccessStart = m_lastRxEnd + m_sifs;
518  if (!m_lastRxReceivedOk)
519  {
520  rxAccessStart += m_eifsNoDifs;
521  }
522  }
523  else
524  {
525  rxAccessStart = m_lastRxStart + m_lastRxDuration + m_sifs;
526  }
527  Time busyAccessStart = m_lastBusyStart + m_lastBusyDuration + m_sifs;
528  Time txAccessStart = m_lastTxStart + m_lastTxDuration + m_sifs;
529  Time navAccessStart = m_lastNavStart + m_lastNavDuration + m_sifs;
530  Time ackTimeoutAccessStart = m_lastAckTimeoutEnd + m_sifs;
531  Time ctsTimeoutAccessStart = m_lastCtsTimeoutEnd + m_sifs;
532  Time switchingAccessStart = m_lastSwitchingStart + m_lastSwitchingDuration + m_sifs;
533  Time accessGrantedStart = MostRecent (rxAccessStart,
534  busyAccessStart,
535  txAccessStart,
536  navAccessStart,
537  ackTimeoutAccessStart,
538  ctsTimeoutAccessStart,
539  switchingAccessStart
540  );
541  NS_LOG_INFO ("access grant start=" << accessGrantedStart <<
542  ", rx access start=" << rxAccessStart <<
543  ", busy access start=" << busyAccessStart <<
544  ", tx access start=" << txAccessStart <<
545  ", nav access start=" << navAccessStart);
546  return accessGrantedStart;
547 }
548 
549 Time
551 {
552  NS_LOG_FUNCTION (this << state);
553  Time mostRecentEvent = MostRecent (state->GetBackoffStart (),
554  GetAccessGrantStart () + MicroSeconds (state->GetAifsn () * m_slotTimeUs));
555 
556  return mostRecentEvent;
557 }
558 
559 Time
561 {
562  return GetBackoffStartFor (state) + MicroSeconds (state->GetBackoffSlots () * m_slotTimeUs);
563 }
564 
565 void
567 {
568  NS_LOG_FUNCTION (this);
569  uint32_t k = 0;
570  for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++, k++)
571  {
572  DcfState *state = *i;
573 
574  Time backoffStart = GetBackoffStartFor (state);
575  if (backoffStart <= Simulator::Now ())
576  {
577  uint32_t nus = (Simulator::Now () - backoffStart).GetMicroSeconds ();
578  uint32_t nIntSlots = nus / m_slotTimeUs;
579  uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ());
580  MY_DEBUG ("dcf " << k << " dec backoff slots=" << n);
581  Time backoffUpdateBound = backoffStart + MicroSeconds (n * m_slotTimeUs);
582  state->UpdateBackoffSlotsNow (n, backoffUpdateBound);
583  }
584  }
585 }
586 
587 void
589 {
590  NS_LOG_FUNCTION (this);
595  bool accessTimeoutNeeded = false;
596  Time expectedBackoffEnd = Simulator::GetMaximumSimulationTime ();
597  for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++)
598  {
599  DcfState *state = *i;
600  if (state->IsAccessRequested ())
601  {
602  Time tmp = GetBackoffEndFor (state);
603  if (tmp > Simulator::Now ())
604  {
605  accessTimeoutNeeded = true;
606  expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
607  }
608  }
609  }
610  if (accessTimeoutNeeded)
611  {
612  MY_DEBUG ("expected backoff end=" << expectedBackoffEnd);
613  Time expectedBackoffDelay = expectedBackoffEnd - Simulator::Now ();
615  && Simulator::GetDelayLeft (m_accessTimeout) > expectedBackoffDelay)
616  {
618  }
619  if (m_accessTimeout.IsExpired ())
620  {
621  m_accessTimeout = Simulator::Schedule (expectedBackoffDelay,
623  }
624  }
625 }
626 
627 void
629 {
630  NS_LOG_FUNCTION (this << duration);
631  MY_DEBUG ("rx start for=" << duration);
632  UpdateBackoff ();
634  m_lastRxDuration = duration;
635  m_rxing = true;
636 }
637 void
639 {
640  NS_LOG_FUNCTION (this);
641  MY_DEBUG ("rx end ok");
643  m_lastRxReceivedOk = true;
644  m_rxing = false;
645 }
646 void
648 {
649  NS_LOG_FUNCTION (this);
650  MY_DEBUG ("rx end error");
652  m_lastRxReceivedOk = false;
653  m_rxing = false;
654 }
655 void
657 {
658  NS_LOG_FUNCTION (this << duration);
659  if (m_rxing)
660  {
661  //this may be caused only if PHY has started to receive a packet
662  //inside SIFS, so, we check that lastRxStart was maximum a SIFS
663  //ago
667  m_lastRxReceivedOk = true;
668  m_rxing = false;
669  }
670  MY_DEBUG ("tx start for " << duration);
671  UpdateBackoff ();
673  m_lastTxDuration = duration;
674 }
675 void
677 {
678  NS_LOG_FUNCTION (this << duration);
679  MY_DEBUG ("busy start for " << duration);
680  UpdateBackoff ();
682  m_lastBusyDuration = duration;
683 }
684 
685 
686 void
688 {
689  NS_LOG_FUNCTION (this << duration);
690  Time now = Simulator::Now ();
693 
694  if (m_rxing)
695  {
696  // channel switching during packet reception
699  m_lastRxReceivedOk = true;
700  m_rxing = false;
701  }
702  if (m_lastNavStart + m_lastNavDuration > now)
703  {
705  }
707  {
709  }
710  if (m_lastAckTimeoutEnd > now)
711  {
712  m_lastAckTimeoutEnd = now;
713  }
714  if (m_lastCtsTimeoutEnd > now)
715  {
716  m_lastCtsTimeoutEnd = now;
717  }
718 
719  // Cancel timeout
720  if (m_accessTimeout.IsRunning ())
721  {
723  }
724 
725  // Reset backoffs
726  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
727  {
728  DcfState *state = *i;
729  uint32_t remainingSlots = state->GetBackoffSlots ();
730  if (remainingSlots > 0)
731  {
732  state->UpdateBackoffSlotsNow (remainingSlots, now);
733  NS_ASSERT (state->GetBackoffSlots () == 0);
734  }
735  state->ResetCw ();
736  state->m_accessRequested = false;
737  state->NotifyChannelSwitching ();
738  }
739 
740  MY_DEBUG ("switching start for " << duration);
742  m_lastSwitchingDuration = duration;
743 
744 }
745 
746 void
748 {
749  NS_LOG_FUNCTION (this << duration);
750  MY_DEBUG ("nav reset for=" << duration);
751  UpdateBackoff ();
753  m_lastNavDuration = duration;
754  UpdateBackoff ();
762 }
763 void
765 {
766  NS_LOG_FUNCTION (this << duration);
768  MY_DEBUG ("nav start for=" << duration);
769  UpdateBackoff ();
770  Time newNavEnd = Simulator::Now () + duration;
771  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
772  if (newNavEnd > lastNavEnd)
773  {
775  m_lastNavDuration = duration;
776  }
777 }
778 void
780 {
781  NS_LOG_FUNCTION (this << duration);
783  m_lastAckTimeoutEnd = Simulator::Now () + duration;
784 }
785 void
787 {
788  NS_LOG_FUNCTION (this);
791 }
792 void
794 {
795  NS_LOG_FUNCTION (this << duration);
796  m_lastCtsTimeoutEnd = Simulator::Now () + duration;
797 }
798 void
800 {
801  NS_LOG_FUNCTION (this);
804 }
805 } // namespace ns3
uint32_t m_cwMin
Definition: dcf-manager.h:208
ns3::DcfManager * m_dcf
DcfManager to forward events to.
Definition: dcf-manager.cc:255
static Time GetDelayLeft(const EventId &id)
Definition: simulator.cc:189
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
ns3::DcfManager * m_dcf
DcfManager to forward events to.
Definition: dcf-manager.cc:209
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
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:481
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:423
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:306
#define NS_ASSERT(condition)
Definition: assert.h:64
Time m_lastAckTimeoutEnd
Definition: dcf-manager.h:475
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:566
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.
Time m_lastCtsTimeoutEnd
Definition: dcf-manager.h:476
#define NS_LOG_INFO(msg)
Definition: log.h:298
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:824
Time m_lastSwitchingDuration
Definition: dcf-manager.h:488
PhyListener(ns3::DcfManager *dcf)
Create a PhyListener for the given DcfManager.
Definition: dcf-manager.cc:223
void Add(DcfState *dcf)
Definition: dcf-manager.cc:343
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:447
void NotifyNavResetNow(Time duration)
Definition: dcf-manager.cc:747
Time GetBackoffStartFor(DcfState *state)
Return the time when the backoff procedure started for the given DcfState.
Definition: dcf-manager.cc:550
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Definition: dcf-manager.cc:793
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Definition: dcf-manager.cc:638
uint32_t m_backoffSlots
Definition: dcf-manager.h:203
PhyListener * m_phyListener
Definition: dcf-manager.h:494
int64_t GetMicroSeconds(void) const
Definition: nstime.h:291
Time GetAccessGrantStart(void) const
Access will never be granted to the medium before the time returned by this method.
Definition: dcf-manager.cc:511
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:560
void NotifyTxStartNow(Time duration)
Definition: dcf-manager.cc:656
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
Definition: dcf-manager.cc:779
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:295
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:229
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
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Definition: int64x64.h:95
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:486
void SetCwMin(uint32_t minCw)
Set the minimum congestion window size.
Definition: dcf-manager.cc:62
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:647
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:487
void SetEifsNoDifs(Time eifsNoDifs)
Definition: dcf-manager.cc:330
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:676
void AccessTimeout(void)
Called when access timeout should occur (e.g.
Definition: dcf-manager.cc:502
virtual void DoNotifyChannelSwitching()=0
Called by DcfManager to notify a DcfState subclass that a channel switching occured.
Time m_lastNavDuration
Definition: dcf-manager.h:478
void SetSlot(Time slotTime)
Definition: dcf-manager.cc:318
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:786
LowDcfListener * m_lowListener
Definition: dcf-manager.h:495
void NotifyNavStartNow(Time duration)
Definition: dcf-manager.cc:764
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:628
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
Definition: dcf-manager.cc:101
virtual ~PhyListener()
Definition: dcf-manager.cc:227
Time GetEifsNoDifs() const
Definition: dcf-manager.cc:336
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 NotifyCtsTimeoutResetNow()
Notify that CTS timer has resetted.
Definition: dcf-manager.cc:799
void NotifyCollision(void)
Notify that collision has occurred.
Definition: dcf-manager.cc:150
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV busy.
Definition: dcf-manager.cc:399
Time m_backoffStart
Definition: dcf-manager.h:207
NS_LOG_COMPONENT_DEFINE("DcfManager")
void DoRestartAccessTimeoutIfNeeded(void)
Definition: dcf-manager.cc:588
EventId m_accessTimeout
Definition: dcf-manager.h:491
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:687
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:492
Time MostRecent(Time a, Time b) const
Return the most recent time.
Definition: dcf-manager.cc:350
void SetSifs(Time sifs)
Definition: dcf-manager.cc:324
virtual void NotifyTxStart(Time duration)
Definition: dcf-manager.cc:242
virtual void AckTimeoutReset()
Notify that ACK timeout has resetted.
Definition: dcf-manager.cc:196