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 
26 #include "dcf-manager.h"
27 #include "wifi-phy.h"
28 #include "wifi-mac.h"
29 #include "mac-low.h"
30 
31 #define MY_DEBUG(x) \
32  NS_LOG_DEBUG (Simulator::Now () << " " << this << " " << x)
33 
34 namespace ns3 {
35 
36 NS_LOG_COMPONENT_DEFINE ("DcfManager");
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 void
166 {
167  DoNotifySleep ();
168 }
169 void
171 {
172  DoNotifyWakeUp ();
173 }
174 
175 
180 {
181 public:
188  : m_dcf (dcf)
189  {
190  }
191  virtual ~LowDcfListener ()
192  {
193  }
194  virtual void NavStart (Time duration)
195  {
196  m_dcf->NotifyNavStartNow (duration);
197  }
198  virtual void NavReset (Time duration)
199  {
200  m_dcf->NotifyNavResetNow (duration);
201  }
202  virtual void AckTimeoutStart (Time duration)
203  {
204  m_dcf->NotifyAckTimeoutStartNow (duration);
205  }
206  virtual void AckTimeoutReset ()
207  {
209  }
210  virtual void CtsTimeoutStart (Time duration)
211  {
212  m_dcf->NotifyCtsTimeoutStartNow (duration);
213  }
214  virtual void CtsTimeoutReset ()
215  {
217  }
218 private:
220 };
221 
226 {
227 public:
234  : m_dcf (dcf)
235  {
236  }
237  virtual ~PhyListener ()
238  {
239  }
240  virtual void NotifyRxStart (Time duration)
241  {
242  m_dcf->NotifyRxStartNow (duration);
243  }
244  virtual void NotifyRxEndOk (void)
245  {
247  }
248  virtual void NotifyRxEndError (void)
249  {
251  }
252  virtual void NotifyTxStart (Time duration, double txPowerDbm)
253  {
254  m_dcf->NotifyTxStartNow (duration);
255  }
256  virtual void NotifyMaybeCcaBusyStart (Time duration)
257  {
258  m_dcf->NotifyMaybeCcaBusyStartNow (duration);
259  }
260  virtual void NotifySwitchingStart (Time duration)
261  {
262  m_dcf->NotifySwitchingStartNow (duration);
263  }
264  virtual void NotifySleep (void)
265  {
266  m_dcf->NotifySleepNow ();
267  }
268  virtual void NotifyWakeup (void)
269  {
271  }
272 private:
274 };
275 
276 /****************************************************************
277  * Implement the DCF manager of all DCF state holders
278  ****************************************************************/
279 
281  : m_lastAckTimeoutEnd (MicroSeconds (0)),
282  m_lastCtsTimeoutEnd (MicroSeconds (0)),
283  m_lastNavStart (MicroSeconds (0)),
284  m_lastNavDuration (MicroSeconds (0)),
285  m_lastRxStart (MicroSeconds (0)),
286  m_lastRxDuration (MicroSeconds (0)),
287  m_lastRxReceivedOk (true),
288  m_lastRxEnd (MicroSeconds (0)),
289  m_lastTxStart (MicroSeconds (0)),
290  m_lastTxDuration (MicroSeconds (0)),
291  m_lastBusyStart (MicroSeconds (0)),
292  m_lastBusyDuration (MicroSeconds (0)),
293  m_lastSwitchingStart (MicroSeconds (0)),
294  m_lastSwitchingDuration (MicroSeconds (0)),
295  m_rxing (false),
296  m_sleeping (false),
297  m_slotTimeUs (0),
298  m_sifs (Seconds (0.0)),
299  m_phyListener (0),
300  m_lowListener (0)
301 {
302  NS_LOG_FUNCTION (this);
303 }
304 
306 {
307  delete m_phyListener;
308  delete m_lowListener;
309  m_phyListener = 0;
310  m_lowListener = 0;
311 }
312 
313 void
315 {
316  NS_LOG_FUNCTION (this << phy);
317  if (m_phyListener != 0)
318  {
319  delete m_phyListener;
320  }
321  m_phyListener = new PhyListener (this);
323 }
324 
325 void
327 {
328  NS_LOG_FUNCTION (this << phy);
329  if (m_phyListener != 0)
330  {
332  delete m_phyListener;
333  m_phyListener = 0;
334  }
335 }
336 
337 void
339 {
340  NS_LOG_FUNCTION (this << low);
341  if (m_lowListener != 0)
342  {
343  delete m_lowListener;
344  }
345  m_lowListener = new LowDcfListener (this);
346  low->RegisterDcfListener (m_lowListener);
347 }
348 
349 void
351 {
352  NS_LOG_FUNCTION (this << slotTime);
353  m_slotTimeUs = slotTime.GetMicroSeconds ();
354 }
355 void
357 {
358  NS_LOG_FUNCTION (this << sifs);
359  m_sifs = sifs;
360 }
361 void
363 {
364  NS_LOG_FUNCTION (this << eifsNoDifs);
365  m_eifsNoDifs = eifsNoDifs;
366 }
367 Time
369 {
370  NS_LOG_FUNCTION (this);
371  return m_eifsNoDifs;
372 }
373 
374 void
376 {
377  NS_LOG_FUNCTION (this << dcf);
378  m_states.push_back (dcf);
379 }
380 
381 Time
383 {
384  NS_LOG_FUNCTION (this << a << b);
385  return Max (a, b);
386 }
387 Time
389 {
390  NS_LOG_FUNCTION (this << a << b << c);
391  Time retval;
392  retval = Max (a, b);
393  retval = Max (retval, c);
394  return retval;
395 }
396 Time
398 {
399  NS_LOG_FUNCTION (this << a << b << c << d);
400  Time e = Max (a, b);
401  Time f = Max (c, d);
402  Time retval = Max (e, f);
403  return retval;
404 }
405 Time
407 {
408  NS_LOG_FUNCTION (this << a << b << c << d << e << f);
409  Time g = Max (a, b);
410  Time h = Max (c, d);
411  Time i = Max (e, f);
412  Time k = Max (g, h);
413  Time retval = Max (k, i);
414  return retval;
415 }
416 
417 Time
418 DcfManager::MostRecent (Time a, Time b, Time c, Time d, Time e, Time f, Time g) const
419 {
420  NS_LOG_FUNCTION (this << a << b << c << d << e << f << g);
421  Time h = Max (a, b);
422  Time i = Max (c, d);
423  Time j = Max (e, f);
424  Time k = Max (h, i);
425  Time l = Max (j, g);
426  Time retval = Max (k, l);
427  return retval;
428 }
429 
430 bool
431 DcfManager::IsBusy (void) const
432 {
433  NS_LOG_FUNCTION (this);
434  // PHY busy
435  if (m_rxing)
436  {
437  return true;
438  }
439  Time lastTxEnd = m_lastTxStart + m_lastTxDuration;
440  if (lastTxEnd > Simulator::Now ())
441  {
442  return true;
443  }
444  // NAV busy
445  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
446  if (lastNavEnd > Simulator::Now ())
447  {
448  return true;
449  }
450  return false;
451 }
452 
453 
454 void
456 {
457  NS_LOG_FUNCTION (this << state);
458  // Deny access if in sleep mode
459  if (m_sleeping)
460  return;
461  UpdateBackoff ();
462  NS_ASSERT (!state->IsAccessRequested ());
463  state->NotifyAccessRequested ();
468  if (state->GetBackoffSlots () == 0
469  && IsBusy ())
470  {
471  MY_DEBUG ("medium is busy: collision");
472  /* someone else has accessed the medium.
473  * generate a backoff.
474  */
475  state->NotifyCollision ();
476  }
477  DoGrantAccess ();
479 }
480 
481 void
483 {
484  NS_LOG_FUNCTION (this);
485  uint32_t k = 0;
486  for (States::const_iterator i = m_states.begin (); i != m_states.end (); k++)
487  {
488  DcfState *state = *i;
489  if (state->IsAccessRequested ()
490  && GetBackoffEndFor (state) <= Simulator::Now () )
491  {
496  MY_DEBUG ("dcf " << k << " needs access. backoff expired. access granted. slots=" << state->GetBackoffSlots ());
497  i++; // go to the next item in the list.
498  k++;
499  std::vector<DcfState *> internalCollisionStates;
500  for (States::const_iterator j = i; j != m_states.end (); j++, k++)
501  {
502  DcfState *otherState = *j;
503  if (otherState->IsAccessRequested ()
504  && GetBackoffEndFor (otherState) <= Simulator::Now ())
505  {
506  MY_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision. slots=" <<
507  otherState->GetBackoffSlots ());
513  internalCollisionStates.push_back (otherState);
514  }
515  }
516 
524  state->NotifyAccessGranted ();
525  for (std::vector<DcfState *>::const_iterator k = internalCollisionStates.begin ();
526  k != internalCollisionStates.end (); k++)
527  {
528  (*k)->NotifyInternalCollision ();
529  }
530  break;
531  }
532  i++;
533  }
534 }
535 
536 void
538 {
539  NS_LOG_FUNCTION (this);
540  UpdateBackoff ();
541  DoGrantAccess ();
543 }
544 
545 Time
547 {
548  NS_LOG_FUNCTION (this);
549  Time rxAccessStart;
550  if (!m_rxing)
551  {
552  rxAccessStart = m_lastRxEnd + m_sifs;
553  if (!m_lastRxReceivedOk)
554  {
555  rxAccessStart += m_eifsNoDifs;
556  }
557  }
558  else
559  {
560  rxAccessStart = m_lastRxStart + m_lastRxDuration + m_sifs;
561  }
562  Time busyAccessStart = m_lastBusyStart + m_lastBusyDuration + m_sifs;
563  Time txAccessStart = m_lastTxStart + m_lastTxDuration + m_sifs;
564  Time navAccessStart = m_lastNavStart + m_lastNavDuration + m_sifs;
565  Time ackTimeoutAccessStart = m_lastAckTimeoutEnd + m_sifs;
566  Time ctsTimeoutAccessStart = m_lastCtsTimeoutEnd + m_sifs;
567  Time switchingAccessStart = m_lastSwitchingStart + m_lastSwitchingDuration + m_sifs;
568  Time accessGrantedStart = MostRecent (rxAccessStart,
569  busyAccessStart,
570  txAccessStart,
571  navAccessStart,
572  ackTimeoutAccessStart,
573  ctsTimeoutAccessStart,
574  switchingAccessStart
575  );
576  NS_LOG_INFO ("access grant start=" << accessGrantedStart <<
577  ", rx access start=" << rxAccessStart <<
578  ", busy access start=" << busyAccessStart <<
579  ", tx access start=" << txAccessStart <<
580  ", nav access start=" << navAccessStart);
581  return accessGrantedStart;
582 }
583 
584 Time
586 {
587  NS_LOG_FUNCTION (this << state);
588  Time mostRecentEvent = MostRecent (state->GetBackoffStart (),
590 
591  return mostRecentEvent;
592 }
593 
594 Time
596 {
597  return GetBackoffStartFor (state) + MicroSeconds (state->GetBackoffSlots () * m_slotTimeUs);
598 }
599 
600 void
602 {
603  NS_LOG_FUNCTION (this);
604  uint32_t k = 0;
605  for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++, k++)
606  {
607  DcfState *state = *i;
608 
609  Time backoffStart = GetBackoffStartFor (state);
610  if (backoffStart <= Simulator::Now ())
611  {
612  uint32_t nus = (Simulator::Now () - backoffStart).GetMicroSeconds ();
613  uint32_t nIntSlots = nus / m_slotTimeUs;
614  uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ());
615  MY_DEBUG ("dcf " << k << " dec backoff slots=" << n);
616  Time backoffUpdateBound = backoffStart + MicroSeconds (n * m_slotTimeUs);
617  state->UpdateBackoffSlotsNow (n, backoffUpdateBound);
618  }
619  }
620 }
621 
622 void
624 {
625  NS_LOG_FUNCTION (this);
630  bool accessTimeoutNeeded = false;
631  Time expectedBackoffEnd = Simulator::GetMaximumSimulationTime ();
632  for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++)
633  {
634  DcfState *state = *i;
635  if (state->IsAccessRequested ())
636  {
637  Time tmp = GetBackoffEndFor (state);
638  if (tmp > Simulator::Now ())
639  {
640  accessTimeoutNeeded = true;
641  expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
642  }
643  }
644  }
645  if (accessTimeoutNeeded)
646  {
647  MY_DEBUG ("expected backoff end=" << expectedBackoffEnd);
648  Time expectedBackoffDelay = expectedBackoffEnd - Simulator::Now ();
650  && Simulator::GetDelayLeft (m_accessTimeout) > expectedBackoffDelay)
651  {
653  }
654  if (m_accessTimeout.IsExpired ())
655  {
656  m_accessTimeout = Simulator::Schedule (expectedBackoffDelay,
658  }
659  }
660 }
661 
662 void
664 {
665  NS_LOG_FUNCTION (this << duration);
666  MY_DEBUG ("rx start for=" << duration);
667  UpdateBackoff ();
669  m_lastRxDuration = duration;
670  m_rxing = true;
671 }
672 void
674 {
675  NS_LOG_FUNCTION (this);
676  MY_DEBUG ("rx end ok");
678  m_lastRxReceivedOk = true;
679  m_rxing = false;
680 }
681 void
683 {
684  NS_LOG_FUNCTION (this);
685  MY_DEBUG ("rx end error");
687  m_lastRxReceivedOk = false;
688  m_rxing = false;
689 }
690 void
692 {
693  NS_LOG_FUNCTION (this << duration);
694  if (m_rxing)
695  {
696  //this may be caused only if PHY has started to receive a packet
697  //inside SIFS, so, we check that lastRxStart was maximum a SIFS
698  //ago
702  m_lastRxReceivedOk = true;
703  m_rxing = false;
704  }
705  MY_DEBUG ("tx start for " << duration);
706  UpdateBackoff ();
708  m_lastTxDuration = duration;
709 }
710 void
712 {
713  NS_LOG_FUNCTION (this << duration);
714  MY_DEBUG ("busy start for " << duration);
715  UpdateBackoff ();
717  m_lastBusyDuration = duration;
718 }
719 
720 
721 void
723 {
724  NS_LOG_FUNCTION (this << duration);
725  Time now = Simulator::Now ();
728 
729  if (m_rxing)
730  {
731  // channel switching during packet reception
734  m_lastRxReceivedOk = true;
735  m_rxing = false;
736  }
737  if (m_lastNavStart + m_lastNavDuration > now)
738  {
740  }
742  {
744  }
745  if (m_lastAckTimeoutEnd > now)
746  {
747  m_lastAckTimeoutEnd = now;
748  }
749  if (m_lastCtsTimeoutEnd > now)
750  {
751  m_lastCtsTimeoutEnd = now;
752  }
753 
754  // Cancel timeout
755  if (m_accessTimeout.IsRunning ())
756  {
758  }
759 
760  // Reset backoffs
761  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
762  {
763  DcfState *state = *i;
764  uint32_t remainingSlots = state->GetBackoffSlots ();
765  if (remainingSlots > 0)
766  {
767  state->UpdateBackoffSlotsNow (remainingSlots, now);
768  NS_ASSERT (state->GetBackoffSlots () == 0);
769  }
770  state->ResetCw ();
771  state->m_accessRequested = false;
772  state->NotifyChannelSwitching ();
773  }
774 
775  MY_DEBUG ("switching start for " << duration);
777  m_lastSwitchingDuration = duration;
778 
779 }
780 
781 void
783 {
784  NS_LOG_FUNCTION (this);
785  m_sleeping = true;
786  // Cancel timeout
787  if (m_accessTimeout.IsRunning ())
788  {
790  }
791 
792  // Reset backoffs
793  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
794  {
795  DcfState *state = *i;
796  state->NotifySleep ();
797  }
798 }
799 
800 void
802 {
803  NS_LOG_FUNCTION (this);
804  m_sleeping = false;
805  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
806  {
807  DcfState *state = *i;
808  uint32_t remainingSlots = state->GetBackoffSlots ();
809  if (remainingSlots > 0)
810  {
811  state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ());
812  NS_ASSERT (state->GetBackoffSlots () == 0);
813  }
814  state->ResetCw ();
815  state->m_accessRequested = false;
816  state->NotifyWakeUp ();
817  }
818 }
819 
820 void
822 {
823  NS_LOG_FUNCTION (this << duration);
824  MY_DEBUG ("nav reset for=" << duration);
825  UpdateBackoff ();
827  m_lastNavDuration = duration;
828  UpdateBackoff ();
836 }
837 void
839 {
840  NS_LOG_FUNCTION (this << duration);
842  MY_DEBUG ("nav start for=" << duration);
843  UpdateBackoff ();
844  Time newNavEnd = Simulator::Now () + duration;
845  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
846  if (newNavEnd > lastNavEnd)
847  {
849  m_lastNavDuration = duration;
850  }
851 }
852 void
854 {
855  NS_LOG_FUNCTION (this << duration);
857  m_lastAckTimeoutEnd = Simulator::Now () + duration;
858 }
859 void
861 {
862  NS_LOG_FUNCTION (this);
865 }
866 void
868 {
869  NS_LOG_FUNCTION (this << duration);
870  m_lastCtsTimeoutEnd = Simulator::Now () + duration;
871 }
872 void
874 {
875  NS_LOG_FUNCTION (this);
878 }
879 } // namespace ns3
uint32_t m_cwMin
Definition: dcf-manager.h:231
ns3::DcfManager * m_dcf
DcfManager to forward events to.
Definition: dcf-manager.cc:273
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:801
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
void NotifySleep(void)
Notify that the device has started to sleep.
Definition: dcf-manager.cc:165
ns3::DcfManager * m_dcf
DcfManager to forward events to.
Definition: dcf-manager.cc:219
#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:198
void NotifyInternalCollision(void)
Notify that internal collision has occurred.
Definition: dcf-manager.cc:155
bool m_lastRxReceivedOk
Definition: dcf-manager.h:518
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:240
void NotifyAccessGranted(void)
Notify that access has been granted.
Definition: dcf-manager.cc:143
void RequestAccess(DcfState *state)
Definition: dcf-manager.cc:455
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:338
#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:512
#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:170
virtual void NotifySwitchingStart(Time duration)
Definition: dcf-manager.cc:260
LowDcfListener(ns3::DcfManager *dcf)
Create a LowDcfListener for the given DcfManager.
Definition: dcf-manager.cc:187
void UpdateBackoff(void)
Update backoff slots for all DcfStates.
Definition: dcf-manager.cc:601
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:268
Time m_lastCtsTimeoutEnd
Definition: dcf-manager.h:513
#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:234
void SetAifsn(uint32_t aifsn)
Definition: dcf-manager.cc:57
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: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:819
Time m_lastSwitchingDuration
Definition: dcf-manager.h:525
PhyListener(ns3::DcfManager *dcf)
Create a PhyListener for the given DcfManager.
Definition: dcf-manager.cc:233
void Add(DcfState *dcf)
Definition: dcf-manager.cc:375
virtual void NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
Definition: dcf-manager.cc:244
virtual void RegisterListener(WifiPhyListener *listener)=0
void DoGrantAccess(void)
Grant access to DCF.
Definition: dcf-manager.cc:482
void NotifyNavResetNow(Time duration)
Definition: dcf-manager.cc:821
Time GetBackoffStartFor(DcfState *state)
Return the time when the backoff procedure started for the given DcfState.
Definition: dcf-manager.cc:585
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Definition: dcf-manager.cc:867
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Definition: dcf-manager.cc:673
uint32_t m_backoffSlots
Definition: dcf-manager.h:226
PhyListener * m_phyListener
Definition: dcf-manager.h:532
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:335
Time GetAccessGrantStart(void) const
Access will never be granted to the medium before the time returned by this method.
Definition: dcf-manager.cc:546
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:595
void NotifyTxStartNow(Time duration)
Definition: dcf-manager.cc:691
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for Phy events.
Definition: dcf-manager.cc:326
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
Definition: dcf-manager.cc:853
virtual void NavStart(Time duration)
Norify that NAV has started for the given duration.
Definition: dcf-manager.cc:194
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for Phy events.
Definition: dcf-manager.cc:314
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:252
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:203
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:202
virtual void CtsTimeoutReset()
Notify that CTS timeout has resetted.
Definition: dcf-manager.cc:214
bool IsAccessRequested(void) const
Definition: dcf-manager.cc:133
Listener for PHY events.
Definition: dcf-manager.cc:225
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:31
uint32_t GetCwMax(void) const
Return the maximum congestion window size.
Definition: dcf-manager.cc:84
Time m_lastBusyDuration
Definition: dcf-manager.h:523
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:264
void StartBackoffNow(uint32_t nSlots)
Definition: dcf-manager.cc:109
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:256
uint32_t m_cwMax
Definition: dcf-manager.h:232
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:138
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully.
Definition: dcf-manager.cc:682
virtual void CtsTimeoutStart(Time duration)
Notify that CTS timeout has started for a given duration.
Definition: dcf-manager.cc:210
uint32_t m_cw
Definition: dcf-manager.h:233
Time m_lastSwitchingStart
Definition: dcf-manager.h:524
void SetEifsNoDifs(Time eifsNoDifs)
Definition: dcf-manager.cc:362
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:148
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
void NotifyMaybeCcaBusyStartNow(Time duration)
Definition: dcf-manager.cc:711
void AccessTimeout(void)
Called when access timeout should occur (e.g.
Definition: dcf-manager.cc:537
Time m_lastNavDuration
Definition: dcf-manager.h:515
void SetSlot(Time slotTime)
Definition: dcf-manager.cc:350
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:860
LowDcfListener * m_lowListener
Definition: dcf-manager.h:533
void NotifyNavStartNow(Time duration)
Definition: dcf-manager.cc:838
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:225
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:663
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:101
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:859
virtual ~PhyListener()
Definition: dcf-manager.cc:237
Time GetEifsNoDifs() const
Definition: dcf-manager.cc:368
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:248
void NotifySleepNow(void)
Notify the DCF that the device has been put in sleep mode.
Definition: dcf-manager.cc:782
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has resetted.
Definition: dcf-manager.cc:873
void NotifyCollision(void)
Notify that collision has occurred.
Definition: dcf-manager.cc:150
virtual void NotifyTxStart(Time duration, double txPowerDbm)
Definition: dcf-manager.cc:252
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV busy.
Definition: dcf-manager.cc:431
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:875
Time m_backoffStart
Definition: dcf-manager.h:230
void DoRestartAccessTimeoutIfNeeded(void)
Definition: dcf-manager.cc:623
EventId m_accessTimeout
Definition: dcf-manager.h:529
virtual ~LowDcfListener()
Definition: dcf-manager.cc:191
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:179
void NotifySwitchingStartNow(Time duration)
Definition: dcf-manager.cc:722
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
Definition: simulator.cc:336
uint32_t m_slotTimeUs
Definition: dcf-manager.h:530
Time MostRecent(Time a, Time b) const
Return the most recent time.
Definition: dcf-manager.cc:382
void SetSifs(Time sifs)
Definition: dcf-manager.cc:356
virtual void AckTimeoutReset()
Notify that ACK timeout has resetted.
Definition: dcf-manager.cc:206