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/log.h"
22 #include "dcf-manager.h"
23 #include "dcf-state.h"
24 
25 namespace ns3 {
26 
27 NS_LOG_COMPONENT_DEFINE ("DcfManager");
28 
33 {
34 public:
41  : m_dcf (dcf)
42  {
43  }
44  virtual ~PhyListener ()
45  {
46  }
47  void NotifyRxStart (Time duration)
48  {
49  m_dcf->NotifyRxStartNow (duration);
50  }
51  void NotifyRxEndOk (void)
52  {
54  }
55  void NotifyRxEndError (void)
56  {
58  }
59  void NotifyTxStart (Time duration, double txPowerDbm)
60  {
61  m_dcf->NotifyTxStartNow (duration);
62  }
63  void NotifyMaybeCcaBusyStart (Time duration)
64  {
66  }
67  void NotifySwitchingStart (Time duration)
68  {
69  m_dcf->NotifySwitchingStartNow (duration);
70  }
71  void NotifySleep (void)
72  {
74  }
75  void NotifyWakeup (void)
76  {
78  }
79 
80 private:
82 };
83 
84 
85 /****************************************************************
86  * Implement the DCF manager of all DCF state holders
87  ****************************************************************/
88 
90  : m_lastAckTimeoutEnd (MicroSeconds (0)),
91  m_lastCtsTimeoutEnd (MicroSeconds (0)),
92  m_lastNavStart (MicroSeconds (0)),
93  m_lastNavDuration (MicroSeconds (0)),
94  m_lastRxStart (MicroSeconds (0)),
95  m_lastRxDuration (MicroSeconds (0)),
96  m_lastRxReceivedOk (true),
97  m_lastRxEnd (MicroSeconds (0)),
98  m_lastTxStart (MicroSeconds (0)),
99  m_lastTxDuration (MicroSeconds (0)),
100  m_lastBusyStart (MicroSeconds (0)),
101  m_lastBusyDuration (MicroSeconds (0)),
102  m_lastSwitchingStart (MicroSeconds (0)),
103  m_lastSwitchingDuration (MicroSeconds (0)),
104  m_rxing (false),
105  m_sleeping (false),
106  m_slotTimeUs (0),
107  m_sifs (Seconds (0.0)),
108  m_phyListener (0)
109 {
110  NS_LOG_FUNCTION (this);
111 }
112 
114 {
115  delete m_phyListener;
116  m_phyListener = 0;
117 }
118 
119 void
121 {
122  NS_LOG_FUNCTION (this);
123  for (Ptr<DcfState> i : m_states)
124  {
125  i->Dispose ();
126  i = 0;
127  }
128 }
129 
130 void
132 {
133  NS_LOG_FUNCTION (this << phy);
134  if (m_phyListener != 0)
135  {
136  delete m_phyListener;
137  }
138  m_phyListener = new PhyListener (this);
140 }
141 
142 void
144 {
145  NS_LOG_FUNCTION (this << phy);
146  if (m_phyListener != 0)
147  {
149  delete m_phyListener;
150  m_phyListener = 0;
151  }
152 }
153 
154 void
156 {
157  NS_LOG_FUNCTION (this << low);
158  low->RegisterDcf (this);
159 }
160 
161 void
163 {
164  NS_LOG_FUNCTION (this << slotTime);
165  m_slotTimeUs = slotTime.GetMicroSeconds ();
166 }
167 
168 void
170 {
171  NS_LOG_FUNCTION (this << sifs);
172  m_sifs = sifs;
173 }
174 
175 void
177 {
178  NS_LOG_FUNCTION (this << eifsNoDifs);
179  m_eifsNoDifs = eifsNoDifs;
180 }
181 
182 Time
184 {
185  NS_LOG_FUNCTION (this);
186  return m_eifsNoDifs;
187 }
188 
189 void
191 {
192  NS_LOG_FUNCTION (this << dcf);
193  m_states.push_back (dcf);
194 }
195 
196 Time
198 {
199  NS_LOG_FUNCTION (this << a << b);
200  return Max (a, b);
201 }
202 
203 Time
205 {
206  NS_LOG_FUNCTION (this << a << b << c);
207  Time retval;
208  retval = Max (a, b);
209  retval = Max (retval, c);
210  return retval;
211 }
212 
213 Time
215 {
216  NS_LOG_FUNCTION (this << a << b << c << d);
217  Time e = Max (a, b);
218  Time f = Max (c, d);
219  Time retval = Max (e, f);
220  return retval;
221 }
222 
223 Time
225 {
226  NS_LOG_FUNCTION (this << a << b << c << d << e << f);
227  Time g = Max (a, b);
228  Time h = Max (c, d);
229  Time i = Max (e, f);
230  Time k = Max (g, h);
231  Time retval = Max (k, i);
232  return retval;
233 }
234 
235 Time
237 {
238  NS_LOG_FUNCTION (this << a << b << c << d << e << f << g);
239  Time h = Max (a, b);
240  Time i = Max (c, d);
241  Time j = Max (e, f);
242  Time k = Max (h, i);
243  Time l = Max (j, g);
244  Time retval = Max (k, l);
245  return retval;
246 }
247 
248 bool
249 DcfManager::IsBusy (void) const
250 {
251  NS_LOG_FUNCTION (this);
252  // PHY busy
253  if (m_rxing)
254  {
255  return true;
256  }
257  Time lastTxEnd = m_lastTxStart + m_lastTxDuration;
258  if (lastTxEnd > Simulator::Now ())
259  {
260  return true;
261  }
262  // NAV busy
263  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
264  if (lastNavEnd > Simulator::Now ())
265  {
266  return true;
267  }
268  // CCA busy
269  Time lastCCABusyEnd = m_lastBusyStart + m_lastBusyDuration;
270  if (lastCCABusyEnd > Simulator::Now ())
271  {
272  return true;
273  }
274  return false;
275 }
276 
277 bool
279 {
280  NS_LOG_FUNCTION (this << state);
281  Time ifsEnd = GetAccessGrantStart () + MicroSeconds (state->GetAifsn () * m_slotTimeUs);
282  if (ifsEnd > Simulator::Now ())
283  {
284  NS_LOG_DEBUG ("IsWithinAifs () true; ifsEnd is at " << ifsEnd.GetSeconds ());
285  return true;
286  }
287  NS_LOG_DEBUG ("IsWithinAifs () false; ifsEnd was at " << ifsEnd.GetSeconds ());
288  return false;
289 }
290 
291 void
293 {
294  NS_LOG_FUNCTION (this << state);
295  //Deny access if in sleep mode
296  if (m_sleeping)
297  {
298  return;
299  }
300  UpdateBackoff ();
301  NS_ASSERT (!state->IsAccessRequested ());
302  state->NotifyAccessRequested ();
303  // If currently transmitting; end of transmission (ACK or no ACK) will cause
304  // a later access request if needed from EndTxNoAck, GotAck, or MissedAck
305  Time lastTxEnd = m_lastTxStart + m_lastTxDuration;
306  if (lastTxEnd > Simulator::Now ())
307  {
308  NS_LOG_DEBUG ("Internal collision (currently transmitting)");
309  state->NotifyInternalCollision ();
311  return;
312  }
317  if (state->GetBackoffSlots () == 0)
318  {
319  if (IsBusy ())
320  {
321  NS_LOG_DEBUG ("medium is busy: collision");
322  // someone else has accessed the medium; generate a backoff.
323  state->NotifyCollision ();
325  return;
326  }
327  else if (IsWithinAifs (state))
328  {
329  NS_LOG_DEBUG ("busy within AIFS");
330  state->NotifyCollision ();
332  return;
333  }
334  }
335  DoGrantAccess ();
337 }
338 
339 void
341 {
342  NS_LOG_FUNCTION (this);
343  uint32_t k = 0;
344  for (States::iterator i = m_states.begin (); i != m_states.end (); k++)
345  {
346  Ptr<DcfState> state = *i;
347  if (state->IsAccessRequested ()
348  && GetBackoffEndFor (state) <= Simulator::Now () )
349  {
354  NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. access granted. slots=" << state->GetBackoffSlots ());
355  i++; //go to the next item in the list.
356  k++;
357  std::vector<Ptr<DcfState> > internalCollisionStates;
358  for (States::iterator j = i; j != m_states.end (); j++, k++)
359  {
360  Ptr<DcfState> otherState = *j;
361  if (otherState->IsAccessRequested ()
362  && GetBackoffEndFor (otherState) <= Simulator::Now ())
363  {
364  NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision. slots=" <<
365  otherState->GetBackoffSlots ());
371  internalCollisionStates.push_back (otherState);
372  }
373  }
374 
382  state->NotifyAccessGranted ();
383  for (std::vector<Ptr<DcfState> >::iterator k = internalCollisionStates.begin ();
384  k != internalCollisionStates.end (); k++)
385  {
386  (*k)->NotifyInternalCollision ();
387  }
388  break;
389  }
390  i++;
391  }
392 }
393 
394 void
396 {
397  NS_LOG_FUNCTION (this);
398  UpdateBackoff ();
399  DoGrantAccess ();
401 }
402 
403 Time
405 {
406  NS_LOG_FUNCTION (this);
407  Time rxAccessStart;
408  if (!m_rxing)
409  {
410  rxAccessStart = m_lastRxEnd + m_sifs;
411  if (!m_lastRxReceivedOk)
412  {
413  rxAccessStart += m_eifsNoDifs;
414  }
415  }
416  else
417  {
418  rxAccessStart = m_lastRxStart + m_lastRxDuration + m_sifs;
419  }
420  Time busyAccessStart = m_lastBusyStart + m_lastBusyDuration + m_sifs;
421  Time txAccessStart = m_lastTxStart + m_lastTxDuration + m_sifs;
422  Time navAccessStart = m_lastNavStart + m_lastNavDuration + m_sifs;
423  Time ackTimeoutAccessStart = m_lastAckTimeoutEnd + m_sifs;
424  Time ctsTimeoutAccessStart = m_lastCtsTimeoutEnd + m_sifs;
425  Time switchingAccessStart = m_lastSwitchingStart + m_lastSwitchingDuration + m_sifs;
426  Time accessGrantedStart = MostRecent (rxAccessStart,
427  busyAccessStart,
428  txAccessStart,
429  navAccessStart,
430  ackTimeoutAccessStart,
431  ctsTimeoutAccessStart,
432  switchingAccessStart
433  );
434  NS_LOG_INFO ("access grant start=" << accessGrantedStart <<
435  ", rx access start=" << rxAccessStart <<
436  ", busy access start=" << busyAccessStart <<
437  ", tx access start=" << txAccessStart <<
438  ", nav access start=" << navAccessStart);
439  return accessGrantedStart;
440 }
441 
442 Time
444 {
445  NS_LOG_FUNCTION (this << state);
446  Time mostRecentEvent = MostRecent (state->GetBackoffStart (),
448 
449  return mostRecentEvent;
450 }
451 
452 Time
454 {
455  NS_LOG_FUNCTION (this << state);
456  NS_LOG_DEBUG ("Backoff start: " << GetBackoffStartFor (state).As (Time::US) <<
457  " end: " << (GetBackoffStartFor (state) +
459  return GetBackoffStartFor (state) + MicroSeconds (state->GetBackoffSlots () * m_slotTimeUs);
460 }
461 
462 void
464 {
465  NS_LOG_FUNCTION (this);
466  uint32_t k = 0;
467  for (States::iterator i = m_states.begin (); i != m_states.end (); i++, k++)
468  {
469  Ptr<DcfState> state = *i;
470 
471  Time backoffStart = GetBackoffStartFor (state);
472  if (backoffStart <= Simulator::Now ())
473  {
474  uint32_t nus = (Simulator::Now () - backoffStart).GetMicroSeconds ();
475  uint32_t nIntSlots = nus / m_slotTimeUs;
476  /*
477  * EDCA behaves slightly different to DCA. For EDCA we
478  * decrement once at the slot boundary at the end of AIFS as
479  * well as once at the end of each clear slot
480  * thereafter. For DCA we only decrement at the end of each
481  * clear slot after DIFS. We account for the extra backoff
482  * by incrementing the slot count here in the case of
483  * EDCA. The if statement whose body we are in has confirmed
484  * that a minimum of AIFS has elapsed since last busy
485  * medium.
486  */
487  if (state->IsEdca ())
488  {
489  nIntSlots++;
490  }
491  uint32_t n = std::min (nIntSlots, state->GetBackoffSlots ());
492  NS_LOG_DEBUG ("dcf " << k << " dec backoff slots=" << n);
493  Time backoffUpdateBound = backoffStart + MicroSeconds (n * m_slotTimeUs);
494  state->UpdateBackoffSlotsNow (n, backoffUpdateBound);
495  }
496  }
497 }
498 
499 void
501 {
502  NS_LOG_FUNCTION (this);
507  bool accessTimeoutNeeded = false;
508  Time expectedBackoffEnd = Simulator::GetMaximumSimulationTime ();
509  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
510  {
511  Ptr<DcfState> state = *i;
512  if (state->IsAccessRequested ())
513  {
514  Time tmp = GetBackoffEndFor (state);
515  if (tmp > Simulator::Now ())
516  {
517  accessTimeoutNeeded = true;
518  expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
519  }
520  }
521  }
522  NS_LOG_DEBUG ("Access timeout needed: " << accessTimeoutNeeded);
523  if (accessTimeoutNeeded)
524  {
525  NS_LOG_DEBUG ("expected backoff end=" << expectedBackoffEnd);
526  Time expectedBackoffDelay = expectedBackoffEnd - Simulator::Now ();
528  && Simulator::GetDelayLeft (m_accessTimeout) > expectedBackoffDelay)
529  {
531  }
532  if (m_accessTimeout.IsExpired ())
533  {
534  m_accessTimeout = Simulator::Schedule (expectedBackoffDelay,
536  }
537  }
538 }
539 
540 void
542 {
543  NS_LOG_FUNCTION (this << duration);
544  NS_LOG_DEBUG ("rx start for=" << duration);
545  UpdateBackoff ();
547  m_lastRxDuration = duration;
548  m_rxing = true;
549 }
550 
551 void
553 {
554  NS_LOG_FUNCTION (this);
555  NS_LOG_DEBUG ("rx end ok");
557  m_lastRxReceivedOk = true;
558  m_rxing = false;
559 }
560 
561 void
563 {
564  NS_LOG_FUNCTION (this);
565  NS_LOG_DEBUG ("rx end error");
567  m_lastRxReceivedOk = false;
568  m_rxing = false;
569 }
570 
571 void
573 {
574  NS_LOG_FUNCTION (this << duration);
575  if (m_rxing)
576  {
577  //this may be caused only if PHY has started to receive a packet
578  //inside SIFS, so, we check that lastRxStart was maximum a SIFS ago
582  m_lastRxReceivedOk = true;
583  m_rxing = false;
584  }
585  NS_LOG_DEBUG ("tx start for " << duration);
586  UpdateBackoff ();
588  m_lastTxDuration = duration;
589 }
590 
591 void
593 {
594  NS_LOG_FUNCTION (this << duration);
595  NS_LOG_DEBUG ("busy start for " << duration);
596  UpdateBackoff ();
598  m_lastBusyDuration = duration;
599 }
600 
601 void
603 {
604  NS_LOG_FUNCTION (this << duration);
605  Time now = Simulator::Now ();
608 
609  if (m_rxing)
610  {
611  //channel switching during packet reception
614  m_lastRxReceivedOk = true;
615  m_rxing = false;
616  }
617  if (m_lastNavStart + m_lastNavDuration > now)
618  {
620  }
622  {
624  }
625  if (m_lastAckTimeoutEnd > now)
626  {
627  m_lastAckTimeoutEnd = now;
628  }
629  if (m_lastCtsTimeoutEnd > now)
630  {
631  m_lastCtsTimeoutEnd = now;
632  }
633 
634  //Cancel timeout
635  if (m_accessTimeout.IsRunning ())
636  {
638  }
639 
640  //Reset backoffs
641  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
642  {
643  Ptr<DcfState> state = *i;
644  uint32_t remainingSlots = state->GetBackoffSlots ();
645  if (remainingSlots > 0)
646  {
647  state->UpdateBackoffSlotsNow (remainingSlots, now);
648  NS_ASSERT (state->GetBackoffSlots () == 0);
649  }
650  state->ResetCw ();
651  state->m_accessRequested = false;
652  state->NotifyChannelSwitching ();
653  }
654 
655  NS_LOG_DEBUG ("switching start for " << duration);
657  m_lastSwitchingDuration = duration;
658 
659 }
660 
661 void
663 {
664  NS_LOG_FUNCTION (this);
665  m_sleeping = true;
666  //Cancel timeout
667  if (m_accessTimeout.IsRunning ())
668  {
670  }
671 
672  //Reset backoffs
673  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
674  {
675  Ptr<DcfState> state = *i;
676  state->NotifySleep ();
677  }
678 }
679 
680 void
682 {
683  NS_LOG_FUNCTION (this);
684  m_sleeping = false;
685  for (States::iterator i = m_states.begin (); i != m_states.end (); i++)
686  {
687  Ptr<DcfState> state = *i;
688  uint32_t remainingSlots = state->GetBackoffSlots ();
689  if (remainingSlots > 0)
690  {
691  state->UpdateBackoffSlotsNow (remainingSlots, Simulator::Now ());
692  NS_ASSERT (state->GetBackoffSlots () == 0);
693  }
694  state->ResetCw ();
695  state->m_accessRequested = false;
696  state->NotifyWakeUp ();
697  }
698 }
699 
700 void
702 {
703  NS_LOG_FUNCTION (this << duration);
704  NS_LOG_DEBUG ("nav reset for=" << duration);
705  UpdateBackoff ();
707  m_lastNavDuration = duration;
715 }
716 
717 void
719 {
720  NS_LOG_FUNCTION (this << duration);
722  NS_LOG_DEBUG ("nav start for=" << duration);
723  UpdateBackoff ();
724  Time newNavEnd = Simulator::Now () + duration;
725  Time lastNavEnd = m_lastNavStart + m_lastNavDuration;
726  if (newNavEnd > lastNavEnd)
727  {
729  m_lastNavDuration = duration;
730  }
731 }
732 
733 void
735 {
736  NS_LOG_FUNCTION (this << duration);
738  m_lastAckTimeoutEnd = Simulator::Now () + duration;
739 }
740 
741 void
743 {
744  NS_LOG_FUNCTION (this);
747 }
748 
749 void
751 {
752  NS_LOG_FUNCTION (this << duration);
753  m_lastCtsTimeoutEnd = Simulator::Now () + duration;
754 }
755 
756 void
758 {
759  NS_LOG_FUNCTION (this);
762 }
763 
764 } //namespace ns3
ns3::DcfManager * m_dcf
DcfManager to forward events to.
Definition: dcf-manager.cc:81
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Definition: simulator.cc:258
void NotifyWakeupNow(void)
Notify the DCF that the device has been resumed from sleep mode.
Definition: dcf-manager.cc:681
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-state.cc:231
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void NotifyInternalCollision(void)
Notify that internal collision has occurred.
Definition: dcf-state.cc:217
Time GetBackoffStartFor(Ptr< DcfState > state)
Return the time when the backoff procedure started for the given DcfState.
Definition: dcf-manager.cc:443
bool m_lastRxReceivedOk
the last receive OK
Definition: dcf-manager.h:337
void NotifyMaybeCcaBusyStart(Time duration)
Definition: dcf-manager.cc:63
#define min(a, b)
Definition: 80211b.c:44
void NotifySwitchingStart(Time duration)
Definition: dcf-manager.cc:67
void NotifyAccessGranted(void)
Notify that access has been granted.
Definition: dcf-state.cc:201
Time m_eifsNoDifs
EIFS no DIFS time.
Definition: dcf-manager.h:347
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
Definition: dcf-state.cc:182
#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_lastBusyStart
the last busy start time
Definition: dcf-manager.h:341
Time m_lastAckTimeoutEnd
the last ACK timeout end time
Definition: dcf-manager.h:331
#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-state.cc:238
void UpdateBackoff(void)
Update backoff slots for all DcfStates.
Definition: dcf-manager.cc:463
Time m_lastCtsTimeoutEnd
the last CTS timeout end time
Definition: dcf-manager.h:332
void UnregisterListener(WifiPhyListener *listener)
Definition: wifi-phy.cc:446
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:277
bool m_accessRequested
flag whether channel access is already requested
Definition: dcf-state.h:213
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-state.cc:130
Time m_lastSwitchingDuration
the last switching duration time
Definition: dcf-manager.h:344
PhyListener(ns3::DcfManager *dcf)
Create a PhyListener for the given DcfManager.
Definition: dcf-manager.cc:40
void NotifyRxEndError(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
Definition: dcf-manager.cc:55
Time GetBackoffEndFor(Ptr< DcfState > state)
Return the time when the backoff procedure ended (or will ended) for the given DcfState.
Definition: dcf-manager.cc:453
void DoGrantAccess(void)
Grant access to DCF.
Definition: dcf-manager.cc:340
void NotifyNavResetNow(Time duration)
Definition: dcf-manager.cc:701
virtual ~DcfManager()
Definition: dcf-manager.cc:113
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Definition: dcf-manager.cc:750
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Definition: dcf-manager.cc:552
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:1375
PhyListener * m_phyListener
the phy listener
Definition: dcf-manager.h:351
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:349
Time m_sifs
the SIFS time
Definition: dcf-manager.h:350
Time GetAccessGrantStart(void) const
Access will never be granted to the medium before the time returned by this method.
Definition: dcf-manager.cc:404
receive notifications about phy events.
Definition: wifi-phy.h:83
void NotifyTxStartNow(Time duration)
Definition: dcf-manager.cc:572
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for Phy events.
Definition: dcf-manager.cc:143
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
Definition: dcf-manager.cc:734
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for Phy events.
Definition: dcf-manager.cc:131
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:51
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:209
void SetupLow(Ptr< MacLow > low)
Set up listener for MacLow events.
Definition: dcf-manager.cc:155
void NotifyWakeup(void)
Notify listeners that we woke up.
Definition: dcf-manager.cc:75
bool IsAccessRequested(void) const
Definition: dcf-state.cc:188
Listener for PHY events.
Definition: dcf-manager.cc:32
void NotifyTxStart(Time duration, double txPowerDbm)
Definition: dcf-manager.cc:59
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: dcf-state.cc:176
void NotifySleep(void)
Notify listeners that we went to sleep.
Definition: dcf-manager.cc:71
Time m_lastBusyDuration
the last busy duration time
Definition: dcf-manager.h:342
double f(double x, void *params)
Definition: 80211b.c:72
void RegisterDcf(Ptr< DcfManager > dcf)
Definition: mac-low.cc:603
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void NotifyAccessRequested(void)
Notify that access request has been received.
Definition: dcf-state.cc:194
void Add(Ptr< DcfState > dcf)
Definition: dcf-manager.cc:190
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully.
Definition: dcf-manager.cc:562
Time m_lastSwitchingStart
the last switching start time
Definition: dcf-manager.h:343
void SetEifsNoDifs(Time eifsNoDifs)
Definition: dcf-manager.cc:176
bool m_sleeping
flag whether it is in sleeping state
Definition: dcf-manager.h:346
Time m_lastRxEnd
the last receive end time
Definition: dcf-manager.h:338
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
void NotifyMaybeCcaBusyStartNow(Time duration)
Definition: dcf-manager.cc:592
void AccessTimeout(void)
Called when access timeout should occur (e.g.
Definition: dcf-manager.cc:395
Time m_lastNavStart
the last NAV start time
Definition: dcf-manager.h:333
Time m_lastNavDuration
the last NAV duration time
Definition: dcf-manager.h:334
void NotifyRxStart(Time duration)
Definition: dcf-manager.cc:47
void SetSlot(Time slotTime)
Definition: dcf-manager.cc:162
microsecond
Definition: nstime.h:116
void NotifyAckTimeoutResetNow()
Notify that ACK timer has resetted.
Definition: dcf-manager.cc:742
void RegisterListener(WifiPhyListener *listener)
Definition: wifi-phy.cc:440
void DoDispose(void)
Destructor implementation.
Definition: dcf-manager.cc:120
TimeWithUnit As(const enum Unit unit) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:388
void NotifyNavStartNow(Time duration)
Definition: dcf-manager.cc:718
void NotifyChannelSwitching(void)
Notify that the device is switching channel.
Definition: dcf-state.cc:224
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dcf-state.cc:106
void NotifyRxStartNow(Time duration)
Definition: dcf-manager.cc:541
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
Definition: dcf-state.cc:145
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:269
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:993
bool m_rxing
flag whether it is in receiving state
Definition: dcf-manager.h:345
virtual ~PhyListener()
Definition: dcf-manager.cc:44
Time GetEifsNoDifs() const
Definition: dcf-manager.cc:183
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
bool IsEdca(void) const
Definition: dcf-state.cc:245
void RequestAccess(Ptr< DcfState > state)
Definition: dcf-manager.cc:292
void NotifySleepNow(void)
Notify the DCF that the device has been put in sleep mode.
Definition: dcf-manager.cc:662
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has resetted.
Definition: dcf-manager.cc:757
void NotifyCollision(void)
Notify that collision has occurred.
Definition: dcf-state.cc:210
States m_states
the DCF states
Definition: dcf-manager.h:330
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV or CCA busy.
Definition: dcf-manager.cc:249
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1009
Time m_lastTxDuration
the last transmit duration time
Definition: dcf-manager.h:340
void DoRestartAccessTimeoutIfNeeded(void)
Definition: dcf-manager.cc:500
EventId m_accessTimeout
the access timeout ID
Definition: dcf-manager.h:348
Time m_lastTxStart
the last transmit start time
Definition: dcf-manager.h:339
bool IsWithinAifs(Ptr< DcfState > state) const
Check if the device is between frames (in DIFS or AIFS interval)
Definition: dcf-manager.cc:278
void NotifySwitchingStartNow(Time duration)
Definition: dcf-manager.cc:602
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Definition: event-id.cc:59
void NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
Definition: dcf-manager.cc:51
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
Definition: simulator.cc:371
uint32_t m_slotTimeUs
the slot time in microseconds
Definition: dcf-manager.h:349
Time MostRecent(Time a, Time b) const
Return the most recent time.
Definition: dcf-manager.cc:197
void SetSifs(Time sifs)
Definition: dcf-manager.cc:169
Time m_lastRxDuration
the last receive duration time
Definition: dcf-manager.h:336
Time m_lastRxStart
the last receive start time
Definition: dcf-manager.h:335