From 17bfd553d73b19fddbf4b6d4b61b2f1589d901c3 Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Sat, 11 Feb 2023 19:17:13 +0100 Subject: [PATCH] wifi: Queue scheduler keeps a mask indicating whether a link is blocked for a queue --- .../model/wifi-mac-queue-scheduler-impl.h | 29 ++++++++++++++----- src/wifi/model/wifi-mac-queue-scheduler.h | 14 +++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/wifi/model/wifi-mac-queue-scheduler-impl.h b/src/wifi/model/wifi-mac-queue-scheduler-impl.h index 0ad3b7256..796bbc4ac 100644 --- a/src/wifi/model/wifi-mac-queue-scheduler-impl.h +++ b/src/wifi/model/wifi-mac-queue-scheduler-impl.h @@ -126,10 +126,12 @@ class WifiMacQueueSchedulerImpl : public WifiMacQueueScheduler struct QueueInfo { std::optional - priorityIt; /**< iterator pointing to the entry - for this queue in the sorted list */ - std::list linkIds; /**< IDs of the links over which packets contained in this - queue can be sent over */ + priorityIt; /**< iterator pointing to the entry + for this queue in the sorted list */ + std::map linkIds; /**< Maps ID of each link on which packets contained + in this queue can be sent to a bitset indicating + whether the link is blocked (at least one bit is + non-zero) and for which reason */ }; /** @@ -321,7 +323,7 @@ WifiMacQueueSchedulerImpl::InitQueueInfo(AcIndex ac, PtrGetWifiRemoteStationManager(linkId)->GetAffiliatedStaAddress(rxAddr)) { - queueInfoIt->second.linkIds.emplace_back(linkId); + queueInfoIt->second.linkIds.emplace(linkId, Mask{}); } } } @@ -332,7 +334,7 @@ WifiMacQueueSchedulerImpl::InitQueueInfo(AcIndex ac, PtrGetLinkIdByAddress(mpdu->GetHeader().GetAddr2()) : SINGLE_LINK_OP_ID; // make unit test happy NS_ASSERT(linkId.has_value()); - queueInfoIt->second.linkIds = {*linkId}; + queueInfoIt->second.linkIds = {{*linkId, Mask{}}}; } } return queueInfoIt; @@ -383,8 +385,18 @@ std::list WifiMacQueueSchedulerImpl::GetLinkIds(AcIndex ac, Ptr mpdu) { auto queueInfoIt = InitQueueInfo(ac, mpdu); + std::list linkIds; - return queueInfoIt->second.linkIds; + // include only links that are not blocked in the returned list + for (const auto [linkId, mask] : queueInfoIt->second.linkIds) + { + if (mask.none()) + { + linkIds.emplace_back(linkId); + } + } + + return linkIds; } template @@ -428,7 +440,8 @@ WifiMacQueueSchedulerImpl::DoGetNext( const auto& queueInfoPair = sortedQueuesIt->second.get(); const auto& linkIds = queueInfoPair.second.linkIds; - if (std::find(linkIds.begin(), linkIds.end(), linkId) != linkIds.end()) + if (const auto linkIt = linkIds.find(linkId); + linkIt != linkIds.cend() && linkIt->second.none()) { // Packets in this queue can be sent over the link we got channel access on. // Now remove packets with expired lifetime from this queue. diff --git a/src/wifi/model/wifi-mac-queue-scheduler.h b/src/wifi/model/wifi-mac-queue-scheduler.h index 784d298a7..c22aa7dc7 100644 --- a/src/wifi/model/wifi-mac-queue-scheduler.h +++ b/src/wifi/model/wifi-mac-queue-scheduler.h @@ -25,6 +25,7 @@ #include "ns3/object.h" +#include #include namespace ns3 @@ -33,6 +34,16 @@ namespace ns3 class WifiMpdu; class WifiMac; +/** + * \ingroup wifi + * + * Enumeration of the reasons to block container queues. + */ +enum class WifiQueueBlockedReason : uint8_t +{ + REASONS_COUNT = 0 +}; + /** * \ingroup wifi * @@ -90,6 +101,9 @@ class WifiMacQueueScheduler : public Object */ virtual std::list GetLinkIds(AcIndex ac, Ptr mpdu) = 0; + /// Bitset identifying the reasons to block individual links for a container queue + using Mask = std::bitset(WifiQueueBlockedReason::REASONS_COUNT)>; + /** * Check whether an MPDU has to be dropped before enqueuing the given MPDU. *