From f2eac3fe7adee582c5f1bc9d23b4dd2e2e9d45df Mon Sep 17 00:00:00 2001 From: "Kirill V. Andreev" Date: Thu, 25 Jun 2009 15:25:10 +0200 Subject: [PATCH] bug 595: PHY may start receive packet inside SIFS --- src/devices/wifi/dcf-manager-test.cc | 28 ++++++++++++++++++++++++++++ src/devices/wifi/dcf-manager.cc | 11 +++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/devices/wifi/dcf-manager-test.cc b/src/devices/wifi/dcf-manager-test.cc index 1e99d14c9..968bbea5f 100644 --- a/src/devices/wifi/dcf-manager-test.cc +++ b/src/devices/wifi/dcf-manager-test.cc @@ -75,6 +75,8 @@ private: void ExpectCollision (uint64_t time, uint32_t from, uint32_t nSlots); void AddRxOkEvt (uint64_t at, uint64_t duration); void AddRxErrorEvt (uint64_t at, uint64_t duration); + void AddRxInsideSifsEvt (uint64_t at, uint64_t duration); + void AddTxEvt (uint64_t at, uint64_t duration); void AddNavReset (uint64_t at, uint64_t duration); void AddNavStart (uint64_t at, uint64_t duration); void AddAckTimeoutReset (uint64_t at); @@ -143,6 +145,13 @@ DcfManagerTest::NotifyAccessGranted (uint32_t i) m_result = result; } } +void +DcfManagerTest::AddTxEvt (uint64_t at, uint64_t duration) +{ + Simulator::Schedule (MicroSeconds (at) - Now (), + &DcfManager::NotifyTxStartNow, m_dcfManager, + MicroSeconds (duration)); +} void DcfManagerTest::NotifyInternalCollision (uint32_t i) { @@ -244,6 +253,13 @@ DcfManagerTest::AddRxOkEvt (uint64_t at, uint64_t duration) Simulator::Schedule (MicroSeconds (at+duration) - Now (), &DcfManager::NotifyRxEndOkNow, m_dcfManager); } +void +DcfManagerTest::AddRxInsideSifsEvt (uint64_t at, uint64_t duration) +{ + Simulator::Schedule (MicroSeconds (at) - Now (), + &DcfManager::NotifyRxStartNow, m_dcfManager, + MicroSeconds (duration)); +} void DcfManagerTest::AddRxErrorEvt (uint64_t at, uint64_t duration) { @@ -321,6 +337,18 @@ DcfManagerTest::RunTests (void) AddAccessRequest (1, 1, 4, 0); AddAccessRequest (10, 2, 10, 0); EndTest (); + // Check that receiving inside SIFS shall be cancelled properly: + // 0 3 4 5 8 9 12 13 14 + // | sifs | aifsn | tx | sifs | ack | sifs | aifsn | |tx | + // + StartTest (1, 3, 10); + AddDcfState (1); + AddAccessRequest (1, 1, 4, 0); + AddRxInsideSifsEvt (6, 10); + AddTxEvt(8, 1); + AddAccessRequest (14, 2, 14, 0); + EndTest (); + // The test below mainly intends to test the case where the medium // becomes busy in the middle of a backoff slot: the backoff counter diff --git a/src/devices/wifi/dcf-manager.cc b/src/devices/wifi/dcf-manager.cc index cdde88f85..7b71217b8 100644 --- a/src/devices/wifi/dcf-manager.cc +++ b/src/devices/wifi/dcf-manager.cc @@ -572,6 +572,17 @@ DcfManager::NotifyRxEndErrorNow (void) void DcfManager::NotifyTxStartNow (Time duration) { + if (m_rxing) + { + //this may be caused only if PHY has started to receive a packet + //inside SIFS, so, we check that lastRxStart was maximum a SIFS + //ago + NS_ASSERT(Simulator::Now () - m_lastRxStart < m_sifs); + m_lastRxEnd = Simulator::Now (); + m_lastRxDuration = m_lastRxEnd - m_lastRxStart; + m_lastRxReceivedOk = true; + m_rxing = false; + } MY_DEBUG ("tx start for "<