diff --git a/src/wifi/model/wifi-assoc-manager.cc b/src/wifi/model/wifi-assoc-manager.cc index 1a7ace907..33991431c 100644 --- a/src/wifi/model/wifi-assoc-manager.cc +++ b/src/wifi/model/wifi-assoc-manager.cc @@ -22,6 +22,7 @@ #include "sta-wifi-mac.h" +#include "ns3/attribute-container.h" #include "ns3/eht-configuration.h" #include "ns3/enum.h" #include "ns3/log.h" @@ -67,7 +68,17 @@ WifiAssocManager::ApInfoCompare::operator()(const StaWifiMac::ApInfo& lhs, TypeId WifiAssocManager::GetTypeId() { - static TypeId tid = TypeId("ns3::WifiAssocManager").SetParent().SetGroupName("Wifi"); + static TypeId tid = + TypeId("ns3::WifiAssocManager") + .SetParent() + .SetGroupName("Wifi") + .AddAttribute( + "AllowedLinks", + "Only Beacon and Probe Response frames received on a link belonging to the given " + "set are processed. An empty set is equivalent to the set of all links.", + AttributeContainerValue(), + MakeAttributeContainerAccessor(&WifiAssocManager::m_allowedLinks), + MakeAttributeContainerChecker(MakeUintegerChecker())); return tid; } @@ -166,10 +177,12 @@ WifiAssocManager::StartScanning(WifiScanParams&& scanParams) NS_LOG_FUNCTION(this); m_scanParams = std::move(scanParams); - // remove stored AP information not matching the scanning parameters + // remove stored AP information not matching the scanning parameters or related to APs + // that are not reachable on an allowed link for (auto ap = m_apList.begin(); ap != m_apList.end();) { - if (!MatchScanParams(*ap)) + if (!MatchScanParams(*ap) || + (!m_allowedLinks.empty() && m_allowedLinks.count(ap->m_linkId) == 0)) { // remove AP info from list m_apListIt.erase(ap->m_bssid); @@ -189,7 +202,8 @@ WifiAssocManager::NotifyApInfo(const StaWifiMac::ApInfo&& apInfo) { NS_LOG_FUNCTION(this << apInfo); - if (!CanBeInserted(apInfo) || !MatchScanParams(apInfo)) + if (!CanBeInserted(apInfo) || !MatchScanParams(apInfo) || + (!m_allowedLinks.empty() && m_allowedLinks.count(apInfo.m_linkId) == 0)) { return; } diff --git a/src/wifi/model/wifi-assoc-manager.h b/src/wifi/model/wifi-assoc-manager.h index 66cb42009..672da56cd 100644 --- a/src/wifi/model/wifi-assoc-manager.h +++ b/src/wifi/model/wifi-assoc-manager.h @@ -233,7 +233,9 @@ class WifiAssocManager : public Object */ bool CanSetupMultiLink(OptMleConstRef& mle, OptRnrConstRef& rnr); - Ptr m_mac; ///< pointer to the STA wifi MAC + Ptr m_mac; ///< pointer to the STA wifi MAC + std::set m_allowedLinks; /**< "Only Beacon and Probe Response frames received on a + link belonging to the this set are processed */ private: /**