From 98f27be294cc9bce4fb34cf7f4264c96eac6405f Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Thu, 2 Nov 2023 11:26:30 +0100 Subject: [PATCH] wifi: Main PHY and aux PHY can switch immediately (no need to schedule) --- src/wifi/model/eht/emlsr-manager.cc | 56 ++++++++++++++--------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/wifi/model/eht/emlsr-manager.cc b/src/wifi/model/eht/emlsr-manager.cc index 0229668d8..0e3387d25 100644 --- a/src/wifi/model/eht/emlsr-manager.cc +++ b/src/wifi/model/eht/emlsr-manager.cc @@ -514,28 +514,26 @@ EmlsrManager::SwitchMainPhy(uint8_t linkId, bool noSwitchDelay) "We should not ask the main PHY to switch channel while transmitting"); // request the main PHY to switch channel - Simulator::ScheduleNow([=, this]() { - auto delay = mainPhy->GetChannelSwitchDelay(); - NS_ASSERT_MSG(noSwitchDelay || delay <= m_lastAdvTransitionDelay, - "Transition delay (" << m_lastAdvTransitionDelay.As(Time::US) - << ") should exceed the channel switch delay (" - << delay.As(Time::US) << ")"); - if (noSwitchDelay) - { - mainPhy->SetAttribute("ChannelSwitchDelay", TimeValue(Seconds(0))); - } - mainPhy->SetOperatingChannel(newMainPhyChannel); - // restore previous channel switch delay - if (noSwitchDelay) - { - mainPhy->SetAttribute("ChannelSwitchDelay", TimeValue(delay)); - } - // re-enable short time slot, if needed - if (m_staMac->GetWifiRemoteStationManager(linkId)->GetShortSlotTimeEnabled()) - { - mainPhy->SetSlot(MicroSeconds(9)); - } - }); + auto delay = mainPhy->GetChannelSwitchDelay(); + NS_ASSERT_MSG(noSwitchDelay || delay <= m_lastAdvTransitionDelay, + "Transition delay (" << m_lastAdvTransitionDelay.As(Time::US) + << ") should exceed the channel switch delay (" + << delay.As(Time::US) << ")"); + if (noSwitchDelay) + { + mainPhy->SetAttribute("ChannelSwitchDelay", TimeValue(Seconds(0))); + } + mainPhy->SetOperatingChannel(newMainPhyChannel); + // restore previous channel switch delay + if (noSwitchDelay) + { + mainPhy->SetAttribute("ChannelSwitchDelay", TimeValue(delay)); + } + // re-enable short time slot, if needed + if (m_staMac->GetWifiRemoteStationManager(linkId)->GetShortSlotTimeEnabled()) + { + mainPhy->SetSlot(MicroSeconds(9)); + } SetCcaEdThresholdOnLinkSwitch(mainPhy, linkId); NotifyMainPhySwitch(*currMainPhyLinkId, linkId); @@ -557,14 +555,12 @@ EmlsrManager::SwitchAuxPhy(uint8_t currLinkId, uint8_t nextLinkId) ->GetChannelAccessManager(currLinkId) ->NotifySwitchingEmlsrLink(auxPhy, newAuxPhyChannel, nextLinkId); - Simulator::ScheduleNow([=, this]() { - auxPhy->SetOperatingChannel(newAuxPhyChannel); - // re-enable short time slot, if needed - if (m_staMac->GetWifiRemoteStationManager(nextLinkId)->GetShortSlotTimeEnabled()) - { - auxPhy->SetSlot(MicroSeconds(9)); - } - }); + auxPhy->SetOperatingChannel(newAuxPhyChannel); + // re-enable short time slot, if needed + if (m_staMac->GetWifiRemoteStationManager(nextLinkId)->GetShortSlotTimeEnabled()) + { + auxPhy->SetSlot(MicroSeconds(9)); + } SetCcaEdThresholdOnLinkSwitch(auxPhy, nextLinkId); }