diff --git a/src/wifi/helper/wifi-mac-helper.cc b/src/wifi/helper/wifi-mac-helper.cc index 39d5c4f03..62c07b0e5 100644 --- a/src/wifi/helper/wifi-mac-helper.cc +++ b/src/wifi/helper/wifi-mac-helper.cc @@ -14,6 +14,7 @@ #include "ns3/emlsr-manager.h" #include "ns3/enum.h" #include "ns3/frame-exchange-manager.h" +#include "ns3/gcr-manager.h" #include "ns3/multi-user-scheduler.h" #include "ns3/pointer.h" #include "ns3/wifi-ack-manager.h" @@ -167,6 +168,13 @@ WifiMacHelper::Create(Ptr device, WifiStandard standard) const apMac->SetApEmlsrManager(apEmlsrManager); } + // create and install the GCR Manager if this is a HT-capable AP + if (apMac && apMac->GetRobustAVStreamingSupported() && m_gcrManager.IsTypeIdSet()) + { + auto gcrManager = m_gcrManager.Create(); + apMac->SetGcrManager(gcrManager); + } + return mac; } diff --git a/src/wifi/helper/wifi-mac-helper.h b/src/wifi/helper/wifi-mac-helper.h index d81c0a4fd..f3e851d0b 100644 --- a/src/wifi/helper/wifi-mac-helper.h +++ b/src/wifi/helper/wifi-mac-helper.h @@ -168,6 +168,16 @@ class WifiMacHelper template void SetApEmlsrManager(std::string type, Args&&... args); + /** + * Helper function used to set the GCR Manager that can be installed on a QoS AP. + * + * @tparam Args \deduced Template type parameter pack for the sequence of name-value pairs. + * @param type the type of GCR Manager + * @param args A sequence of name-value pairs of the attributes to set. + */ + template + void SetGcrManager(std::string type, Args&&... args); + /** * @param device the device within which the MAC object will reside * @param standard the standard to configure during installation @@ -190,6 +200,7 @@ class WifiMacHelper ObjectFactory m_muScheduler; ///< Multi-user Scheduler object factory ObjectFactory m_emlsrManager; ///< EMLSR Manager object factory ObjectFactory m_apEmlsrManager; ///< AP EMLSR Manager object factory + ObjectFactory m_gcrManager; ///< GCR Manager object factory }; } // namespace ns3 @@ -295,6 +306,14 @@ WifiMacHelper::SetApEmlsrManager(std::string type, Args&&... args) m_apEmlsrManager.Set(args...); } +template +void +WifiMacHelper::SetGcrManager(std::string type, Args&&... args) +{ + m_gcrManager.SetTypeId(type); + m_gcrManager.Set(args...); +} + } // namespace ns3 #endif /* WIFI_MAC_HELPER_H */ diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index 375935baa..bf31fbb4d 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -12,6 +12,7 @@ #include "amsdu-subframe-header.h" #include "channel-access-manager.h" +#include "gcr-manager.h" #include "mac-rx-middle.h" #include "mac-tx-middle.h" #include "mgt-action-headers.h" @@ -168,6 +169,13 @@ ApWifiMac::GetTypeId() MakeAttributeContainerAccessor( &ApWifiMac::m_txopLimitsForSta), GetTimeAccessParamsChecker()) + .AddAttribute("GcrManager", + "The GCR manager object.", + TypeId::ATTR_GET | + TypeId::ATTR_CONSTRUCT, // prevent setting after construction + PointerValue(), + MakePointerAccessor(&ApWifiMac::GetGcrManager, &ApWifiMac::SetGcrManager), + MakePointerChecker()) .AddTraceSource("AssociatedSta", "A station associated with this access point.", MakeTraceSourceAccessor(&ApWifiMac::m_assocLogger), @@ -228,6 +236,11 @@ ApWifiMac::DoDispose() m_apEmlsrManager->Dispose(); } m_apEmlsrManager = nullptr; + if (m_gcrManager) + { + m_gcrManager->Dispose(); + } + m_gcrManager = nullptr; WifiMac::DoDispose(); } @@ -263,6 +276,20 @@ ApWifiMac::GetApEmlsrManager() const return m_apEmlsrManager; } +void +ApWifiMac::SetGcrManager(Ptr gcrManager) +{ + NS_LOG_FUNCTION(this << gcrManager); + m_gcrManager = gcrManager; + m_gcrManager->SetWifiMac(this); +} + +Ptr +ApWifiMac::GetGcrManager() const +{ + return m_gcrManager; +} + void ApWifiMac::DoCompleteConfig() { @@ -2568,6 +2595,11 @@ ApWifiMac::DoInitialize() UpdateShortPreambleEnabled(linkId); } + if (m_gcrManager) + { + m_gcrManager->Initialize(); + } + NS_ABORT_IF(!TraceConnectWithoutContext("AckedMpdu", MakeCallback(&ApWifiMac::TxOk, this))); NS_ABORT_IF( !TraceConnectWithoutContext("DroppedMpdu", MakeCallback(&ApWifiMac::TxFailed, this))); diff --git a/src/wifi/model/ap-wifi-mac.h b/src/wifi/model/ap-wifi-mac.h index 56f4686f8..88ed6a14a 100644 --- a/src/wifi/model/ap-wifi-mac.h +++ b/src/wifi/model/ap-wifi-mac.h @@ -39,6 +39,7 @@ class CfParameterSet; class UniformRandomVariable; class MgtEmlOmn; class ApEmlsrManager; +class GcrManager; /// variant holding a reference to a (Re)Association Request using AssocReqRefVariant = std::variant, @@ -85,6 +86,18 @@ class ApWifiMac : public WifiMac */ Ptr GetApEmlsrManager() const; + /** + * Set the GCR Manager. + * + * @param gcrManager the GCR Manager + */ + void SetGcrManager(Ptr gcrManager); + + /** + * @return the GCR Manager + */ + Ptr GetGcrManager() const; + /** * @param interval the interval between two beacon transmissions. */ @@ -607,6 +620,7 @@ class ApWifiMac : public WifiMac /// transition timeout events running for EMLSR clients std::map m_transitionTimeoutEvents; Ptr m_apEmlsrManager; ///< AP EMLSR Manager + Ptr m_gcrManager; //!< GCR Manager UintAccessParamsMap m_cwMinsForSta; //!< Per-AC CW min values to advertise to stations UintAccessParamsMap m_cwMaxsForSta; //!< Per-AC CW max values to advertise to stations