A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::DcfManager Class Reference

Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a single DCF within a MAC stack. Each ns3::DcfState has a priority implicitely associated with it (the priority is determined when the ns3::DcfState is added to the DcfManager: the first DcfState to be added gets the highest priority, the second, the second highest priority, and so on.) which is used to handle "internal" collisions. i.e., when two local DcfState are expected to get access to the medium at the same time, the highest priority local DcfState wins access to the medium and the other DcfState suffers a "internal" collision. More...

#include <dcf-manager.h>

+ Collaboration diagram for ns3::DcfManager:

Public Member Functions

 DcfManager ()
 ~DcfManager ()
void Add (DcfState *dcf)
Time GetEifsNoDifs () const
void NotifyAckTimeoutResetNow ()
void NotifyAckTimeoutStartNow (Time duration)
void NotifyCtsTimeoutResetNow ()
void NotifyCtsTimeoutStartNow (Time duration)
void NotifyMaybeCcaBusyStartNow (Time duration)
void NotifyNavResetNow (Time duration)
void NotifyNavStartNow (Time duration)
void NotifyRxEndErrorNow (void)
void NotifyRxEndOkNow (void)
void NotifyRxStartNow (Time duration)
void NotifySwitchingStartNow (Time duration)
void NotifyTxStartNow (Time duration)
void RequestAccess (DcfState *state)
void SetEifsNoDifs (Time eifsNoDifs)
void SetSifs (Time sifs)
void SetSlot (Time slotTime)
void SetupLowListener (Ptr< MacLow > low)
void SetupPhyListener (Ptr< WifiPhy > phy)

Private Types

typedef std::vector< DcfState * > States

Private Member Functions

void AccessTimeout (void)
void DoGrantAccess (void)
void DoRestartAccessTimeoutIfNeeded (void)
Time GetAccessGrantStart (void) const
Time GetBackoffEndFor (DcfState *state)
Time GetBackoffStartFor (DcfState *state)
bool IsBusy (void) const
Time MostRecent (Time a, Time b) const
Time MostRecent (Time a, Time b, Time c) const
Time MostRecent (Time a, Time b, Time c, Time d) const
Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f) const
Time MostRecent (Time a, Time b, Time c, Time d, Time e, Time f, Time g) const
void UpdateBackoff (void)

Private Attributes

EventId m_accessTimeout
Time m_eifsNoDifs
Time m_lastAckTimeoutEnd
Time m_lastBusyDuration
Time m_lastBusyStart
Time m_lastCtsTimeoutEnd
Time m_lastNavDuration
Time m_lastNavStart
Time m_lastRxDuration
Time m_lastRxEnd
bool m_lastRxReceivedOk
Time m_lastRxStart
Time m_lastSwitchingDuration
Time m_lastSwitchingStart
Time m_lastTxDuration
Time m_lastTxStart
LowDcfListenerm_lowListener
PhyListenerm_phyListener
bool m_rxing
Time m_sifs
bool m_sleeping
uint32_t m_slotTimeUs
States m_states

Detailed Description

Manage a set of ns3::DcfState

Handle a set of independent ns3::DcfState, each of which represents a single DCF within a MAC stack. Each ns3::DcfState has a priority implicitely associated with it (the priority is determined when the ns3::DcfState is added to the DcfManager: the first DcfState to be added gets the highest priority, the second, the second highest priority, and so on.) which is used to handle "internal" collisions. i.e., when two local DcfState are expected to get access to the medium at the same time, the highest priority local DcfState wins access to the medium and the other DcfState suffers a "internal" collision.

Definition at line 173 of file dcf-manager.h.

Member Typedef Documentation

typedef std::vector<DcfState *> ns3::DcfManager::States
private

Definition at line 309 of file dcf-manager.h.

Constructor & Destructor Documentation

ns3::DcfManager::DcfManager ( )

Definition at line 254 of file dcf-manager.cc.

ns3::DcfManager::~DcfManager ( )

Definition at line 277 of file dcf-manager.cc.

References m_lowListener, and m_phyListener.

Member Function Documentation

void ns3::DcfManager::AccessTimeout ( void  )
private

Definition at line 470 of file dcf-manager.cc.

References DoGrantAccess(), DoRestartAccessTimeoutIfNeeded(), and UpdateBackoff().

Referenced by DoRestartAccessTimeoutIfNeeded().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::Add ( DcfState dcf)
Parameters
dcfa new DcfState.

