Skip to content

Commit

Permalink
wifi: Do not reset end busy times in case of EMLSR link switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefano Avallone committed Sep 23, 2024
1 parent a46abc4 commit e990fc0
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 20 deletions.
75 changes: 57 additions & 18 deletions src/wifi/model/channel-access-manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ ChannelAccessManager::SetupPhyListener(Ptr<WifiPhy> phy)
DeactivatePhyListener(m_phy);
}
m_phy = phy; // this is the new active PHY
InitLastBusyStructs();
ResizeLastBusyStructs();
phy->RegisterListener(phyListener);
if (phy->IsStateSwitching())
{
Expand Down Expand Up @@ -362,43 +362,82 @@ ChannelAccessManager::Add(Ptr<Txop> txop)
}

void
ChannelAccessManager::InitLastBusyStructs()
ChannelAccessManager::ResizeLastBusyStructs()
{
NS_LOG_FUNCTION(this);
Time now = Simulator::Now();
m_lastBusyEnd.clear();
m_lastPer20MHzBusyEnd.clear();
m_lastIdle.clear();
m_lastBusyEnd[WIFI_CHANLIST_PRIMARY] = now;
m_lastIdle[WIFI_CHANLIST_PRIMARY] = {now, now};
const auto now = Simulator::Now();

m_lastBusyEnd.emplace(WIFI_CHANLIST_PRIMARY, now);
m_lastIdle.emplace(WIFI_CHANLIST_PRIMARY, Timespan{now, now});

const auto width = m_phy ? m_phy->GetChannelWidth() : 0;
std::size_t size =
(width > 20 && m_phy->GetStandard() >= WIFI_STANDARD_80211ax) ? width / 20 : 0;
m_lastPer20MHzBusyEnd.resize(size, now);

if (!m_phy || !m_phy->GetOperatingChannel().IsOfdm())
{
return;
}

const auto width = m_phy->GetChannelWidth();

if (width >= 40)
{
m_lastBusyEnd[WIFI_CHANLIST_SECONDARY] = now;
m_lastIdle[WIFI_CHANLIST_SECONDARY] = {now, now};
m_lastBusyEnd.emplace(WIFI_CHANLIST_SECONDARY, now);
m_lastIdle.emplace(WIFI_CHANLIST_SECONDARY, Timespan{now, now});
}
else
{
m_lastBusyEnd.erase(WIFI_CHANLIST_SECONDARY);
m_lastIdle.erase(WIFI_CHANLIST_SECONDARY);
}

if (width >= 80)
{
m_lastBusyEnd[WIFI_CHANLIST_SECONDARY40] = now;
m_lastIdle[WIFI_CHANLIST_SECONDARY40] = {now, now};
m_lastBusyEnd.emplace(WIFI_CHANLIST_SECONDARY40, now);
m_lastIdle.emplace(WIFI_CHANLIST_SECONDARY40, Timespan{now, now});
}
else
{
m_lastBusyEnd.erase(WIFI_CHANLIST_SECONDARY40);
m_lastIdle.erase(WIFI_CHANLIST_SECONDARY40);
}

if (width >= 160)
{
m_lastBusyEnd[WIFI_CHANLIST_SECONDARY80] = now;
m_lastIdle[WIFI_CHANLIST_SECONDARY80] = {now, now};
m_lastBusyEnd.emplace(WIFI_CHANLIST_SECONDARY80, now);
m_lastIdle.emplace(WIFI_CHANLIST_SECONDARY80, Timespan{now, now});
}
else
{
m_lastBusyEnd.erase(WIFI_CHANLIST_SECONDARY80);
m_lastIdle.erase(WIFI_CHANLIST_SECONDARY80);
}

// TODO Add conditions for new channel widths as they get supported
}

void
ChannelAccessManager::InitLastBusyStructs()
{
NS_LOG_FUNCTION(this);
Time now = Simulator::Now();

ResizeLastBusyStructs();

// reset all values
for (auto& [chType, time] : m_lastBusyEnd)
{
time = now;
}

for (auto& [chType, timeSpan] : m_lastIdle)
{
timeSpan = Timespan{now, now};
}

if (m_phy->GetStandard() >= WIFI_STANDARD_80211ax && width > 20)
for (auto& time : m_lastPer20MHzBusyEnd)
{
m_lastPer20MHzBusyEnd.assign(width / 20, now);
time = now;
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/wifi/model/channel-access-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,17 @@ class ChannelAccessManager : public Object
std::shared_ptr<PhyListener> GetPhyListener(Ptr<WifiPhy> phy) const;

/**
* Initialize the structures holding busy end times per channel type (primary,
* secondary, etc.) and per 20 MHz channel.
* Initialize the structures holding busy end times per channel type (primary, secondary, etc.)
* and per 20 MHz channel. All values are set to the current time.
*/
void InitLastBusyStructs();

/**
* Resize the structures holding busy end times per channel type (primary, secondary, etc.)
* and per 20 MHz channel. If a value (e.g., the busy end time for secondary40 channel) already
* exists, it is not changed; otherwise, it is set to the current time.
*/
void ResizeLastBusyStructs();
/**
* Update backoff slots for all Txops.
*/
Expand Down

0 comments on commit e990fc0

Please sign in to comment.