From 370dbb04d573f6acddbc7b4c0d44e14099c77231 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Mon, 11 Mar 2024 23:08:30 +0100 Subject: [PATCH] wifi: Advanced EMLSR manager can interrupt main PHY switch after CTS timeout --- src/wifi/model/eht/advanced-emlsr-manager.cc | 62 ++++++++++++++++++++ src/wifi/model/eht/advanced-emlsr-manager.h | 12 ++-- 2 files changed, 70 insertions(+), 4 deletions(-) diff --git a/src/wifi/model/eht/advanced-emlsr-manager.cc b/src/wifi/model/eht/advanced-emlsr-manager.cc index f19560aed..4f6fc4f22 100644 --- a/src/wifi/model/eht/advanced-emlsr-manager.cc +++ b/src/wifi/model/eht/advanced-emlsr-manager.cc @@ -42,6 +42,12 @@ AdvancedEmlsrManager::GetTypeId() "If this attribute is true, the PPDU may be dropped.", BooleanValue(false), MakeBooleanAccessor(&AdvancedEmlsrManager::m_allowUlTxopInRx), + MakeBooleanChecker()) + .AddAttribute("InterruptSwitch", + "Whether the main PHY can be interrupted while switching to start " + "switching to another link.", + BooleanValue(false), + MakeBooleanAccessor(&AdvancedEmlsrManager::m_interruptSwitching), MakeBooleanChecker()); return tid; } @@ -209,4 +215,60 @@ AdvancedEmlsrManager::ReceivedMacHdr(Ptr phy, } } +void +AdvancedEmlsrManager::DoNotifyTxopEnd(uint8_t linkId) +{ + NS_LOG_FUNCTION(this << linkId); + + auto mainPhy = GetStaMac()->GetDevice()->GetPhy(m_mainPhyId); + + if (m_switchAuxPhy && (!mainPhy->IsStateSwitching() || !m_interruptSwitching)) + { + NS_LOG_DEBUG("SwitchAuxPhy true, nothing to do"); + return; + } + + if (!m_switchAuxPhy && !m_auxPhyToReconnect) + { + NS_LOG_DEBUG("SwitchAuxPhy false, nothing to do"); + return; + } + + // we get here if: + // - SwitchAuxPhy is true, the main PHY is switching and switching can be interrupted + // or + // - SwitchAuxPhy is false and there is an aux PHY to reconnect + + // Note that the main PHY may be switching at the end of a TXOP when, e.g., the main PHY + // starts switching to a link on which an aux PHY gained a TXOP and sent an RTS, but the CTS + // is not received and the UL TXOP ends before the main PHY channel switch is completed. + // In such cases, wait until the main PHY channel switch is completed (unless the channel + // switching can be interrupted) before requesting a new channel switch. Given that the + // TXOP ended, the event to put the aux PHY to sleep can be cancelled. + // Backoff shall not be reset on the link left by the main PHY because a TXOP ended and + // a new backoff value must be generated. + m_auxPhyToSleepEvent.Cancel(); + + if (m_switchAuxPhy || !mainPhy->IsStateSwitching() || m_interruptSwitching) + { + NS_ASSERT_MSG( + !m_switchAuxPhy || m_mainPhySwitchInfo.end >= Simulator::Now(), + "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, DONT_RESET_BACKOFF, REQUEST_ACCESS); + } + else + { + // delay link switch until current channel switching is completed + Simulator::Schedule(mainPhy->GetDelayUntilIdle(), [=, this]() { + // request the main PHY to switch back to the primary link only if in the meantime + // no TXOP started on another link (which will require the main PHY to switch link) + if (!GetEhtFem(linkId)->UsingOtherEmlsrLink()) + { + SwitchMainPhy(GetMainPhyId(), false, DONT_RESET_BACKOFF, REQUEST_ACCESS); + } + }); + } +} + } // namespace ns3 diff --git a/src/wifi/model/eht/advanced-emlsr-manager.h b/src/wifi/model/eht/advanced-emlsr-manager.h index ed21f9d41..0eb47e3a5 100644 --- a/src/wifi/model/eht/advanced-emlsr-manager.h +++ b/src/wifi/model/eht/advanced-emlsr-manager.h @@ -52,10 +52,14 @@ class AdvancedEmlsrManager : public DefaultEmlsrManager Time psduDuration); private: - bool m_useNotifiedMacHdr; //!< whether to use the information about the MAC header of - //!< the MPDU being received (if notified by the PHY) - bool m_allowUlTxopInRx; //!< whether a (main or aux) PHY is allowed to start an UL - //!< TXOP if another PHY is receiving a PPDU + void DoNotifyTxopEnd(uint8_t linkId) override; + + bool m_useNotifiedMacHdr; //!< whether to use the information about the MAC header of + //!< the MPDU being received (if notified by the PHY) + bool m_allowUlTxopInRx; //!< whether a (main or aux) PHY is allowed to start an UL + //!< TXOP if another PHY is receiving a PPDU + bool m_interruptSwitching; //!< whether a main PHY switching can be interrupted to start + //!< switching to another link }; } // namespace ns3