The DcfManager does not take ownership of this pointer so, the callee must make sure that the DcfState pointer will stay valid as long as the DcfManager is valid. Note that the order in which DcfState objects are added to a DcfManager matters: the first DcfState added has the highest priority, the second DcfState added, has the second highest priority, etc.

Definition at line 320 of file dcf-manager.cc.

References m_states.

Referenced by ns3::DcfManagerTest::AddDcfState(), ns3::DcaTxop::SetManager(), and ns3::EdcaTxopN::SetManager().

+ Here is the caller graph for this function:

void ns3::DcfManager::DoGrantAccess ( void  )
private

This is the first dcf we find with an expired backoff and which needs access to the medium. i.e., it has data to send.

all other dcfs with a lower priority whose backoff has expired and which needed access to the medium must be notified that we did get an internal collision.

Now, we notify all of these changes in one go. It is necessary to perform first the calculations of which states are colliding and then only apply the changes because applying the changes through notification could change the global state of the manager, and, thus, could change the result of the calculations.

Definition at line 416 of file dcf-manager.cc.

References GetBackoffEndFor(), ns3::DcfState::GetBackoffSlots(), ns3::DcfState::IsAccessRequested(), m_states, MY_DEBUG, ns3::DcfState::NotifyAccessGranted(), and ns3::Now().

Referenced by AccessTimeout(), and RequestAccess().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::DoRestartAccessTimeoutIfNeeded ( void  )
private

Is there a DcfState which needs to access the medium, and, if there is one, how many slots for AIFS+backoff does it require ?

Definition at line 552 of file dcf-manager.cc.

References AccessTimeout(), ns3::EventId::Cancel(), GetBackoffEndFor(), ns3::Simulator::GetDelayLeft(), ns3::Simulator::GetMaximumSimulationTime(), ns3::DcfState::IsAccessRequested(), ns3::EventId::IsExpired(), ns3::EventId::IsRunning(), m_accessTimeout, m_states, MY_DEBUG, ns3::Now(), ns3::Simulator::Now(), and ns3::Simulator::Schedule().

Referenced by AccessTimeout(), NotifyAckTimeoutResetNow(), NotifyCtsTimeoutResetNow(), NotifyNavResetNow(), and RequestAccess().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Time ns3::DcfManager::GetAccessGrantStart ( void  ) const
private

Access will never be granted to the medium before the time returned by this method.

Returns
the absolute time at which access could start to be granted

Definition at line 478 of file dcf-manager.cc.

References m_eifsNoDifs, m_lastAckTimeoutEnd, m_lastBusyDuration, m_lastBusyStart, m_lastCtsTimeoutEnd, m_lastNavDuration, m_lastNavStart, m_lastRxDuration, m_lastRxEnd, m_lastRxReceivedOk, m_lastRxStart, m_lastSwitchingDuration, m_lastSwitchingStart, m_lastTxDuration, m_lastTxStart, m_rxing, m_sifs, MostRecent(), and NS_LOG_INFO.

Referenced by GetBackoffStartFor().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Time ns3::DcfManager::GetBackoffEndFor ( DcfState state)
private

Definition at line 525 of file dcf-manager.cc.

References ns3::DcfState::GetBackoffSlots(), GetBackoffStartFor(), m_slotTimeUs, and ns3::MicroSeconds().

Referenced by DoGrantAccess(), and DoRestartAccessTimeoutIfNeeded().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Time ns3::DcfManager::GetBackoffStartFor ( DcfState state)
private

Definition at line 516 of file dcf-manager.cc.

References GetAccessGrantStart(), ns3::DcfState::GetAifsn(), ns3::DcfState::GetBackoffStart(), m_slotTimeUs, ns3::MicroSeconds(), and MostRecent().

Referenced by GetBackoffEndFor(), and UpdateBackoff().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Time ns3::DcfManager::GetEifsNoDifs ( ) const
Returns
value set previously using SetEifsNoDifs.

Definition at line 314 of file dcf-manager.cc.

References m_eifsNoDifs.

Referenced by ns3::RegularWifiMac::GetEifsNoDifs().

+ Here is the caller graph for this function:

bool ns3::DcfManager::IsBusy ( void  ) const
private

Definition at line 370 of file dcf-manager.cc.

References m_lastNavDuration, m_lastNavStart, m_lastTxDuration, m_lastTxStart, m_rxing, and ns3::Simulator::Now().

