|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/simulator.h"
108 m_lastRxReceivedOk (true),
202 return *std::max_element (
list.begin (),
list.end ());
316 uint32_t nIntSlots = (diff /
GetSlot ()).GetHigh () + 1;
336 && (!txop->
IsQosTxop () || !StaticCast<QosTxop> (txop)->EdcaDisabled ())
346 std::vector<Ptr<Txop> > internalCollisionTxops;
347 for (Txops::iterator j = i; j !=
m_txops.end (); j++,
k++)
353 NS_LOG_DEBUG (
"dcf " <<
k <<
" needs access. backoff expired. internal collision. slots=" <<
360 internalCollisionTxops.push_back (otherTxop);
376 for (
auto& collidingTxop : internalCollisionTxops)
378 m_feManager->NotifyInternalCollision (collidingTxop);
387 k = std::distance (
m_txops.begin (), i);
409 Time rxAccessStart = lastRxEnd + sifs;
420 Time accessGrantedStart;
423 accessGrantedStart =
MostRecent ({rxAccessStart,
426 ackTimeoutAccessStart,
427 ctsTimeoutAccessStart,
428 switchingAccessStart}
433 accessGrantedStart =
MostRecent ({rxAccessStart,
437 ackTimeoutAccessStart,
438 ctsTimeoutAccessStart,
439 switchingAccessStart}
442 NS_LOG_INFO (
"access grant start=" << accessGrantedStart <<
443 ", rx access start=" << rxAccessStart <<
444 ", busy access start=" << busyAccessStart <<
445 ", tx access start=" << txAccessStart <<
446 ", nav access start=" << navAccessStart);
447 return accessGrantedStart;
458 return mostRecentEvent;
493 if (txop->IsQosTxop ())
497 uint32_t
n =
std::min (nIntSlots, txop->GetBackoffSlots ());
499 Time backoffUpdateBound = backoffStart + (
n *
GetSlot ());
500 txop->UpdateBackoffSlotsNow (
n, backoffUpdateBound);
514 bool accessTimeoutNeeded =
false;
523 accessTimeoutNeeded =
true;
524 expectedBackoffEnd =
std::min (expectedBackoffEnd, tmp);
528 NS_LOG_DEBUG (
"Access timeout needed: " << accessTimeoutNeeded);
529 if (accessTimeoutNeeded)
531 NS_LOG_DEBUG (
"expected backoff end=" << expectedBackoffEnd);
553 NS_LOG_DEBUG (
"Backoff will resume at time " << resume <<
" with "
666 uint32_t remainingSlots = txop->GetBackoffSlots ();
667 if (remainingSlots > 0)
669 txop->UpdateBackoffSlotsNow (remainingSlots, now);
670 NS_ASSERT (txop->GetBackoffSlots () == 0);
674 txop->NotifyChannelSwitching ();
696 txop->NotifySleep ();
725 uint32_t remainingSlots = txop->GetBackoffSlots ();
726 if (remainingSlots > 0)
729 NS_ASSERT (txop->GetBackoffSlots () == 0);
733 txop->NotifyWakeUp ();
744 uint32_t remainingSlots = txop->GetBackoffSlots ();
745 if (remainingSlots > 0)
748 NS_ASSERT (txop->GetBackoffSlots () == 0);
782 if (newNavEnd > lastNavEnd)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual Time GetEifsNoDifs(void) const
Return the EIFS duration minus a DIFS.
void NotifySleep(void)
Notify listeners that we went to sleep.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void DisableEdcaFor(Ptr< Txop > qosTxop, Time duration)
Manage a set of ns3::Txop.
Time m_lastSwitchingStart
the last switching start time
Time GetSlot(void) const
Return the slot duration for this PHY.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void NotifyTxStartNow(Time duration)
Time m_lastTxDuration
the last transmit duration time
void SetupPhyListener(Ptr< WifiPhy > phy)
Set up listener for PHY events.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
receive notifications about PHY events.
static Time GetDelayLeft(const EventId &id)
Get the remaining time until this event will execute.
void NotifyWakeupNow(void)
Notify the Txop that the device has been resumed from sleep mode.
PhyListener * m_phyListener
the PHY listener
Ptr< FrameExchangeManager > m_feManager
pointer to the Frame Exchange Manager
virtual ChannelAccessStatus GetAccessStatus(void) const
void NotifyOffNow(void)
Notify the Txop that the device has been put in off mode.
Time m_lastNavDuration
the last NAV duration time
bool m_sleeping
flag whether it is in sleeping state
Time GetBackoffStartFor(Ptr< Txop > txop)
Return the time when the backoff procedure started for the given Txop.
void DoGrantDcfAccess(void)
Grant access to Txop using DCF/EDCF contention rules.
void NotifyRxEndErrorNow(void)
Notify the Txop that a packet reception was just completed unsuccessfully.
bool m_lastRxReceivedOk
the last receive OK
virtual Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
void NotifyChannelAccessRequested(void)
Notify the PHY that an access to the channel was requested.
EventId m_accessTimeout
the access timeout ID
Time m_lastRxDuration
the last receive duration time
void NotifySleepNow(void)
Notify the Txop that the device has been put in sleep mode.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
void NotifyOff(void)
Notify listeners that we went to switch off.
Time GetAckTxTime(void) const
Return the estimated Ack TX time for this PHY.
Time MostRecent(std::initializer_list< Time > list) const
Return the most recent time.
virtual ~ChannelAccessManager()
void NotifySwitchingStartNow(Time duration)
void RequestAccess(Ptr< Txop > txop)
void NotifyRxEndError(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and,...
void DoRestartAccessTimeoutIfNeeded(void)
Time m_lastBusyDuration
the last busy duration time
ns3::ChannelAccessManager * m_cam
ChannelAccessManager to forward events to.
void NotifyTxStart(Time duration, double txPowerDbm)
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Time m_lastBusyStart
the last busy start time
bool m_off
flag whether it is in off state
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Time m_lastCtsTimeoutEnd
the last CTS timeout end time
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
void NotifyNavStartNow(Time duration)
void NotifyAckTimeoutStartNow(Time duration)
Notify that ack timer has started for the given duration.
void NotifyOn(void)
Notify listeners that we went to switch on.
void NotifyCtsTimeoutStartNow(Time duration)
Notify that CTS timer has started for the given duration.
void SetupFrameExchangeManager(Ptr< FrameExchangeManager > feManager)
Set up the Frame Exchange Manager.
bool NeedBackoffUponAccess(Ptr< Txop > txop)
Determine if a new backoff needs to be generated when a packet is queued for transmission.
Simulation virtual time values and global simulation resolution.
void NotifySwitchingStart(Time duration)
void NotifyRxEndOk(void)
We have received the last bit of a packet for which NotifyRxStart was invoked first and,...
Txops m_txops
the vector of managed Txops
virtual bool IsQosTxop() const
Check for QoS TXOP.
void Add(Ptr< Txop > txop)
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV or CCA busy.
Time m_lastSwitchingDuration
the last switching duration time
void UpdateBackoff(void)
Update backoff slots for all Txops.
PhyListener(ns3::ChannelAccessManager *cam)
Create a PhyListener for the given ChannelAccessManager.
Time GetBackoffEndFor(Ptr< Txop > txop)
Return the time when the backoff procedure ended (or will ended) for the given Txop.
Ptr< WifiPhy > m_phy
pointer to the PHY
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time m_lastAckTimeoutEnd
the last Ack timeout end time
Time Seconds(double value)
Construct a Time in the indicated unit.
void NotifyRxStart(Time duration)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
virtual uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
void NotifyRxStartNow(Time duration)
virtual void NotifyAccessRequested(void)
Notify that access request has been received.
void NotifyCtsTimeoutResetNow(void)
Notify that CTS timer has reset.
void AccessTimeout(void)
Called when access timeout should occur (e.g.
virtual Time GetSlot(void) const
Return the slot duration for this PHY.
Time m_lastRxStart
the last receive start time
void NotifyWakeup(void)
Notify listeners that we woke up.
void RemovePhyListener(Ptr< WifiPhy > phy)
Remove current registered listener for PHY events.
virtual bool HasFramesToTransmit(void)
Check if the Txop has frames to transmit.
void DoDispose(void) override
Destructor implementation.
Time GetSifs(void) const
Return the Short Interframe Space (SIFS) for this PHY.
void NotifyRxEndOkNow(void)
Notify the Txop that a packet reception was just completed successfully.
void NotifyAckTimeoutResetNow(void)
Notify that ack timer has reset.
Time m_lastTxStart
the last transmit start time
Time GetAccessGrantStart(bool ignoreNav=false) const
Access will never be granted to the medium before the time returned by this method.
void NotifyNavResetNow(Time duration)
void NotifyOnNow(void)
Notify the Txop that the device has been resumed from off mode.
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
void NotifyMaybeCcaBusyStartNow(Time duration)
Time m_lastNavStart
the last NAV start time
void NotifyMaybeCcaBusyStart(Time duration)