A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends 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>

Public Member Functions

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 NotifySensingStartNow (Time duration)
 
void NotifySwitchingStartNow (Time duration, uint16_t toChannel)
 
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, Time h) 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_lastSensingDuration
 
Time m_lastSensingStart
 
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 175 of file dcf-manager.h.

Member Function Documentation

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 338 of file dcf-manager.cc.

References NS_LOG_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 443 of file dcf-manager.cc.

References ns3::DcfState::IsAccessRequested(), ns3::Simulator::Now(), and NS_LOG_FUNCTION.

Referenced by RequestAccess().

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 586 of file dcf-manager.cc.

References ns3::EventId::Cancel(), ns3::Simulator::GetDelayLeft(), ns3::Simulator::GetMaximumSimulationTime(), ns3::DcfState::IsAccessRequested(), ns3::EventId::IsExpired(), ns3::EventId::IsRunning(), ns3::Simulator::Now(), NS_LOG_FUNCTION, and ns3::Simulator::Schedule().

Referenced by NotifyNavResetNow(), and RequestAccess().

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 507 of file dcf-manager.cc.

References NS_LOG_FUNCTION, and NS_LOG_INFO.

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

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

References NS_LOG_FUNCTION.

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

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 674 of file dcf-manager.cc.

References ns3::Simulator::Now(), and NS_LOG_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 805 of file dcf-manager.cc.

References DoRestartAccessTimeoutIfNeeded(), ns3::Simulator::Now(), and NS_LOG_FUNCTION.

Referenced by ns3::MeshWifiInterfaceMac::SwitchFrequencyChannel().

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

Called at end of rx

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

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

void ns3::DcfManager::NotifyRxEndErrorNow ( void  )

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

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

References ns3::Simulator::Now(), and NS_LOG_FUNCTION.

void ns3::DcfManager::NotifyRxEndOkNow ( void  )

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

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

References ns3::Simulator::Now(), and NS_LOG_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 626 of file dcf-manager.cc.

References ns3::Simulator::Now(), and NS_LOG_FUNCTION.

void ns3::DcfManager::NotifySwitchingStartNow ( Time  duration,
uint16_t  toChannel 
)
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 685 of file dcf-manager.cc.

References ns3::EventId::Cancel(), ns3::EventId::IsRunning(), ns3::Simulator::Now(), NS_ASSERT, NS_LOG_FUNCTION, and ns3::DcfState::ResetCw().

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 654 of file dcf-manager.cc.

References ns3::Simulator::Now(), NS_ASSERT, and NS_LOG_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 419 of file dcf-manager.cc.

References DoGrantAccess(), DoRestartAccessTimeoutIfNeeded(), ns3::DcfState::IsAccessRequested(), NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by ns3::DcaTxop::RestartAccessIfNeeded().

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 325 of file dcf-manager.cc.

References NS_LOG_FUNCTION.

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

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 319 of file dcf-manager.cc.

References NS_LOG_FUNCTION.

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

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 313 of file dcf-manager.cc.

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

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


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