diff --git a/src/wifi/helper/wifi-mac-helper.cc b/src/wifi/helper/wifi-mac-helper.cc index 82360bfa3..54009aeed 100644 --- a/src/wifi/helper/wifi-mac-helper.cc +++ b/src/wifi/helper/wifi-mac-helper.cc @@ -20,6 +20,8 @@ #include "wifi-mac-helper.h" #include "ns3/boolean.h" +#include "ns3/eht-configuration.h" +#include "ns3/emlsr-manager.h" #include "ns3/frame-exchange-manager.h" #include "ns3/multi-user-scheduler.h" #include "ns3/wifi-ack-manager.h" @@ -40,6 +42,7 @@ WifiMacHelper::WifiMacHelper() m_queueScheduler.SetTypeId("ns3::FcfsWifiQueueScheduler"); m_protectionManager.SetTypeId("ns3::WifiDefaultProtectionManager"); m_ackManager.SetTypeId("ns3::WifiDefaultAckManager"); + m_emlsrManager.SetTypeId("ns3::DefaultEmlsrManager"); } WifiMacHelper::~WifiMacHelper() @@ -107,12 +110,23 @@ WifiMacHelper::Create(Ptr device, WifiStandard standard) const } // create and install the Association Manager if this is a STA - if (auto staMac = DynamicCast(mac); staMac != nullptr) + auto staMac = DynamicCast(mac); + if (staMac) { Ptr assocManager = m_assocManager.Create(); staMac->SetAssocManager(assocManager); } + // create and install the EMLSR Manager if this is an EHT non-AP MLD with EMLSR activated + if (BooleanValue emlsrActivated; + standard >= WIFI_STANDARD_80211be && staMac && staMac->GetNLinks() > 1 && + device->GetEhtConfiguration()->GetAttributeFailSafe("EmlsrActivated", emlsrActivated) && + emlsrActivated.Get()) + { + auto emlsrManager = m_emlsrManager.Create(); + staMac->SetEmlsrManager(emlsrManager); + } + return mac; } diff --git a/src/wifi/helper/wifi-mac-helper.h b/src/wifi/helper/wifi-mac-helper.h index 6f4a1d0d5..f09f2299a 100644 --- a/src/wifi/helper/wifi-mac-helper.h +++ b/src/wifi/helper/wifi-mac-helper.h @@ -119,6 +119,16 @@ class WifiMacHelper template void SetMultiUserScheduler(std::string type, Args&&... args); + /** + * Helper function used to set the EMLSR Manager that can be installed on an EHT non-AP MLD. + * + * \tparam Args \deduced Template type parameter pack for the sequence of name-value pairs. + * \param type the type of EMLSR Manager + * \param args A sequence of name-value pairs of the attributes to set. + */ + template + void SetEmlsrManager(std::string type, Args&&... args); + /** * \param device the device within which the MAC object will reside * \param standard the standard to configure during installation @@ -135,6 +145,7 @@ class WifiMacHelper ObjectFactory m_protectionManager; ///< Factory to create a protection manager ObjectFactory m_ackManager; ///< Factory to create an acknowledgment manager ObjectFactory m_muScheduler; ///< Multi-user Scheduler object factory + ObjectFactory m_emlsrManager; ///< EMLSR Manager object factory }; } // namespace ns3 @@ -194,6 +205,14 @@ WifiMacHelper::SetMultiUserScheduler(std::string type, Args&&... args) m_muScheduler.Set(args...); } +template +void +WifiMacHelper::SetEmlsrManager(std::string type, Args&&... args) +{ + m_emlsrManager.SetTypeId(type); + m_emlsrManager.Set(args...); +} + } // namespace ns3 #endif /* WIFI_MAC_HELPER_H */ diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 62218eab9..46c20818b 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -30,6 +30,7 @@ #include "wifi-net-device.h" #include "wifi-phy.h" +#include "ns3/emlsr-manager.h" #include "ns3/he-configuration.h" #include "ns3/ht-configuration.h" #include "ns3/log.h" @@ -153,6 +154,11 @@ StaWifiMac::DoDispose() m_assocManager->Dispose(); } m_assocManager = nullptr; + if (m_emlsrManager) + { + m_emlsrManager->Dispose(); + } + m_emlsrManager = nullptr; WifiMac::DoDispose(); } @@ -194,6 +200,20 @@ StaWifiMac::SetAssocManager(Ptr assocManager) m_assocManager->SetStaWifiMac(this); } +void +StaWifiMac::SetEmlsrManager(Ptr emlsrManager) +{ + NS_LOG_FUNCTION(this << emlsrManager); + m_emlsrManager = emlsrManager; + m_emlsrManager->SetWifiMac(this); +} + +Ptr +StaWifiMac::GetEmlsrManager() const +{ + return m_emlsrManager; +} + uint16_t StaWifiMac::GetAssociationId() const { diff --git a/src/wifi/model/sta-wifi-mac.h b/src/wifi/model/sta-wifi-mac.h index 18bbc31e4..76f2d6132 100644 --- a/src/wifi/model/sta-wifi-mac.h +++ b/src/wifi/model/sta-wifi-mac.h @@ -40,6 +40,7 @@ class SupportedRates; class CapabilityInformation; class RandomVariableStream; class WifiAssocManager; +class EmlsrManager; /** * \ingroup wifi @@ -190,6 +191,18 @@ class StaWifiMac : public WifiMac */ void SetAssocManager(Ptr assocManager); + /** + * Set the EMLSR Manager. + * + * \param emlsrManager the EMLSR Manager + */ + void SetEmlsrManager(Ptr emlsrManager); + + /** + * \return the EMLSR Manager + */ + Ptr GetEmlsrManager() const; + /** * Enqueue a probe request packet for transmission on the given link. * @@ -492,6 +505,7 @@ class StaWifiMac : public WifiMac MacState m_state; ///< MAC state uint16_t m_aid; ///< Association AID Ptr m_assocManager; ///< Association Manager + Ptr m_emlsrManager; ///< EMLSR Manager Time m_waitBeaconTimeout; ///< wait beacon timeout Time m_probeRequestTimeout; ///< probe request timeout Time m_assocRequestTimeout; ///< association request timeout