Referenced by RequestAccess().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Time ns3::DcfManager::MostRecent ( Time  a,
Time  b 
) const
private

Definition at line 326 of file dcf-manager.cc.

References ns3::Max().

Referenced by GetAccessGrantStart(), and GetBackoffStartFor().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Time ns3::DcfManager::MostRecent ( Time  a,
Time  b,
Time  c 
) const
private

Definition at line 331 of file dcf-manager.cc.

References ns3::Max().

+ Here is the call graph for this function:

Time ns3::DcfManager::MostRecent ( Time  a,
Time  b,
Time  c,
Time  d 
) const
private

Definition at line 339 of file dcf-manager.cc.

References ns3::Max().

+ Here is the call graph for this function:

Time ns3::DcfManager::MostRecent ( Time  a,
Time  b,
Time  c,
Time  d,
Time  e,
Time  f 
) const
private

Definition at line 347 of file dcf-manager.cc.

References ns3::Max().

+ Here is the call graph for this function:

Time ns3::DcfManager::MostRecent ( Time  a,
Time  b,
Time  c,
Time  d,
Time  e,
Time  f,
Time  g 
) const
private

Definition at line 358 of file dcf-manager.cc.

References ns3::Max().

+ Here is the call graph for this function:

void ns3::DcfManager::NotifyAckTimeoutResetNow ( )

Definition at line 740 of file dcf-manager.cc.

References DoRestartAccessTimeoutIfNeeded(), m_lastAckTimeoutEnd, and ns3::Now().

Referenced by ns3::LowDcfListener::AckTimeoutReset(), and ns3::DcfManagerTest::AddAckTimeoutReset().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::NotifyAckTimeoutStartNow ( Time  duration)

Definition at line 734 of file dcf-manager.cc.

References m_lastAckTimeoutEnd, ns3::Now(), ns3::Simulator::Now(), and NS_ASSERT.

Referenced by ns3::LowDcfListener::AckTimeoutStart(), and ns3::DcfManagerTest::NotifyAccessGranted().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::NotifyCtsTimeoutResetNow ( )

Definition at line 751 of file dcf-manager.cc.

References DoRestartAccessTimeoutIfNeeded(), m_lastCtsTimeoutEnd, and ns3::Now().

Referenced by ns3::LowDcfListener::CtsTimeoutReset().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::NotifyCtsTimeoutStartNow ( Time  duration)

Definition at line 746 of file dcf-manager.cc.

References m_lastCtsTimeoutEnd, and ns3::Now().

Referenced by ns3::LowDcfListener::CtsTimeoutStart().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::NotifyMaybeCcaBusyStartNow ( Time  duration)
Parameters
durationexpected duration of cca busy period

Notify the DCF that a CCA busy period has just started.

Definition at line 635 of file dcf-manager.cc.

References m_lastBusyDuration, m_lastBusyStart, MY_DEBUG, ns3::Now(), and UpdateBackoff().

Referenced by ns3::DcfManagerTest::AddCcaBusyEvt(), and ns3::PhyListener::NotifyMaybeCcaBusyStart().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::NotifyNavResetNow ( Time  duration)
Parameters
durationthe value of the received NAV.

Called at end of rx

If the nav reset indicates an end-of-nav which is earlier than the previous end-of-nav, the expected end of backoff might be later than previously thought so, we might need to restart a new access timeout.

Definition at line 704 of file dcf-manager.cc.

References DoRestartAccessTimeoutIfNeeded(), m_lastNavDuration, m_lastNavStart, MY_DEBUG, ns3::Now(), and UpdateBackoff().

Referenced by ns3::DcfManagerTest::AddNavReset(), ns3::LowDcfListener::NavReset(), and ns3::MeshWifiInterfaceMac::SwitchFrequencyChannel().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::NotifyNavStartNow ( Time  duration)
Parameters
durationthe value of the received NAV.

Called at end of rx

Definition at line 720 of file dcf-manager.cc.

References m_lastNavDuration, m_lastNavStart, MY_DEBUG, ns3::Now(), ns3::Simulator::Now(), NS_ASSERT, and UpdateBackoff().

Referenced by ns3::DcfManagerTest::AddNavStart(), and ns3::LowDcfListener::NavStart().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::NotifyRxEndErrorNow ( void  )

Notify the DCF that a packet reception was just completed unsuccessfully.

Definition at line 608 of file dcf-manager.cc.

References m_lastRxEnd, m_lastRxReceivedOk, m_rxing, MY_DEBUG, and ns3::Now().

