Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a single DCF within a MAC stack. More...
#include <dcf-manager.h>
Public Member Functions | |
DcfManager () | |
~DcfManager () | |
void | Add (DcfState *dcf) |
Time | GetEifsNoDifs () const |
void | NotifyAckTimeoutResetNow () |
Notify that ACK timer has resetted. More... | |
void | NotifyAckTimeoutStartNow (Time duration) |
Notify that ACK timer has started for the given duration. More... | |
void | NotifyCtsTimeoutResetNow () |
Notify that CTS timer has resetted. More... | |
void | NotifyCtsTimeoutStartNow (Time duration) |
Notify that CTS timer has started for the given duration. More... | |
void | NotifyMaybeCcaBusyStartNow (Time duration) |
void | NotifyNavResetNow (Time duration) |
void | NotifyNavStartNow (Time duration) |
void | NotifyRxEndErrorNow (void) |
Notify the DCF that a packet reception was just completed unsuccessfully. More... | |
void | NotifyRxEndOkNow (void) |
Notify the DCF that a packet reception was just completed successfully. More... | |
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) |
Set up listener for MacLow events. More... | |
void | SetupPhyListener (Ptr< WifiPhy > phy) |
Set up listener for Phy events. More... | |
Private Types | |
typedef std::vector< DcfState * > | States |
typedef for a vector of DcfStates More... | |
Private Member Functions | |
void | AccessTimeout (void) |
Called when access timeout should occur (e.g. More... | |
void | DoGrantAccess (void) |
Grant access to DCF. More... | |
void | DoRestartAccessTimeoutIfNeeded (void) |
Time | GetAccessGrantStart (void) const |
Access will never be granted to the medium before the time returned by this method. More... | |
Time | GetBackoffEndFor (DcfState *state) |
Return the time when the backoff procedure ended (or will ended) for the given DcfState. More... | |
Time | GetBackoffStartFor (DcfState *state) |
Return the time when the backoff procedure started for the given DcfState. More... | |
bool | IsBusy (void) const |
Check if the device is busy sending or receiving, or NAV busy. More... | |
Time | MostRecent (Time a, Time b) const |
Return the most recent time. More... | |
Time | MostRecent (Time a, Time b, Time c) const |
Return the most recent time. More... | |
Time | MostRecent (Time a, Time b, Time c, Time d) const |
Return the most recent time. More... | |
Time | MostRecent (Time a, Time b, Time c, Time d, Time e, Time f) const |
Return the most recent time. More... | |
Time | MostRecent (Time a, Time b, Time c, Time d, Time e, Time f, Time g) const |
Return the most recent time. More... | |
void | UpdateBackoff (void) |
Update backoff slots for all DcfStates. More... | |
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 229 of file dcf-manager.h.
|
private |
typedef for a vector of DcfStates
Definition at line 472 of file dcf-manager.h.
ns3::DcfManager::DcfManager | ( | ) |
Definition at line 262 of file dcf-manager.cc.
References NS_LOG_FUNCTION.
ns3::DcfManager::~DcfManager | ( | ) |
Definition at line 286 of file dcf-manager.cc.
References m_lowListener, and m_phyListener.
|
private |
Called when access timeout should occur (e.g.
backoff procedure expired).
Definition at line 502 of file dcf-manager.cc.
References DoGrantAccess(), DoRestartAccessTimeoutIfNeeded(), NS_LOG_FUNCTION, and UpdateBackoff().
Referenced by DoRestartAccessTimeoutIfNeeded().
void ns3::DcfManager::Add | ( | DcfState * | dcf | ) |
dcf | a 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 343 of file dcf-manager.cc.
References m_states, and NS_LOG_FUNCTION.
Referenced by ns3::DcfManagerTest::AddDcfState(), ns3::DcaTxop::SetManager(), and ns3::EdcaTxopN::SetManager().
|
private |
Grant access to DCF.
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 447 of file dcf-manager.cc.
References GetBackoffEndFor(), ns3::DcfState::GetBackoffSlots(), ns3::DcfState::IsAccessRequested(), m_states, MY_DEBUG, ns3::DcfState::NotifyAccessGranted(), ns3::Simulator::Now(), and NS_LOG_FUNCTION.
Referenced by AccessTimeout(), and RequestAccess().
|
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 588 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::Simulator::Now(), NS_LOG_FUNCTION, and ns3::Simulator::Schedule().
Referenced by AccessTimeout(), NotifyAckTimeoutResetNow(), NotifyCtsTimeoutResetNow(), NotifyNavResetNow(), and RequestAccess().
|
private |
Access will never be granted to the medium before the time returned by this method.
Definition at line 511 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(), NS_LOG_FUNCTION, and NS_LOG_INFO.
Referenced by GetBackoffStartFor().
Return the time when the backoff procedure ended (or will ended) for the given DcfState.
state |
Definition at line 560 of file dcf-manager.cc.
References ns3::DcfState::GetBackoffSlots(), GetBackoffStartFor(), and m_slotTimeUs.
Referenced by DoGrantAccess(), and DoRestartAccessTimeoutIfNeeded().
Return the time when the backoff procedure started for the given DcfState.
state |
Definition at line 550 of file dcf-manager.cc.
References GetAccessGrantStart(), ns3::DcfState::GetAifsn(), ns3::DcfState::GetBackoffStart(), m_slotTimeUs, MostRecent(), and NS_LOG_FUNCTION.
Referenced by GetBackoffEndFor(), and UpdateBackoff().
Time ns3::DcfManager::GetEifsNoDifs | ( | ) | const |
Definition at line 336 of file dcf-manager.cc.
References m_eifsNoDifs, and NS_LOG_FUNCTION.
Referenced by ns3::RegularWifiMac::GetEifsNoDifs().
|
private |
Check if the device is busy sending or receiving, or NAV busy.
Definition at line 399 of file dcf-manager.cc.
References m_lastNavDuration, m_lastNavStart, m_lastTxDuration, m_lastTxStart, m_rxing, ns3::Simulator::Now(), and NS_LOG_FUNCTION.
Referenced by RequestAccess().
Return the most recent time.
a | |
b |
Definition at line 350 of file dcf-manager.cc.
References ns3::Max(), and NS_LOG_FUNCTION.
Referenced by GetAccessGrantStart(), and GetBackoffStartFor().
Return the most recent time.
a | |
b | |
c |
Definition at line 356 of file dcf-manager.cc.
References ns3::Max(), and NS_LOG_FUNCTION.
Return the most recent time.
a | |
b | |
c | |
d |
Definition at line 365 of file dcf-manager.cc.
References ns3::Max(), and NS_LOG_FUNCTION.
Return the most recent time.
a | |
b | |
c | |
d | |
e | |
f |
Definition at line 374 of file dcf-manager.cc.
References ns3::Max(), and NS_LOG_FUNCTION.
|
private |
Return the most recent time.
a | |
b | |
c | |
d | |
e | |
f | |
g |
Definition at line 386 of file dcf-manager.cc.
References ns3::Max(), and NS_LOG_FUNCTION.
void ns3::DcfManager::NotifyAckTimeoutResetNow | ( | ) |
Notify that ACK timer has resetted.
Definition at line 786 of file dcf-manager.cc.
References DoRestartAccessTimeoutIfNeeded(), m_lastAckTimeoutEnd, ns3::Simulator::Now(), and NS_LOG_FUNCTION.
Referenced by ns3::LowDcfListener::AckTimeoutReset(), and ns3::DcfManagerTest::AddAckTimeoutReset().
void ns3::DcfManager::NotifyAckTimeoutStartNow | ( | Time | duration | ) |
Notify that ACK timer has started for the given duration.
duration |
Definition at line 779 of file dcf-manager.cc.
References m_lastAckTimeoutEnd, ns3::Simulator::Now(), NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ns3::LowDcfListener::AckTimeoutStart(), and ns3::DcfManagerTest::NotifyAccessGranted().
void ns3::DcfManager::NotifyCtsTimeoutResetNow | ( | ) |
Notify that CTS timer has resetted.
Definition at line 799 of file dcf-manager.cc.
References DoRestartAccessTimeoutIfNeeded(), m_lastCtsTimeoutEnd, ns3::Simulator::Now(), and NS_LOG_FUNCTION.
Referenced by ns3::LowDcfListener::CtsTimeoutReset().
void ns3::DcfManager::NotifyCtsTimeoutStartNow | ( | Time | duration | ) |
Notify that CTS timer has started for the given duration.
duration |
Definition at line 793 of file dcf-manager.cc.
References m_lastCtsTimeoutEnd, ns3::Simulator::Now(), and NS_LOG_FUNCTION.
Referenced by ns3::LowDcfListener::CtsTimeoutStart().
void ns3::DcfManager::NotifyMaybeCcaBusyStartNow | ( | Time | duration | ) |
duration | expected duration of cca busy period |
Notify the DCF that a CCA busy period has just started.
Definition at line 676 of file dcf-manager.cc.
References m_lastBusyDuration, m_lastBusyStart, MY_DEBUG, ns3::Simulator::Now(), NS_LOG_FUNCTION, and UpdateBackoff().
Referenced by ns3::DcfManagerTest::AddCcaBusyEvt(), and ns3::PhyListener::NotifyMaybeCcaBusyStart().
void ns3::DcfManager::NotifyNavResetNow | ( | Time | duration | ) |
duration | the 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 747 of file dcf-manager.cc.
References DoRestartAccessTimeoutIfNeeded(), m_lastNavDuration, m_lastNavStart, MY_DEBUG, ns3::Simulator::Now(), NS_LOG_FUNCTION, and UpdateBackoff().
Referenced by ns3::DcfManagerTest::AddNavReset(), ns3::LowDcfListener::NavReset(), and ns3::MeshWifiInterfaceMac::SwitchFrequencyChannel().
void ns3::DcfManager::NotifyNavStartNow | ( | Time | duration | ) |
duration | the value of the received NAV. |
Called at end of rx
Definition at line 764 of file dcf-manager.cc.
References m_lastNavDuration, m_lastNavStart, MY_DEBUG, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_FUNCTION, and UpdateBackoff().
Referenced by ns3::DcfManagerTest::AddNavStart(), and ns3::LowDcfListener::NavStart().
void ns3::DcfManager::NotifyRxEndErrorNow | ( | void | ) |
Notify the DCF that a packet reception was just completed unsuccessfully.
Definition at line 647 of file dcf-manager.cc.
References m_lastRxEnd, m_lastRxReceivedOk, m_rxing, MY_DEBUG, ns3::Simulator::Now(), and NS_LOG_FUNCTION.
Referenced by ns3::DcfManagerTest::AddRxErrorEvt(), and ns3::PhyListener::NotifyRxEndError().
void ns3::DcfManager::NotifyRxEndOkNow | ( | void | ) |
Notify the DCF that a packet reception was just completed successfully.
Definition at line 638 of file dcf-manager.cc.
References m_lastRxEnd, m_lastRxReceivedOk, m_rxing, MY_DEBUG, ns3::Simulator::Now(), and NS_LOG_FUNCTION.
Referenced by ns3::DcfManagerTest::AddRxOkEvt(), and ns3::PhyListener::NotifyRxEndOk().
void ns3::DcfManager::NotifyRxStartNow | ( | Time | duration | ) |
duration | expected duration of reception |
Notify the DCF that a packet reception started for the expected duration.
Definition at line 628 of file dcf-manager.cc.
References m_lastRxDuration, m_lastRxStart, m_rxing, MY_DEBUG, ns3::Simulator::Now(), NS_LOG_FUNCTION, and UpdateBackoff().
Referenced by ns3::DcfManagerTest::AddRxErrorEvt(), ns3::DcfManagerTest::AddRxInsideSifsEvt(), ns3::DcfManagerTest::AddRxOkEvt(), ns3::DcfManagerTest::AddRxStartEvt(), and ns3::PhyListener::NotifyRxStart().
void ns3::DcfManager::NotifySwitchingStartNow | ( | Time | duration | ) |
duration | expected 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 687 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::Simulator::Now(), NS_ASSERT, NS_LOG_FUNCTION, ns3::DcfState::ResetCw(), and ns3::DcfState::UpdateBackoffSlotsNow().
Referenced by ns3::DcfManagerTest::AddSwitchingEvt(), and ns3::PhyListener::NotifySwitchingStart().
void ns3::DcfManager::NotifyTxStartNow | ( | Time | duration | ) |
duration | expected 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 656 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::Simulator::Now(), NS_ASSERT, NS_LOG_FUNCTION, and UpdateBackoff().
Referenced by ns3::DcfManagerTest::AddTxEvt(), ns3::DcfManagerTest::NotifyAccessGranted(), and ns3::PhyListener::NotifyTxStart().
void ns3::DcfManager::RequestAccess | ( | DcfState * | state | ) |
state | a 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 423 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, NS_LOG_FUNCTION, and UpdateBackoff().
Referenced by ns3::DcfManagerTest::DoAccessRequest(), ns3::DcaTxop::RestartAccessIfNeeded(), ns3::EdcaTxopN::RestartAccessIfNeeded(), ns3::DcaTxop::StartAccessIfNeeded(), and ns3::EdcaTxopN::StartAccessIfNeeded().
void ns3::DcfManager::SetEifsNoDifs | ( | Time | eifsNoDifs | ) |
eifsNoDifs | the 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 330 of file dcf-manager.cc.
References m_eifsNoDifs, and NS_LOG_FUNCTION.
Referenced by ns3::RegularWifiMac::SetEifsNoDifs(), and ns3::DcfManagerTest::StartTest().
void ns3::DcfManager::SetSifs | ( | Time | sifs | ) |
sifs | the 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 324 of file dcf-manager.cc.
References m_sifs, and NS_LOG_FUNCTION.
Referenced by ns3::RegularWifiMac::SetSifs(), and ns3::DcfManagerTest::StartTest().
void ns3::DcfManager::SetSlot | ( | Time | slotTime | ) |
slotTime | the 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 318 of file dcf-manager.cc.
References ns3::Time::GetMicroSeconds(), m_slotTimeUs, and NS_LOG_FUNCTION.
Referenced by ns3::RegularWifiMac::SetSlot(), and ns3::DcfManagerTest::StartTest().
Set up listener for MacLow events.
low |
Definition at line 306 of file dcf-manager.cc.
References m_lowListener, and NS_LOG_FUNCTION.
Referenced by ns3::OcbWifiMac::OcbWifiMac(), and ns3::RegularWifiMac::RegularWifiMac().
Set up listener for Phy events.
phy |
Definition at line 295 of file dcf-manager.cc.
References m_phyListener, NS_LOG_FUNCTION, and ns3::WifiPhy::RegisterListener().
Referenced by ns3::RegularWifiMac::SetWifiPhy().
|
private |
Update backoff slots for all DcfStates.
Definition at line 566 of file dcf-manager.cc.
References ns3::DcfState::GetBackoffSlots(), GetBackoffStartFor(), m_slotTimeUs, m_states, MY_DEBUG, ns3::Simulator::Now(), NS_LOG_FUNCTION, and ns3::DcfState::UpdateBackoffSlotsNow().
Referenced by AccessTimeout(), NotifyMaybeCcaBusyStartNow(), NotifyNavResetNow(), NotifyNavStartNow(), NotifyRxStartNow(), NotifyTxStartNow(), and RequestAccess().
|
private |
Definition at line 491 of file dcf-manager.h.
Referenced by DoRestartAccessTimeoutIfNeeded(), and NotifySwitchingStartNow().
|
private |
Definition at line 490 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), GetEifsNoDifs(), and SetEifsNoDifs().
|
private |
Definition at line 475 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), NotifyAckTimeoutResetNow(), NotifyAckTimeoutStartNow(), and NotifySwitchingStartNow().
|
private |
Definition at line 486 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), NotifyMaybeCcaBusyStartNow(), and NotifySwitchingStartNow().
|
private |
Definition at line 485 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), NotifyMaybeCcaBusyStartNow(), and NotifySwitchingStartNow().
|
private |
Definition at line 476 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), NotifyCtsTimeoutResetNow(), NotifyCtsTimeoutStartNow(), and NotifySwitchingStartNow().
|
private |
Definition at line 478 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), IsBusy(), NotifyNavResetNow(), NotifyNavStartNow(), and NotifySwitchingStartNow().
|
private |
Definition at line 477 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), IsBusy(), NotifyNavResetNow(), NotifyNavStartNow(), and NotifySwitchingStartNow().
|
private |
Definition at line 480 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), NotifyRxStartNow(), NotifySwitchingStartNow(), and NotifyTxStartNow().
|
private |
Definition at line 482 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), NotifyRxEndErrorNow(), NotifyRxEndOkNow(), NotifySwitchingStartNow(), and NotifyTxStartNow().
|
private |
Definition at line 481 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), NotifyRxEndErrorNow(), NotifyRxEndOkNow(), NotifySwitchingStartNow(), and NotifyTxStartNow().
|
private |
Definition at line 479 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), NotifyRxStartNow(), NotifySwitchingStartNow(), and NotifyTxStartNow().
|
private |
Definition at line 488 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), and NotifySwitchingStartNow().
|
private |
Definition at line 487 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), and NotifySwitchingStartNow().
|
private |
Definition at line 484 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), IsBusy(), NotifySwitchingStartNow(), and NotifyTxStartNow().
|
private |
Definition at line 483 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), IsBusy(), NotifySwitchingStartNow(), and NotifyTxStartNow().
|
private |
Definition at line 495 of file dcf-manager.h.
Referenced by SetupLowListener(), and ~DcfManager().
|
private |
Definition at line 494 of file dcf-manager.h.
Referenced by SetupPhyListener(), and ~DcfManager().
|
private |
Definition at line 489 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), IsBusy(), NotifyRxEndErrorNow(), NotifyRxEndOkNow(), NotifyRxStartNow(), NotifySwitchingStartNow(), and NotifyTxStartNow().
|
private |
Definition at line 493 of file dcf-manager.h.
Referenced by GetAccessGrantStart(), NotifyTxStartNow(), and SetSifs().
|
private |
Definition at line 492 of file dcf-manager.h.
Referenced by GetBackoffEndFor(), GetBackoffStartFor(), SetSlot(), and UpdateBackoff().
|
private |
Definition at line 474 of file dcf-manager.h.
Referenced by Add(), DoGrantAccess(), DoRestartAccessTimeoutIfNeeded(), NotifySwitchingStartNow(), and UpdateBackoff().