From 384467cd965f8da3f72a19296719e1bff53d32b9 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Mon, 2 Dec 2024 15:52:52 +0100 Subject: [PATCH] wifi: Take sleep/off period into account when computing access grant start --- src/wifi/model/channel-access-manager.cc | 15 ++++++++++++--- src/wifi/model/channel-access-manager.h | 2 ++ src/wifi/test/wifi-emlsr-test.cc | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/wifi/model/channel-access-manager.cc b/src/wifi/model/channel-access-manager.cc index 0b3e42a13..9f6b525a0 100644 --- a/src/wifi/model/channel-access-manager.cc +++ b/src/wifi/model/channel-access-manager.cc @@ -219,6 +219,8 @@ ChannelAccessManager::ChannelAccessManager() m_lastRxReceivedOk(true), m_lastTxEnd(0), m_lastSwitchingEnd(0), + m_lastSleepEnd(0), + m_lastOffEnd(0), m_linkId(0) { NS_LOG_FUNCTION(this); @@ -683,14 +685,18 @@ ChannelAccessManager::GetAccessGrantStart(bool ignoreNav) const navAccessStart, m_lastAckTimeoutEnd, m_lastCtsTimeoutEnd, - m_lastSwitchingEnd}); + m_lastSwitchingEnd, + m_lastSleepEnd, + m_lastOffEnd}); NS_LOG_INFO("access grant start=" << accessGrantedStart.As(Time::US) << ", rx access start=" << rxAccessStart.As(Time::US) << ", busy access start=" << busyAccessStart.As(Time::US) << ", tx access start=" << m_lastTxEnd.As(Time::US) << ", nav access start=" << navAccessStart.As(Time::US) - << ", switching access start=" << m_lastSwitchingEnd.As(Time::US)); + << ", switching access start=" << m_lastSwitchingEnd.As(Time::US) + << ", sleep access start=" << m_lastSleepEnd.As(Time::US) + << ", off access start=" << m_lastOffEnd.As(Time::US)); return accessGrantedStart + GetSifs(); } @@ -1146,6 +1152,7 @@ void ChannelAccessManager::NotifyWakeupNow() { NS_LOG_FUNCTION(this); + m_lastSleepEnd = Simulator::Now(); for (auto txop : m_txops) { ResetBackoff(txop); @@ -1157,6 +1164,7 @@ void ChannelAccessManager::NotifyOnNow() { NS_LOG_FUNCTION(this); + m_lastOffEnd = Simulator::Now(); for (auto txop : m_txops) { ResetBackoff(txop); @@ -1232,7 +1240,8 @@ void ChannelAccessManager::UpdateLastIdlePeriod() { NS_LOG_FUNCTION(this); - Time idleStart = std::max({m_lastTxEnd, m_lastRx.end, m_lastSwitchingEnd}); + Time idleStart = + std::max({m_lastTxEnd, m_lastRx.end, m_lastSwitchingEnd, m_lastSleepEnd, m_lastOffEnd}); Time now = Simulator::Now(); if (idleStart >= now) diff --git a/src/wifi/model/channel-access-manager.h b/src/wifi/model/channel-access-manager.h index 31d478ebd..83871661a 100644 --- a/src/wifi/model/channel-access-manager.h +++ b/src/wifi/model/channel-access-manager.h @@ -480,6 +480,8 @@ class ChannelAccessManager : public Object std::map m_lastIdle; //!< the last idle start and end time for each channel type Time m_lastSwitchingEnd; //!< the last switching end time + Time m_lastSleepEnd; //!< the last sleep end time + Time m_lastOffEnd; //!< the last off end time Time m_eifsNoDifs; //!< EIFS no DIFS time EventId m_accessTimeout; //!< the access timeout ID bool m_generateBackoffOnNoTx; //!< whether the backoff should be invoked when the AC gains the diff --git a/src/wifi/test/wifi-emlsr-test.cc b/src/wifi/test/wifi-emlsr-test.cc index ea7e6b035..58887c2b2 100644 --- a/src/wifi/test/wifi-emlsr-test.cc +++ b/src/wifi/test/wifi-emlsr-test.cc @@ -301,7 +301,7 @@ EmlsrOperationsTestBase::DoSetup() { RngSeedManager::SetSeed(1); RngSeedManager::SetRun(1); - int64_t streamNumber = 100; + int64_t streamNumber = 11; Config::SetDefault("ns3::WifiMac::MpduBufferSize", UintegerValue(64)); Config::SetDefault("ns3::EmlsrManager::InDeviceInterference", BooleanValue(true));