From 636c2578f4e68de16155e46b342478a622cd606c Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Mon, 3 Apr 2023 17:34:57 +0200 Subject: [PATCH] wifi: Add attributes to EMLSR manager to switch EMLSR links --- src/wifi/model/eht/default-emlsr-manager.cc | 16 +++++-- src/wifi/model/eht/default-emlsr-manager.h | 2 + src/wifi/model/eht/emlsr-manager.cc | 47 ++++++++++++++++++++- src/wifi/model/eht/emlsr-manager.h | 30 +++++++++++++ 4 files changed, 90 insertions(+), 5 deletions(-) diff --git a/src/wifi/model/eht/default-emlsr-manager.cc b/src/wifi/model/eht/default-emlsr-manager.cc index 7e2218543..016ef7a05 100644 --- a/src/wifi/model/eht/default-emlsr-manager.cc +++ b/src/wifi/model/eht/default-emlsr-manager.cc @@ -19,6 +19,7 @@ #include "default-emlsr-manager.h" +#include "ns3/boolean.h" #include "ns3/log.h" #include "ns3/wifi-mpdu.h" @@ -32,10 +33,17 @@ NS_OBJECT_ENSURE_REGISTERED(DefaultEmlsrManager); TypeId DefaultEmlsrManager::GetTypeId() { - static TypeId tid = TypeId("ns3::DefaultEmlsrManager") - .SetParent() - .SetGroupName("Wifi") - .AddConstructor(); + static TypeId tid = + TypeId("ns3::DefaultEmlsrManager") + .SetParent() + .SetGroupName("Wifi") + .AddConstructor() + .AddAttribute("SwitchAuxPhy", + "Whether Aux PHY should switch channel to operate on the link on which " + "the Main PHY was operating before moving to the link of the Aux PHY.", + BooleanValue(true), + MakeBooleanAccessor(&DefaultEmlsrManager::m_switchAuxPhy), + MakeBooleanChecker()); return tid; } diff --git a/src/wifi/model/eht/default-emlsr-manager.h b/src/wifi/model/eht/default-emlsr-manager.h index 3f0c12269..b5cd515f6 100644 --- a/src/wifi/model/eht/default-emlsr-manager.h +++ b/src/wifi/model/eht/default-emlsr-manager.h @@ -54,6 +54,8 @@ class DefaultEmlsrManager : public EmlsrManager std::optional m_assocLinkId; /**< ID of the link on which Association Response was received */ + bool m_switchAuxPhy; /**< whether Aux PHY should switch channel to operate on the link on which + the Main PHY was operating before moving to the link of the Aux PHY */ }; } // namespace ns3 diff --git a/src/wifi/model/eht/emlsr-manager.cc b/src/wifi/model/eht/emlsr-manager.cc index 24c206478..f6874fd69 100644 --- a/src/wifi/model/eht/emlsr-manager.cc +++ b/src/wifi/model/eht/emlsr-manager.cc @@ -54,13 +54,32 @@ EmlsrManager::GetTypeId() TimeValue(MicroSeconds(0)), MakeTimeAccessor(&EmlsrManager::m_emlsrTransitionDelay), MakeTimeChecker(MicroSeconds(0), MicroSeconds(256))) + .AddAttribute( + "MainPhyId", + "The ID of the main PHY (position in the vector of PHYs held by " + "WifiNetDevice). This attribute cannot be set after initialization.", + UintegerValue(0), + MakeUintegerAccessor(&EmlsrManager::SetMainPhyId, &EmlsrManager::GetMainPhyId), + MakeUintegerChecker()) + .AddAttribute("AuxPhyChannelWidth", + "The maximum channel width (MHz) supported by Aux PHYs", + UintegerValue(20), + MakeUintegerAccessor(&EmlsrManager::m_auxPhyMaxWidth), + MakeUintegerChecker(20, 160)) .AddAttribute( "EmlsrLinkSet", "IDs of the links on which EMLSR mode will be enabled. An empty set " "indicates to disable EMLSR.", AttributeContainerValue(), MakeAttributeContainerAccessor(&EmlsrManager::SetEmlsrLinks), - MakeAttributeContainerChecker(MakeUintegerChecker())); + MakeAttributeContainerChecker(MakeUintegerChecker())) + .AddAttribute("ResetCamState", + "Whether to reset the state of the ChannelAccessManager associated with " + "the link on which the main PHY has just switched to.", + BooleanValue(false), + MakeBooleanAccessor(&EmlsrManager::SetCamStateReset, + &EmlsrManager::GetCamStateReset), + MakeBooleanChecker()); return tid; } @@ -103,6 +122,32 @@ EmlsrManager::SetWifiMac(Ptr mac) MakeCallback(&EmlsrManager::TxDropped, this)); } +void +EmlsrManager::SetMainPhyId(uint8_t mainPhyId) +{ + NS_LOG_FUNCTION(this << mainPhyId); + NS_ABORT_MSG_IF(IsInitialized(), "Cannot be called once this object has been initialized"); + m_mainPhyId = mainPhyId; +} + +uint8_t +EmlsrManager::GetMainPhyId() const +{ + return m_mainPhyId; +} + +void +EmlsrManager::SetCamStateReset(bool enable) +{ + m_resetCamState = enable; +} + +bool +EmlsrManager::GetCamStateReset() const +{ + return m_resetCamState; +} + const std::set& EmlsrManager::GetEmlsrLinks() const { diff --git a/src/wifi/model/eht/emlsr-manager.h b/src/wifi/model/eht/emlsr-manager.h index 24e0a2e92..6a04bb817 100644 --- a/src/wifi/model/eht/emlsr-manager.h +++ b/src/wifi/model/eht/emlsr-manager.h @@ -70,6 +70,19 @@ class EmlsrManager : public Object */ std::optional