diff --git a/AUTHORS b/AUTHORS index 12a7bde30..df6c9db7f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -189,3 +189,4 @@ He Wu (mdzz@u.washington.edu) Yoshihiko Yazawa (yoshiyaz@gmail.com) Dizhi Zhou (dizhi.zhou@gmail.com) Gaurav Sathe (gaurav.sathe@tcs.com) +Ali Rostami (a.rostami@rutgers.edu) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index e947fa012..daf747b29 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -39,6 +39,7 @@ Bugs fixed - Bug 2329 - TCP Veno implementation - Bug 2333 - TCP Scalable implementation - Bug 2347 - LrWpan Ascii traces are hooked to the wrong traces. +- Bug 2352 - Add 'drop oldest' drop policy to WifiMacQueue - Bug 2353 - TCP Vegas implementation - Bug 2375 - Flowmonitor parse crashes when no pkt is received - Bug 2377 - SocketIpTosTag and SocketIpv6TclassTag may be added twice in UDP diff --git a/src/wifi/model/wifi-mac-queue.cc b/src/wifi/model/wifi-mac-queue.cc index fed57a333..346cf7d83 100644 --- a/src/wifi/model/wifi-mac-queue.cc +++ b/src/wifi/model/wifi-mac-queue.cc @@ -23,6 +23,7 @@ #include "ns3/simulator.h" #include "ns3/packet.h" #include "ns3/uinteger.h" +#include "ns3/enum.h" #include "wifi-mac-queue.h" #include "qos-blocked-destinations.h" @@ -54,6 +55,11 @@ WifiMacQueue::GetTypeId (void) TimeValue (MilliSeconds (500.0)), MakeTimeAccessor (&WifiMacQueue::m_maxDelay), MakeTimeChecker ()) + .AddAttribute ("DropPolicy", "Upon enqueue with full queue, drop oldest (DropOldest) or newest (DropNewest) packet", + EnumValue (DROP_NEWEST), + MakeEnumAccessor (&WifiMacQueue::m_dropPolicy), + MakeEnumChecker (WifiMacQueue::DROP_OLDEST, "DropOldest", + WifiMacQueue::DROP_NEWEST, "DropNewest")) ; return tid; } @@ -98,7 +104,15 @@ WifiMacQueue::Enqueue (Ptr packet, const WifiMacHeader &hdr) Cleanup (); if (m_size == m_maxSize) { - return; + if (m_dropPolicy == DROP_NEWEST) + { + return; + } + else if (m_dropPolicy == DROP_OLDEST) + { + m_queue.pop_front (); + m_size--; + } } Time now = Simulator::Now (); m_queue.push_back (Item (packet, hdr, now)); diff --git a/src/wifi/model/wifi-mac-queue.h b/src/wifi/model/wifi-mac-queue.h index 6afb8a4e4..6d7198554 100644 --- a/src/wifi/model/wifi-mac-queue.h +++ b/src/wifi/model/wifi-mac-queue.h @@ -55,6 +55,12 @@ public: WifiMacQueue (); ~WifiMacQueue (); + enum DropPolicy + { + DROP_NEWEST, + DROP_OLDEST + }; + /** * Set the maximum queue size. * @@ -271,6 +277,7 @@ protected: uint32_t m_size; //!< Current queue size uint32_t m_maxSize; //!< Queue capacity Time m_maxDelay; //!< Time to live for packets in the queue + enum DropPolicy m_dropPolicy; //!< Drop behavior of queue }; } //namespace ns3