22 #include "ns3/simulator.h" 108 m_lastRxReceivedOk (true),
304 NS_LOG_DEBUG (
"Internal collision (currently transmitting)");
359 std::vector<Ptr<Txop> > internalCollisionStates;
360 for (States::iterator j = i; j !=
m_states.end (); j++, k++)
366 NS_LOG_DEBUG (
"dcf " << k <<
" needs access. backoff expired. internal collision. slots=" <<
373 internalCollisionStates.push_back (otherState);
385 for (std::vector<
Ptr<Txop> >::iterator l = internalCollisionStates.begin ();
386 l != internalCollisionStates.end (); l++)
388 (*l)->NotifyInternalCollision ();
428 Time accessGrantedStart;
431 accessGrantedStart =
MostRecent (rxAccessStart,
434 ackTimeoutAccessStart,
435 ctsTimeoutAccessStart,
441 accessGrantedStart =
MostRecent (rxAccessStart,
445 ackTimeoutAccessStart,
446 ctsTimeoutAccessStart,
450 NS_LOG_INFO (
"access grant start=" << accessGrantedStart <<
451 ", rx access start=" << rxAccessStart <<
452 ", busy access start=" << busyAccessStart <<
453 ", tx access start=" << txAccessStart <<
454 ", nav access start=" << navAccessStart);
455 return accessGrantedStart;
465 return mostRecentEvent;
482 for (States::iterator i =
m_states.begin (); i !=
m_states.end (); i++, k++)
507 Time backoffUpdateBound = backoffStart + (
n *
m_slot);
521 bool accessTimeoutNeeded =
false;
531 accessTimeoutNeeded =
true;
532 expectedBackoffEnd =
std::min (expectedBackoffEnd, tmp);
536 NS_LOG_DEBUG (
"Access timeout needed: " << accessTimeoutNeeded);
537 if (accessTimeoutNeeded)
539 NS_LOG_DEBUG (
"expected backoff end=" << expectedBackoffEnd);
659 if (remainingSlots > 0)
722 if (remainingSlots > 0)
742 if (remainingSlots > 0)
779 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.
void GrantPcfAccess(Ptr< Txop > state)
Grant access to PCF.
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()
Time GetEifsNoDifs() const
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
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.
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.
void SetEifsNoDifs(Time eifsNoDifs)
receive notifications about phy events.
void NotifyCtsTimeoutResetNow()
Notify that CTS timer has reset.
void NotifyOffNow(void)
Notify the DCF that the device has been put in off mode.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Time m_lastRxEnd
the last receive end time
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.
void DoGrantAccess(void)
Grant access to DCF.
double f(double x, void *params)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void RegisterDcf(Ptr< ChannelAccessManager > dcf)
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
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 NotifyAckTimeoutResetNow()
Notify that ACK timer has reset.
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.
bool m_rxing
flag whether it is in receiving state
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)
Time MostRecent(Time a, Time b) const
Return the most recent time.
void DoDispose(void)
Destructor implementation.