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)),
353 retval =
Max (retval, c);
428 MY_DEBUG (
"medium is busy: collision");
443 for (States::const_iterator i =
m_states.begin (); i !=
m_states.end (); k++)
453 MY_DEBUG (
"dcf " << k <<
" needs access. backoff expired. access granted. slots=" << state->
GetBackoffSlots ());
456 std::vector<DcfState *> internalCollisionStates;
457 for (States::const_iterator j = i; j !=
m_states.end (); j++, k++)
463 MY_DEBUG (
"dcf " << k <<
" needs access. backoff expired. internal collision. slots=" <<
470 internalCollisionStates.push_back (otherState);
482 for (std::vector<DcfState *>::const_iterator k = internalCollisionStates.begin ();
483 k != internalCollisionStates.end (); k++)
485 (*k)->NotifyInternalCollision ();
529 ackTimeoutAccessStart,
530 ctsTimeoutAccessStart,
533 NS_LOG_INFO (
"access grant start=" << accessGrantedStart <<
534 ", rx access start=" << rxAccessStart <<
535 ", busy access start=" << busyAccessStart <<
536 ", tx access start=" << txAccessStart <<
537 ", nav access start=" << navAccessStart);
538 return accessGrantedStart;
548 return mostRecentEvent;
562 for (States::const_iterator i =
m_states.begin (); i !=
m_states.end (); i++, k++)
569 uint32_t nus = (
Simulator::Now () - backoffStart).GetMicroSeconds ();
572 MY_DEBUG (
"dcf " << k <<
" dec backoff slots=" << n);
587 bool accessTimeoutNeeded =
false;
589 for (States::const_iterator i =
m_states.begin (); i !=
m_states.end (); i++)
597 accessTimeoutNeeded =
true;
598 expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
602 if (accessTimeoutNeeded)
604 MY_DEBUG (
"expected backoff end=" << expectedBackoffEnd);
623 MY_DEBUG (
"rx start for=" << duration);
662 MY_DEBUG (
"tx start for " << duration);
671 MY_DEBUG (
"busy start for " << duration);
722 if (remainingSlots > 0)
732 MY_DEBUG (
"switching start for " << duration);
742 MY_DEBUG (
"nav reset for=" << duration);
760 MY_DEBUG (
"nav start for=" << duration);
764 if (newNavEnd > lastNavEnd)
767 m_lastNavDuration = duration;
static Time GetDelayLeft(const EventId &id)
keep track of time values and allow control of global simulation resolution
#define NS_LOG_FUNCTION(parameters)
virtual void NavReset(Time duration)
void NotifyInternalCollision(void)
uint32_t GetCwMin(void) const
virtual void NotifyRxStart(Time duration)
void NotifyAccessGranted(void)
void RequestAccess(DcfState *state)
Time GetBackoffStart(void) const
void SetupLowListener(Ptr< MacLow > low)
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
virtual void NotifySwitchingStart(Time duration)
LowDcfListener(ns3::DcfManager *dcf)
virtual void DoNotifyCollision(void)=0
void SetAifsn(uint32_t aifsn)
bool IsRunning(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Time m_lastSwitchingDuration
PhyListener(ns3::DcfManager *dcf)
virtual void NotifyRxEndOk(void)
virtual void RegisterListener(WifiPhyListener *listener)=0
void NotifyNavResetNow(Time duration)
Time GetBackoffStartFor(DcfState *state)
void NotifyCtsTimeoutStartNow(Time duration)
void NotifyRxEndOkNow(void)
PhyListener * m_phyListener
int64_t GetMicroSeconds(void) const
Time GetAccessGrantStart(void) const
receive notifications about phy events.
Time GetBackoffEndFor(DcfState *state)
void NotifyTxStartNow(Time duration)
void NotifyAckTimeoutStartNow(Time duration)
virtual void NavStart(Time duration)
void SetupPhyListener(Ptr< WifiPhy > phy)
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
keep track of the state needed for a single DCF function.Multiple instances of a DcfState can be regi...
virtual void AckTimeoutStart(Time duration)
virtual void CtsTimeoutReset()
bool IsAccessRequested(void) const
uint32_t GetBackoffSlots(void) const
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
uint32_t GetCwMax(void) const
void SetCwMin(uint32_t minCw)
void StartBackoffNow(uint32_t nSlots)
virtual void NotifyMaybeCcaBusyStart(Time duration)
virtual void DoNotifyAccessGranted(void)=0
void NotifyAccessRequested(void)
void NotifyRxEndErrorNow(void)
virtual void CtsTimeoutStart(Time duration)
Time m_lastSwitchingStart
void SetEifsNoDifs(Time eifsNoDifs)
virtual void DoNotifyInternalCollision(void)=0
listen to NAV eventsThis class is typically connected to an instance of ns3::Dcf and calls to its met...
void NotifyMaybeCcaBusyStartNow(Time duration)
virtual void DoNotifyChannelSwitching()=0
void SetSlot(Time slotTime)
void SetCwMax(uint32_t maxCw)
void NotifyAckTimeoutResetNow()
LowDcfListener * m_lowListener
void NotifyNavStartNow(Time duration)
void NotifyChannelSwitching(void)
uint32_t GetCw(void) const
uint32_t GetAifsn(void) const
void NotifyRxStartNow(Time duration)
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Time GetEifsNoDifs() const
virtual void NotifyRxEndError(void)
void NotifyCtsTimeoutResetNow()
void NotifyCollision(void)
void DoRestartAccessTimeoutIfNeeded(void)
virtual ~LowDcfListener()
void UpdateFailedCw(void)
void NotifySwitchingStartNow(Time duration)
bool IsExpired(void) const
static Time GetMaximumSimulationTime(void)
Time MostRecent(Time a, Time b) const
virtual void NotifyTxStart(Time duration)
virtual void AckTimeoutReset()