diff --git a/src/wifi/model/sta-wifi-mac.cc b/src/wifi/model/sta-wifi-mac.cc index 5ba9c94c5..246277fea 100644 --- a/src/wifi/model/sta-wifi-mac.cc +++ b/src/wifi/model/sta-wifi-mac.cc @@ -596,16 +596,35 @@ StaWifiMac::MissedBeacons (uint8_t linkId) { delay = GetWifiPhy (linkId)->GetDelayUntilIdle (); } - Simulator::Schedule (delay, &StaWifiMac::Disassociated, this); + Simulator::Schedule (delay, &StaWifiMac::Disassociated, this, linkId); } void -StaWifiMac::Disassociated (void) +StaWifiMac::Disassociated (uint8_t linkId) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << +linkId); + + // disable the given link + GetLink (linkId).apLinkId = std::nullopt; + GetLink (linkId).phy->SetOffMode (); + + for (uint8_t id = 0; id < GetNLinks (); id++) + { + if (GetLink (id).apLinkId.has_value ()) + { + // found an enabled link + return; + } + } + NS_LOG_DEBUG ("Set state to UNASSOCIATED and start scanning"); SetState (UNASSOCIATED); m_aid = 0; // reset AID + // ensure all links are on + for (uint8_t id = 0; id < GetNLinks (); id++) + { + GetLink (id).phy->ResumeFromOff (); + } TryToEnsureAssociated (); } @@ -1251,10 +1270,9 @@ StaWifiMac::NotifyChannelSwitching (uint8_t linkId) WifiMac::NotifyChannelSwitching (linkId); - if (IsInitialized ()) + if (IsInitialized () && IsAssociated ()) { - // TODO handle deassociation of a link in ML setup - Disassociated (); + Disassociated (linkId); } } diff --git a/src/wifi/model/sta-wifi-mac.h b/src/wifi/model/sta-wifi-mac.h index 7cd93e098..e22f4fc2b 100644 --- a/src/wifi/model/sta-wifi-mac.h +++ b/src/wifi/model/sta-wifi-mac.h @@ -382,9 +382,13 @@ private: */ void RestartBeaconWatchdog (Time delay, uint8_t linkId); /** - * Take actions after disassociation. + * Check if any enabled link remains after the given link is disabled (because, + * e.g., the maximum number of beacons is missed or the channel is switched). + * If no enabled link remains, proceed with disassociation. + * + * \param linkId the ID of the given link */ - void Disassociated (void); + void Disassociated (uint8_t linkId); /** * Return an instance of SupportedRates that contains all rates that we support * including HT rates.