wifi: Queue scheduler keeps a mask indicating whether a link is blocked for a queue

This commit is contained in:
Stefano Avallone
2023-02-11 19:17:13 +01:00
parent 19454e862f
commit 17bfd553d7
2 changed files with 35 additions and 8 deletions

View File

@@ -126,10 +126,12 @@ class WifiMacQueueSchedulerImpl : public WifiMacQueueScheduler
struct QueueInfo
{
std::optional<typename SortedQueues::iterator>
priorityIt; /**< iterator pointing to the entry
for this queue in the sorted list */
std::list<uint8_t> 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<uint8_t, Mask> 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<Priority, Compare>::InitQueueInfo(AcIndex ac, Ptr<cons
if (rxAddr.IsGroup() ||
GetMac()->GetWifiRemoteStationManager(linkId)->GetAffiliatedStaAddress(rxAddr))
{
queueInfoIt->second.linkIds.emplace_back(linkId);
queueInfoIt->second.linkIds.emplace(linkId, Mask{});
}
}
}
@@ -332,7 +334,7 @@ WifiMacQueueSchedulerImpl<Priority, Compare>::InitQueueInfo(AcIndex ac, Ptr<cons
auto linkId = GetMac() ? GetMac()->GetLinkIdByAddress(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<uint8_t>
WifiMacQueueSchedulerImpl<Priority, Compare>::GetLinkIds(AcIndex ac, Ptr<const WifiMpdu> mpdu)
{
auto queueInfoIt = InitQueueInfo(ac, mpdu);
std::list<uint8_t> 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 <class Priority, class Compare>
@@ -428,7 +440,8 @@ WifiMacQueueSchedulerImpl<Priority, Compare>::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.

View File

@@ -25,6 +25,7 @@
#include "ns3/object.h"
#include <bitset>
#include <optional>
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<uint8_t> GetLinkIds(AcIndex ac, Ptr<const WifiMpdu> mpdu) = 0;
/// Bitset identifying the reasons to block individual links for a container queue
using Mask = std::bitset<static_cast<std::size_t>(WifiQueueBlockedReason::REASONS_COUNT)>;
/**
* Check whether an MPDU has to be dropped before enqueuing the given MPDU.
*