This documentation is not the Latest Release.
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  m_cwMin = minCw;
65  ResetCw ();
66 }
67 
68 void
69 DcfState::SetCwMax (uint32_t maxCw)
70 {
71  m_cwMax = maxCw;
72  ResetCw ();
73 }
74 
75 uint32_t
76 DcfState::GetAifsn (void) const
77 {
78  return m_aifsn;
79 }
80 
81 uint32_t
82 DcfState::GetCwMin (void) const
83 {
84  return m_cwMin;
85 }
86 
87 uint32_t
88 DcfState::GetCwMax (void) const
89 {
90  return m_cwMax;
91 }
92 
93 void
95 {
96  m_cw = m_cwMin;
97 }
98 
99 void
101 {
102  //see 802.11-2012, section 9.19.2.5
103  m_cw = std::min ( 2 * (m_cw + 1) - 1, m_cwMax);
104 }
105 
106 void
107 DcfState::UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound)
108 {
109  m_backoffSlots -= nSlots;
110  m_backoffStart = backoffUpdateBound;
111  MY_DEBUG ("update slots=" << nSlots << " slots, backoff=" << m_backoffSlots);
112 }
113 
114 void
115 DcfState::StartBackoffNow (uint32_t nSlots)
116 {
117  NS_ASSERT (m_backoffSlots == 0);
118  MY_DEBUG ("start backoff=" << nSlots << " slots");
119  m_backoffSlots = nSlots;
121 }
122 
123 uint32_t
124 DcfState::GetCw (void) const
125 {
126  return m_cw;
127 }
128 
129 uint32_t
131 {
132  return m_backoffSlots;
133 }
134 
135 Time
137 {
138  return m_backoffStart;
139 }
140 
141 bool
143 {
144  return m_accessRequested;
145 }
146 void
148 {
149  m_accessRequested = true;
150 }
151 
152 void
154 {
156  m_accessRequested = false;
158 }
159 
160 void
162 {
164 }
165 
166 void
168 {
170 }
171 
172 void
174 {
176 }
177 
178 void
180 {
181  DoNotifySleep ();
182 }
183 
184 void
186 {
187  DoNotifyWakeUp ();
188 }
189 
190 
195 {
196 public:
203  : m_dcf (dcf)
204  {
205  }
206  virtual ~LowDcfListener ()
207  {
208  }
209  virtual void NavStart (Time duration)
210  {
211  m_dcf->NotifyNavStartNow (duration);
212  }
213  virtual void NavReset (Time duration)
214  {
215  m_dcf->NotifyNavResetNow (duration);
216  }
217  virtual void AckTimeoutStart (Time duration)
218  {
219  m_dcf->NotifyAckTimeoutStartNow (duration);
220  }
221  virtual void AckTimeoutReset ()
222  {
224  }
225  virtual void CtsTimeoutStart (Time duration)
226  {
227  m_dcf->NotifyCtsTimeoutStartNow (duration);
228  }
229  virtual void CtsTimeoutReset ()
230  {
232  }
233 
234 private:
236 };
237 
238 
243 {
244 public:
251  : m_dcf (dcf)
252  {
253  }
254  virtual ~PhyListener ()
255  {
256  }
257  virtual void NotifyRxStart (Time duration)
258  {
259  m_dcf->NotifyRxStartNow (duration);
260  }
261  virtual void NotifyRxEndOk (void)
262  {
264  }
265  virtual void NotifyRxEndError (void)
266  {
268  }
269  virtual void NotifyTxStart (Time duration, double txPowerDbm)
270  {
271  m_dcf->NotifyTxStartNow (duration);
272  }
273  virtual void NotifyMaybeCcaBusyStart (Time duration)
274  {
275  m_dcf->NotifyMaybeCcaBusyStartNow (duration);
276  }
277  virtual void NotifySwitchingStart (Time duration)
278  {
279  m_dcf->NotifySwitchingStartNow (duration);
280  }
281  virtual void NotifySleep (void)
282  {
283  m_dcf->NotifySleepNow ();
284  }
285  virtual void NotifyWakeup (void)
286  {
288  }
289 
290 private:
292 };
293 
294 
295 /****************************************************************
296  * Implement the DCF manager of all DCF state holders
297  ****************************************************************/
298 
300  : m_lastAckTimeoutEnd (MicroSeconds (0)),
301  m_lastCtsTimeoutEnd (MicroSeconds (0)),
302  m_lastNavStart (MicroSeconds (0)),
303  m_lastNavDuration (MicroSeconds (0)),
304  m_lastRxStart (MicroSeconds (0)),
305  m_lastRxDuration (MicroSeconds (0)),
306  m_lastRxReceivedOk (true),
307  m_lastRxEnd (MicroSeconds (0)),
308  m_lastTxStart (MicroSeconds (0)),
309  m_lastTxDuration (MicroSeconds (0)),
310  m_lastBusyStart (MicroSeconds (0)),
311  m_lastBusyDuration (MicroSeconds (0)),
312  m_lastSwitchingStart (MicroSeconds (0)),
313  m_lastSwitchingDuration (MicroSeconds (0)),
314  m_rxing (false),
315  m_sleeping (false),
316  m_slotTimeUs (0),
317  m_sifs (Seconds (0.0)),
318  m_phyListener (0),
319  m_lowListener (0)
320 {
321  NS_LOG_FUNCTION (this);
322 }
323 
325 {
326  delete m_phyListener;
327  delete m_lowListener;
328  m_phyListener = 0;
329  m_lowListener = 0;
330 }
331 
332 void
334 {
335  NS_LOG_FUNCTION (this << phy);
336  if (m_phyListener != 0)
337  {
338  delete m_phyListener;
339  }
340  m_phyListener = new PhyListener (this);
342 }
343 
344 void
346 {
347  NS_LOG_FUNCTION (this << phy);
348  if (m_phyListener != 0)
349  {
351  delete m_phyListener;
352  m_phyListener = 0;
353  }
354 }
355 
356 void
358 {
359  NS_LOG_FUNCTION (this << low);
360  if (m_lowListener != 0)
361  {
362  delete m_lowListener;
363  }
364  m_lowListener = new LowDcfListener (this);
366 }
367 
368 void
370 {
371  NS_LOG_FUNCTION (this << slotTime);
372  m_slotTimeUs = slotTime.GetMicroSeconds ();
373 }
374 
375 void
377 {
378  NS_LOG_FUNCTION (this << sifs);
379  m_sifs = sifs;
380 }
381 
382 void
384 {
385  NS_LOG_FUNCTION (this << eifsNoDifs);
386  m_eifsNoDifs = eifsNoDifs;
387 }
388 
389 Time
391 {
392  NS_LOG_FUNCTION (this);
393  return m_eifsNoDifs;
394 }
395 
396 void
398 {
399  NS_LOG_FUNCTION (this << dcf);
400  m_states.push_back (dcf);
401 }
402 
403 Time
405 {
406  NS_LOG_FUNCTION (this << a << b);
407  return Max (a, b);
408 }
409 
410 Time
412 {
413  NS_LOG_FUNCTION (this << a << b << c);
414  Time retval;
415  retval = Max (a, b);
416  retval = Max (retval, c);
417  return retval;
418 }
419 
420 Time
422 {
423  NS_LOG_FUNCTION (this << a << b << c << d);
424  Time e = Max (a, b);
425  Time f = Max (c, d);
426  Time retval = Max (e, f);
427  return retval;
428 }
429 
430 Time
432 {
433  NS_LOG_FUNCTION (this << a << b << c << d << e << f);
434  Time g = Max (a, b);
435  Time h = Max (c, d);
436  Time i = Max (e, f);
437  Time k = Max (g, h);
438  Time retval = Max (k, i);
439  return retval;
440 }
441 
442 Time
443 DcfManager::MostRecent (Time a, Time b, Time c, Time d, Time e, Time f, Time g) const
444 {
445  NS_LOG_FUNCTION (this << a << b << c << d << e << f << g);
446  Time h = Max (a, b);
447  Time i = Max (c, d);
448  Time j = Max (e, f);
449  Time k = Max (h, i);
450  Time l = Max (j, g);
451  Time retval = Max (k, l);
452  return retval;
453 }
454 
455 bool
456 DcfManager::IsBusy (void) const
457 {
458  NS_LOG_FUNCTION (this);
459  // PHY busy
460  if (m_rxing)
461  {
462  return true;
463  }
464  Time lastTxEnd = m_lastTxStart + m_lastTxDuration;
465  if (lastTxEnd > Simulator::Now ())
466  {
467  return true;
468  }
469  // NAV busy
470  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
471  if (lastNavEnd > Simulator::Now ())
472  {
473  return true;
474  }
475  return false;
476 }
477 
478 void
480 {
481  NS_LOG_FUNCTION (this << state);
482  //Deny access if in sleep mode
483  if (m_sleeping)
484  {
485  return;
486  }
487  UpdateBackoff ();
488  NS_ASSERT (!state->IsAccessRequested ());
489  state->NotifyAccessRequested ();
494  if (state->GetBackoffSlots () == 0
495  && IsBusy ())
496  {
497  MY_DEBUG ("medium is busy: collision");
498  /* someone else has accessed the medium.
499  * generate a backoff.
500  */
501  state->NotifyCollision ();
502  }
503  DoGrantAccess ();
505 }
506 
507 void
509 {
510  NS_LOG_FUNCTION (this);
511  uint32_t k = 0;
512  for (States::const_iterator i = m_states.begin (); i != m_states.end (); k++)
513  {
514  DcfState *state = *i;
515  if (state->IsAccessRequested ()
516  && GetBackoffEndFor (state) <= Simulator::Now () )
517  {
522  MY_DEBUG ("dcf " << k << " needs access. backoff expired. access granted. slots=" << state->GetBackoffSlots ());
523  i++; //go to the next item in the list.
524  k++;
525  std::vector<DcfState *> internalCollisionStates;
526  for (States::const_iterator j = i; j != m_states.end (); j++, k++)
527  {
528  DcfState *otherState = *j;
529  if (otherState->IsAccessRequested ()
530  && GetBackoffEndFor (otherState) <= Simulator::Now ())
531  {
532  MY_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision. slots=" <<
533  otherState->GetBackoffSlots ());
539  internalCollisionStates.push_back (otherState);
540  }
541  }
542 
550  state->NotifyAccessGranted ();
551  for (std::vector<DcfState *>::const_iterator k = internalCollisionStates.begin ();
552  k != internalCollisionStates.end (); k++)
553  {
554  (*k)->NotifyInternalCollision ();
555  }
556  break;
557  }
558  i++;
559  }
560 }
561 
562 void
564 {
565  NS_LOG_FUNCTION (this);
566  UpdateBackoff ();
567  DoGrantAccess ();
569 }
570 
571 Time
573 {
574  NS_LOG_FUNCTION (this);
575  Time rxAccessStart;
576  if (!m_rxing)
577  {
578  rxAccessStart = m_lastRxEnd + m_sifs;
579  if (!m_lastRxReceivedOk)
580  {
581  rxAccessStart += m_eifsNoDifs;
582  }
583  }
584  else
585  {
586  rxAccessStart = m_lastRxStart + m_lastRxDuration + m_sifs;
587  }
588  Time busyAccessStart = m_lastBusyStart + m_lastBusyDuration + m_sifs;
589  Time txAccessStart = m_lastTxStart + m_lastTxDuration + m_sifs;
590  Time navAccessStart = m_lastNavStart + m_lastNavDuration + m_sifs;
591  Time ackTimeoutAccessStart = m_lastAckTimeoutEnd + m_sifs;
592  Time ctsTimeoutAccessStart = m_lastCtsTimeoutEnd + m_sifs;
593  Time switchingAccessStart = m_lastSwitchingStart + m_lastSwitchingDuration + m_sifs;
594  Time accessGrantedStart = MostRecent (rxAccessStart,
595  busyAccessStart,
596  txAccessStart,
597  navAccessStart,
598  ackTimeoutAccessStart,
599  ctsTimeoutAccessStart,
600  switchingAccessStart
601  );
602  NS_LOG_INFO ("access grant start=" << accessGrantedStart <<
603  ", rx access start=" << rxAccessStart <<
604  ", busy access start=" << busyAccessStart <<
605  ", tx access start=" << txAccessStart <<
606  ", nav access start=" << navAccessStart);
607  return accessGrantedStart;
608 }
609 
610 Time
612 {
613  NS_LOG_FUNCTION (this << state);
614  Time mostRecentEvent = MostRecent (state->GetBackoffStart (),
616 
617  return mostRecentEvent;
618 }
619 
620 Time
622 {
623  return GetBackoffStartFor (state) + MicroSeconds (state->GetBackoffSlots () * m_slotTimeUs);
624 }
625 
626 void
628 {
629  NS_LOG_FUNCTION (this);
630  uint32_t k = 0;
631  for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++, k++)
632  {
633  DcfState *state = *i;
634 
635  Time backoffStart = GetBackoffStartFor (state);
636  if (backoffStart <= Simulator::Now ())
637  {
638  uint32_t nus = (Simulator::Now () - backoffStart).GetMicroSeconds ();
639  uint32_t nIntSlots = nus / m_slotTimeUs;
640  uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ());
641  MY_DEBUG ("dcf " << k << " dec backoff slots=" << n);
642  Time backoffUpdateBound = backoffStart + MicroSeconds (n * m_slotTimeUs);
643  state->UpdateBackoffSlotsNow (n, backoffUpdateBound);
644  }
645  }
646 }
647 
648 void
650 {
651  NS_LOG_FUNCTION (this);
656  bool accessTimeoutNeeded = false;
657  Time expectedBackoffEnd = Simulator::GetMaximumSimulationTime ();
658  for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++)
659  {
660  DcfState *state = *i;
661  if (state->IsAccessRequested ())
662  {
663  Time tmp = GetBackoffEndFor (state);
664  if (tmp > Simulator::Now ())
665  {
666  accessTimeoutNeeded = true;
667  expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
668  }
669  }
670  }
671  if (accessTimeoutNeeded)
672  {
673  MY_DEBUG ("expected backoff end=" << expectedBackoffEnd);
674  Time expectedBackoffDelay = expectedBackoffEnd - Simulator::Now ();
676  && Simulator::GetDelayLeft (m_accessTimeout) > expectedBackoffDelay)
677  {
679  }
680  if (m_accessTimeout.IsExpired ())
681  {
682  m_accessTimeout = Simulator::Schedule (expectedBackoffDelay,
684  }
685  }
686 }
687 
688 void
690 {
691  NS_LOG_FUNCTION (this << duration);
692  MY_DEBUG ("rx start for=" << duration);
693  UpdateBackoff ();
695  m_lastRxDuration = duration;
696  m_rxing = true;
697 }
698 
699 void
701 {
702  NS_LOG_FUNCTION (this);
703  MY_DEBUG ("rx end ok");
705  m_lastRxReceivedOk = true;
706  m_rxing = false;
707 }
708 
709 void
711 {
712  NS_LOG_FUNCTION (this);
713  MY_DEBUG ("rx end error");
715  m_lastRxReceivedOk = false;
716  m_rxing = false;
717 }
718 
719 void
721 {
722  NS_LOG_FUNCTION (this << duration);
723  if (m_rxing)
724  {
725  //this may be caused only if PHY has started to receive a packet
726  //inside SIFS, so, we check that lastRxStart was maximum a SIFS ago
730  m_lastRxReceivedOk = true;
731  m_rxing = false;
732  }
733  MY_DEBUG ("tx start for " << duration);
734  UpdateBackoff ();
736  m_lastTxDuration = duration;
737 }
738 
739 void
741 {
742  NS_LOG_FUNCTION (this << duration);
743  MY_DEBUG ("busy start for " << duration);
744  UpdateBackoff ();
746  m_lastBusyDuration = duration;
747 }
748 
749 void
751 {
752  NS_LOG_FUNCTION (this << duration);
753  Time now = Simulator::Now ();
756 
757  if (m_rxing)
758  {
759  //channel switching during packet reception
762  m_lastRxReceivedOk = true;
763  m_rxing = false;
764  }
765  if (m_lastNavStart + m_lastNavDuration > now)
766  {
768  }
770  {
772  }
773  if (m_lastAckTimeoutEnd > now)
774  {
775  m_lastAckTimeoutEnd = now;
776  }
777  if (m_lastCtsTimeoutEnd > now)
778  {
779  m_lastCtsTimeoutEnd = now;
780  }
781 
782  //Cancel timeout
783  if (m_accessTimeout.IsRunning ())
784  {
786  }
787 
788  //Reset backoffs
789  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
790  {
791  DcfState *state = *i;
792  uint32_t remainingSlots = state->GetBackoffSlots ();
793  if (remainingSlots > 0)
794  {
795  state->UpdateBackoffSlotsNow (remainingSlots, now);
796  NS_ASSERT (state->GetBackoffSlots () == 0);
797  }
798  state->ResetCw ();
799  state->m_accessRequested = false;
800  state->NotifyChannelSwitching ();
801  }
802 
803  MY_DEBUG ("switching start for " << duration);
805  m_lastSwitchingDuration = duration;
806 
807 }
808 
809 void
811 {
812  NS_LOG_FUNCTION (this);
813  m_sleeping = true;
814  //Cancel timeout
815  if (m_accessTimeout.IsRunning ())
816  {
818  }
819 
820  //Reset backoffs
821  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
822  {
823  DcfState *state = *i;
824  state->NotifySleep ();
825  }
826 }
827 
828 void
830 {
831  NS_LOG_FUNCTION (this);
832  m_sleeping = false;
833  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
834  {
835  DcfState *state = *i;
836  uint32_t remainingSlots = state->GetBackoffSlots ();
837  if (remainingSlots > 0)
838  {
839  state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ());
840  NS_ASSERT (state->GetBackoffSlots () == 0);
841  }
842  state->ResetCw ();
843  state->m_accessRequested = false;
844  state->NotifyWakeUp ();
845  }
846 }
847 
848 void
850 {
851  NS_LOG_FUNCTION (this << duration);
852  MY_DEBUG ("nav reset for=" << duration);
853  UpdateBackoff ();
855  m_lastNavDuration = duration;
856  UpdateBackoff ();
864 }
865 
866 void
868 {
869  NS_LOG_FUNCTION (this << duration);
871  MY_DEBUG ("nav start for=" << duration);
872  UpdateBackoff ();
873  Time newNavEnd = Simulator::Now () + duration;
874  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
875  if (newNavEnd > lastNavEnd)
876  {
878  m_lastNavDuration = duration;
879  }
880 }
881 
882 void
884 {
885  NS_LOG_FUNCTION (this << duration);
887  m_lastAckTimeoutEnd = Simulator::Now () + duration;
888 }
889 
890 void
892 {
893  NS_LOG_FUNCTION (this);
896 }
897 
898 void
900 {
901  NS_LOG_FUNCTION (this << duration);
902  m_lastCtsTimeoutEnd = Simulator::Now () + duration;
903 }
904 
905 void
907 {
908  NS_LOG_FUNCTION (this);
911 }
912 } //namespace ns3
uint32_t m_cwMin
Definition: dcf-manager.h:230
ns3::DcfManager * m_dcf
DcfManager to forward events to.
Definition: dcf-manager.cc:291
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:829
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:179
ns3::DcfManager * m_dcf
DcfManager to forward events to.
Definition: dcf-manager.cc:235
#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:213
void NotifyInternalCollision(void)
Notify that internal collision has occurred.
Definition: dcf-manager.cc:167
bool m_lastRxReceivedOk
Definition: dcf-manager.h:527
uint32_t GetCwMin(void) const
Return the minimum congestion window size.
Definition: dcf-manager.cc:82
virtual void NotifyRxStart(Time duration)
Definition: dcf-manager.cc:257
void NotifyAccessGranted(void)
Notify that access has been granted.
Definition: dcf-manager.cc:153
void RequestAccess(DcfState *state)
Definition: dcf-manager.cc:479
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
Definition: dcf-manager.cc:136
void SetupLowListener(Ptr< MacLow > low)
Set up listener for MacLow events.
Definition: dcf-manager.cc:357
#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:521
#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:185
virtual void NotifySwitchingStart(Time duration)
Definition: dcf-manager.cc:277
LowDcfListener(ns3::DcfManager *dcf)
Create a LowDcfListener for the given DcfManager.
Definition: dcf-manager.cc:202
void UpdateBackoff(void)
Update backoff slots for all DcfStates.
Definition: dcf-manager.cc:627
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:285
Time m_lastCtsTimeoutEnd
Definition: dcf-manager.h:522
#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:233
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:94
Time m_lastSwitchingDuration
Definition: dcf-manager.h:534
PhyListener(ns3::DcfManager *dcf)
Create a PhyListener for the given DcfManager.
Definition: dcf-manager.cc:250
void Add(DcfState *dcf)
Definition: dcf-manager.cc:397
virtual void NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
Definition: dcf-manager.cc:261
virtual void RegisterListener(WifiPhyListener *listener)=0
void DoGrantAccess(void)
Grant access to DCF.
Definition: dcf-manager.cc:508
void NotifyNavResetNow(Time duration)
Definition: dcf-manager.cc:849
Time GetBackoffStartFor(DcfState *state)
Return the time when the backoff procedure started for the given DcfState.
Definition: dcf-manager.cc:611
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Definition: dcf-manager.cc:899
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Definition: dcf-manager.cc:700
uint32_t m_backoffSlots
Definition: dcf-manager.h:225
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:541
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:572
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:621
void NotifyTxStartNow(Time duration)
Definition: dcf-manager.cc:720
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for Phy events.
Definition: dcf-manager.cc:345
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
Definition: dcf-manager.cc:883
virtual void NavStart(Time duration)
Norify that NAV has started for the given duration.
Definition: dcf-manager.cc:209
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for Phy events.
Definition: dcf-manager.cc:333
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: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:217
virtual void CtsTimeoutReset()
Notify that CTS timeout has resetted.
Definition: dcf-manager.cc:229
bool IsAccessRequested(void) const
Definition: dcf-manager.cc:142
Listener for PHY events.
Definition: dcf-manager.cc:242
void RegisterDcfListener(MacLowDcfListener *listener)
Definition: mac-low.cc:696
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: dcf-manager.cc:130
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:88
Time m_lastBusyDuration
Definition: dcf-manager.h:532
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:281
void StartBackoffNow(uint32_t nSlots)
Definition: dcf-manager.cc:115
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:273
uint32_t m_cwMax
Definition: dcf-manager.h:231
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:147
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully.
Definition: dcf-manager.cc:710
virtual void CtsTimeoutStart(Time duration)
Notify that CTS timeout has started for a given duration.
Definition: dcf-manager.cc:225
uint32_t m_cw
Definition: dcf-manager.h:232
Time m_lastSwitchingStart
Definition: dcf-manager.h:533
void SetEifsNoDifs(Time eifsNoDifs)
Definition: dcf-manager.cc:383
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:151
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
void NotifyMaybeCcaBusyStartNow(Time duration)
Definition: dcf-manager.cc:740
void AccessTimeout(void)
Called when access timeout should occur (e.g.
Definition: dcf-manager.cc:563
Time m_lastNavDuration
Definition: dcf-manager.h:524
void SetSlot(Time slotTime)
Definition: dcf-manager.cc:369
void SetCwMax(uint32_t maxCw)
Set the maximum congestion window size.
Definition: dcf-manager.cc:69
void NotifyAckTimeoutResetNow()
Notify that ACK timer has resetted.
Definition: dcf-manager.cc:891
LowDcfListener * m_lowListener
Definition: dcf-manager.h:542
void NotifyNavStartNow(Time duration)
Definition: dcf-manager.cc:867
void NotifyChannelSwitching(void)
Notify that the device is switching channel.
Definition: dcf-manager.cc:173
uint32_t GetCw(void) const
Definition: dcf-manager.cc:124
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dcf-manager.cc:76
uint32_t m_aifsn
Definition: dcf-manager.h:224
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:689
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:107
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
virtual ~PhyListener()
Definition: dcf-manager.cc:254
Time GetEifsNoDifs() const
Definition: dcf-manager.cc:390
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:265
void NotifySleepNow(void)
Notify the DCF that the device has been put in sleep mode.
Definition: dcf-manager.cc:810
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has resetted.
Definition: dcf-manager.cc:906
void NotifyCollision(void)
Notify that collision has occurred.
Definition: dcf-manager.cc:161
virtual void NotifyTxStart(Time duration, double txPowerDbm)
Definition: dcf-manager.cc:269
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV busy.
Definition: dcf-manager.cc:456
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:911
Time m_backoffStart
Definition: dcf-manager.h:229
void DoRestartAccessTimeoutIfNeeded(void)
Definition: dcf-manager.cc:649
EventId m_accessTimeout
Definition: dcf-manager.h:538
virtual ~LowDcfListener()
Definition: dcf-manager.cc:206
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Definition: dcf-manager.cc:100
Listener for NAV events.
Definition: dcf-manager.cc:194
void NotifySwitchingStartNow(Time duration)
Definition: dcf-manager.cc:750
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:539
Time MostRecent(Time a, Time b) const
Return the most recent time.
Definition: dcf-manager.cc:404
void SetSifs(Time sifs)
Definition: dcf-manager.cc:376
virtual void AckTimeoutReset()
Notify that ACK timeout has resetted.
Definition: dcf-manager.cc:221