27 #include "ns3/simulator.h"
42 TypeId(
"ns3::WifiDefaultAssocManager")
44 .AddConstructor<WifiDefaultAssocManager>()
46 .AddAttribute(
"ChannelSwitchTimeout",
47 "After requesting a channel switch on a link to setup that link, "
48 "wait at most this amount of time. If a channel switch is not "
49 "notified within this amount of time, we give up setting up that link.",
120 std::list<WifiAssocManager::RnrLinkInfo> apList;
134 ->
SetMldAddress(bestAp.m_apAddr, mle->get().GetMldMacAddress());
138 setupLinks.emplace_back(bestAp.m_linkId, mle->get().GetLinkIdInfo());
142 std::list<uint8_t> localLinkIds;
146 if (linkId == bestAp.m_linkId)
155 localLinkIds.push_front(linkId);
159 localLinkIds.push_back(linkId);
164 for (
const auto& linkId : localLinkIds)
167 auto apIt = apList.begin();
169 while (apIt != apList.end())
176 if (
phy->HasFixedPhyBand() &&
phy->GetPhyBand() != apChannel.GetPhyBand())
182 bool needChannelSwitch =
false;
183 if (
const auto&
channel =
phy->GetOperatingChannel();
184 channel.GetNumber() != apChannel.GetNumber() ||
185 channel.GetWidth() != apChannel.GetWidth() ||
186 channel.GetPhyBand() != apChannel.GetPhyBand())
188 needChannelSwitch =
true;
191 if (needChannelSwitch &&
phy->IsStateSwitching())
202 Mac48Address bssid = rnr->get().GetBssid(apIt->m_nbrApInfoId, apIt->m_tbttInfoFieldId);
207 mle->get().GetMldMacAddress());
208 setupLinks.emplace_back(
210 rnr->get().GetLinkId(apIt->m_nbrApInfoId, apIt->m_tbttInfoFieldId));
212 if (needChannelSwitch)
214 if (
phy->IsStateSleep())
217 phy->ResumeFromSleep();
222 << +linkId <<
" to using channel " << +apChannel.GetNumber()
223 <<
" in band " << apChannel.GetPhyBand() <<
" frequency "
224 << apChannel.GetFrequency() <<
"MHz width " << apChannel.GetWidth()
227 apChannel.GetWidth(),
228 apChannel.GetPhyBand(),
229 apChannel.GetPrimaryChannelIndex(20)};
230 phy->SetOperatingChannel(chTuple);
251 return info.timer.IsRunning();
275 return info.timer.IsRunning();
292 auto it = std::find_if(setupLinks.begin(), setupLinks.end(), [&linkId](
auto&& linkIds) {
293 return linkIds.first == linkId;
296 setupLinks.erase(it);
299 return info.timer.IsRunning();
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
void SendProbeRequest()
Forward a probe request packet to the DCF.
AttributeValue implementation for Time.
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
std::optional< std::reference_wrapper< const MultiLinkElement > > OptMleConstRef
typedef for an optional const reference to a MultiLinkElement object
Ptr< StaWifiMac > m_mac
pointer to the STA wifi MAC
void ScanningTimeout()
Extract the best AP to associate with from the sorted list and return it, if any, to the STA wifi MAC...
std::optional< std::reference_wrapper< const ReducedNeighborReport > > OptRnrConstRef
typedef for an optional const reference to a ReducedNeighborReport object
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.
const WifiScanParams & GetScanParams() const
void DoDispose() override
Destructor implementation.
bool CanSetupMultiLink(OptMleConstRef &mle, OptRnrConstRef &rnr)
Check whether 11be Multi-Link setup can be established with the current best AP.
std::list< std::pair< std::uint8_t, uint8_t > > & GetSetupLinks(const StaWifiMac::ApInfo &apInfo)
Get a reference to the list of the links to setup with the given AP.
void EndScanning()
Perform operations to do at the end of a scanning procedure, such as identifying the links to setup i...
void DoDispose() override
Destructor implementation.
EventId m_probeRequestEvent
probe request event
~WifiDefaultAssocManager() override
void DoStartScanning() override
Start a scanning procedure.
bool CanBeInserted(const StaWifiMac::ApInfo &apInfo) const override
Allow subclasses to choose whether the given ApInfo shall be considered and hence inserted in the sor...
Time m_channelSwitchTimeout
maximum delay for channel switching
void NotifyChannelSwitched(uint8_t linkId) override
Notify that the given link has completed channel switching.
WifiDefaultAssocManager()
bool Compare(const StaWifiMac::ApInfo &lhs, const StaWifiMac::ApInfo &rhs) const override
Compare two ApInfo objects for the purpose of keeping a sorted list of ApInfo objects.
EventId m_waitBeaconEvent
wait beacon event
static TypeId GetTypeId()
Get the type ID.
void ChannelSwitchTimeout(uint8_t linkId)
Take action upon the expiration of the timer set when requesting channel switch on the given link.
std::vector< ChannelSwitchInfo > m_channelSwitchInfo
per-link channel switch info
bool CanBeReturned(const StaWifiMac::ApInfo &apInfo) const override
Allow subclasses to choose whether the given ApInfo shall be returned or discarded when the STA wifi ...
uint8_t GetNLinks() const
Get the number of links (can be greater than 1 for 11be devices only).
Ptr< WifiPhy > GetWifiPhy(uint8_t linkId=SINGLE_LINK_OP_ID) const
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
bool HasFixedPhyBand() const
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
const WifiPhyOperatingChannel & GetOperatingChannel() const
Get a const reference to the operating channel.
void SetMldAddress(const Mac48Address &address, const Mac48Address &mldAddress)
Set the address of the MLD the given station is affiliated with.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Struct to hold information regarding observed AP through active/passive scanning.
double m_snr
SNR in linear scale.