From 60b4feb74dfdf83656fe131358ea739c01730aaf Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Sat, 28 Sep 2024 19:12:51 +0200 Subject: [PATCH] wifi: Interrupt switch main PHY back timer if medium gets busy for too long --- src/wifi/model/eht/advanced-emlsr-manager.cc | 119 +++++++++++++++++++ src/wifi/model/eht/advanced-emlsr-manager.h | 15 +++ 2 files changed, 134 insertions(+) diff --git a/src/wifi/model/eht/advanced-emlsr-manager.cc b/src/wifi/model/eht/advanced-emlsr-manager.cc index 36992cc49..4c85ae84c 100644 --- a/src/wifi/model/eht/advanced-emlsr-manager.cc +++ b/src/wifi/model/eht/advanced-emlsr-manager.cc @@ -13,6 +13,7 @@ #include "ns3/boolean.h" #include "ns3/log.h" #include "ns3/wifi-net-device.h" +#include "ns3/wifi-phy-listener.h" #include "ns3/wifi-phy.h" #include @@ -24,6 +25,85 @@ NS_LOG_COMPONENT_DEFINE("AdvancedEmlsrManager"); NS_OBJECT_ENSURE_REGISTERED(AdvancedEmlsrManager); +/** + * PHY listener connected to the main PHY while operating on the link of an aux PHY that is + * not TX capable. + * + * PHY notifications are forwarded to this EMLSR manager one timestep later because this EMLSR + * manager may then decide to switch the main PHY back to the preferred link. Given that notifying + * a PHY listener is only one of the actions that are performed when handling events such as RX end + * or CCA busy start, it is not a good idea to request a main PHY switch while performing other + * actions. Forwarding notifications a timestep later allows to first complete the handling of the + * given event and then (possibly) starting a main PHY switch. + */ +class EmlsrPhyListener : public WifiPhyListener +{ + public: + /** + * Constructor + * + * @param emlsrManager the EMLSR manager + */ + EmlsrPhyListener(Ptr emlsrManager) + : m_emlsrManager(emlsrManager) + { + } + + void NotifyRxStart(Time /* duration */) override + { + Simulator::Schedule(TimeStep(1), + &AdvancedEmlsrManager::InterruptSwitchMainPhyBackTimerIfNeeded, + m_emlsrManager); + } + + void NotifyRxEndOk() override + { + Simulator::Schedule(TimeStep(1), + &AdvancedEmlsrManager::InterruptSwitchMainPhyBackTimerIfNeeded, + m_emlsrManager); + } + + void NotifyRxEndError() override + { + } + + void NotifyTxStart(Time /* duration */, dBm_u /* txPower */) override + { + } + + void NotifyCcaBusyStart(Time /* duration */, + WifiChannelListType /* channelType */, + const std::vector