14#include "ns3/attribute-container.h"
15#include "ns3/eht-configuration.h"
38 "Comparing two ApInfo objects with the same BSSID: " << lhs.
m_bssid);
40 bool lhsBefore = m_manager.Compare(lhs, rhs);
46 bool rhsBefore = m_manager.Compare(rhs, lhs);
61 TypeId(
"ns3::WifiAssocManager")
66 "Only Beacon and Probe Response frames received on a link belonging to the given "
67 "set are processed. An empty set is equivalent to the set of all links.",
120 if (
auto beacon = std::get_if<MgtBeaconHeader>(&apInfo.
m_frame); beacon)
122 apSsid = beacon->Get<
Ssid>().value();
126 auto probeResp = std::get_if<MgtProbeResponseHeader>(&apInfo.
m_frame);
128 apSsid = probeResp->Get<
Ssid>().value();
139 auto channelMatch = [&apInfo](
auto&& channel) {
203 auto [hashIt, hashInserted] =
m_apListIt.insert({apInfo.m_bssid, {}});
211 auto [listIt, listInserted] =
m_apList.insert(std::move(apInfo));
214 "An entry (" << listIt->m_apAddr <<
", " << listIt->m_bssid <<
", "
216 <<
") prevented insertion of given ApInfo object");
217 hashIt->second = listIt;
231 m_mac->ScanningTimeout(std::nullopt);
239 m_mac->ScanningTimeout(std::move(bestAp));
242std::list<StaWifiMac::ApInfo::SetupLinksInfo>&
245 return const_cast<std::list<StaWifiMac::ApInfo::SetupLinksInfo>&
>(apInfo.
m_setupLinks);
260 if (
auto beacon = std::get_if<MgtBeaconHeader>(&
m_apList.begin()->m_frame); beacon)
267 auto probeResp = std::get_if<MgtProbeResponseHeader>(&
m_apList.begin()->m_frame);
273 if (!mle.has_value())
275 NS_LOG_DEBUG(
"No Multi-Link Element in Beacon/Probe Response");
279 if (!rnr.has_value() || rnr->get().GetNNbrApInfoFields() == 0)
281 NS_LOG_DEBUG(
"No Reduced Neighbor Report Element in Beacon/Probe Response");
287 if (!mle->get().HasLinkIdInfo())
289 NS_LOG_DEBUG(
"No Link ID Info subfield in the Multi-Link Element");
293 if (
const auto& mldCapabilities = mle->get().GetCommonInfoBasic().m_mldCapabilities)
295 auto ehtConfig =
m_mac->GetEhtConfiguration();
298 ehtConfig->GetAttributeFailSafe(
"TidToLinkMappingNegSupport", negSupport);
306 if (mldCapabilities->tidToLinkMappingSupport > 0 &&
309 NS_LOG_DEBUG(
"AP MLD supports TID-to-Link Mapping negotiation, while we don't");
317std::optional<WifiAssocManager::RnrLinkInfo>
331 std::size_t tbttInfoFieldIndex = 0;
333 rnr.
GetMldId(nbrApInfoId, tbttInfoFieldIndex) != 0)
335 tbttInfoFieldIndex++;
342 return RnrLinkInfo{nbrApInfoId, tbttInfoFieldIndex};
350std::list<WifiAssocManager::RnrLinkInfo>
353 std::list<WifiAssocManager::RnrLinkInfo> apList;
354 std::size_t nbrApInfoId = 0;
355 std::optional<WifiAssocManager::RnrLinkInfo> next;
359 apList.push_back({*next});
360 nbrApInfoId = next->m_nbrApInfoId + 1;
A container for one type of attribute.
Hold variables of type enum.
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
The Reduced Neighbor Report element.
std::size_t GetNNbrApInfoFields() const
Get the number of Neighbor AP Information fields.
std::size_t GetNTbttInformationFields(std::size_t nbrApInfoId) const
Get the number of TBTT Information fields included in the TBTT Information Set field of the given Nei...
uint8_t GetMldId(std::size_t nbrApInfoId, std::size_t index) const
Get the MLD ID value in the MLD Parameters subfield (must be present) in the i-th TBTT Information fi...
bool HasMldParameters(std::size_t nbrApInfoId) const
Return true if the MLD Parameters subfield is present in all the TBTT Information fields of the given...
The IEEE 802.11 SSID Information Element.
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
bool IsBroadcast() const
Check if the SSID is broadcast.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Abstract base class for the Association Manager, which manages scanning and association for single li...
const SortedList & GetSortedList() const
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::optional< std::reference_wrapper< const MultiLinkElement > > OptMleConstRef
typedef for an optional const reference to a MultiLinkElement object
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.
std::optional< std::reference_wrapper< const ReducedNeighborReport > > OptRnrConstRef
typedef for an optional const reference to a ReducedNeighborReport object
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...
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
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.
~WifiAssocManager() override
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.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< AttributeChecker > MakeAttributeContainerChecker()
Make uninitialized AttributeContainerChecker using explicit types.
Ptr< const AttributeAccessor > MakeAttributeContainerAccessor(T1 a1)
Make AttributeContainerAccessor using explicit types.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
@ WIFI_PHY_BAND_UNSPECIFIED
Unspecified.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeUintegerChecker()
Struct to hold information regarding observed AP through active/passive scanning.
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.
std::list< SetupLinksInfo > m_setupLinks
information about the links to setup between MLDs
uint8_t m_linkId
ID of the link used to communicate with the AP.
Mac48Address m_bssid
BSSID.
Struct providing a function call operator to compare two ApInfo objects.
ApInfoCompare(const WifiAssocManager &manager)
Constructor.
bool operator()(const StaWifiMac::ApInfo &lhs, const StaWifiMac::ApInfo &rhs) const
Function call operator.
Struct to identify a specific TBTT Information field of a Neighbor AP Information field in a Reduced ...
WifiPhyBand band
PHY band.
uint16_t number
channel number
Structure holding scan parameters.
std::vector< ChannelList > channelList
list of channels to scan, for each link
Ssid ssid
desired SSID or wildcard SSID