From c0ce2ea2b752d532a774efc425ad5d6d52fe98db Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Sun, 14 May 2023 18:29:03 +0200 Subject: [PATCH] wifi: Do not rely on AssocManager subclass to store BSSIDs in remote station manager --- src/wifi/model/sta-wifi-mac.cc | 19 +++++--------- src/wifi/model/sta-wifi-mac.h | 14 ++++++++-- src/wifi/model/wifi-assoc-manager.cc | 4 +-- src/wifi/model/wifi-assoc-manager.h | 2 +- src/wifi/model/wifi-default-assoc-manager.cc | 27 +++++--------------- 5 files changed, 29 insertions(+), 37 deletions(-) diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 667b0c0ba..dc98dd722 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -617,22 +617,17 @@ StaWifiMac::ScanningTimeout(const std::optional& bestAp) GetLink(bestAp->m_linkId).sendAssocReq = true; GetLink(bestAp->m_linkId).bssid = bestAp->m_bssid; // update info on links to setup (11be MLDs only) - for (const auto& [localLinkId, apLinkId] : bestAp->m_setupLinks) + const auto& mle = + std::visit([](auto&& frame) { return frame.template Get(); }, + bestAp->m_frame); + for (const auto& [localLinkId, apLinkId, bssid] : bestAp->m_setupLinks) { + NS_ASSERT_MSG(mle, "We get here only for ML setup"); NS_LOG_DEBUG("Setting up link (local ID=" << +localLinkId << ", AP ID=" << +apLinkId << ")"); GetLink(localLinkId).apLinkId = apLinkId; - if (localLinkId == bestAp->m_linkId) - { - continue; - } - auto mldAddress = - GetWifiRemoteStationManager(bestAp->m_linkId)->GetMldAddress(bestAp->m_bssid); - NS_ABORT_MSG_IF(!mldAddress.has_value(), "AP MLD address not set"); - auto bssid = GetWifiRemoteStationManager(localLinkId)->GetAffiliatedStaAddress(*mldAddress); - NS_ABORT_MSG_IF(!mldAddress.has_value(), - "AP link address not set for local link " << +localLinkId); - GetLink(localLinkId).bssid = *bssid; + GetLink(localLinkId).bssid = bssid; + GetWifiRemoteStationManager(localLinkId)->SetMldAddress(bssid, mle->GetMldMacAddress()); } // lambda to get beacon interval from Beacon or Probe Response auto getBeaconInterval = [](auto&& frame) { diff --git a/src/wifi/model/sta-wifi-mac.h b/src/wifi/model/sta-wifi-mac.h index 731e9a6e8..9c185c480 100644 --- a/src/wifi/model/sta-wifi-mac.h +++ b/src/wifi/model/sta-wifi-mac.h @@ -162,14 +162,24 @@ class StaWifiMac : public WifiMac */ struct ApInfo { + /** + * Information about links to setup + */ + struct SetupLinksInfo + { + uint8_t localLinkId; ///< local link ID + uint8_t apLinkId; ///< AP link ID + Mac48Address bssid; ///< BSSID + }; + Mac48Address m_bssid; ///< BSSID Mac48Address m_apAddr; ///< AP MAC address double m_snr; ///< SNR in linear scale MgtFrameType m_frame; ///< The body of the management frame used to update AP info WifiScanParams::Channel m_channel; ///< The channel the management frame was received on uint8_t m_linkId; ///< ID of the link used to communicate with the AP - /// list of (local link ID, AP link ID) pairs identifying the links to setup between MLDs - std::list> m_setupLinks; + std::list + m_setupLinks; ///< information about the links to setup between MLDs }; /** diff --git a/src/wifi/model/wifi-assoc-manager.cc b/src/wifi/model/wifi-assoc-manager.cc index dd253d5d0..83c869b73 100644 --- a/src/wifi/model/wifi-assoc-manager.cc +++ b/src/wifi/model/wifi-assoc-manager.cc @@ -234,10 +234,10 @@ WifiAssocManager::ScanningTimeout() m_mac->ScanningTimeout(std::move(bestAp)); } -std::list>& +std::list& WifiAssocManager::GetSetupLinks(const StaWifiMac::ApInfo& apInfo) { - return const_cast>&>(apInfo.m_setupLinks); + return const_cast&>(apInfo.m_setupLinks); } bool diff --git a/src/wifi/model/wifi-assoc-manager.h b/src/wifi/model/wifi-assoc-manager.h index 6e1827276..66cb42009 100644 --- a/src/wifi/model/wifi-assoc-manager.h +++ b/src/wifi/model/wifi-assoc-manager.h @@ -178,7 +178,7 @@ class WifiAssocManager : public Object * \param apInfo the info about the given AP * \return a reference to the list of the links to setup with the given AP */ - std::list>& GetSetupLinks(const StaWifiMac::ApInfo& apInfo); + std::list& GetSetupLinks(const StaWifiMac::ApInfo& apInfo); /** * \return the scanning parameters. diff --git a/src/wifi/model/wifi-default-assoc-manager.cc b/src/wifi/model/wifi-default-assoc-manager.cc index 79e6e81a7..ba6d8bb3a 100644 --- a/src/wifi/model/wifi-default-assoc-manager.cc +++ b/src/wifi/model/wifi-default-assoc-manager.cc @@ -133,15 +133,12 @@ WifiDefaultAssocManager::EndScanning() } auto& bestAp = *GetSortedList().begin(); - - // store AP MLD MAC address in the WifiRemoteStationManager associated with - // the link on which the Beacon/Probe Response was received - m_mac->GetWifiRemoteStationManager(bestAp.m_linkId) - ->SetMldAddress(bestAp.m_apAddr, mle->get().GetMldMacAddress()); auto& setupLinks = GetSetupLinks(bestAp); setupLinks.clear(); - setupLinks.emplace_back(bestAp.m_linkId, mle->get().GetLinkIdInfo()); + setupLinks.emplace_back(StaWifiMac::ApInfo::SetupLinksInfo{bestAp.m_linkId, + mle->get().GetLinkIdInfo(), + bestAp.m_bssid}); // sort local PHY objects so that radios with constrained PHY band comes first, // then radios with no constraint @@ -203,14 +200,10 @@ WifiDefaultAssocManager::EndScanning() // if we get here, it means we can setup a link with this affiliated AP // set the BSSID for this link Mac48Address bssid = rnr->get().GetBssid(apIt->m_nbrApInfoId, apIt->m_tbttInfoFieldId); - // store AP MLD MAC address in the WifiRemoteStationManager associated with - // the link requested to setup - m_mac->GetWifiRemoteStationManager(linkId)->SetMldAddress( - bssid, - mle->get().GetMldMacAddress()); - setupLinks.emplace_back( + setupLinks.emplace_back(StaWifiMac::ApInfo::SetupLinksInfo{ linkId, - rnr->get().GetLinkId(apIt->m_nbrApInfoId, apIt->m_tbttInfoFieldId)); + rnr->get().GetLinkId(apIt->m_nbrApInfoId, apIt->m_tbttInfoFieldId), + bssid}); if (needChannelSwitch) { @@ -264,12 +257,6 @@ WifiDefaultAssocManager::NotifyChannelSwitched(uint8_t linkId) // we were waiting for this notification m_channelSwitchInfo[linkId].timer.Cancel(); - // the remote station manager has been reset after switching, hence store - // information about AP link address and AP MLD address - m_mac->GetWifiRemoteStationManager(linkId)->SetMldAddress( - m_channelSwitchInfo[linkId].apLinkAddress, - m_channelSwitchInfo[linkId].apMldAddress); - if (std::none_of(m_channelSwitchInfo.begin(), m_channelSwitchInfo.end(), [](auto&& info) { return info.timer.IsRunning(); })) @@ -289,7 +276,7 @@ WifiDefaultAssocManager::ChannelSwitchTimeout(uint8_t linkId) auto& bestAp = *GetSortedList().begin(); auto& setupLinks = GetSetupLinks(bestAp); auto it = std::find_if(setupLinks.begin(), setupLinks.end(), [&linkId](auto&& linkIds) { - return linkIds.first == linkId; + return linkIds.localLinkId == linkId; }); NS_ASSERT(it != setupLinks.end()); setupLinks.erase(it);