A Discrete-Event Network Simulator
API
wifi-assoc-manager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Universita' degli Studi di Napoli Federico II
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Stefano Avallone <stavallo@unina.it>
18  */
19 
20 #ifndef WIFI_ASSOC_MANAGER_H
21 #define WIFI_ASSOC_MANAGER_H
22 
23 #include "qos-utils.h"
24 #include "sta-wifi-mac.h"
25 
26 #include <optional>
27 #include <set>
28 #include <unordered_map>
29 
30 namespace ns3
31 {
32 
40 class WifiAssocManager : public Object
41 {
48  {
54  ApInfoCompare(const WifiAssocManager& manager);
64  bool operator()(const StaWifiMac::ApInfo& lhs, const StaWifiMac::ApInfo& rhs) const;
65 
66  private:
68  };
69 
70  public:
75  struct RnrLinkInfo
76  {
77  std::size_t m_nbrApInfoId;
78  std::size_t m_tbttInfoFieldId;
79  };
80 
85  static TypeId GetTypeId();
86 
87  ~WifiAssocManager() override;
88 
95 
104  void StartScanning(WifiScanParams&& scanParams);
105 
114  virtual void NotifyApInfo(const StaWifiMac::ApInfo&& apInfo);
115 
121  virtual void NotifyChannelSwitched(uint8_t linkId) = 0;
122 
133  virtual bool Compare(const StaWifiMac::ApInfo& lhs, const StaWifiMac::ApInfo& rhs) const = 0;
134 
144  static std::optional<WifiAssocManager::RnrLinkInfo> GetNextAffiliatedAp(
145  const ReducedNeighborReport& rnr,
146  std::size_t nbrApInfoId);
147 
156  static std::list<WifiAssocManager::RnrLinkInfo> GetAllAffiliatedAps(
157  const ReducedNeighborReport& rnr);
158 
159  protected:
164  void DoDispose() override;
165 
167  using SortedList = std::set<StaWifiMac::ApInfo, ApInfoCompare>;
168 
172  const SortedList& GetSortedList() const;
173 
181  std::list<StaWifiMac::ApInfo::SetupLinksInfo>& GetSetupLinks(const StaWifiMac::ApInfo& apInfo);
182 
186  const WifiScanParams& GetScanParams() const;
187 
194  bool MatchScanParams(const StaWifiMac::ApInfo& apInfo) const;
195 
203  virtual bool CanBeInserted(const StaWifiMac::ApInfo& apInfo) const = 0;
211  virtual bool CanBeReturned(const StaWifiMac::ApInfo& apInfo) const = 0;
212 
218  void ScanningTimeout();
219 
221  using OptRnrConstRef = std::optional<std::reference_wrapper<const ReducedNeighborReport>>;
223  using OptMleConstRef = std::optional<std::reference_wrapper<const MultiLinkElement>>;
224 
235 
237  std::set<uint8_t> m_allowedLinks;
240  private:
245  virtual void DoStartScanning() = 0;
246 
250  std::unordered_map<Mac48Address, SortedList::const_iterator, WifiAddressHash> m_apListIt;
251 };
252 
253 } // namespace ns3
254 
255 #endif /* WIFI_ASSOC_MANAGER_H */
A base class which provides memory management and object aggregation.
Definition: object.h:89
The Reduced Neighbor Report element.
a unique identifier for an interface.
Definition: type-id.h:59
Abstract base class for the Association Manager, which manages scanning and association for single li...
const SortedList & GetSortedList() const
std::optional< std::reference_wrapper< const MultiLinkElement > > OptMleConstRef
typedef for an optional const reference to a MultiLinkElement object
virtual void NotifyChannelSwitched(uint8_t linkId)=0
Notify that the given link has completed channel switching.
virtual void NotifyApInfo(const StaWifiMac::ApInfo &&apInfo)
STA wifi MAC received a Beacon frame or Probe Response frame while scanning and notifies us the AP in...
Ptr< StaWifiMac > m_mac
pointer to the STA wifi MAC
virtual void DoStartScanning()=0
Start a scanning procedure.
void SetStaWifiMac(Ptr< StaWifiMac > mac)
Set the pointer to the STA wifi MAC.
std::list< StaWifiMac::ApInfo::SetupLinksInfo > & GetSetupLinks(const StaWifiMac::ApInfo &apInfo)
Get a reference to the list of the links to setup with the given AP.
void ScanningTimeout()
Extract the best AP to associate with from the sorted list and return it, if any, to the STA wifi MAC...
virtual bool CanBeInserted(const StaWifiMac::ApInfo &apInfo) const =0
Allow subclasses to choose whether the given ApInfo shall be considered and hence inserted in the sor...
std::optional< std::reference_wrapper< const ReducedNeighborReport > > OptRnrConstRef
typedef for an optional const reference to a ReducedNeighborReport object
SortedList m_apList
sorted list of candidate APs
static std::optional< WifiAssocManager::RnrLinkInfo > GetNextAffiliatedAp(const ReducedNeighborReport &rnr, std::size_t nbrApInfoId)
Search the given RNR element for APs affiliated to the same AP MLD as the reporting AP.
WifiScanParams m_scanParams
scanning parameters
virtual bool CanBeReturned(const StaWifiMac::ApInfo &apInfo) const =0
Allow subclasses to choose whether the given ApInfo shall be returned or discarded when the STA wifi ...
void StartScanning(WifiScanParams &&scanParams)
Request the Association Manager to start a scanning procedure according to the given scanning paramet...
std::set< StaWifiMac::ApInfo, ApInfoCompare > SortedList
typedef for the sorted list of ApInfo objects
std::set< uint8_t > m_allowedLinks
"Only Beacon and Probe Response frames received on a link belonging to the this set are processed
virtual bool Compare(const StaWifiMac::ApInfo &lhs, const StaWifiMac::ApInfo &rhs) const =0
Compare two ApInfo objects for the purpose of keeping a sorted list of ApInfo objects.
static std::list< WifiAssocManager::RnrLinkInfo > GetAllAffiliatedAps(const ReducedNeighborReport &rnr)
Find all the APs affiliated to the same AP MLD as the reporting AP that sent the given RNR element.
static TypeId GetTypeId()
Get the type ID.
const WifiScanParams & GetScanParams() const
void DoDispose() override
Destructor implementation.
std::unordered_map< Mac48Address, SortedList::const_iterator, WifiAddressHash > m_apListIt
hash table to help locate ApInfo objects in the sorted list based on the BSSID
bool CanSetupMultiLink(OptMleConstRef &mle, OptRnrConstRef &rnr)
Check whether 11be Multi-Link setup can be established with the current best AP.
WifiAssocManager()
Constructor (protected as this is an abstract base class)
bool MatchScanParams(const StaWifiMac::ApInfo &apInfo) const
Check whether the given AP information match the current scanning parameters.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mac
Definition: third.py:92
Struct to hold information regarding observed AP through active/passive scanning.
Definition: sta-wifi-mac.h:158
Struct providing a function call operator to compare two ApInfo objects.
const WifiAssocManager & m_manager
Association Manager.
ApInfoCompare(const WifiAssocManager &manager)
Constructor.
bool operator()(const StaWifiMac::ApInfo &lhs, const StaWifiMac::ApInfo &rhs) const
Function call operator.
Structure holding scan parameters.
Definition: sta-wifi-mac.h:60