From 4a4bc1ca9be85e156ff69c3b7f68660f1ae4dc36 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Tue, 5 Jul 2022 23:53:21 +0200 Subject: [PATCH] wifi: ApWifiMac keeps one AID-to-Address map for each link --- src/wifi/model/ap-wifi-mac.cc | 37 ++++++++++++++++++++--------------- src/wifi/model/ap-wifi-mac.h | 19 ++++++++++-------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/wifi/model/ap-wifi-mac.cc b/src/wifi/model/ap-wifi-mac.cc index d255768ce..b125c3961 100644 --- a/src/wifi/model/ap-wifi-mac.cc +++ b/src/wifi/model/ap-wifi-mac.cc @@ -118,7 +118,6 @@ ApWifiMac::ApWifiMac () ApWifiMac::~ApWifiMac () { NS_LOG_FUNCTION (this); - m_staList.clear (); } void @@ -241,7 +240,7 @@ ApWifiMac::UpdateShortSlotTimeEnabled (void) NS_LOG_FUNCTION (this); if (GetErpSupported (SINGLE_LINK_OP_ID) && GetShortSlotTimeSupported () && (m_numNonErpStations == 0)) { - for (const auto& sta : m_staList) + for (const auto& sta : GetLink (SINGLE_LINK_OP_ID).staList) { if (!GetWifiRemoteStationManager ()->GetShortSlotTimeSupported (sta.second)) { @@ -263,7 +262,7 @@ ApWifiMac::UpdateShortPreambleEnabled (void) NS_LOG_FUNCTION (this); if (GetErpSupported (SINGLE_LINK_OP_ID) && GetWifiPhy ()->GetShortPhyPreambleSupported ()) { - for (const auto& sta : m_staList) + for (const auto& sta : GetLink (SINGLE_LINK_OP_ID).staList) { if (!GetWifiRemoteStationManager ()->GetErpOfdmSupported (sta.second) || !GetWifiRemoteStationManager ()->GetShortPreambleSupported (sta.second)) @@ -668,7 +667,7 @@ ApWifiMac::GetHtOperation (void) const uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedTxSpatialStreams (); auto mcsList = GetWifiPhy ()->GetMcsList (WIFI_MOD_CLASS_HT); uint8_t nMcs = mcsList.size (); - for (const auto& sta : m_staList) + for (const auto& sta : GetLink (SINGLE_LINK_OP_ID).staList) { if (GetWifiRemoteStationManager ()->GetHtSupported (sta.second)) { @@ -744,7 +743,7 @@ ApWifiMac::GetVhtOperation (void) const // which the VHT BSS operates. operation.SetChannelCenterFrequencySegment1 ((bssBandwidth == 160) ? GetWifiPhy ()->GetChannelNumber () : 0); uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams (); - for (const auto& sta : m_staList) + for (const auto& sta : GetLink (SINGLE_LINK_OP_ID).staList) { if (GetWifiRemoteStationManager ()->GetVhtSupported (sta.second)) { @@ -772,7 +771,7 @@ ApWifiMac::GetHeOperation (void) const { operation.SetHeSupported (1); uint8_t maxSpatialStream = GetWifiPhy ()->GetMaxSupportedRxSpatialStreams (); - for (const auto& sta : m_staList) + for (const auto& sta : GetLink (SINGLE_LINK_OP_ID).staList) { if (GetWifiRemoteStationManager ()->GetHeSupported (sta.second)) { @@ -908,7 +907,7 @@ ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc) bool found = false; if (isReassoc) { - for (const auto& sta : m_staList) + for (const auto& sta : GetLink (SINGLE_LINK_OP_ID).staList) { if (sta.second == to) { @@ -920,8 +919,8 @@ ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc) } if (!found) { - aid = GetNextAssociationId (); - m_staList.insert (std::make_pair (aid, to)); + aid = GetNextAssociationId ({SINGLE_LINK_OP_ID}); + GetLink (SINGLE_LINK_OP_ID).staList.insert (std::make_pair (aid, to)); m_assocLogger (aid, to); GetWifiRemoteStationManager ()->SetAssociationId (to, aid); if (GetWifiRemoteStationManager ()->GetDsssSupported (to) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (to)) @@ -1251,11 +1250,12 @@ ApWifiMac::Receive (Ptr mpdu, uint8_t linkId) { NS_LOG_DEBUG ("Disassociation received from " << from); GetWifiRemoteStationManager ()->RecordDisassociated (from); - for (auto it = m_staList.begin (); it != m_staList.end (); ++it) + auto& staList = GetLink (SINGLE_LINK_OP_ID).staList; + for (auto it = staList.begin (); it != staList.end (); ++it) { if (it->second == from) { - m_staList.erase (it); + staList.erase (it); m_deAssocLogger (it->first, it->second); if (GetWifiRemoteStationManager ()->GetDsssSupported (from) && !GetWifiRemoteStationManager ()->GetErpOfdmSupported (from)) { @@ -1505,12 +1505,17 @@ ApWifiMac::GetUseNonErpProtection (void) const } uint16_t -ApWifiMac::GetNextAssociationId (void) +ApWifiMac::GetNextAssociationId (std::list linkIds) { - //Return the first free AID value between 1 and 2007 + // Return the first AID value between 1 and 2007 that is free for all the given links for (uint16_t nextAid = 1; nextAid <= 2007; nextAid++) { - if (m_staList.find (nextAid) == m_staList.end ()) + if (std::all_of (linkIds.begin (), linkIds.end (), + [&](auto&& linkId) + { + auto& staList = GetLink (linkId).staList; + return staList.find (nextAid) == staList.end (); + })) { return nextAid; } @@ -1520,9 +1525,9 @@ ApWifiMac::GetNextAssociationId (void) } const std::map& -ApWifiMac::GetStaList (void) const +ApWifiMac::GetStaList (uint8_t linkId) const { - return m_staList; + return GetLink (linkId).staList; } uint16_t diff --git a/src/wifi/model/ap-wifi-mac.h b/src/wifi/model/ap-wifi-mac.h index 4f5b9c1ed..c04647847 100644 --- a/src/wifi/model/ap-wifi-mac.h +++ b/src/wifi/model/ap-wifi-mac.h @@ -98,13 +98,14 @@ public: int64_t AssignStreams (int64_t stream); /** - * Get a const reference to the map of associated stations. Each station is - * specified by an (association ID, MAC address) pair. Make sure not to use - * the returned reference after that this object has been deallocated. + * Get a const reference to the map of associated stations on the given link. + * Each station is specified by an (association ID, MAC address) pair. Make sure + * not to use the returned reference after that this object has been deallocated. * + * \param linkId the ID of the given link * \return a const reference to the map of associated stations */ - const std::map& GetStaList (void) const; + const std::map& GetStaList (uint8_t linkId = SINGLE_LINK_OP_ID) const; /** * \param addr the address of the associated station * \return the Association ID allocated by the AP to the station, SU_STA_ID if unallocated @@ -159,7 +160,9 @@ protected: /// Destructor (a virtual method is needed to make this struct polymorphic) virtual ~ApLinkEntity (); - EventId beaconEvent; //!< Event to generate one beacon + EventId beaconEvent; //!< Event to generate one beacon + std::map staList; //!< Map of all stations currently associated + //!< to the AP with their association ID }; /** @@ -369,16 +372,16 @@ private: void DoInitialize (void) override; /** - * \return the next Association ID to be allocated by the AP + * \param linkIds the IDs of the links for which the next Association ID is requested + * \return the next Association ID to be allocated by the AP on the given links */ - uint16_t GetNextAssociationId (void); + uint16_t GetNextAssociationId (std::list linkIds); Ptr m_beaconTxop; //!< Dedicated Txop for beacons bool m_enableBeaconGeneration; //!< Flag whether beacons are being generated Time m_beaconInterval; //!< Beacon interval Ptr m_beaconJitter; //!< UniformRandomVariable used to randomize the time of the first beacon bool m_enableBeaconJitter; //!< Flag whether the first beacon should be generated at random time - std::map m_staList; //!< Map of all stations currently associated to the AP with their association ID uint16_t m_numNonErpStations; //!< Number of non-ERP stations currently associated to the AP uint16_t m_numNonHtStations; //!< Number of non-HT stations currently associated to the AP bool m_shortSlotTimeEnabled; //!< Flag whether short slot time is enabled within the BSS