diff --git a/src/wave/model/wave-frame-exchange-manager.cc b/src/wave/model/wave-frame-exchange-manager.cc index 7f69c37a3..d6404e40e 100644 --- a/src/wave/model/wave-frame-exchange-manager.cc +++ b/src/wave/model/wave-frame-exchange-manager.cc @@ -133,7 +133,7 @@ WaveFrameExchangeManager::StartTransmission (Ptr dcf) } m_dcf->NotifyChannelAccessed (); - Ptr mpdu = *queue->Peek ()->GetQueueIteratorPair ().it; + Ptr mpdu = *queue->Peek ()->GetQueueIterator (); NS_ASSERT (mpdu != 0); // assign a sequence number if this is not a fragment nor a retransmission diff --git a/src/wifi/model/block-ack-manager.cc b/src/wifi/model/block-ack-manager.cc index 7f38664ac..f74103f39 100644 --- a/src/wifi/model/block-ack-manager.cc +++ b/src/wifi/model/block-ack-manager.cc @@ -309,10 +309,9 @@ BlockAckManager::GetBar (bool remove, uint8_t tid, Mac48Address address) continue; } - WifiMacQueue::ConstIterator queueIt = (*mpduIt)->GetQueueIteratorPair ().it; - WifiMacQueue* queue = (*mpduIt)->GetQueueIteratorPair ().queue; + WifiMacQueue::ConstIterator queueIt = (*mpduIt)->GetQueueIterator (); - if ((*mpduIt)->GetTimeStamp () + queue->GetMaxDelay () <= now) + if ((*mpduIt)->GetTimeStamp () + m_queue->GetMaxDelay () <= now) { // MPDU expired it->second.first.NotifyDiscardedMpdu (*mpduIt); @@ -320,7 +319,7 @@ BlockAckManager::GetBar (bool remove, uint8_t tid, Mac48Address address) // consequent call to NotifyDiscardedMpdu does nothing (in particular, // does not schedule a BAR) because we have advanced the transmit window // and hence this MPDU became an old packet - queue->TtlExceeded (queueIt, now); + m_queue->TtlExceeded (queueIt, now); mpduIt = it->second.second.erase (mpduIt); } else @@ -392,8 +391,7 @@ BlockAckManager::HandleInFlightMpdu (PacketQueueI mpduIt, MpduStatus status, } WifiMacHeader& hdr = (*mpduIt)->GetHeader (); - WifiMacQueue::ConstIterator queueIt = (*mpduIt)->GetQueueIteratorPair ().it; - WifiMacQueue* queue = (*mpduIt)->GetQueueIteratorPair ().queue; + WifiMacQueue::ConstIterator queueIt = (*mpduIt)->GetQueueIterator (); NS_ASSERT (hdr.GetAddr1 () == it->first.first); NS_ASSERT (hdr.IsQosData () && hdr.GetQosTid () == it->first.second); @@ -405,13 +403,13 @@ BlockAckManager::HandleInFlightMpdu (PacketQueueI mpduIt, MpduStatus status, { m_droppedOldMpduCallback (*queueIt); } - queue->Remove (queueIt); + m_queue->Remove (queueIt); return it->second.second.erase (mpduIt); } auto nextIt = std::next (mpduIt); - if (queue->TtlExceeded (queueIt, now)) + if (m_queue->TtlExceeded (queueIt, now)) { // WifiMacQueue::TtlExceeded() has removed the MPDU from the EDCA queue // and fired the Expired trace source, which called NotifyDiscardedMpdu, diff --git a/src/wifi/model/frame-exchange-manager.cc b/src/wifi/model/frame-exchange-manager.cc index e1f8426c8..d2b619194 100644 --- a/src/wifi/model/frame-exchange-manager.cc +++ b/src/wifi/model/frame-exchange-manager.cc @@ -281,7 +281,7 @@ FrameExchangeManager::StartTransmission (Ptr dcf) } m_dcf->NotifyChannelAccessed (); - Ptr mpdu = *queue->Peek ()->GetQueueIteratorPair ().it; + Ptr mpdu = *queue->Peek ()->GetQueueIterator (); NS_ASSERT (mpdu != 0); NS_ASSERT (mpdu->GetHeader ().IsData () || mpdu->GetHeader ().IsMgt ()); @@ -327,15 +327,15 @@ FrameExchangeManager::GetFirstFragmentIfNeeded (Ptr mpdu) { NS_LOG_DEBUG ("Fragmenting the MSDU"); m_fragmentedPacket = mpdu->GetPacket ()->Copy (); + AcIndex ac = mpdu->GetQueueAc (); // dequeue the MSDU - WifiMacQueueItem::QueueIteratorPair queueIt = mpdu->GetQueueIteratorPair (); - queueIt.queue->DequeueIfQueued (*queueIt.it); + DequeueMpdu (mpdu); // create the first fragment mpdu->GetHeader ().SetMoreFragments (); Ptr fragment = m_fragmentedPacket->CreateFragment (0, m_mac->GetWifiRemoteStationManager ()->GetFragmentSize (mpdu, 0)); // enqueue the first fragment Ptr item = Create (fragment, mpdu->GetHeader (), mpdu->GetTimeStamp ()); - queueIt.queue->PushFront (item); + m_mac->GetTxopQueue (ac)->PushFront (item); return item; } return mpdu; @@ -453,8 +453,7 @@ FrameExchangeManager::DequeueMpdu (Ptr mpdu) if (mpdu->IsQueued ()) { - const WifiMacQueueItem::QueueIteratorPair& queueIt = mpdu->GetQueueIteratorPair (); - queueIt.queue->DequeueIfQueued (*queueIt.it); + m_mac->GetTxopQueue (mpdu->GetQueueAc ())->DequeueIfQueued (mpdu); } } diff --git a/src/wifi/model/he/he-frame-exchange-manager.cc b/src/wifi/model/he/he-frame-exchange-manager.cc index 54fa544eb..c364e91c0 100644 --- a/src/wifi/model/he/he-frame-exchange-manager.cc +++ b/src/wifi/model/he/he-frame-exchange-manager.cc @@ -1191,7 +1191,7 @@ HeFrameExchangeManager::ReceiveBasicTrigger (const CtrlTriggerHeader& trigger, c // otherwise, check if a suitable data frame is available if ((mpdu = edca->PeekNextMpdu (tid, hdr.GetAddr2 ())) != 0) { - WifiMacQueueItem::QueueIteratorPair queueIt; + WifiMacQueueItem::ConstIterator queueIt; Ptr item = edca->GetNextMpdu (mpdu, txParams, ppduDuration, false, queueIt); if (item != 0) diff --git a/src/wifi/model/he/rr-multi-user-scheduler.cc b/src/wifi/model/he/rr-multi-user-scheduler.cc index b64e0ebe2..0f1d262f0 100644 --- a/src/wifi/model/he/rr-multi-user-scheduler.cc +++ b/src/wifi/model/he/rr-multi-user-scheduler.cc @@ -728,10 +728,9 @@ RrMultiUserScheduler::ComputeDlMuInfo (void) NS_ASSERT (receiver == candidate.first->address); NS_ASSERT (mpdu->IsQueued ()); - WifiMacQueueItem::QueueIteratorPair queueIt = mpdu->GetQueueIteratorPair (); - NS_ASSERT (queueIt.queue != nullptr); - Ptr item = *queueIt.it; - queueIt.it++; + WifiMacQueueItem::ConstIterator queueIt = mpdu->GetQueueIterator (); + Ptr item = *queueIt; + queueIt++; if (!mpdu->GetHeader ().IsRetry ()) { @@ -742,7 +741,7 @@ RrMultiUserScheduler::ComputeDlMuInfo (void) if (item == nullptr) { // A-MSDU aggregation failed or disabled - item = *mpdu->GetQueueIteratorPair ().it; + item = *mpdu->GetQueueIterator (); } m_apMac->GetQosTxop (QosUtilsMapTidToAc (tid))->AssignSequenceNumber (item); } diff --git a/src/wifi/model/ht/ht-frame-exchange-manager.cc b/src/wifi/model/ht/ht-frame-exchange-manager.cc index 205ca0098..20fb6a915 100644 --- a/src/wifi/model/ht/ht-frame-exchange-manager.cc +++ b/src/wifi/model/ht/ht-frame-exchange-manager.cc @@ -447,7 +447,7 @@ HtFrameExchangeManager::SendDataFrame (Ptr peekedItem, Ptr edca = m_mac->GetQosTxop (peekedItem->GetHeader ().GetQosTid ()); WifiTxParameters txParams; txParams.m_txVector = m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (peekedItem->GetHeader ()); - WifiMacQueueItem::QueueIteratorPair queueIt; + WifiMacQueueItem::ConstIterator queueIt; Ptr mpdu = edca->GetNextMpdu (peekedItem, txParams, availableTime, initialFrame, queueIt); if (mpdu == nullptr) diff --git a/src/wifi/model/mpdu-aggregator.cc b/src/wifi/model/mpdu-aggregator.cc index cf743d3b4..608d74013 100644 --- a/src/wifi/model/mpdu-aggregator.cc +++ b/src/wifi/model/mpdu-aggregator.cc @@ -192,7 +192,7 @@ MpduAggregator::GetAmpduSubframeHeader (uint16_t mpduSize, bool isSingle) std::vector> MpduAggregator::GetNextAmpdu (Ptr mpdu, WifiTxParameters& txParams, - Time availableTime, WifiMacQueueItem::QueueIteratorPair queueIt) const + Time availableTime, WifiMacQueueItem::ConstIterator queueIt) const { NS_LOG_FUNCTION (this << *mpdu << &txParams << availableTime); diff --git a/src/wifi/model/mpdu-aggregator.h b/src/wifi/model/mpdu-aggregator.h index 0bfd28ca3..8938a9544 100644 --- a/src/wifi/model/mpdu-aggregator.h +++ b/src/wifi/model/mpdu-aggregator.h @@ -125,7 +125,7 @@ public: std::vector> GetNextAmpdu (Ptr mpdu, WifiTxParameters& txParams, Time availableTime, - WifiMacQueueItem::QueueIteratorPair queueIt) const; + WifiMacQueueItem::ConstIterator queueIt) const; /** * Set the MAC layer to use. diff --git a/src/wifi/model/msdu-aggregator.cc b/src/wifi/model/msdu-aggregator.cc index 48393ed97..e1139c81e 100644 --- a/src/wifi/model/msdu-aggregator.cc +++ b/src/wifi/model/msdu-aggregator.cc @@ -84,12 +84,12 @@ MsduAggregator::GetSizeIfAggregated (uint16_t msduSize, uint16_t amsduSize) Ptr MsduAggregator::GetNextAmsdu (Ptr peekedItem, WifiTxParameters& txParams, - Time availableTime, WifiMacQueueItem::QueueIteratorPair& queueIt) const + Time availableTime, WifiMacQueueItem::ConstIterator& queueIt) const { NS_LOG_FUNCTION (this << *peekedItem << &txParams << availableTime); - WifiMacQueue* queue = peekedItem->GetQueueIteratorPair ().queue; - WifiMacQueue::ConstIterator it = peekedItem->GetQueueIteratorPair ().it; + Ptr queue = m_mac->GetTxopQueue (peekedItem->GetQueueAc ()); + auto it = peekedItem->GetQueueIterator (); NS_ASSERT ((*it)->GetPacket () == peekedItem->GetPacket ()); uint8_t tid = peekedItem->GetHeader ().GetQosTid (); @@ -132,7 +132,7 @@ MsduAggregator::GetNextAmsdu (Ptr peekedItem, WifiTxPara Ptr msdu = *it++; queue->DequeueIfQueued (msdu); - auto pos = std::next (amsdu->GetQueueIteratorPair ().it); + auto pos = std::next (amsdu->GetQueueIterator ()); queue->DequeueIfQueued (amsdu); amsdu->Aggregate (msdu); @@ -151,7 +151,7 @@ MsduAggregator::GetNextAmsdu (Ptr peekedItem, WifiTxPara } // Aggregation succeeded - queueIt = {queue, it}; + queueIt = it; return amsdu; } diff --git a/src/wifi/model/msdu-aggregator.h b/src/wifi/model/msdu-aggregator.h index 92419896f..9923bb869 100644 --- a/src/wifi/model/msdu-aggregator.h +++ b/src/wifi/model/msdu-aggregator.h @@ -96,13 +96,13 @@ public: * \param peekedItem the MSDU which we attempt to aggregate other MSDUs to * \param txParams the TX parameters for the current frame * \param availableTime the time available for the frame exchange - * \param[out] queueIt a QueueIteratorPair pointing to the queue item following the + * \param[out] queueIt a queue iterator pointing to the queue item following the * last item used to prepare the returned A-MSDU, if any; otherwise, * its value is unchanged * \return the resulting A-MSDU, if aggregation is possible, a null pointer otherwise. */ Ptr GetNextAmsdu (Ptr peekedItem, WifiTxParameters& txParams, - Time availableTime, WifiMacQueueItem::QueueIteratorPair& queueIt) const; + Time availableTime, WifiMacQueueItem::ConstIterator& queueIt) const; /** * Determine the maximum size for an A-MSDU of the given TID that can be sent diff --git a/src/wifi/model/qos-frame-exchange-manager.cc b/src/wifi/model/qos-frame-exchange-manager.cc index b21eee0f9..cc218c164 100644 --- a/src/wifi/model/qos-frame-exchange-manager.cc +++ b/src/wifi/model/qos-frame-exchange-manager.cc @@ -277,7 +277,7 @@ QosFrameExchangeManager::StartFrameExchange (Ptr edca, Time availableTi WifiTxParameters txParams; txParams.m_txVector = m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (mpdu->GetHeader ()); - WifiMacQueueItem::QueueIteratorPair queueIt; + WifiMacQueueItem::ConstIterator queueIt; Ptr item = edca->GetNextMpdu (mpdu, txParams, availableTime, initialFrame, queueIt); if (item == nullptr) diff --git a/src/wifi/model/qos-txop.cc b/src/wifi/model/qos-txop.cc index 2e5cd0413..c23f05d71 100644 --- a/src/wifi/model/qos-txop.cc +++ b/src/wifi/model/qos-txop.cc @@ -356,11 +356,11 @@ QosTxop::IsQosOldPacket (Ptr mpdu) Ptr QosTxop::PeekNextMpdu (uint8_t tid, Mac48Address recipient) { - return PeekNextMpdu ({nullptr, WifiMacQueue::EMPTY}, tid, recipient); + return PeekNextMpdu (WifiMacQueue::EMPTY, tid, recipient); } Ptr -QosTxop::PeekNextMpdu (WifiMacQueueItem::QueueIteratorPair queueIt, uint8_t tid, Mac48Address recipient) +QosTxop::PeekNextMpdu (WifiMacQueueItem::ConstIterator queueIt, uint8_t tid, Mac48Address recipient) { NS_LOG_FUNCTION (this << +tid << recipient); @@ -369,52 +369,46 @@ QosTxop::PeekNextMpdu (WifiMacQueueItem::QueueIteratorPair queueIt, uint8_t tid, { if (tid == 8 && recipient.IsBroadcast ()) // undefined TID and recipient { - return queueIt.queue->PeekFirstAvailable (m_qosBlockedDestinations, queueIt.it); + return m_queue->PeekFirstAvailable (m_qosBlockedDestinations, queueIt); } if (m_qosBlockedDestinations->IsBlocked (recipient, tid)) { - return queueIt.queue->end (); + return m_queue->end (); } - return queueIt.queue->PeekByTidAndAddress (tid, recipient, queueIt.it); + return m_queue->PeekByTidAndAddress (tid, recipient, queueIt); }; - if (queueIt.queue == nullptr && queueIt.it == WifiMacQueue::EMPTY) - { - // check if there is a packet in the EDCA queue - queueIt.queue = PeekPointer (m_queue); - } - - queueIt.it = peek (); + queueIt = peek (); // remove old packets (must be retransmissions or in flight, otherwise they did // not get a sequence number assigned) - while (queueIt.it != m_queue->end () && !(*queueIt.it)->IsFragment ()) + while (queueIt != m_queue->end () && !(*queueIt)->IsFragment ()) { - if (((*queueIt.it)->GetHeader ().IsRetry () || (*queueIt.it)->IsInFlight ()) - && IsQosOldPacket (*queueIt.it)) + if (((*queueIt)->GetHeader ().IsRetry () || (*queueIt)->IsInFlight ()) + && IsQosOldPacket (*queueIt)) { - NS_LOG_DEBUG ("Removing an old packet from EDCA queue: " << **queueIt.it); + NS_LOG_DEBUG ("Removing an old packet from EDCA queue: " << **queueIt); if (!m_droppedMpduCallback.IsNull ()) { - m_droppedMpduCallback (WIFI_MAC_DROP_QOS_OLD_PACKET, *queueIt.it); + m_droppedMpduCallback (WIFI_MAC_DROP_QOS_OLD_PACKET, *queueIt); } - queueIt.it = m_queue->Remove (queueIt.it); - queueIt.it = peek (); + queueIt = m_queue->Remove (queueIt); + queueIt = peek (); } - else if ((*queueIt.it)->IsInFlight ()) + else if ((*queueIt)->IsInFlight ()) { - NS_LOG_DEBUG ("Skipping in flight MPDU: " << **queueIt.it); - ++queueIt.it; - queueIt.it = peek (); + NS_LOG_DEBUG ("Skipping in flight MPDU: " << **queueIt); + ++queueIt; + queueIt = peek (); } else { break; } } - if (queueIt.it != m_queue->end ()) + if (queueIt != m_queue->end ()) { - NS_ASSERT (!(*queueIt.it)->IsInFlight ()); - WifiMacHeader& hdr = (*queueIt.it)->GetHeader (); + NS_ASSERT (!(*queueIt)->IsInFlight ()); + WifiMacHeader& hdr = (*queueIt)->GetHeader (); // peek the next sequence number and check if it is within the transmit window // in case of QoS data frame @@ -434,12 +428,12 @@ QosTxop::PeekNextMpdu (WifiMacQueueItem::QueueIteratorPair queueIt, uint8_t tid, } // Assign a sequence number if this is not a fragment nor a retransmission - if (!(*queueIt.it)->IsFragment () && !hdr.IsRetry ()) + if (!(*queueIt)->IsFragment () && !hdr.IsRetry ()) { hdr.SetSequenceNumber (sequence); } - NS_LOG_DEBUG ("Packet peeked from EDCA queue: " << **queueIt.it); - return *queueIt.it; + NS_LOG_DEBUG ("Packet peeked from EDCA queue: " << **queueIt); + return *queueIt; } return 0; @@ -447,7 +441,7 @@ QosTxop::PeekNextMpdu (WifiMacQueueItem::QueueIteratorPair queueIt, uint8_t tid, Ptr QosTxop::GetNextMpdu (Ptr peekedItem, WifiTxParameters& txParams, - Time availableTime, bool initialFrame, WifiMacQueueItem::QueueIteratorPair& queueIt) + Time availableTime, bool initialFrame, WifiMacQueueItem::ConstIterator& queueIt) { NS_ASSERT (peekedItem != 0); NS_ASSERT (m_qosFem != 0); @@ -467,9 +461,9 @@ QosTxop::GetNextMpdu (Ptr peekedItem, WifiTxParameters& } NS_ASSERT (peekedItem->IsQueued ()); - WifiMacQueueItem::QueueIteratorPair peekedIt = peekedItem->GetQueueIteratorPair (); - NS_ASSERT ((*peekedIt.it)->GetPacket () == peekedItem->GetPacket ()); - NS_ASSERT (peekedIt.queue == PeekPointer (m_queue)); + WifiMacQueueItem::ConstIterator peekedIt = peekedItem->GetQueueIterator (); + NS_ASSERT ((*peekedIt)->GetPacket () == peekedItem->GetPacket ()); + NS_ASSERT ((*peekedIt)->GetQueueAc () == m_ac); Ptr mpdu; // If it is a non-broadcast QoS Data frame and it is not a retransmission nor a fragment, @@ -504,8 +498,8 @@ QosTxop::GetNextMpdu (Ptr peekedItem, WifiTxParameters& if (mpdu == 0) { - mpdu = *peekedIt.it; - peekedIt.it++; + mpdu = *peekedIt; + peekedIt++; } // Assign a sequence number if this is not a fragment nor a retransmission diff --git a/src/wifi/model/qos-txop.h b/src/wifi/model/qos-txop.h index 8981cb9b8..3c9457664 100644 --- a/src/wifi/model/qos-txop.h +++ b/src/wifi/model/qos-txop.h @@ -335,7 +335,7 @@ public: * \param recipient the receiver station address. * \returns the peeked frame. */ - Ptr PeekNextMpdu (WifiMacQueueItem::QueueIteratorPair queueIt, + Ptr PeekNextMpdu (WifiMacQueueItem::ConstIterator queueIt, uint8_t tid = 8, Mac48Address recipient = Mac48Address::GetBroadcast ()); /** @@ -354,14 +354,14 @@ public: (including protection and acknowledgment); a value of * Time::Min() indicates no time constraint * \param initialFrame true if the frame is the initial PPDU of a TXOP - * \param[out] queueIt a QueueIteratorPair pointing to the queue item following the + * \param[out] queueIt a queue iterator pointing to the queue item following the * last item used to prepare the returned MPDU, if any; if no MPDU * is returned, its value is unchanged * \return the frame to transmit or a null pointer if no frame meets the time constraints */ Ptr GetNextMpdu (Ptr peekedItem, WifiTxParameters& txParams, Time availableTime, bool initialFrame, - WifiMacQueueItem::QueueIteratorPair& queueIt); + WifiMacQueueItem::ConstIterator& queueIt); /** * Assign a sequence number to the given MPDU, if it is not a fragment diff --git a/src/wifi/model/wifi-mac-queue-item.cc b/src/wifi/model/wifi-mac-queue-item.cc index 3274fa1b7..5582055d3 100644 --- a/src/wifi/model/wifi-mac-queue-item.cc +++ b/src/wifi/model/wifi-mac-queue-item.cc @@ -41,13 +41,13 @@ WifiMacQueueItem::WifiMacQueueItem (Ptr p, const WifiMacHeader & h WifiMacQueueItem::WifiMacQueueItem (Ptr p, const WifiMacHeader & header, Time tstamp) : m_packet (p), m_header (header), - m_tstamp (tstamp) + m_tstamp (tstamp), + m_queueAc (AC_UNDEF) { if (header.IsQosData () && header.IsQosAmsdu ()) { m_msduList = MsduAggregator::Deaggregate (p->Copy ()); } - m_queueIt.queue = nullptr; m_inFlight = false; } @@ -204,11 +204,18 @@ WifiMacQueueItem::DoAggregate (Ptr msdu) bool WifiMacQueueItem::IsQueued (void) const { - return m_queueIt.queue != nullptr; + return m_queueAc != AC_UNDEF; } -const WifiMacQueueItem::QueueIteratorPair& -WifiMacQueueItem::GetQueueIteratorPair (void) const +AcIndex +WifiMacQueueItem::GetQueueAc (void) const +{ + NS_ASSERT (IsQueued ()); + return m_queueAc; +} + +WifiMacQueueItem::ConstIterator +WifiMacQueueItem::GetQueueIterator (void) const { NS_ASSERT (IsQueued ()); return m_queueIt; diff --git a/src/wifi/model/wifi-mac-queue-item.h b/src/wifi/model/wifi-mac-queue-item.h index e7c5ebd45..00cbfbddf 100644 --- a/src/wifi/model/wifi-mac-queue-item.h +++ b/src/wifi/model/wifi-mac-queue-item.h @@ -27,13 +27,13 @@ #include "ns3/nstime.h" #include "wifi-mac-header.h" #include "amsdu-subframe-header.h" +#include "qos-utils.h" #include namespace ns3 { class QosBlockedDestinations; class Packet; -class WifiMacQueue; /** * \ingroup wifi @@ -142,12 +142,6 @@ public: /// Const iterator typedef typedef std::list>::const_iterator ConstIterator; - /// Information needed to remove an MSDU from the queue - struct QueueIteratorPair - { - WifiMacQueue* queue; //!< pointer to the queue where the MSDU is enqueued - ConstIterator it; //!< iterator pointing to the MSDU in the queue - }; /** * Return true if this item is stored in some queue, false otherwise. @@ -155,16 +149,20 @@ public: * \return true if this item is stored in some queue, false otherwise */ bool IsQueued (void) const; - /** - * Get a const reference to the QueueIteratorPair struct variable containing - * a pointer to the queue where the MPDU is stored and an iterator pointing to - * the position of the MPDU in the queue. This method should not be called if - * the MPDU is not stored in a queue. + * Get the AC of the queue this item is stored into. Abort if this item + * is not stored in a queue. + * + * \return the AC of the queue this item is stored into + */ + AcIndex GetQueueAc (void) const; + /** + * Get a const iterator pointing to the position of the MPDU in the queue. This + * method should not be called if the MPDU is not stored in a queue. * * \return an iterator pointing to the position of the MPDU in the queue */ - const QueueIteratorPair& GetQueueIteratorPair (void) const; + ConstIterator GetQueueIterator (void) const; /** * \brief Get the MAC protocol data unit (MPDU) corresponding to this item @@ -204,13 +202,14 @@ private: */ void DoAggregate (Ptr msdu); - friend class WifiMacQueue; // to set QueueIteratorPair information + friend class WifiMacQueue; // to set queue AC and iterator information Ptr m_packet; //!< The packet (MSDU or A-MSDU) contained in this queue item WifiMacHeader m_header; //!< Wifi MAC header associated with the packet Time m_tstamp; //!< timestamp when the packet arrived at the queue DeaggregatedMsdus m_msduList; //!< The list of aggregated MSDUs included in this MPDU - QueueIteratorPair m_queueIt; //!< Queue iterator pointing to this MPDU, if queued + ConstIterator m_queueIt; //!< Queue iterator pointing to this MPDU, if queued + AcIndex m_queueAc; //!< AC associated with the queue this MPDU is stored into bool m_inFlight; //!< whether the MPDU is in flight }; diff --git a/src/wifi/model/wifi-mac-queue.cc b/src/wifi/model/wifi-mac-queue.cc index 03f310e92..5e7431bee 100644 --- a/src/wifi/model/wifi-mac-queue.cc +++ b/src/wifi/model/wifi-mac-queue.cc @@ -179,10 +179,10 @@ WifiMacQueue::DequeueIfQueued (Ptr mpdu) if (mpdu->IsQueued ()) { - NS_ASSERT (mpdu->m_queueIt.queue == this); - NS_ASSERT (*mpdu->m_queueIt.it == mpdu); + NS_ASSERT (mpdu->m_queueAc == m_ac); + NS_ASSERT (*mpdu->m_queueIt == mpdu); - DoDequeue (mpdu->m_queueIt.it); + DoDequeue (mpdu->m_queueIt); } } @@ -516,7 +516,8 @@ WifiMacQueue::DoEnqueue (ConstIterator pos, Ptr item) m_nQueuedBytes[addressTidPair] += item->GetSize (); } // set item's information about its position in the queue - item->m_queueIt = {this, ret}; + item->m_queueAc = m_ac; + item->m_queueIt = ret; return true; } return false; @@ -549,7 +550,7 @@ WifiMacQueue::DoDequeue (ConstIterator pos) if (item != 0) { NS_ASSERT (item->IsQueued ()); - item->m_queueIt.queue = nullptr; + item->m_queueAc = AC_UNDEF; } return item; @@ -574,7 +575,7 @@ WifiMacQueue::DoRemove (ConstIterator pos) if (item != 0) { NS_ASSERT (item->IsQueued ()); - item->m_queueIt.queue = nullptr; + item->m_queueAc = AC_UNDEF; } return item; diff --git a/src/wifi/test/wifi-aggregation-test.cc b/src/wifi/test/wifi-aggregation-test.cc index b128c8427..bddb979ca 100644 --- a/src/wifi/test/wifi-aggregation-test.cc +++ b/src/wifi/test/wifi-aggregation-test.cc @@ -192,7 +192,7 @@ AmpduAggregationTest::DoRun (void) Ptr peeked = m_mac->GetBEQueue ()->PeekNextMpdu (); WifiTxParameters txParams; txParams.m_txVector = m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (peeked->GetHeader ()); - WifiMacQueueItem::QueueIteratorPair queueIt; + WifiMacQueueItem::ConstIterator queueIt; Ptr item = m_mac->GetBEQueue ()->GetNextMpdu (peeked, txParams, Time::Min (), true, queueIt); @@ -276,7 +276,7 @@ AmpduAggregationTest::DoRun (void) peeked = m_mac->GetBEQueue ()->PeekNextMpdu (); txParams.Clear (); txParams.m_txVector = m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (peeked->GetHeader ()); - queueIt = {nullptr, WifiMacQueue::EMPTY}; // reset queueIt + queueIt = WifiMacQueue::EMPTY; // reset queueIt item = m_mac->GetBEQueue ()->GetNextMpdu (peeked, txParams, Time::Min (), true, queueIt); mpduList = mpduAggregator->GetNextAmpdu (item, txParams, Time::Min (), queueIt); @@ -288,7 +288,7 @@ AmpduAggregationTest::DoRun (void) peeked = m_mac->GetBEQueue ()->PeekNextMpdu (); txParams.Clear (); txParams.m_txVector = m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (peeked->GetHeader ()); - queueIt = {nullptr, WifiMacQueue::EMPTY}; // reset queueIt + queueIt = WifiMacQueue::EMPTY; // reset queueIt item = m_mac->GetBEQueue ()->GetNextMpdu (peeked, txParams, Time::Min (), true, queueIt); mpduList = mpduAggregator->GetNextAmpdu (item, txParams, Time::Min (), queueIt); @@ -424,7 +424,7 @@ TwoLevelAggregationTest::DoRun (void) WifiTxParameters txParams; txParams.m_txVector = m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (peeked->GetHeader ()); htFem->TryAddMpdu (peeked, txParams, Time::Min ()); - WifiMacQueueItem::QueueIteratorPair queueIt; + WifiMacQueueItem::ConstIterator queueIt; Ptr item = msduAggregator->GetNextAmsdu (peeked, txParams, Time::Min (), queueIt); bool result = (item != 0); @@ -451,7 +451,7 @@ TwoLevelAggregationTest::DoRun (void) NS_TEST_EXPECT_MSG_EQ ((item == 0), true, "A-MSDU aggregation did not fail"); - htFem->DequeueMpdu (*peeked->GetQueueIteratorPair ().it); + htFem->DequeueMpdu (*peeked->GetQueueIterator ()); NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->GetWifiMacQueue ()->GetNPackets (), 0, "queue should be empty"); @@ -502,7 +502,7 @@ TwoLevelAggregationTest::DoRun (void) // Compute the first MPDU to be aggregated in an A-MPDU. It must contain an A-MSDU // aggregating two MSDUs - queueIt = {nullptr, WifiMacQueue::EMPTY}; // reset queueIt + queueIt = WifiMacQueue::EMPTY; // reset queueIt item = m_mac->GetVIQueue ()->GetNextMpdu (peeked, txParams, txopLimit, true, queueIt); NS_TEST_EXPECT_MSG_EQ (std::distance (item->begin (), item->end ()), 2, "There must be 2 MSDUs in the A-MSDU"); @@ -684,7 +684,7 @@ HeAggregationTest::DoRunSubTest (uint16_t bufferSize) Ptr peeked = m_mac->GetBEQueue ()->PeekNextMpdu (); WifiTxParameters txParams; txParams.m_txVector = m_mac->GetWifiRemoteStationManager ()->GetDataTxVector (peeked->GetHeader ()); - WifiMacQueueItem::QueueIteratorPair queueIt; + WifiMacQueueItem::ConstIterator queueIt; Ptr item = m_mac->GetBEQueue ()->GetNextMpdu (peeked, txParams, Time::Min (), true, queueIt); diff --git a/src/wifi/test/wifi-mac-ofdma-test.cc b/src/wifi/test/wifi-mac-ofdma-test.cc index 26dc25148..ae01e8357 100644 --- a/src/wifi/test/wifi-mac-ofdma-test.cc +++ b/src/wifi/test/wifi-mac-ofdma-test.cc @@ -205,7 +205,7 @@ TestMultiUserScheduler::SelectTxFormat (void) return SU_TX; } - WifiMacQueueItem::QueueIteratorPair queueIt; + WifiMacQueueItem::ConstIterator queueIt; Ptr mpdu = m_apMac->GetQosTxop (AC_BE)->GetNextMpdu (peeked, m_txParams, m_availableTime, m_initialFrame, queueIt);