diff --git a/src/devices/wifi/dcf-manager-test.cc b/src/devices/wifi/dcf-manager-test.cc index 2c2acf34e..d1ec00317 100644 --- a/src/devices/wifi/dcf-manager-test.cc +++ b/src/devices/wifi/dcf-manager-test.cc @@ -6,15 +6,6 @@ #include "dcf-manager.h" #include "mac-parameters.h" -#define TEST_ASSERT_EQUAL(got, expected) \ - if ((got) != (expected)) \ - { \ - std::clog << __FILE__ << ":" <<__LINE__ \ - << ": expected " << (expected) \ - << ", got " << (got) << std::endl; \ - } - - namespace ns3 { class DcfManagerTest; @@ -90,11 +81,15 @@ DcfStateTest::NotifyAccessGranted (void) void DcfStateTest::NotifyInternalCollision (void) { + UpdateFailedCw (); + StartBackoffNow (0); m_test->NotifyInternalCollision (m_i); } void DcfStateTest::NotifyCollision (void) { + UpdateFailedCw (); + StartBackoffNow (0); m_test->NotifyCollision (m_i); } @@ -265,7 +260,7 @@ DcfManagerTest::RunTests (void) m_result = true; StartTest (); - AddDcfState (2, 5, 1); + AddDcfState (8, 64, 1); AddAccessRequest (10, 0); ExpectAccessGranted (10, 0); EndTest (); diff --git a/src/devices/wifi/dcf-manager.cc b/src/devices/wifi/dcf-manager.cc index 815f209a7..cd4a74833 100644 --- a/src/devices/wifi/dcf-manager.cc +++ b/src/devices/wifi/dcf-manager.cc @@ -190,6 +190,7 @@ DcfManager::RequestAccess (DcfState *state) if (state->GetBackoffSlots () == 0 && IsBusy ()) { + NS_LOG_DEBUG ("medium is busy: collision"); /* someone else has accessed the medium. * generate a backoff. */ @@ -203,7 +204,8 @@ DcfManager::RequestAccess (DcfState *state) void DcfManager::DoGrantAccess (void) { - for (States::const_iterator i = m_states.begin (); i != m_states.end (); ) + uint32_t k = 0; + for (States::const_iterator i = m_states.begin (); i != m_states.end (); k++) { DcfState *state = *i; if (state->GetBackoffSlots () == 0 && state->NeedsAccess ()) @@ -212,13 +214,16 @@ DcfManager::DoGrantAccess (void) * 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. */ + NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. access granted."); state->NotifyAccessGranted (); i++; // go to the next item in the list. - for (States::const_iterator j = i; j != m_states.end (); j++) + k++; + for (States::const_iterator j = i; j != m_states.end (); j++, k++) { DcfState *state = *j; if (state->GetBackoffSlots () == 0 && state->NeedsAccess ()) { + NS_LOG_DEBUG ("dcf " << k << " needs access. backoff expired. internal collision."); /** * all other dcfs with a lower priority whose backoff * has expired and which needed access to the medium @@ -271,7 +276,8 @@ DcfManager::GetAccessGrantStart (void) const void DcfManager::UpdateBackoff (void) { - for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++) + uint32_t k = 0; + for (States::const_iterator i = m_states.begin (); i != m_states.end (); i++, k++) { DcfState *state = *i; @@ -289,6 +295,7 @@ DcfManager::UpdateBackoff (void) */ if (nIntSlots > state->GetAifsn ()) { + NS_LOG_DEBUG ("dcf " << k << " dec backoff slots=" << nIntSlots - state->GetAifsn ()); state->UpdateBackoffSlotsNow (nIntSlots - state->GetAifsn ()); } } @@ -321,6 +328,7 @@ DcfManager::DoRestartAccessTimeoutIfNeeded (void) * backoff is expected to end. */ Time expectedBackoffEnd = GetAccessGrantStart () + Scalar (minNSlots) * m_parameters->GetSlotTime (); + NS_LOG_DEBUG ("min n slots=" << minNSlots << ", expected backoff end="<