Referenced by ns3::DcfManagerTest::AddRxErrorEvt(), and ns3::PhyListener::NotifyRxEndError().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::NotifyRxEndOkNow ( void  )

Notify the DCF that a packet reception was just completed successfully.

Definition at line 600 of file dcf-manager.cc.

References m_lastRxEnd, m_lastRxReceivedOk, m_rxing, MY_DEBUG, and ns3::Now().

Referenced by ns3::DcfManagerTest::AddRxOkEvt(), and ns3::PhyListener::NotifyRxEndOk().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::NotifyRxStartNow ( Time  duration)
Parameters
durationexpected duration of reception

Notify the DCF that a packet reception started for the expected duration.

Definition at line 591 of file dcf-manager.cc.

References m_lastRxDuration, m_lastRxStart, m_rxing, MY_DEBUG, ns3::Now(), and UpdateBackoff().

Referenced by ns3::DcfManagerTest::AddRxErrorEvt(), ns3::DcfManagerTest::AddRxInsideSifsEvt(), ns3::DcfManagerTest::AddRxOkEvt(), ns3::DcfManagerTest::AddRxStartEvt(), and ns3::PhyListener::NotifyRxStart().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::NotifySwitchingStartNow ( Time  duration)
Parameters
durationexpected duration of channel switching period

Notify the DCF that a channel switching period has just started. During switching state, new packets can be enqueued in DcaTxop/EdcaTxop but they won't access to the medium until the end of the channel switching.

Definition at line 645 of file dcf-manager.cc.

References ns3::EventId::Cancel(), ns3::DcfState::GetBackoffSlots(), ns3::EventId::IsRunning(), ns3::DcfState::m_accessRequested, m_accessTimeout, m_lastAckTimeoutEnd, m_lastBusyDuration, m_lastBusyStart, m_lastCtsTimeoutEnd, m_lastNavDuration, m_lastNavStart, m_lastRxDuration, m_lastRxEnd, m_lastRxReceivedOk, m_lastRxStart, m_lastSwitchingDuration, m_lastSwitchingStart, m_lastTxDuration, m_lastTxStart, m_rxing, m_states, MY_DEBUG, ns3::DcfState::NotifyChannelSwitching(), ns3::Now(), NS_ASSERT, ns3::DcfState::ResetCw(), and ns3::DcfState::UpdateBackoffSlotsNow().

Referenced by ns3::DcfManagerTest::AddSwitchingEvt(), and ns3::PhyListener::NotifySwitchingStart().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::NotifyTxStartNow ( Time  duration)
Parameters
durationexpected duration of transmission

Notify the DCF that a packet transmission was just started and is expected to last for the specified duration.

Definition at line 616 of file dcf-manager.cc.

References m_lastRxDuration, m_lastRxEnd, m_lastRxReceivedOk, m_lastRxStart, m_lastTxDuration, m_lastTxStart, m_rxing, m_sifs, MY_DEBUG, ns3::Now(), ns3::Simulator::Now(), NS_ASSERT, and UpdateBackoff().

Referenced by ns3::DcfManagerTest::AddTxEvt(), ns3::DcfManagerTest::NotifyAccessGranted(), and ns3::PhyListener::NotifyTxStart().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::RequestAccess ( DcfState state)
Parameters
statea DcfState

Notify the DcfManager that a specific DcfState needs access to the medium. The DcfManager is then responsible for starting an access timer and, invoking DcfState::DoNotifyAccessGranted when the access is granted if it ever gets granted.

If there is a collision, generate a backoff by notifying the collision to the user.

Definition at line 393 of file dcf-manager.cc.

References DoGrantAccess(), DoRestartAccessTimeoutIfNeeded(), ns3::DcfState::GetBackoffSlots(), ns3::DcfState::IsAccessRequested(), IsBusy(), MY_DEBUG, ns3::DcfState::NotifyAccessRequested(), ns3::DcfState::NotifyCollision(), NS_ASSERT, and UpdateBackoff().

Referenced by ns3::DcfManagerTest::DoAccessRequest(), ns3::EdcaTxopN::RestartAccessIfNeeded(), ns3::DcaTxop::RestartAccessIfNeeded(), ns3::EdcaTxopN::StartAccessIfNeeded(), and ns3::DcaTxop::StartAccessIfNeeded().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::SetEifsNoDifs ( Time  eifsNoDifs)
Parameters
eifsNoDifsthe duration of a EIFS minus the duration of DIFS.

