use a simple request/grant scheme for dcf accesses

This commit is contained in:
Mathieu Lacage
2007-11-19 16:20:30 +01:00
parent 632a762654
commit b699ad9ae1
3 changed files with 50 additions and 21 deletions

View File

@@ -18,10 +18,9 @@ public:
void QueueTx (uint64_t txTime, uint64_t expectedGrantTime);
private:
friend class DcfManagerTest;
virtual bool NeedsAccess (void) const;
virtual void NotifyAccessGranted (void);
virtual void NotifyInternalCollision (void);
virtual void NotifyCollision (void);
virtual void DoNotifyAccessGranted (void);
virtual void DoNotifyInternalCollision (void);
virtual void DoNotifyCollision (void);
typedef std::pair<uint64_t,uint64_t> ExpectedGrant;
typedef std::list<ExpectedGrant> ExpectedGrants;
@@ -83,23 +82,18 @@ DcfStateTest::QueueTx (uint64_t txTime, uint64_t expectedGrantTime)
{
m_expectedGrants.push_back (std::make_pair (txTime, expectedGrantTime));
}
bool
DcfStateTest::NeedsAccess (void) const
{
return !m_expectedGrants.empty ();
}
void
DcfStateTest::NotifyAccessGranted (void)
DcfStateTest::DoNotifyAccessGranted (void)
{
m_test->NotifyAccessGranted (m_i);
}
void
DcfStateTest::NotifyInternalCollision (void)
DcfStateTest::DoNotifyInternalCollision (void)
{
m_test->NotifyInternalCollision (m_i);
}
void
DcfStateTest::NotifyCollision (void)
DcfStateTest::DoNotifyCollision (void)
{
m_test->NotifyCollision (m_i);
}

View File

@@ -21,7 +21,8 @@ namespace ns3 {
DcfState::DcfState ()
: m_backoffSlots (0),
m_backoffStart (Seconds (0.0))
m_backoffStart (Seconds (0.0)),
m_accessRequested (false)
{}
DcfState::~DcfState ()
@@ -91,6 +92,33 @@ DcfState::GetBackoffStart (void) const
{
return m_backoffStart;
}
bool
DcfState::IsAccessRequested (void) const
{
return m_accessRequested;
}
void
DcfState::NotifyAccessRequested (void)
{
m_accessRequested = true;
}
void
DcfState::NotifyAccessGranted (void)
{
NS_ASSERT (m_accessRequested);
m_accessRequested = false;
DoNotifyAccessGranted ();
}
void
DcfState::NotifyCollision (void)
{
DoNotifyCollision ();
}
void
DcfState::NotifyInternalCollision (void)
{
DoNotifyInternalCollision ();
}
/****************************************************************
@@ -185,6 +213,8 @@ void
DcfManager::RequestAccess (DcfState *state)
{
UpdateBackoff ();
NS_ASSERT (!state->IsAccessRequested ());
state->NotifyAccessRequested ();
/**
* If there is a collision, generate a backoff
* by notifying the collision to the user.
@@ -211,7 +241,7 @@ DcfManager::DoGrantAccess (void)
for (States::const_iterator i = m_states.begin (); i != m_states.end (); k++)
{
DcfState *state = *i;
if (state->NeedsAccess () &&
if (state->IsAccessRequested () &&
GetBackoffEndFor (state) <= Simulator::Now ())
{
/**
@@ -225,7 +255,7 @@ DcfManager::DoGrantAccess (void)
for (States::const_iterator j = i; j != m_states.end (); j++, k++)
{
DcfState *otherState = *j;
if (otherState->NeedsAccess () &&
if (otherState->IsAccessRequested () &&
GetBackoffEndFor (otherState) <= Simulator::Now ())
{
MY_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision. slots=" <<
@@ -346,7 +376,7 @@ DcfManager::DoRestartAccessTimeoutIfNeeded (void)
for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++)
{
DcfState *state = *i;
if (state->NeedsAccess ())
if (state->IsAccessRequested ())
{
Time tmp = GetBackoffEndFor (state);
if (tmp > Simulator::Now ())

View File

@@ -21,6 +21,7 @@ public:
void UpdateFailedCw (void);
void StartBackoffNow (uint32_t nSlots);
uint32_t GetCw (void) const;
bool IsAccessRequested (void) const;
private:
friend class DcfManager;
@@ -28,13 +29,16 @@ private:
uint32_t GetAifsn (void) const;
uint32_t GetBackoffSlots (void) const;
Time GetBackoffStart (void) const;
void UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound);
void NotifyAccessRequested (void);
void NotifyAccessGranted (void);
void NotifyCollision (void);
void NotifyInternalCollision (void);
virtual bool NeedsAccess (void) const = 0;
virtual void NotifyAccessGranted (void) = 0;
virtual void NotifyInternalCollision (void) = 0;
virtual void NotifyCollision (void) = 0;
virtual void DoNotifyAccessGranted (void) = 0;
virtual void DoNotifyInternalCollision (void) = 0;
virtual void DoNotifyCollision (void) = 0;
uint32_t m_aifsn;
uint32_t m_backoffSlots;
@@ -45,6 +49,7 @@ private:
uint32_t m_cwMin;
uint32_t m_cwMax;
uint32_t m_cw;
bool m_accessRequested;
};
class DcfManager