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");
 
  263   : m_lastAckTimeoutEnd (MicroSeconds (0)),
 
  264     m_lastCtsTimeoutEnd (MicroSeconds (0)),
 
  265     m_lastNavStart (MicroSeconds (0)),
 
  266     m_lastNavDuration (MicroSeconds (0)),
 
  267     m_lastRxStart (MicroSeconds (0)),
 
  268     m_lastRxDuration (MicroSeconds (0)),
 
  269     m_lastRxReceivedOk (true),
 
  270     m_lastRxEnd (MicroSeconds (0)),
 
  271     m_lastTxStart (MicroSeconds (0)),
 
  272     m_lastTxDuration (MicroSeconds (0)),
 
  273     m_lastBusyStart (MicroSeconds (0)),
 
  274     m_lastBusyDuration (MicroSeconds (0)),
 
  275     m_lastSwitchingStart (MicroSeconds (0)),
 
  276     m_lastSwitchingDuration (MicroSeconds (0)),
 
  279     m_sifs (Seconds (0.0)),
 
  361   retval = 
Max (retval, c);
 
  436       MY_DEBUG (
"medium is busy: collision");
 
  451   for (States::const_iterator i = 
m_states.begin (); i != 
m_states.end (); k++)
 
  461           MY_DEBUG (
"dcf " << k << 
" needs access. backoff expired. access granted. slots=" << state->
GetBackoffSlots ());
 
  464           std::vector<DcfState *> internalCollisionStates;
 
  465           for (States::const_iterator j = i; j != 
m_states.end (); j++, k++)
 
  471                   MY_DEBUG (
"dcf " << k << 
" needs access. backoff expired. internal collision. slots=" <<
 
  478                   internalCollisionStates.push_back (otherState);
 
  490           for (std::vector<DcfState *>::const_iterator k = internalCollisionStates.begin ();
 
  491                k != internalCollisionStates.end (); k++)
 
  493               (*k)->NotifyInternalCollision ();
 
  537                                         ackTimeoutAccessStart,
 
  538                                         ctsTimeoutAccessStart,
 
  541   NS_LOG_INFO (
"access grant start=" << accessGrantedStart <<
 
  542                ", rx access start=" << rxAccessStart <<
 
  543                ", busy access start=" << busyAccessStart <<
 
  544                ", tx access start=" << txAccessStart <<
 
  545                ", nav access start=" << navAccessStart);
 
  546   return accessGrantedStart;
 
  556   return mostRecentEvent;
 
  570   for (States::const_iterator i = 
m_states.begin (); i != 
m_states.end (); i++, k++)
 
  577           uint32_t nus = (
Simulator::Now () - backoffStart).GetMicroSeconds ();
 
  580           MY_DEBUG (
"dcf " << k << 
" dec backoff slots=" << n);
 
  595   bool accessTimeoutNeeded = 
false;
 
  597   for (States::const_iterator i = 
m_states.begin (); i != 
m_states.end (); i++)
 
  605               accessTimeoutNeeded = 
true;
 
  606               expectedBackoffEnd = std::min (expectedBackoffEnd, tmp);
 
  610   if (accessTimeoutNeeded)
 
  612       MY_DEBUG (
"expected backoff end=" << expectedBackoffEnd);
 
  631   MY_DEBUG (
"rx start for=" << duration);
 
  670   MY_DEBUG (
"tx start for " << duration);
 
  679   MY_DEBUG (
"busy start for " << duration);
 
  730       if (remainingSlots > 0)
 
  740   MY_DEBUG (
"switching start for " << duration);
 
  750   MY_DEBUG (
"nav reset for=" << duration);
 
  768   MY_DEBUG (
"nav start for=" << duration);
 
  772   if (newNavEnd > lastNavEnd)
 
  775       m_lastNavDuration = duration;
 
ns3::DcfManager * m_dcf
DcfManager to forward events to. 
static Time GetDelayLeft(const EventId &id)
Simulation virtual time values and global simulation resolution. 
ns3::DcfManager * m_dcf
DcfManager to forward events to. 
#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. 
void NotifyInternalCollision(void)
Notify that internal collision has occurred. 
uint32_t GetCwMin(void) const 
Return the minimum congestion window size. 
virtual void NotifyRxStart(Time duration)
void NotifyAccessGranted(void)
Notify that access has been granted. 
void RequestAccess(DcfState *state)
Time GetBackoffStart(void) const 
Return the time when the backoff procedure started. 
void SetupLowListener(Ptr< MacLow > low)
Set up listener for MacLow events. 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
virtual void NotifySwitchingStart(Time duration)
LowDcfListener(ns3::DcfManager *dcf)
Create a LowDcfListener for the given DcfManager. 
void UpdateBackoff(void)
Update backoff slots for all DcfStates. 
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. 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
void SetAifsn(uint32_t aifsn)
bool IsRunning(void) const 
This method is syntactic sugar for the ns3::Simulator::isExpired method. 
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached. 
Time m_lastSwitchingDuration
PhyListener(ns3::DcfManager *dcf)
Create a PhyListener for the given DcfManager. 
virtual void NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
virtual void RegisterListener(WifiPhyListener *listener)=0
void DoGrantAccess(void)
Grant access to DCF. 
void NotifyNavResetNow(Time duration)
Time GetBackoffStartFor(DcfState *state)
Return the time when the backoff procedure started for the given DcfState. 
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration. 
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully. 
PhyListener * m_phyListener
int64_t GetMicroSeconds(void) const 
Time GetAccessGrantStart(void) const 
Access will never be granted to the medium before the time returned by this method. 
receive notifications about phy events. 
Time GetBackoffEndFor(DcfState *state)
Return the time when the backoff procedure ended (or will ended) for the given DcfState. 
void NotifyTxStartNow(Time duration)
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration. 
virtual void NavStart(Time duration)
Norify that NAV has started for the given duration. 
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for Phy events. 
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum. 
keep track of the state needed for a single DCF function. 
virtual void AckTimeoutStart(Time duration)
Notify that ACK timeout has started for a given duration. 
virtual void CtsTimeoutReset()
Notify that CTS timeout has resetted. 
bool IsAccessRequested(void) const 
uint32_t GetBackoffSlots(void) const 
Return the current number of backoff slots. 
uint32_t GetCwMax(void) const 
Return the maximum congestion window size. 
void SetCwMin(uint32_t minCw)
Set the minimum congestion window size. 
void StartBackoffNow(uint32_t nSlots)
virtual void NotifyMaybeCcaBusyStart(Time duration)
virtual void DoNotifyAccessGranted(void)=0
Called by DcfManager to notify a DcfState subclass that access to the medium is granted and can start...
void NotifyAccessRequested(void)
Notify that access request has been received. 
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully. 
virtual void CtsTimeoutStart(Time duration)
Notify that CTS timeout has started for a given duration. 
Time m_lastSwitchingStart
void SetEifsNoDifs(Time eifsNoDifs)
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...
static Time Now(void)
Return the "current simulation time". 
void NotifyMaybeCcaBusyStartNow(Time duration)
void AccessTimeout(void)
Called when access timeout should occur (e.g. 
virtual void DoNotifyChannelSwitching()=0
Called by DcfManager to notify a DcfState subclass that a channel switching occured. 
void SetSlot(Time slotTime)
void SetCwMax(uint32_t maxCw)
Set the maximum congestion window size. 
void NotifyAckTimeoutResetNow()
Notify that ACK timer has resetted. 
LowDcfListener * m_lowListener
void NotifyNavStartNow(Time duration)
void NotifyChannelSwitching(void)
Notify that the device is switching channel. 
uint32_t GetCw(void) const 
uint32_t GetAifsn(void) const 
Return the number of slots that make up an AIFS. 
void NotifyRxStartNow(Time duration)
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed. 
Time GetEifsNoDifs() const 
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method. 
virtual void NotifyRxEndError(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has resetted. 
void NotifyCollision(void)
Notify that collision has occurred. 
bool IsBusy(void) const 
Check if the device is busy sending or receiving, or NAV busy. 
void DoRestartAccessTimeoutIfNeeded(void)
virtual ~LowDcfListener()
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure. 
void NotifySwitchingStartNow(Time duration)
bool IsExpired(void) const 
This method is syntactic sugar for the ns3::Simulator::isExpired method. 
static Time GetMaximumSimulationTime(void)
Time MostRecent(Time a, Time b) const 
Return the most recent time. 
virtual void NotifyTxStart(Time duration)
virtual void AckTimeoutReset()
Notify that ACK timeout has resetted.