From 2d4ff42649e7d7473cb196c01cf628023072a1d5 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Fri, 10 May 2024 17:25:29 +0200 Subject: [PATCH] wifi: Allow more reuse/customization of RrMultiUserScheduler code --- src/wifi/model/he/rr-multi-user-scheduler.cc | 33 +++++++++------- src/wifi/model/he/rr-multi-user-scheduler.h | 41 +++++++++++++------- 2 files changed, 48 insertions(+), 26 deletions(-) diff --git a/src/wifi/model/he/rr-multi-user-scheduler.cc b/src/wifi/model/he/rr-multi-user-scheduler.cc index 190dda6a9..d6bd6da49 100644 --- a/src/wifi/model/he/rr-multi-user-scheduler.cc +++ b/src/wifi/model/he/rr-multi-user-scheduler.cc @@ -167,9 +167,8 @@ RrMultiUserScheduler::SelectTxFormat() return TrySendingDlMuPpdu(); } -template WifiTxVector -RrMultiUserScheduler::GetTxVectorForUlMu(Func canBeSolicited) +RrMultiUserScheduler::GetTxVectorForUlMu(std::function canBeSolicited) { NS_LOG_FUNCTION(this); @@ -277,6 +276,13 @@ RrMultiUserScheduler::GetTxVectorForUlMu(Func canBeSolicited) return txVector; } +bool +RrMultiUserScheduler::CanSolicitStaInBsrpTf(const MasterInfo& info) const +{ + // only consider stations that have setup the current link + return m_apMac->GetStaList(m_linkId).contains(info.aid); +} + MultiUserScheduler::TxFormat RrMultiUserScheduler::TrySendingBsrpTf() { @@ -288,11 +294,8 @@ RrMultiUserScheduler::TrySendingBsrpTf() return TxFormat::SU_TX; } - // only consider stations that have setup the current link - WifiTxVector txVector = GetTxVectorForUlMu([this](const MasterInfo& info) { - const auto& staList = m_apMac->GetStaList(m_linkId); - return staList.contains(info.aid); - }); + auto txVector = GetTxVectorForUlMu( + std::bind(&RrMultiUserScheduler::CanSolicitStaInBsrpTf, this, std::placeholders::_1)); if (txVector.GetHeMuUserInfoMap().empty()) { @@ -361,6 +364,14 @@ RrMultiUserScheduler::TrySendingBsrpTf() return UL_MU_TX; } +bool +RrMultiUserScheduler::CanSolicitStaInBasicTf(const MasterInfo& info) const +{ + // only consider stations that setup the current link and do not have reported a null queue size + return m_apMac->GetStaList(m_linkId).contains(info.aid) && + m_apMac->GetMaxBufferStatus(info.address) > 0; +} + MultiUserScheduler::TxFormat RrMultiUserScheduler::TrySendingBasicTf() { @@ -375,12 +386,8 @@ RrMultiUserScheduler::TrySendingBasicTf() // check if an UL OFDMA transmission is possible after a DL OFDMA transmission NS_ABORT_MSG_IF(m_ulPsduSize == 0, "The UlPsduSize attribute must be set to a non-null value"); - // only consider stations that have setup the current link and do not have - // reported a null queue size - WifiTxVector txVector = GetTxVectorForUlMu([this](const MasterInfo& info) { - const auto& staList = m_apMac->GetStaList(m_linkId); - return staList.contains(info.aid) && m_apMac->GetMaxBufferStatus(info.address) > 0; - }); + auto txVector = GetTxVectorForUlMu( + std::bind(&RrMultiUserScheduler::CanSolicitStaInBasicTf, this, std::placeholders::_1)); if (txVector.GetHeMuUserInfoMap().empty()) { diff --git a/src/wifi/model/he/rr-multi-user-scheduler.h b/src/wifi/model/he/rr-multi-user-scheduler.h index 9b43993de..e41606e9e 100644 --- a/src/wifi/model/he/rr-multi-user-scheduler.h +++ b/src/wifi/model/he/rr-multi-user-scheduler.h @@ -11,6 +11,7 @@ #include "multi-user-scheduler.h" +#include #include namespace ns3 @@ -45,6 +46,32 @@ class RrMultiUserScheduler : public MultiUserScheduler void DoDispose() override; void DoInitialize() override; + /** + * Information used to sort stations + */ + struct MasterInfo + { + uint16_t aid; //!< station's AID + Mac48Address address; //!< station's MAC Address + double credits; //!< credits accumulated by the station + }; + + /** + * Determine whether the given STA can be solicited via a Basic Trigger Frame. + * + * \param info the information about the given STA + * \return whether the given STA can be solicited via a Basic Trigger Frame + */ + virtual bool CanSolicitStaInBasicTf(const MasterInfo& info) const; + + /** + * Determine whether the given STA can be solicited via a BSRP Trigger Frame. + * + * \param info the information about the given STA + * \return whether the given STA can be solicited via a BSRP Trigger Frame + */ + virtual bool CanSolicitStaInBsrpTf(const MasterInfo& info) const; + private: TxFormat SelectTxFormat() override; DlMuInfo ComputeDlMuInfo() override; @@ -82,13 +109,11 @@ class RrMultiUserScheduler : public MultiUserScheduler * transmissions from suitable stations, i.e., stations that have established a * BlockAck agreement with the AP and for which the given predicate returns true. * - * \tparam Func \deduced the type of the given predicate * \param canBeSolicited a predicate returning false for stations that shall not be solicited * \return a TXVECTOR that can be used to construct a Trigger Frame to solicit * transmissions from suitable stations */ - template - WifiTxVector GetTxVectorForUlMu(Func canBeSolicited); + virtual WifiTxVector GetTxVectorForUlMu(std::function canBeSolicited); /** * Notify the scheduler that a station associated with the AP @@ -105,16 +130,6 @@ class RrMultiUserScheduler : public MultiUserScheduler */ void NotifyStationDeassociated(uint16_t aid, Mac48Address address); - /** - * Information used to sort stations - */ - struct MasterInfo - { - uint16_t aid; //!< station's AID - Mac48Address address; //!< station's MAC Address - double credits; //!< credits accumulated by the station - }; - /** * Finalize the given TXVECTOR by only including the largest subset of the * current set of candidate stations that can be allocated equal-sized RUs