wifi: (fixes #2352) Add 'drop oldest' drop policy to WifiMacQueue (patch from Ali Rostami)

This commit is contained in:
Ali Rostami
2016-03-31 10:08:49 -07:00
parent 178c70829f
commit 3e34eb965a
4 changed files with 24 additions and 1 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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<const Packet> 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));

View File

@@ -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