21 #include "ns3/assert.h"
23 #include "ns3/simulator.h"
34 NS_LOG_DEBUG (Simulator::Now () << " " << this << " " << x)
44 m_backoffStart (Seconds (0.0)),
48 m_accessRequested (false)
112 MY_DEBUG (
"start backoff=" << nSlots <<
" slots");
255 : m_lastAckTimeoutEnd (MicroSeconds (0)),
256 m_lastCtsTimeoutEnd (MicroSeconds (0)),
257 m_lastNavStart (MicroSeconds (0)),
258 m_lastNavDuration (MicroSeconds (0)),
259 m_lastRxStart (MicroSeconds (0)),
260 m_lastRxDuration (MicroSeconds (0)),
261 m_lastRxReceivedOk (true),
262 m_lastRxEnd (MicroSeconds (0)),
263 m_lastTxStart (MicroSeconds (0)),
264 m_lastTxDuration (MicroSeconds (0)),
265 m_lastBusyStart (MicroSeconds (0)),
266 m_lastBusyDuration (MicroSeconds (0)),
267 m_lastSwitchingStart (MicroSeconds (0)),
268 m_lastSwitchingDuration (MicroSeconds (0)),
271 m_sifs (Seconds (0.0)),
345 retval =
Max (retval, c);
420 MY_DEBUG (
"medium is busy: collision");
435 for (States::const_iterator i =
m_states.begin (); i !=
m_states.end (); k++)
445 MY_DEBUG (
"dcf " << k <<
" needs access. backoff expired. access granted. slots=" << state->
GetBackoffSlots ());
448 std::vector<DcfState *> internalCollisionStates;
449 for (States::const_iterator j = i; j !=
m_states.end (); j++, k++)
455 MY_DEBUG (
"dcf " << k <<
" needs access. backoff expired. internal collision. slots=" <<
462 internalCollisionStates.push_back (otherState);
474 for (std::vector<DcfState *>::const_iterator k = internalCollisionStates.begin ();
475 k != internalCollisionStates.end (); k++)
477 (*k)->NotifyInternalCollision ();
521 ackTimeoutAccessStart,
522 ctsTimeoutAccessStart,
525 NS_LOG_INFO (
"access grant start=" << accessGrantedStart <<
526 ", rx access start=" << rxAccessStart <<
527 ", busy access start=" << busyAccessStart <<
528 ", tx access start=" << txAccessStart <<
529 ", nav access start=" << navAccessStart);
530 return accessGrantedStart;
540 return mostRecentEvent;
554 for (States::const_iterator i =
m_states.begin (); i !=
m_states.end (); i++, k++)
561 uint32_t nus = (
Simulator::Now () - backoffStart).GetMicroSeconds ();
564 MY_DEBUG (
"dcf " << k <<
" dec backoff slots=" << n);
579 bool accessTimeoutNeeded =
false;
581 for (States::const_iterator i =
m_states.begin (); i !=
m_states.end (); i++)
589 accessTimeoutNeeded =
true;
590 expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
594 if (accessTimeoutNeeded)
596 MY_DEBUG (
"expected backoff end=" << expectedBackoffEnd);
615 MY_DEBUG (
"rx start for=" << duration);
654 MY_DEBUG (
"tx start for " << duration);
663 MY_DEBUG (
"busy start for " << duration);
714 if (remainingSlots > 0)
724 MY_DEBUG (
"switching start for " << duration);
734 MY_DEBUG (
"nav reset for=" << duration);
752 MY_DEBUG (
"nav start for=" << duration);
756 if (newNavEnd > lastNavEnd)
759 m_lastNavDuration = duration;