add WifiMacQueue::GetNPacketsByTidAndAddress method
authorMirko Banchi <mk.banchi@gmail.com>
Wed, 03 Feb 2010 20:34:52 +0100
changeset 5959 66bc2d3da45f
parent 5958 dd0accd82659
child 5960 111680cdfa52
add WifiMacQueue::GetNPacketsByTidAndAddress method
src/devices/wifi/wifi-mac-queue.cc
src/devices/wifi/wifi-mac-queue.h
--- a/src/devices/wifi/wifi-mac-queue.cc	Wed Feb 03 20:34:52 2010 +0100
+++ b/src/devices/wifi/wifi-mac-queue.cc	Wed Feb 03 20:34:52 2010 +0100
@@ -274,4 +274,28 @@
   m_size++;
 }
 
+uint32_t
+WifiMacQueue::GetNPacketsByTidAndAddress (uint8_t tid, WifiMacHeader::AddressType type,
+                                          Mac48Address addr)
+{
+  Cleanup ();
+  uint32_t nPackets = 0;
+  if (!m_queue.empty ())
+    {
+      PacketQueueI it;
+      NS_ASSERT (type <= 4);
+      for (it = m_queue.begin (); it != m_queue.end (); it++)
+        {
+          if (GetAddressForPacket (type, it) == addr)
+            {
+              if (it->hdr.IsQosData () && it->hdr.GetQosTid () == tid)
+                {
+                  nPackets++;
+                }
+            }
+        }
+    }
+  return nPackets;
+}
+
 } // namespace ns3
--- a/src/devices/wifi/wifi-mac-queue.h	Wed Feb 03 20:34:52 2010 +0100
+++ b/src/devices/wifi/wifi-mac-queue.h	Wed Feb 03 20:34:52 2010 +0100
@@ -92,6 +92,13 @@
    * performed in linear time (O(n)).  
    */
   bool Remove (Ptr<const Packet> packet);
+  /**
+   * Returns number of QoS packets having tid equals to <i>tid</i> and address
+   * specified by <i>type</i> equals to <i>addr</i>.
+   */
+  uint32_t GetNPacketsByTidAndAddress (uint8_t tid,
+                                       WifiMacHeader::AddressType type,
+                                       Mac48Address addr);
   
   void Flush (void);