diff --git a/src/wifi/model/wifi-mac-queue-scheduler-impl.h b/src/wifi/model/wifi-mac-queue-scheduler-impl.h index e8d83aa7d..a6e2cc2f0 100644 --- a/src/wifi/model/wifi-mac-queue-scheduler-impl.h +++ b/src/wifi/model/wifi-mac-queue-scheduler-impl.h @@ -66,11 +66,14 @@ class WifiMacQueueSchedulerImpl : public WifiMacQueueScheduler /** \copydoc ns3::WifiMacQueueScheduler::SetWifiMac */ void SetWifiMac(Ptr mac) final; - /** \copydoc ns3::WifiMacQueueScheduler::GetNext(AcIndex,uint8_t) */ - std::optional GetNext(AcIndex ac, uint8_t linkId) final; - /** \copydoc ns3::WifiMacQueueScheduler::GetNext(AcIndex,uint8_t,const WifiContainerQueueId&) */ + /** \copydoc ns3::WifiMacQueueScheduler::GetNext(AcIndex,std::optional) */ + std::optional GetNext(AcIndex ac, std::optional linkId) final; + /** + * \copydoc ns3::WifiMacQueueScheduler::GetNext(AcIndex,std::optional, + * const WifiContainerQueueId&) + */ std::optional GetNext(AcIndex ac, - uint8_t linkId, + std::optional linkId, const WifiContainerQueueId& prevQueueId) final; /** \copydoc ns3::WifiMacQueueScheduler::GetLinkIds */ std::list GetLinkIds(AcIndex ac, Ptr mpdu) final; @@ -202,12 +205,13 @@ class WifiMacQueueSchedulerImpl : public WifiMacQueueScheduler * Queues containing MPDUs that cannot be sent over the given link are ignored. * * \param ac the Access Category that we want to serve - * \param linkId the ID of the link on which we got channel access + * \param linkId the ID of the link on which MPDUs contained in the returned queue must be + * allowed to be sent * \param sortedQueuesIt iterator pointing to the queue we start the search from * \return the ID of the selected container queue (if any) */ std::optional DoGetNext(AcIndex ac, - uint8_t linkId, + std::optional linkId, typename SortedQueues::iterator sortedQueuesIt); /** @@ -566,19 +570,19 @@ WifiMacQueueSchedulerImpl::GetQueueLinkMask(AcIndex ac, template std::optional -WifiMacQueueSchedulerImpl::GetNext(AcIndex ac, uint8_t linkId) +WifiMacQueueSchedulerImpl::GetNext(AcIndex ac, std::optional linkId) { - NS_LOG_FUNCTION(this << +ac << +linkId); + NS_LOG_FUNCTION(this << +ac << linkId.has_value()); return DoGetNext(ac, linkId, m_perAcInfo[ac].sortedQueues.begin()); } template std::optional WifiMacQueueSchedulerImpl::GetNext(AcIndex ac, - uint8_t linkId, + std::optional linkId, const WifiContainerQueueId& prevQueueId) { - NS_LOG_FUNCTION(this << +ac << +linkId); + NS_LOG_FUNCTION(this << +ac << linkId.has_value()); auto queueInfoIt = m_perAcInfo[ac].queueInfoMap.find(prevQueueId); NS_ABORT_IF(queueInfoIt == m_perAcInfo[ac].queueInfoMap.end() || @@ -594,19 +598,20 @@ template std::optional WifiMacQueueSchedulerImpl::DoGetNext( AcIndex ac, - uint8_t linkId, + std::optional linkId, typename SortedQueues::iterator sortedQueuesIt) { - NS_LOG_FUNCTION(this << +ac << +linkId); + NS_LOG_FUNCTION(this << +ac << linkId.has_value()); NS_ASSERT(static_cast(ac) < AC_UNDEF); while (sortedQueuesIt != m_perAcInfo[ac].sortedQueues.end()) { const auto& queueInfoPair = sortedQueuesIt->second.get(); const auto& linkIds = queueInfoPair.second.linkIds; + typename std::decay_t::const_iterator linkIt; - if (const auto linkIt = linkIds.find(linkId); - linkIt != linkIds.cend() && linkIt->second.none()) + if (!linkId.has_value() || + ((linkIt = linkIds.find(*linkId)) != 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 b650e7694..51ccbcc62 100644 --- a/src/wifi/model/wifi-mac-queue-scheduler.h +++ b/src/wifi/model/wifi-mac-queue-scheduler.h @@ -104,26 +104,29 @@ class WifiMacQueueScheduler : public Object /** * Get the next queue to serve, which is guaranteed to contain at least an MPDU * whose lifetime has not expired. Queues containing MPDUs that cannot be sent - * over the given link are ignored. + * over the given link (if any) are ignored. * * \param ac the Access Category that we want to serve - * \param linkId the ID of the link on which we got channel access + * \param linkId the ID of the link on which MPDUs contained in the returned queue must be + * allowed to be sent * \return the ID of the selected container queue (if any) */ - virtual std::optional GetNext(AcIndex ac, uint8_t linkId) = 0; + virtual std::optional GetNext(AcIndex ac, + std::optional linkId) = 0; /** * Get the next queue to serve after the given one. The returned queue is * guaranteed to contain at least an MPDU whose lifetime has not expired. - * Queues containing MPDUs that cannot be sent over the given link are ignored. + * Queues containing MPDUs that cannot be sent over the given link (if any) are ignored. * * \param ac the Access Category that we want to serve - * \param linkId the ID of the link on which we got channel access + * \param linkId the ID of the link on which MPDUs contained in the returned queue must be + * allowed to be sent * \param prevQueueId the ID of the container queue served previously * \return the ID of the selected container queue (if any) */ virtual std::optional GetNext( AcIndex ac, - uint8_t linkId, + std::optional linkId, const WifiContainerQueueId& prevQueueId) = 0; /**