It is a bad idea to call this method after RequestAccess or one of the Notify methods has been invoked.

Definition at line 309 of file dcf-manager.cc.

References m_eifsNoDifs.

Referenced by ns3::RegularWifiMac::SetEifsNoDifs(), and ns3::DcfManagerTest::StartTest().

+ Here is the caller graph for this function:

void ns3::DcfManager::SetSifs ( Time  sifs)
Parameters
sifsthe duration of a SIFS.

It is a bad idea to call this method after RequestAccess or one of the Notify methods has been invoked.

Definition at line 304 of file dcf-manager.cc.

References m_sifs.

Referenced by ns3::RegularWifiMac::SetSifs(), and ns3::DcfManagerTest::StartTest().

+ Here is the caller graph for this function:

void ns3::DcfManager::SetSlot ( Time  slotTime)
Parameters
slotTimethe duration of a slot.

It is a bad idea to call this method after RequestAccess or one of the Notify methods has been invoked.

Definition at line 299 of file dcf-manager.cc.

References ns3::Time::GetMicroSeconds(), and m_slotTimeUs.

Referenced by ns3::RegularWifiMac::SetSlot(), and ns3::DcfManagerTest::StartTest().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::SetupLowListener ( Ptr< MacLow low)

Definition at line 292 of file dcf-manager.cc.

References m_lowListener, and ns3::MacLow::RegisterDcfListener().

Referenced by ns3::RegularWifiMac::RegularWifiMac().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::SetupPhyListener ( Ptr< WifiPhy phy)

Definition at line 286 of file dcf-manager.cc.

References m_phyListener, and ns3::WifiPhy::RegisterListener().

Referenced by ns3::RegularWifiMac::SetWifiPhy().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::DcfManager::UpdateBackoff ( void  )
private

Member Data Documentation

EventId ns3::DcfManager::m_accessTimeout
private

Definition at line 329 of file dcf-manager.h.

Referenced by DoRestartAccessTimeoutIfNeeded(), and NotifySwitchingStartNow().

Time ns3::DcfManager::m_eifsNoDifs
private

Definition at line 328 of file dcf-manager.h.

Referenced by GetAccessGrantStart(), GetEifsNoDifs(), and SetEifsNoDifs().

Time ns3::DcfManager::m_lastAckTimeoutEnd
private
Time ns3::DcfManager::m_lastBusyDuration
private
Time ns3::DcfManager::m_lastBusyStart
private
Time ns3::DcfManager::m_lastCtsTimeoutEnd
private
Time ns3::DcfManager::m_lastNavDuration
private
Time ns3::DcfManager::m_lastNavStart
private
Time ns3::DcfManager::m_lastRxDuration
private
Time ns3::DcfManager::m_lastRxEnd
private
bool ns3::DcfManager::m_lastRxReceivedOk
private
Time ns3::DcfManager::m_lastRxStart
private
Time ns3::DcfManager::m_lastSwitchingDuration
private

Definition at line 325 of file dcf-manager.h.

Referenced by GetAccessGrantStart(), and NotifySwitchingStartNow().

Time ns3::DcfManager::m_lastSwitchingStart
private

Definition at line 324 of file dcf-manager.h.

Referenced by GetAccessGrantStart(), and NotifySwitchingStartNow().

Time ns3::DcfManager::m_lastTxDuration
private
Time ns3::DcfManager::m_lastTxStart
private
LowDcfListener* ns3::DcfManager::m_lowListener
private

Definition at line 333 of file dcf-manager.h.

Referenced by SetupLowListener(), and ~DcfManager().

PhyListener* ns3::DcfManager::m_phyListener
private

Definition at line 332 of file dcf-manager.h.

Referenced by SetupPhyListener(), and ~DcfManager().

bool ns3::DcfManager::m_rxing
private
Time ns3::DcfManager::m_sifs
private

Definition at line 331 of file dcf-manager.h.

Referenced by GetAccessGrantStart(), NotifyTxStartNow(), and SetSifs().

bool ns3::DcfManager::m_sleeping
private

Definition at line 327 of file dcf-manager.h.

uint32_t ns3::DcfManager::m_slotTimeUs
private

Definition at line 330 of file dcf-manager.h.

Referenced by GetBackoffEndFor(), GetBackoffStartFor(), SetSlot(), and UpdateBackoff().

States ns3::DcfManager::m_states
private

The documentation for this class was generated from the following files: