A RED packet queue. More...
#include <red-queue.h>
Classes | |
struct | Stats |
Stats. More... | |
Public Types | |
enum | { DTYPE_NONE, DTYPE_FORCED, DTYPE_UNFORCED } |
Drop types. More... | |
![]() | |
enum | QueueMode { QUEUE_MODE_PACKETS, QUEUE_MODE_BYTES } |
Enumeration of the modes supported in the class. More... | |
Public Member Functions | |
RedQueue () | |
RedQueue Constructor. More... | |
virtual | ~RedQueue () |
Destructor. More... | |
int64_t | AssignStreams (int64_t stream) |
Assign a fixed random variable stream number to the random variables used by this model. More... | |
RedQueue::QueueMode | GetMode (void) |
Get the encapsulation mode of this queue. More... | |
uint32_t | GetQueueSize (void) |
Get the current value of the queue in bytes or packets. More... | |
Stats | GetStats () |
Get the RED statistics after running. More... | |
void | SetMode (RedQueue::QueueMode mode) |
Set the operating mode of this queue. More... | |
void | SetQueueLimit (uint32_t lim) |
Set the limit of the queue. More... | |
void | SetTh (double minTh, double maxTh) |
Set the thresh limits of RED. More... | |
![]() | |
Queue () | |
virtual | ~Queue () |
Ptr< Packet > | Dequeue (void) |
Remove a packet from the front of the Queue. More... | |
void | DequeueAll (void) |
Flush the queue. More... | |
bool | Enqueue (Ptr< Packet > p) |
Place a packet into the rear of the Queue. More... | |
uint32_t | GetNBytes (void) const |
uint32_t | GetNPackets (void) const |
uint32_t | GetTotalDroppedBytes (void) const |
uint32_t | GetTotalDroppedPackets (void) const |
uint32_t | GetTotalReceivedBytes (void) const |
uint32_t | GetTotalReceivedPackets (void) const |
bool | IsEmpty (void) const |
Ptr< const Packet > | Peek (void) const |
Get a copy of the item at the front of the queue without removing it. More... | |
void | ResetStatistics (void) |
Resets the counts for dropped packets, dropped bytes, received packets, and received bytes. More... | |
![]() | |
Object () | |
virtual | ~Object () |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
Run the DoDispose methods of this object and all the objects aggregated to it. More... | |
AggregateIterator | GetAggregateIterator (void) const |
virtual TypeId | GetInstanceTypeId (void) const |
template<typename T > | |
Ptr< T > | GetObject (void) const |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
void | Initialize (void) |
This method calls the virtual DoInitialize method on all the objects aggregated to this object. More... | |
![]() | |
SimpleRefCount () | |
Constructor. More... | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
![]() | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
![]() | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
![]() | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
![]() | |
static void | Cleanup (void) |
Noop. More... | |
![]() | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Private Member Functions | |
double | CalculatePNew (double qAvg, double, bool gentle, double vA, double vB, double vC, double vD, double maxP) |
Returns a probability using these function parameters for the DropEarly function. More... | |
virtual Ptr< Packet > | DoDequeue (void) |
Pull a packet from the queue. More... | |
virtual bool | DoEnqueue (Ptr< Packet > p) |
Push a packet in the queue. More... | |
virtual Ptr< const Packet > | DoPeek (void) const |
Peek the front packet in the queue. More... | |
uint32_t | DropEarly (Ptr< Packet > p, uint32_t qSize) |
Check if packet p needs to be dropped due to probability mark. More... | |
double | Estimator (uint32_t nQueued, uint32_t m, double qAvg, double qW) |
Compute the average queue size. More... | |
void | InitializeParams (void) |
Initialize the queue parameters. More... | |
double | ModifyP (double p, uint32_t count, uint32_t countBytes, uint32_t meanPktSize, bool wait, uint32_t size) |
Returns a probability using these function parameters for the DropEarly function. More... | |
Private Attributes | |
uint32_t | m_bytesInQueue |
bytes in the queue More... | |
uint32_t | m_cautious |
0 for default RED 1 experimental (see red-queue.cc) 2 experimental (see red-queue.cc) 3 use Idle packet size in the ptc More... | |
uint32_t | m_count |
Number of packets since last random number generation. More... | |
uint32_t | m_countBytes |
Number of bytes since last drop. More... | |
double | m_curMaxP |
Current max_p. More... | |
bool | m_hasRedStarted |
True if RED has started. More... | |
uint32_t | m_idle |
0/1 idle status More... | |
uint32_t | m_idlePktSize |
Avg pkt size used during idle times. More... | |
Time | m_idleTime |
Start of current idle period. More... | |
bool | m_isGentle |
True to increases dropping prob. More... | |
bool | m_isNs1Compat |
Ns-1 compatibility. More... | |
bool | m_isWait |
True for waiting between dropped packets. More... | |
DataRate | m_linkBandwidth |
Link bandwidth. More... | |
Time | m_linkDelay |
Link delay. More... | |
double | m_lInterm |
The max probability of dropping a packet. More... | |
double | m_maxTh |
Max avg length threshold (bytes), should be >= 2*minTh. More... | |
uint32_t | m_meanPktSize |
Avg pkt size. More... | |
double | m_minTh |
Min avg length threshold (bytes) More... | |
QueueMode | m_mode |
Mode (Bytes or packets) More... | |
uint32_t | m_old |
0 when average queue first exceeds threshold More... | |
std::list< Ptr< Packet > > | m_packets |
packets in the queue More... | |
double | m_ptc |
packet time constant in packets/second More... | |
double | m_qAvg |
Average queue length. More... | |
uint32_t | m_queueLimit |
Queue limit in bytes / packets. More... | |
double | m_qW |
Queue weight given to cur queue size sample. More... | |
Stats | m_stats |
RED statistics. More... | |
Ptr< UniformRandomVariable > | m_uv |
rng stream More... | |
double | m_vA |
1.0 / (m_maxTh - m_minTh) More... | |
double | m_vB |
-m_minTh / (m_maxTh - m_minTh) More... | |
double | m_vC |
(1.0 - m_curMaxP) / m_maxTh - used in "gentle" mode More... | |
double | m_vD |
2.0 * m_curMaxP - 1.0 - used in "gentle" mode More... | |
double | m_vProb |
Prob. More... | |
double | m_vProb1 |
Prob. More... | |
Additional Inherited Members | |
![]() | |
void | Drop (Ptr< Packet > packet) |
Drop a packet. More... | |
![]() | |
Object (const Object &o) | |
virtual void | DoDispose (void) |
This method is called by Object::Dispose or by the object's destructor, whichever comes first. More... | |
virtual void | DoInitialize (void) |
This method is called only once by Object::Initialize. More... | |
virtual void | NotifyNewAggregate (void) |
This method is invoked whenever two sets of objects are aggregated together. More... | |
![]() | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
virtual void | NotifyConstructionCompleted (void) |
This method is invoked once all member attributes have been initialized. More... | |
A RED packet queue.
ns3::RedQueue is accessible through the following paths with Config::Set and Config::Connect:
No TraceSources are defined for this type.
Definition at line 82 of file red-queue.h.
anonymous enum |
Drop types.
Enumerator | |
---|---|
DTYPE_NONE |
Ok, no drop. |
DTYPE_FORCED |
A "forced" drop. |
DTYPE_UNFORCED |
An "unforced" (random) drop. |
Definition at line 117 of file red-queue.h.
ns3::RedQueue::RedQueue | ( | ) |
RedQueue Constructor.
Create a RED queue
Definition at line 150 of file red-queue.cc.
References m_uv, and NS_LOG_FUNCTION.
|
virtual |
int64_t ns3::RedQueue::AssignStreams | ( | int64_t | stream | ) |
Assign a fixed random variable stream number to the random variables used by this model.
Return the number of streams (possibly zero) that have been assigned.
stream | first stream index to use |
Definition at line 203 of file red-queue.cc.
References m_uv, NS_LOG_FUNCTION, and ns3::RandomVariableStream::SetStream().
|
private |
Returns a probability using these function parameters for the DropEarly function.
qAvg | Average queue length |
maxTh | Max avg length threshold |
gentle | "gentle" algorithm |
vA | vA |
vB | vB |
vC | vC |
vD | vD |
maxP | max_p |
Definition at line 501 of file red-queue.cc.
References NS_LOG_FUNCTION.
Referenced by DropEarly().
Pull a packet from the queue.
Implements ns3::Queue.
Definition at line 612 of file red-queue.cc.
References ns3::Packet::GetSize(), m_bytesInQueue, m_idle, m_idleTime, m_packets, ns3::Simulator::Now(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Push a packet in the queue.
p | the packet to enqueue |
Implements ns3::Queue.
Definition at line 211 of file red-queue.cc.
References ns3::Queue::Drop(), DropEarly(), DTYPE_FORCED, DTYPE_NONE, DTYPE_UNFORCED, Estimator(), ns3::RedQueue::Stats::forcedDrop, GetMode(), ns3::Packet::GetSize(), InitializeParams(), m_bytesInQueue, m_cautious, m_count, m_countBytes, m_hasRedStarted, m_idle, m_idlePktSize, m_idleTime, m_isGentle, m_isNs1Compat, m_maxTh, m_meanPktSize, m_minTh, m_old, m_packets, m_ptc, m_qAvg, m_queueLimit, m_qW, m_stats, m_vProb, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_LOGIC, ns3::RedQueue::Stats::qLimDrop, ns3::Queue::QUEUE_MODE_BYTES, ns3::Queue::QUEUE_MODE_PACKETS, and ns3::RedQueue::Stats::unforcedDrop.
Peek the front packet in the queue.
Implements ns3::Queue.
Definition at line 641 of file red-queue.cc.
References m_bytesInQueue, m_packets, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Check if packet p needs to be dropped due to probability mark.
p | packet |
qSize | queue size |
Definition at line 440 of file red-queue.cc.
References CalculatePNew(), ns3::Packet::GetSize(), ns3::UniformRandomVariable::GetValue(), m_cautious, m_count, m_countBytes, m_curMaxP, m_isGentle, m_isWait, m_maxTh, m_meanPktSize, m_ptc, m_qAvg, m_qW, m_uv, m_vA, m_vB, m_vC, m_vD, m_vProb, m_vProb1, ModifyP(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by DoEnqueue().
|
private |
Compute the average queue size.
nQueued | number of queued packets |
m | simulated number of packets arrival during idle period |
qAvg | average queue size |
qW | queue weight given to cur q size sample |
Definition at line 420 of file red-queue.cc.
References NS_LOG_FUNCTION.
Referenced by DoEnqueue().
RedQueue::QueueMode ns3::RedQueue::GetMode | ( | void | ) |
Get the encapsulation mode of this queue.
Get the encapsulation mode of this queue
Definition at line 173 of file red-queue.cc.
References m_mode, and NS_LOG_FUNCTION.
Referenced by DoEnqueue(), GetQueueSize(), ModifyP(), and RedQueueTestCase::RunRedTest().
uint32_t ns3::RedQueue::GetQueueSize | ( | void | ) |
Get the current value of the queue in bytes or packets.
Definition at line 594 of file red-queue.cc.
References GetMode(), m_bytesInQueue, m_packets, NS_ABORT_MSG, NS_LOG_FUNCTION, ns3::Queue::QUEUE_MODE_BYTES, and ns3::Queue::QUEUE_MODE_PACKETS.
Referenced by RedQueueTestCase::RunRedTest().
RedQueue::Stats ns3::RedQueue::GetStats | ( | ) |
Get the RED statistics after running.
Definition at line 196 of file red-queue.cc.
References m_stats, and NS_LOG_FUNCTION.
|
static |
Get the type ID.
Definition at line 74 of file red-queue.cc.
References m_idlePktSize, m_isGentle, m_isNs1Compat, m_isWait, m_linkBandwidth, m_linkDelay, m_lInterm, m_maxTh, m_meanPktSize, m_minTh, m_queueLimit, m_qW, ns3::MakeEnumAccessor(), ns3::MakeEnumChecker(), ns3::MakeTimeChecker(), ns3::MilliSeconds(), ns3::Queue::QUEUE_MODE_BYTES, ns3::Queue::QUEUE_MODE_PACKETS, SetMode(), and ns3::TypeId::SetParent().
|
private |
Initialize the queue parameters.
Note: if the link bandwidth changes in the course of the simulation, the bandwidth-dependent RED parameters do not change. This should be fixed, but it would require some extra parameters, and didn't seem worth the trouble...
Definition at line 341 of file red-queue.cc.
References ns3::RedQueue::Stats::forcedDrop, ns3::DataRate::GetBitRate(), ns3::Time::GetSeconds(), m_cautious, m_count, m_countBytes, m_curMaxP, m_idle, m_idleTime, m_isGentle, m_isWait, m_linkBandwidth, m_linkDelay, m_lInterm, m_maxTh, m_meanPktSize, m_minTh, m_old, m_ptc, m_qAvg, m_qW, m_stats, m_vA, m_vB, m_vC, m_vD, ns3::NanoSeconds(), NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::RedQueue::Stats::qLimDrop, and ns3::RedQueue::Stats::unforcedDrop.
Referenced by DoEnqueue().
|
private |
Returns a probability using these function parameters for the DropEarly function.
p | Prob. of packet drop before "count" |
count | number of packets since last random number generation |
countBytes | number of bytes since last drop |
meanPktSize | Avg pkt size |
wait | True for waiting between dropped packets |
size | packet size |
Definition at line 542 of file red-queue.cc.
References GetMode(), NS_LOG_FUNCTION, and ns3::Queue::QUEUE_MODE_BYTES.
Referenced by DropEarly().
void ns3::RedQueue::SetMode | ( | RedQueue::QueueMode | mode | ) |
Set the operating mode of this queue.
Set operating mode
mode | The operating mode of this queue. |
Definition at line 166 of file red-queue.cc.
References m_mode, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
void ns3::RedQueue::SetQueueLimit | ( | uint32_t | lim | ) |
Set the limit of the queue.
lim | The limit in bytes or packets. |
Definition at line 180 of file red-queue.cc.
References m_queueLimit, and NS_LOG_FUNCTION.
Referenced by RedQueueTestCase::RunRedTest().
void ns3::RedQueue::SetTh | ( | double | minTh, |
double | maxTh | ||
) |
Set the thresh limits of RED.
minTh | Minimum thresh in bytes or packets. |
maxTh | Maximum thresh in bytes or packets. |
Definition at line 187 of file red-queue.cc.
References m_maxTh, m_minTh, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by RedQueueTestCase::RunRedTest().
|
private |
bytes in the queue
Definition at line 238 of file red-queue.h.
Referenced by DoDequeue(), DoEnqueue(), DoPeek(), and GetQueueSize().
|
private |
0 for default RED 1 experimental (see red-queue.cc) 2 experimental (see red-queue.cc) 3 use Idle packet size in the ptc
Definition at line 277 of file red-queue.h.
Referenced by DoEnqueue(), DropEarly(), and InitializeParams().
|
private |
Number of packets since last random number generation.
Definition at line 270 of file red-queue.h.
Referenced by DoEnqueue(), DropEarly(), and InitializeParams().
|
private |
Number of bytes since last drop.
Definition at line 265 of file red-queue.h.
Referenced by DoEnqueue(), DropEarly(), and InitializeParams().
|
private |
Current max_p.
Definition at line 263 of file red-queue.h.
Referenced by DropEarly(), and InitializeParams().
|
private |
|
private |
0/1 idle status
Definition at line 267 of file red-queue.h.
Referenced by DoDequeue(), DoEnqueue(), and InitializeParams().
|
private |
Avg pkt size used during idle times.
Definition at line 245 of file red-queue.h.
Referenced by DoEnqueue(), and GetTypeId().
|
private |
Start of current idle period.
Definition at line 278 of file red-queue.h.
Referenced by DoDequeue(), DoEnqueue(), and InitializeParams().
|
private |
True to increases dropping prob.
slowly when ave queue exceeds maxthresh
Definition at line 247 of file red-queue.h.
Referenced by DoEnqueue(), DropEarly(), GetTypeId(), and InitializeParams().
|
private |
Ns-1 compatibility.
Definition at line 253 of file red-queue.h.
Referenced by DoEnqueue(), and GetTypeId().
|
private |
True for waiting between dropped packets.
Definition at line 246 of file red-queue.h.
Referenced by DropEarly(), GetTypeId(), and InitializeParams().
|
private |
Link bandwidth.
Definition at line 254 of file red-queue.h.
Referenced by GetTypeId(), and InitializeParams().
|
private |
Link delay.
Definition at line 255 of file red-queue.h.
Referenced by GetTypeId(), and InitializeParams().
|
private |
The max probability of dropping a packet.
Definition at line 252 of file red-queue.h.
Referenced by GetTypeId(), and InitializeParams().
|
private |
Max avg length threshold (bytes), should be >= 2*minTh.
Definition at line 249 of file red-queue.h.
Referenced by DoEnqueue(), DropEarly(), GetTypeId(), InitializeParams(), and SetTh().
|
private |
Avg pkt size.
Definition at line 244 of file red-queue.h.
Referenced by DoEnqueue(), DropEarly(), GetTypeId(), and InitializeParams().
|
private |
Min avg length threshold (bytes)
Definition at line 248 of file red-queue.h.
Referenced by DoEnqueue(), GetTypeId(), InitializeParams(), and SetTh().
|
private |
Mode (Bytes or packets)
Definition at line 243 of file red-queue.h.
|
private |
0 when average queue first exceeds threshold
Definition at line 266 of file red-queue.h.
Referenced by DoEnqueue(), and InitializeParams().
packets in the queue
Definition at line 236 of file red-queue.h.
Referenced by DoDequeue(), DoEnqueue(), DoPeek(), and GetQueueSize().
|
private |
packet time constant in packets/second
Definition at line 268 of file red-queue.h.
Referenced by DoEnqueue(), DropEarly(), and InitializeParams().
|
private |
Average queue length.
Definition at line 269 of file red-queue.h.
Referenced by DoEnqueue(), DropEarly(), and InitializeParams().
|
private |
Queue limit in bytes / packets.
Definition at line 250 of file red-queue.h.
Referenced by DoEnqueue(), GetTypeId(), and SetQueueLimit().
|
private |
Queue weight given to cur queue size sample.
Definition at line 251 of file red-queue.h.
Referenced by DoEnqueue(), DropEarly(), GetTypeId(), and InitializeParams().
|
private |
RED statistics.
Definition at line 240 of file red-queue.h.
Referenced by DoEnqueue(), GetStats(), and InitializeParams().
|
private |
rng stream
Definition at line 280 of file red-queue.h.
Referenced by AssignStreams(), DropEarly(), and RedQueue().
|
private |
1.0 / (m_maxTh - m_minTh)
Definition at line 259 of file red-queue.h.
Referenced by DropEarly(), and InitializeParams().
|
private |
-m_minTh / (m_maxTh - m_minTh)
Definition at line 260 of file red-queue.h.
Referenced by DropEarly(), and InitializeParams().
|
private |
(1.0 - m_curMaxP) / m_maxTh - used in "gentle" mode
Definition at line 261 of file red-queue.h.
Referenced by DropEarly(), and InitializeParams().
|
private |
2.0 * m_curMaxP - 1.0 - used in "gentle" mode
Definition at line 262 of file red-queue.h.
Referenced by DropEarly(), and InitializeParams().
|
private |
Prob.
of packet drop
Definition at line 264 of file red-queue.h.
Referenced by DoEnqueue(), and DropEarly().
|
private |
Prob.
of packet drop before "count"
Definition at line 258 of file red-queue.h.
Referenced by DropEarly().