diff --git a/src/wifi/model/wifi-mac-queue.cc b/src/wifi/model/wifi-mac-queue.cc index 0f6324b42..07d4ae93e 100644 --- a/src/wifi/model/wifi-mac-queue.cc +++ b/src/wifi/model/wifi-mac-queue.cc @@ -203,6 +203,26 @@ WifiMacQueue::DequeueByAddress (Mac48Address dest) return 0; } +Ptr +WifiMacQueue::DequeueByTid (uint8_t tid) +{ + NS_LOG_FUNCTION (this << +tid); + for (auto it = Head (); it != Tail (); ) + { + if (!TtlExceeded (it)) + { + if ((*it)->GetHeader ().IsQosData () && (*it)->GetHeader ().GetQosTid () == tid) + { + return DoDequeue (it); + } + + it++; + } + } + NS_LOG_DEBUG ("The queue is empty"); + return 0; +} + Ptr WifiMacQueue::DequeueByTidAndAddress (uint8_t tid, Mac48Address dest) { @@ -262,6 +282,26 @@ WifiMacQueue::Peek (void) const return 0; } +Ptr +WifiMacQueue::PeekByTid (uint8_t tid) +{ + NS_LOG_FUNCTION (this << +tid); + for (auto it = Head (); it != Tail (); ) + { + if (!TtlExceeded (it)) + { + if ((*it)->GetHeader ().IsQosData () && (*it)->GetHeader ().GetQosTid () == tid) + { + return DoPeek (it); + } + + it++; + } + } + NS_LOG_DEBUG ("The queue is empty"); + return 0; +} + Ptr WifiMacQueue::PeekByTidAndAddress (uint8_t tid, Mac48Address dest) { diff --git a/src/wifi/model/wifi-mac-queue.h b/src/wifi/model/wifi-mac-queue.h index 130d62757..f57412602 100644 --- a/src/wifi/model/wifi-mac-queue.h +++ b/src/wifi/model/wifi-mac-queue.h @@ -128,6 +128,16 @@ public: * \return the packet */ Ptr DequeueByAddress (Mac48Address dest); + /** + * Search and return, if present in the queue, the first packet having the + * tid equal to tid. + * This method removes the packet from the queue. + * + * \param tid the given tid + * + * \return the packet + */ + Ptr DequeueByTid (uint8_t tid); /** * Search and return, if present in the queue, the first packet having the * address indicated by type equal to addr, and tid @@ -160,6 +170,15 @@ public: * \return the packet */ Ptr Peek (void) const; + /** + * Search and return, if present in the queue, the first packet having the + * tid equal to tid. This method does not remove the packet from the queue. + * + * \param tid the given TID + * + * \return packet + */ + Ptr PeekByTid (uint8_t tid); /** * Search and return, if present in the queue, the first packet having the * address indicated by type equal to addr, and tid