wifi: STAs disassociate when no enabled link remains

This commit is contained in:
Stefano Avallone
2022-07-19 19:10:20 +02:00
committed by Stefano Avallone
parent 23d508d193
commit 43f20f90c8
2 changed files with 30 additions and 8 deletions

View File

@@ -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);
}
}

View File

@@ -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.