From 7048b99fc1d9ff0a65f4e092497c94f0e38e4e59 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Thu, 27 Feb 2025 22:44:02 +0100 Subject: [PATCH] wifi: Track if main PHY is disconnected rather than switching --- src/wifi/model/eht/advanced-emlsr-manager.cc | 4 ++-- src/wifi/model/eht/emlsr-manager.cc | 23 ++++++++++++-------- src/wifi/model/eht/emlsr-manager.h | 9 ++++---- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/wifi/model/eht/advanced-emlsr-manager.cc b/src/wifi/model/eht/advanced-emlsr-manager.cc index 34f5a5967..2d5fc9360 100644 --- a/src/wifi/model/eht/advanced-emlsr-manager.cc +++ b/src/wifi/model/eht/advanced-emlsr-manager.cc @@ -302,7 +302,7 @@ AdvancedEmlsrManager::ReceivedMacHdr(Ptr phy, // expires (plus a channel switch delay), try to switch the main PHY back to the preferred link const auto mainPhyInvolved = (phy->GetPhyId() == GetMainPhyId()) || - (m_mainPhySwitchInfo.end >= Simulator::Now() && m_mainPhySwitchInfo.to == *linkId); + (m_mainPhySwitchInfo.disconnected && m_mainPhySwitchInfo.to == *linkId); const auto delay = Simulator::GetDelayLeft(m_switchMainPhyBackEvent) + phy->GetChannelSwitchDelay(); @@ -363,7 +363,7 @@ AdvancedEmlsrManager::DoNotifyTxopEnd(uint8_t linkId) if (m_switchAuxPhy || !mainPhy->IsStateSwitching() || m_interruptSwitching) { NS_ASSERT_MSG( - !m_switchAuxPhy || m_mainPhySwitchInfo.end >= Simulator::Now(), + !m_switchAuxPhy || m_mainPhySwitchInfo.disconnected, "Aux PHY next link ID should have a value when interrupting a main PHY switch"); uint8_t nextLinkId = m_switchAuxPhy ? m_mainPhySwitchInfo.from : GetMainPhyId(); SwitchMainPhy(nextLinkId, false, REQUEST_ACCESS, std::move(*traceInfo)); diff --git a/src/wifi/model/eht/emlsr-manager.cc b/src/wifi/model/eht/emlsr-manager.cc index de519015a..3377d485f 100644 --- a/src/wifi/model/eht/emlsr-manager.cc +++ b/src/wifi/model/eht/emlsr-manager.cc @@ -141,10 +141,9 @@ EmlsrManager::GetTypeId() } EmlsrManager::EmlsrManager() - : m_mainPhySwitchInfo{}, - // The STA initializes dot11MSDTimerDuration to aPPDUMaxTime defined in Table 36-70 - // (Sec. 35.3.16.8.1 of 802.11be D3.1) - m_mediumSyncDuration(MicroSeconds(DEFAULT_MSD_DURATION_USEC)), + // The STA initializes dot11MSDTimerDuration to aPPDUMaxTime defined in Table 36-70 + // (Sec. 35.3.16.8.1 of 802.11be D3.1) + : m_mediumSyncDuration(MicroSeconds(DEFAULT_MSD_DURATION_USEC)), // The default value of dot11MSDOFDMEDthreshold is –72 dBm and the default value of // dot11MSDTXOPMax is 1, respectively (Sec. 35.3.16.8.1 of 802.11be D3.1) m_msdOfdmEdThreshold(DEFAULT_MSD_OFDM_ED_THRESH), @@ -243,6 +242,12 @@ EmlsrManager::EmlsrLinkSwitchCallback(uint8_t linkId, Ptr phy, bool con SetCcaEdThresholdOnLinkSwitch(phy, linkId); + if (phy->GetPhyId() == m_mainPhyId) + { + // main PHY has been connected to a link + m_mainPhySwitchInfo.disconnected = false; + } + Simulator::ScheduleNow([=, this]() { // phy switched to operate on the link with ID equal to linkId auto it = m_noPhySince.find(linkId); @@ -888,6 +893,11 @@ EmlsrManager::SwitchMainPhy(uint8_t linkId, traceInfo.toLinkId = linkId; m_mainPhySwitchTrace(traceInfo); + m_mainPhySwitchInfo.from = currMainPhyLinkId.value_or(m_mainPhySwitchInfo.from); + m_mainPhySwitchInfo.to = linkId; + m_mainPhySwitchInfo.start = Simulator::Now(); + m_mainPhySwitchInfo.disconnected = true; + const auto newMainPhyChannel = GetChannelForMainPhy(linkId); NS_LOG_DEBUG("Main PHY (" << mainPhy << ") is about to switch to " << newMainPhyChannel @@ -958,11 +968,6 @@ EmlsrManager::SwitchMainPhy(uint8_t linkId, }); } - m_mainPhySwitchInfo.from = currMainPhyLinkId.value_or(m_mainPhySwitchInfo.from); - m_mainPhySwitchInfo.to = linkId; - m_mainPhySwitchInfo.start = Simulator::Now(); - m_mainPhySwitchInfo.end = Simulator::Now() + timeToSwitchEnd; - NotifyMainPhySwitch(currMainPhyLinkId, linkId, auxPhy, timeToSwitchEnd); } diff --git a/src/wifi/model/eht/emlsr-manager.h b/src/wifi/model/eht/emlsr-manager.h index 3c0bc70e4..06cf659b5 100644 --- a/src/wifi/model/eht/emlsr-manager.h +++ b/src/wifi/model/eht/emlsr-manager.h @@ -507,10 +507,11 @@ class EmlsrManager : public Object /// Store information about a main PHY switch. struct MainPhySwitchInfo { - Time start; //!< start of channel switching - Time end; //!< end of channel switching - uint8_t from{}; //!< ID of the link which the main PHY is/has been leaving - uint8_t to{}; //!< ID of the link which the main PHY is moving to + Time start; //!< start of channel switching + bool disconnected{false}; //!< true if the main PHY is not connected to any link, i.e., it + //!< is switching or waiting to be connected to a link + uint8_t from{}; //!< ID of the link which the main PHY is/has been leaving + uint8_t to{}; //!< ID of the link which the main PHY is moving to }; Time m_emlsrPaddingDelay; //!< EMLSR Padding delay