wifi: Link IDs for a container queue can be autonomously set by the scheduler

No need for the SetupLinkIds method being called by other components
This commit is contained in:
Stefano Avallone
2023-02-11 17:29:32 +01:00
parent 93673b3045
commit 2a8ea316c4
4 changed files with 27 additions and 91 deletions

View File

@@ -1269,11 +1269,6 @@ ApWifiMac::SendAssocResp(Mac48Address to, bool isReassoc, uint8_t linkId)
auto linkIdStaAddrMap = GetLinkIdStaAddrMap(assoc, to, linkId);
SetAid(assoc, linkIdStaAddrMap);
if (GetNLinks() > 1)
{
ConfigQueueScheduler(linkIdStaAddrMap, to, linkId);
}
Ptr<Packet> packet = Create<Packet>();
packet->AddHeader(assoc);
@@ -1298,39 +1293,6 @@ ApWifiMac::SendAssocResp(Mac48Address to, bool isReassoc, uint8_t linkId)
}
}
void
ApWifiMac::ConfigQueueScheduler(const LinkIdStaAddrMap& linkIdStaAddrMap,
const Mac48Address& to,
uint8_t linkId)
{
NS_LOG_FUNCTION(this << to << +linkId);
// get a list of the IDs of the links to setup
std::list<uint8_t> linkIds;
std::transform(linkIdStaAddrMap.cbegin(),
linkIdStaAddrMap.cend(),
std::back_inserter(linkIds),
[](auto&& linkIdStaAddrPair) { return linkIdStaAddrPair.first; });
// get the MLD address of the STA, if affiliated with a non-AP MLD, or the STA address
auto staAddr = to;
if (auto mldAddr = GetWifiRemoteStationManager(linkId)->GetMldAddress(to))
{
staAddr = *mldAddr;
}
// configure the queue scheduler to only use the links that have been setup for
// transmissions to this station
for (const auto& [acIndex, wifiAc] : wifiAcList)
{
for (auto tid : {wifiAc.GetLowTid(), wifiAc.GetHighTid()})
{
WifiContainerQueueId queueId(WIFI_QOSDATA_UNICAST_QUEUE, staAddr, tid);
m_scheduler->SetLinkIds(acIndex, queueId, linkIds);
}
}
}
void
ApWifiMac::SendOneBeacon(uint8_t linkId)
{

View File

@@ -328,18 +328,6 @@ class ApWifiMac : public WifiMac
LinkIdStaAddrMap GetLinkIdStaAddrMap(MgtAssocResponseHeader& assoc,
const Mac48Address& to,
uint8_t linkId);
/**
* Configure the queue scheduler so that frames stored in the container queues associated
* with the station which we are sending an Association Response frame to are only transmitted
* on the setup links.
*
* \param linkIdStaAddrMap a map of (link ID, remote STA address) of the links to setup
* \param to the Receiver Address (RA) of the Association Response frame
* \param linkId the ID of the link on which the Association Response frame is being sent
*/
void ConfigQueueScheduler(const LinkIdStaAddrMap& linkIdStaAddrMap,
const Mac48Address& to,
uint8_t linkId);
/**
* Forward an association or a reassociation response packet to the DCF/EDCA.
*

View File

@@ -74,10 +74,6 @@ class WifiMacQueueSchedulerImpl : public WifiMacQueueScheduler
const WifiContainerQueueId& prevQueueId) final;
/** \copydoc ns3::WifiMacQueueScheduler::GetLinkIds */
std::list<uint8_t> GetLinkIds(AcIndex ac, Ptr<const WifiMpdu> mpdu) final;
/** \copydoc ns3::WifiMacQueueScheduler::SetLinkIds */
void SetLinkIds(AcIndex ac,
const WifiContainerQueueId& queueId,
const std::list<uint8_t>& linkIds) final;
/** \copydoc ns3::WifiMacQueueScheduler::HasToDropBeforeEnqueue */
Ptr<WifiMpdu> HasToDropBeforeEnqueue(AcIndex ac, Ptr<WifiMpdu> mpdu) final;
/** \copydoc ns3::WifiMacQueueScheduler::NotifyEnqueue */
@@ -305,26 +301,38 @@ WifiMacQueueSchedulerImpl<Priority, Compare>::InitQueueInfo(AcIndex ac, Ptr<cons
{
// The given queueid has just been inserted in the queue info map.
// Initialize the set of link IDs depending on the container queue type
auto queueType = std::get<WifiContainerQueueType>(queueId);
auto address = std::get<Mac48Address>(queueId);
if (queueType == WIFI_MGT_QUEUE ||
(queueType == WIFI_CTL_QUEUE && GetMac() && address != GetMac()->GetAddress()) ||
queueType == WIFI_QOSDATA_BROADCAST_QUEUE)
if (GetMac() && GetMac()->GetNLinks() > 1 &&
mpdu->GetHeader().GetAddr2() == GetMac()->GetAddress())
{
// these queue types are associated with just one link
NS_ASSERT(GetMac());
auto linkId = GetMac()->GetLinkIdByAddress(address);
NS_ASSERT(linkId.has_value());
queueInfoIt->second.linkIds = {*linkId};
// this is an MLD and the TA field of the frame contains the MLD address,
// which means that the frame can be sent on multiple links
// this assert checks that association (ML setup) has been established
// between sender and receiver (unless the receiver is the broadcast address)
const auto rxAddr = mpdu->GetHeader().GetAddr1();
NS_ASSERT_MSG(GetMac()->CanForwardPacketsTo(rxAddr),
"Cannot forward frame to " << rxAddr);
// we have to include all the links in case of broadcast frame (we are an AP)
// and the links that have been setup with the receiver in case of unicast frame
for (uint8_t linkId = 0; linkId < GetMac()->GetNLinks(); linkId++)
{
if (rxAddr.IsGroup() ||
GetMac()->GetWifiRemoteStationManager(linkId)->GetAffiliatedStaAddress(rxAddr))
{
queueInfoIt->second.linkIds.emplace_back(linkId);
}
}
}
else
{
// all available links can be used. Note that AP's and STA's MACs may update
// the set of links upon association
const uint8_t nLinks = GetMac() ? GetMac()->GetNLinks() : 1; // make unit test happy
queueInfoIt->second.linkIds.resize(nLinks);
std::iota(queueInfoIt->second.linkIds.begin(), queueInfoIt->second.linkIds.end(), 0);
// the TA field of the frame contains a link address, which means that the
// frame can only be sent on the corresponding link
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};
}
}
return queueInfoIt;
@@ -379,17 +387,6 @@ WifiMacQueueSchedulerImpl<Priority, Compare>::GetLinkIds(AcIndex ac, Ptr<const W
return queueInfoIt->second.linkIds;
}
template <class Priority, class Compare>
void
WifiMacQueueSchedulerImpl<Priority, Compare>::SetLinkIds(AcIndex ac,
const WifiContainerQueueId& queueId,
const std::list<uint8_t>& linkIds)
{
NS_LOG_FUNCTION(this << +ac);
auto [queueInfoIt, ret] = m_perAcInfo[ac].queueInfoMap.insert({queueId, QueueInfo()});
queueInfoIt->second.linkIds = linkIds;
}
template <class Priority, class Compare>
std::optional<WifiContainerQueueId>
WifiMacQueueSchedulerImpl<Priority, Compare>::GetNext(AcIndex ac, uint8_t linkId)

View File

@@ -89,17 +89,6 @@ class WifiMacQueueScheduler : public Object
* \return the list of the IDs of the links the given MPDU can be sent over
*/
virtual std::list<uint8_t> GetLinkIds(AcIndex ac, Ptr<const WifiMpdu> mpdu) = 0;
/**
* Set the list of the IDs of the links the given container queue (belonging to
* the given Access Category) is associated with.
*
* \param ac the given Access Category
* \param queueId the given container queue
* \param linkIds the list of the IDs of the links the given container queue is associated with
*/
virtual void SetLinkIds(AcIndex ac,
const WifiContainerQueueId& queueId,
const std::list<uint8_t>& linkIds) = 0;
/**
* Check whether an MPDU has to be dropped before enqueuing the given MPDU.