From e0195af625cbf854bd689dfd6671210ca02e6758 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Tue, 4 Feb 2025 12:07:03 +0100 Subject: [PATCH] wifi: Set CCA-ED threshold when a PHY is connected to a link ...rather than when it starts switching. Fixes cases in which the medium sync delay timer is stopped during the link switch, i.e., when the main PHY switches to the link of an aux PHY that is receiving a CTS in response to an RTS (receiving the CTS terminates the medium sync delay timer on the aux PHY link) --- src/wifi/model/eht/default-emlsr-manager.cc | 1 - src/wifi/model/eht/emlsr-manager.cc | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/wifi/model/eht/default-emlsr-manager.cc b/src/wifi/model/eht/default-emlsr-manager.cc index 4adcbec80..e9b754975 100644 --- a/src/wifi/model/eht/default-emlsr-manager.cc +++ b/src/wifi/model/eht/default-emlsr-manager.cc @@ -124,7 +124,6 @@ DefaultEmlsrManager::NotifyMainPhySwitch(std::optional currLinkId, // the Aux PHY is not actually switching (hence no switching delay) GetStaMac()->NotifySwitchingEmlsrLink(m_auxPhyToReconnect, *currLinkId, Seconds(0)); - SetCcaEdThresholdOnLinkSwitch(m_auxPhyToReconnect, *currLinkId); } // if currLinkId has no value, it means that the main PHY switch is interrupted, hence reset diff --git a/src/wifi/model/eht/emlsr-manager.cc b/src/wifi/model/eht/emlsr-manager.cc index 95c45271b..831beeae0 100644 --- a/src/wifi/model/eht/emlsr-manager.cc +++ b/src/wifi/model/eht/emlsr-manager.cc @@ -243,6 +243,8 @@ EmlsrManager::EmlsrLinkSwitchCallback(uint8_t linkId, Ptr phy, bool con return; } + SetCcaEdThresholdOnLinkSwitch(phy, linkId); + Simulator::ScheduleNow([=, this]() { // phy switched to operate on the link with ID equal to linkId auto it = m_noPhySince.find(linkId); @@ -848,8 +850,9 @@ EmlsrManager::SetCcaEdThresholdOnLinkSwitch(Ptr phy, uint8_t linkId) if (auto statusIt = m_mediumSyncDelayStatus.find(linkId); statusIt != m_mediumSyncDelayStatus.cend() && statusIt->second.timer.IsPending()) { - NS_LOG_DEBUG("Setting CCA ED threshold of PHY " << phy << " to " << +m_msdOfdmEdThreshold - << " on link " << +linkId); + NS_LOG_DEBUG("Setting CCA ED threshold of PHY " << +phy->GetPhyId() << " to " + << +m_msdOfdmEdThreshold << " on link " + << +linkId); // store the current CCA ED threshold in the m_prevCcaEdThreshold map, if not present m_prevCcaEdThreshold.try_emplace(phy, phy->GetCcaEdThreshold()); @@ -860,8 +863,8 @@ EmlsrManager::SetCcaEdThresholdOnLinkSwitch(Ptr phy, uint8_t linkId) else if (auto threshIt = m_prevCcaEdThreshold.find(phy); threshIt != m_prevCcaEdThreshold.cend()) { - NS_LOG_DEBUG("Resetting CCA ED threshold of PHY " << phy << " to " << threshIt->second - << " on link " << +linkId); + NS_LOG_DEBUG("Resetting CCA ED threshold of PHY " + << +phy->GetPhyId() << " to " << threshIt->second << " on link " << +linkId); phy->SetCcaEdThreshold(threshIt->second); m_prevCcaEdThreshold.erase(threshIt); } @@ -968,7 +971,6 @@ EmlsrManager::SwitchMainPhy(uint8_t linkId, m_mainPhySwitchInfo.to = linkId; m_mainPhySwitchInfo.end = Simulator::Now() + timeToSwitchEnd; - SetCcaEdThresholdOnLinkSwitch(mainPhy, linkId); NotifyMainPhySwitch(currMainPhyLinkId, linkId, auxPhy, timeToSwitchEnd); } @@ -1003,8 +1005,6 @@ EmlsrManager::SwitchAuxPhy(Ptr auxPhy, uint8_t currLinkId, uint8_t next Txop::CHECK_MEDIUM_BUSY); } }); - - SetCcaEdThresholdOnLinkSwitch(auxPhy, nextLinkId); } void @@ -1035,7 +1035,7 @@ EmlsrManager::StartMediumSyncDelayTimer(uint8_t linkId) if (!it->second.timer.IsPending()) { NS_LOG_DEBUG("Setting CCA ED threshold on link " - << +linkId << " to " << +m_msdOfdmEdThreshold << " PHY " << phy); + << +linkId << " to " << +m_msdOfdmEdThreshold << " PHY " << +phy->GetPhyId()); m_prevCcaEdThreshold[phy] = phy->GetCcaEdThreshold(); phy->SetCcaEdThreshold(m_msdOfdmEdThreshold); }