22 #include "ns3/simulator.h" 108 m_lastRxReceivedOk (true),
171 low->RegisterDcf (
this);
213 return *std::max_element (
list.begin (),
list.end ());
288 NS_LOG_DEBUG (
"Internal collision (currently transmitting)");
343 std::vector<Ptr<Txop> > internalCollisionStates;
344 for (States::iterator j = i; j !=
m_states.end (); j++, k++)
350 NS_LOG_DEBUG (
"dcf " << k <<
" needs access. backoff expired. internal collision. slots=" <<
357 internalCollisionStates.push_back (otherState);
369 for (std::vector<
Ptr<Txop> >::iterator l = internalCollisionStates.begin ();
370 l != internalCollisionStates.end (); l++)
372 (*l)->NotifyInternalCollision ();
412 Time accessGrantedStart;
415 accessGrantedStart =
MostRecent ({rxAccessStart,
418 ackTimeoutAccessStart,
419 ctsTimeoutAccessStart,
420 switchingAccessStart}
425 accessGrantedStart =
MostRecent ({rxAccessStart,
429 ackTimeoutAccessStart,
430 ctsTimeoutAccessStart,
431 switchingAccessStart}
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;
449 return mostRecentEvent;
466 for (States::iterator i =
m_states.begin (); i !=
m_states.end (); i++, k++)
491 Time backoffUpdateBound = backoffStart + (
n *
m_slot);
505 bool accessTimeoutNeeded =
false;
515 accessTimeoutNeeded =
true;
516 expectedBackoffEnd =
std::min (expectedBackoffEnd, tmp);
520 NS_LOG_DEBUG (
"Access timeout needed: " << accessTimeoutNeeded);
521 if (accessTimeoutNeeded)
523 NS_LOG_DEBUG (
"expected backoff end=" << expectedBackoffEnd);
641 if (remainingSlots > 0)
704 if (remainingSlots > 0)
724 if (remainingSlots > 0)
761 if (newNavEnd > lastNavEnd)
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
Time GetBackoffEndFor(Ptr< Txop > state)
Return the time when the backoff procedure ended (or will ended) for the given Txop.
Simulation virtual time values and global simulation resolution.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Time m_eifsNoDifs
EIFS no DIFS time.
void UpdateBackoff(void)
Update backoff slots for all Txops.
bool m_off
flag whether it is in off state
uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
void NotifyMaybeCcaBusyStart(Time duration)
Time m_lastRxDuration
the last receive duration time
Time m_lastCtsTimeoutEnd
the last CTS timeout end time
void NotifySwitchingStart(Time duration)
void NotifyOnNow(void)
Notify the DCF that the device has been resumed from off mode.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
virtual void NotifyAccessGranted(void)
Notify the DCF that access has been granted.
virtual ~ChannelAccessManager()
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for Phy 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.
void NotifyOff(void)
Notify listeners that we went to switch off.
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
void NotifyMaybeCcaBusyStartNow(Time duration)
Time m_lastBusyStart
the last busy start time
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV or CCA busy.
EventId m_accessTimeout
the access timeout ID
Time MostRecent(std::initializer_list< Time > list) const
Return the most recent time.
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for Phy events.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Manage a set of ns3::TxopHandle a set of independent ns3::Txop, each of which represents a single DCF...
bool m_sleeping
flag whether it is in sleeping state
Time m_lastTxDuration
the last transmit duration time
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
void NotifyRxStartNow(Time duration)
void NotifyRxEndError(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
Time m_lastRxStart
the last receive start time
virtual void NotifyOff(void)
When off operation occurs, the queue gets cleaned up.
Time m_lastBusyDuration
the last busy duration time
void NotifyRxEndErrorNow(void)
Notify the DCF that a packet reception was just completed unsuccessfully.
Time m_lastNavDuration
the last NAV duration time
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
Ptr< WifiPhy > m_phy
Ptr to the PHY.
PhyListener(ns3::ChannelAccessManager *dcf)
Create a PhyListener for the given ChannelAccessManager.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Time GetEifsNoDifs(void) const
void SetEifsNoDifs(Time eifsNoDifs)
receive notifications about phy events.
void NotifyOffNow(void)
Notify the DCF that the device has been put in off mode.
Time m_lastRxEnd
the last receive end time
void NotifyChannelAccessRequested(void)
Notify the PHY that an access to the channel was requested.
Time m_lastSwitchingStart
the last switching start time
void NotifyWakeup(void)
Notify listeners that we woke up.
void NotifySleepNow(void)
Notify the DCF that the device has been put in sleep mode.
void NotifyTxStart(Time duration, double txPowerDbm)
virtual bool IsAccessRequested(void) const
virtual bool IsQosTxop() const
Check for QoS TXOP.
Time m_lastTxStart
the last transmit start time
void NotifyNavResetNow(Time duration)
void NotifyAckTimeoutStartNow(Time duration)
Notify that ACK timer has started for the given duration.
void NotifySleep(void)
Notify listeners that we went to sleep.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
void NotifyOn(void)
Notify listeners that we went to switch on.
void NotifyRxEndOkNow(void)
Notify the DCF that a packet reception was just completed successfully.
Time GetAccessGrantStart(bool ignoreNav=false) const
Access will never be granted to the medium before the time returned by this method.
virtual void NotifyOn(void)
When on operation occurs, channel access will be started.
bool m_lastRxReceivedOk
the last receive OK
PhyListener * m_phyListener
the phy listener
void NotifyCtsTimeoutResetNow(void)
Notify that CTS timer has reset.
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
ns3::ChannelAccessManager * m_dcf
ChannelAccessManager to forward events to.
static Time Now(void)
Return the current simulation virtual time.
virtual void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
void NotifyRxStart(Time duration)
void DoGrantPcfAccess(Ptr< Txop > state)
Grant access to PCF.
void DoGrantDcfAccess(void)
Grant access to DCF.
bool m_accessRequested
flag whether channel access is already requested
Time m_lastNavStart
the last NAV start time
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
virtual void NotifyCollision(void)
Notify the DCF that collision has occurred.
Time Seconds(double value)
Construct a Time in the indicated unit.
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
void NotifySwitchingStartNow(Time duration)
void NotifyNavStartNow(Time duration)
States m_states
the DCF states
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Time m_lastSwitchingDuration
the last switching duration time
void SetSlot(Time slotTime)
void Add(Ptr< Txop > dcf)
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
void AccessTimeout(void)
Called when access timeout should occur (e.g.
void NotifyTxStartNow(Time duration)
virtual void NotifyAccessRequested(void)
Notify that access request has been received.
Time GetBackoffStartFor(Ptr< Txop > state)
Return the time when the backoff procedure started for the given Txop.
void SetupLow(Ptr< MacLow > low)
Set up listener for MacLow events.
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
void NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and...
void DoRestartAccessTimeoutIfNeeded(void)
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
void NotifyWakeupNow(void)
Notify the DCF that the device has been resumed from sleep mode.
void RequestAccess(Ptr< Txop > state, bool isCfPeriod=false)
Time m_lastAckTimeoutEnd
the last ACK timeout end time
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
bool IsWithinAifs(Ptr< Txop > state) const
Check if the device is between frames (in DIFS or AIFS interval)
void DoDispose(void)
Destructor implementation.
void NotifyAckTimeoutResetNow(void)
Notify that ACK timer has reset.