From 60853792b2e21f4e97933fdb3ef70bdb6e514c1c Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Wed, 14 Aug 2024 10:42:14 +0200 Subject: [PATCH] wifi: Extend EMLSR test to check that SwitchMainPhyBackDelay timer expires --- src/wifi/test/wifi-emlsr-test.cc | 39 ++++++++++++++++++++++++++++---- src/wifi/test/wifi-emlsr-test.h | 4 ++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/wifi/test/wifi-emlsr-test.cc b/src/wifi/test/wifi-emlsr-test.cc index 66dd72a96..7f65bd2a7 100644 --- a/src/wifi/test/wifi-emlsr-test.cc +++ b/src/wifi/test/wifi-emlsr-test.cc @@ -2592,7 +2592,8 @@ EmlsrUlTxopTest::EmlsrUlTxopTest(const Params& params) m_countRtsframes(0), m_genBackoffIfTxopWithoutTx(params.genBackoffAndUseAuxPhyCca), m_useAuxPhyCca(params.genBackoffAndUseAuxPhyCca), - m_nSlotsLeftAlert(params.nSlotsLeftAlert) + m_nSlotsLeftAlert(params.nSlotsLeftAlert), + m_switchMainPhyBackDelayTimeout(params.switchMainPhyBackDelayTimeout) { m_nEmlsrStations = 1; m_nNonEmlsrStations = 0; @@ -3217,6 +3218,34 @@ EmlsrUlTxopTest::CheckBlockAck(const WifiConstPsduMap& psduMap, false, false); + if (m_switchMainPhyBackDelayTimeout) + { + TimeValue switchMainPhyBackDelay; + m_staMacs[0]->GetEmlsrManager()->GetAttribute("SwitchMainPhyBackDelay", + switchMainPhyBackDelay); + + // set the NAV on all the links for enough time to make the + // SwitchMainPhyBackDelay timer expire + for (uint8_t id = 0; id < m_staMacs[0]->GetNLinks(); ++id) + { + if (!m_staMacs[0]->GetWifiPhy(id)) + { + continue; // no PHY on this link + } + m_staMacs[0]->GetChannelAccessManager(id)->NotifyNavStartNow( + 2 * switchMainPhyBackDelay.Get()); + } + // check that the SwitchMainPhyBackDelay timer expires + Simulator::Schedule(2 * switchMainPhyBackDelay.Get() - mainPhy->GetPifs(), + [=, this]() { + CheckMainPhyTraceInfo(0, + "TxopNotGainedOnAuxPhyLink", + std::nullopt, + m_mainPhyId, + false); + }); + } + // events to be scheduled when main PHY finishes switching to auxiliary link Simulator::Schedule(mainPhy->GetDelayUntilIdle(), [=, this]() { auto nonPrimLinkId = m_staMacs[0]->GetLinkForPhy(mainPhy); @@ -3685,7 +3714,7 @@ EmlsrUlTxopTest::CheckResults() // transmission is done (if the backoff expires while the main PHY is switching, a new // backoff is generated and, before this backoff expires, the main PHY may be requested // to switch to another auxiliary link; this may happen multiple times...) - if (!m_genBackoffIfTxopWithoutTx) + if (!m_genBackoffIfTxopWithoutTx && !m_switchMainPhyBackDelayTimeout) { NS_TEST_EXPECT_MSG_LT_OR_EQ(psduIt->startTx, m_5thQosFrameTxTime, @@ -4931,7 +4960,8 @@ WifiEmlsrTestSuite::WifiEmlsrTestSuite() 3, genBackoffAndUseAuxPhyCca, nSlotsLeft, - true /* putAuxPhyToSleep */}), + true, /* putAuxPhyToSleep */ + false /* switchMainPhyBackDelayTimeout */}), TestCase::Duration::QUICK); AddTestCase(new EmlsrUlTxopTest({{0, 1}, 40, @@ -4940,7 +4970,8 @@ WifiEmlsrTestSuite::WifiEmlsrTestSuite() 1, genBackoffAndUseAuxPhyCca, nSlotsLeft, - false /* putAuxPhyToSleep */}), + false, /* putAuxPhyToSleep */ + true /* switchMainPhyBackDelayTimeout */}), TestCase::Duration::QUICK); } } diff --git a/src/wifi/test/wifi-emlsr-test.h b/src/wifi/test/wifi-emlsr-test.h index 84d849fa0..81fac6be2 100644 --- a/src/wifi/test/wifi-emlsr-test.h +++ b/src/wifi/test/wifi-emlsr-test.h @@ -609,6 +609,8 @@ class EmlsrUlTxopTest : public EmlsrOperationsTestBase uint8_t nSlotsLeftAlert; //!< value to set the ChannelAccessManager NSlotsLeft //!< attribute to bool putAuxPhyToSleep; //!< whether aux PHYs are put to sleep during DL/UL TXOPs + bool switchMainPhyBackDelayTimeout; //!< whether a SwitchMainPhyBackDelay timer expires + //!< after that the main PHY moved to an aux PHY link }; /** @@ -714,6 +716,8 @@ class EmlsrUlTxopTest : public EmlsrOperationsTestBase bool m_useAuxPhyCca; //!< whether CCA info from aux PHY is used when //!< aux PHY is not TX capable uint8_t m_nSlotsLeftAlert; //!< value for ChannelAccessManager NSlotsLeft attribute + bool m_switchMainPhyBackDelayTimeout; //!< whether a SwitchMainPhyBackDelay timer expires + //!< after that the main PHY moved to an aux PHY link std::optional m_corruptCts; //!< whether the transmitted CTS must be corrupted Time m_5thQosFrameTxTime; //!< start transmission time of the 5th QoS data frame };