From 879929f3f924544040e206f2cc9a88f91bb1b487 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Tue, 4 Mar 2025 19:05:21 +0100 Subject: [PATCH] wifi: Take preamble detection period into account in CheckPossiblyReceivingIcf() --- src/wifi/model/eht/emlsr-manager.cc | 7 ++++++- src/wifi/test/wifi-emlsr-test.cc | 8 ++++++++ src/wifi/test/wifi-emlsr-test.h | 15 ++++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/wifi/model/eht/emlsr-manager.cc b/src/wifi/model/eht/emlsr-manager.cc index 3377d485f..a5b32642b 100644 --- a/src/wifi/model/eht/emlsr-manager.cc +++ b/src/wifi/model/eht/emlsr-manager.cc @@ -590,7 +590,12 @@ EmlsrManager::CheckPossiblyReceivingIcf(uint8_t linkId) const return {false, Time{0}}; } - if (auto macHdr = GetEhtFem(linkId)->GetReceivedMacHdr(); macHdr && m_useNotifiedMacHdr) + if (auto endPreamble = phy->GetTimeToPreambleDetectionEnd()) + { + NS_LOG_DEBUG("Detecting a PPDU preamble, postpone by " << endPreamble->As(Time::US)); + return {true, endPreamble.value()}; + } + else if (auto macHdr = GetEhtFem(linkId)->GetReceivedMacHdr(); macHdr && m_useNotifiedMacHdr) { NS_LOG_DEBUG("Receiving the MAC payload of a PSDU and MAC header info can be used"); NS_ASSERT(phy->GetState()->GetLastTime({WifiPhyState::RX}) == Simulator::Now()); diff --git a/src/wifi/test/wifi-emlsr-test.cc b/src/wifi/test/wifi-emlsr-test.cc index f32be0525..9393dc599 100644 --- a/src/wifi/test/wifi-emlsr-test.cc +++ b/src/wifi/test/wifi-emlsr-test.cc @@ -5506,6 +5506,9 @@ EmlsrIcfSentDuringMainPhySwitchTest::RunOne() switch (m_csdIndex) { + case DURING_PREAMBLE_DETECTION: + channelSwitchDelay = MicroSeconds(1); + break; case BEFORE_PHY_HDR_END: channelSwitchDelay = phyHdrDuration - margin; break; @@ -5581,6 +5584,11 @@ EmlsrIcfSentDuringMainPhySwitchTest::RunOne() true, m_testStr << ": Expected to be receiving the PHY header"); break; + case DURING_PREAMBLE_DETECTION: + NS_TEST_EXPECT_MSG_EQ(auxPhy->GetTimeToPreambleDetectionEnd().has_value(), + true, + m_testStr + << ": Expected to be in preamble detection period"); default: NS_ABORT_MSG("Unexpected channel switch duration index"); } diff --git a/src/wifi/test/wifi-emlsr-test.h b/src/wifi/test/wifi-emlsr-test.h index d2b8a6081..aee4c8ca3 100644 --- a/src/wifi/test/wifi-emlsr-test.h +++ b/src/wifi/test/wifi-emlsr-test.h @@ -1110,14 +1110,14 @@ class SingleLinkEmlsrTest : public EmlsrOperationsTestBase * * The channel switch delay for the main PHY varies across test scenarios and is computed so that * the channel switch terminates during one of the different steps of the reception of the ICF: - * before the PHY header end, before the MAC header end, before the padding start and after the - * padding start. + * during preamble detection period, before the PHY header end, before the MAC header end, before + * the padding start and after the padding start. * \verbatim - ┌──────┬──────┬────────────────────┬───────┐ - │ PHY │ MAC │ MAC PAYLOAD │ │ - │HEADER│HEADER│(COMMON & USER INFO)│PADDING│ - └──────┴──────┴────────────────────┴───────┘ + ┌────────┬──────┬──────┬────────────────────┬───────┐ + │PREAMBLE│ PHY │ MAC │ MAC PAYLOAD │ │ + │ DETECT │HEADER│HEADER│(COMMON & USER INFO)│PADDING│ + └────────┴──────┴──────┴────────────────────┴───────┘ \endverbatim * * All the combinations of the following are tested: @@ -1148,7 +1148,8 @@ class EmlsrIcfSentDuringMainPhySwitchTest : public EmlsrOperationsTestBase */ enum ChannelSwitchEnd : uint8_t { - BEFORE_PHY_HDR_END = 0, + DURING_PREAMBLE_DETECTION = 0, + BEFORE_PHY_HDR_END, BEFORE_MAC_HDR_END, BEFORE_MAC_PAYLOAD_END, BEFORE_PADDING_END,