A CoDel packet queue. More...
#include <codel-queue.h>
Public Member Functions | |
CoDelQueue () | |
CoDelQueue Constructor. More... | |
virtual | ~CoDelQueue () |
uint32_t | GetDropCount (void) |
Get the number of packets dropped according to CoDel algorithm. More... | |
uint32_t | GetDropNext (void) |
Get the time for next packet drop while in the dropping state. More... | |
uint32_t | GetDropOverLimit (void) |
Get the number of packets dropped when packets arrive at a full queue and cannot be enqueued. More... | |
Time | GetInterval (void) |
Get the interval. More... | |
CoDelQueue::QueueMode | GetMode (void) |
Get the encapsulation mode of this device. More... | |
uint32_t | GetQueueSize (void) |
Get the current value of the queue in bytes or packets. More... | |
Time | GetTarget (void) |
Get the target queue delay. More... | |
void | SetMode (CoDelQueue::QueueMode mode) |
Set the operating mode of this device. 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 () | |
Constructor. More... | |
virtual | ~Object () |
Destructor. More... | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. More... | |
void | Dispose (void) |
Dispose of this Object. More... | |
AggregateIterator | GetAggregateIterator (void) const |
Get an iterator to the Objects aggregated to this one. More... | |
virtual TypeId | GetInstanceTypeId (void) const |
Implement the GetInstanceTypeId method defined in ObjectBase. More... | |
template<typename T > | |
Ptr< T > | GetObject (void) const |
Get a pointer to the requested aggregated Object. More... | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object. More... | |
void | Initialize (void) |
Invoke DoInitialize on all Objects aggregated to this one. 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 |
Get the value of an attribute, raising fatal errors if unsuccessful. More... | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising erros. More... | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. More... | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. More... | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. More... | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. More... | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. More... | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. More... | |
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 | |
bool | CoDelTimeAfter (uint32_t a, uint32_t b) |
Check if CoDel time a is successive to b. More... | |
bool | CoDelTimeAfterEq (uint32_t a, uint32_t b) |
Check if CoDel time a is successive or equal to b. More... | |
bool | CoDelTimeBefore (uint32_t a, uint32_t b) |
Check if CoDel time a is preceding b. More... | |
bool | CoDelTimeBeforeEq (uint32_t a, uint32_t b) |
Check if CoDel time a is preceding or equal to b. More... | |
uint32_t | ControlLaw (uint32_t t) |
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count). More... | |
virtual Ptr< Packet > | DoDequeue (void) |
Remove a packet from queue based on the current state If we are in dropping state, check if we could leave the dropping state or if we should perform next drop If we are not currently in dropping state, check if we need to enter the state and drop the first packet. More... | |
virtual bool | DoEnqueue (Ptr< Packet > p) |
Add a packet to the queue. More... | |
virtual Ptr< const Packet > | DoPeek (void) const |
Peek the front packet in the queue. More... | |
void | NewtonStep (void) |
Calculate the reciprocal square root of m_count by using Newton's method http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Iterative_methods_for_reciprocal_square_roots m_recInvSqrt (new) = (m_recInvSqrt (old) / 2) * (3 - m_count * m_recInvSqrt^2) More... | |
bool | OkToDrop (Ptr< Packet > p, uint32_t now) |
Determine whether a packet is OK to be dropped. More... | |
uint32_t | Time2CoDel (Time t) |
returned unsigned 32-bit integer representation of the input Time object units are microseconds More... | |
Private Attributes | |
TracedValue< uint32_t > | m_bytesInQueue |
The total number of bytes in queue. More... | |
TracedValue< uint32_t > | m_count |
Number of packets dropped since entering drop state. More... | |
TracedValue< uint32_t > | m_dropCount |
Number of dropped packets according CoDel algorithm. More... | |
TracedValue< uint32_t > | m_dropNext |
Time to drop next packet. More... | |
uint32_t | m_dropOverLimit |
The number of packets dropped due to full queue. More... | |
TracedValue< bool > | m_dropping |
True if in dropping state. More... | |
uint32_t | m_firstAboveTime |
Time to declare sojourn time above target. More... | |
Time | m_interval |
100 ms sliding minimum time window width More... | |
TracedValue< uint32_t > | m_lastCount |
Last number of packets dropped since entering drop state. More... | |
uint32_t | m_maxBytes |
Max # of bytes accepted by the queue. More... | |
uint32_t | m_maxPackets |
Max # of packets accepted by the queue. More... | |
uint32_t | m_minBytes |
Minimum bytes in queue to allow a packet drop. More... | |
QueueMode | m_mode |
The operating mode (Bytes or packets) More... | |
std::queue< Ptr< Packet > > | m_packets |
The packet queue. More... | |
uint16_t | m_recInvSqrt |
Reciprocal inverse square root. More... | |
TracedValue< Time > | m_sojourn |
Time in queue. More... | |
uint32_t | m_state1 |
Number of times packet sojourn goes above target for interval. More... | |
uint32_t | m_state2 |
Number of times we perform next drop while in dropping state. More... | |
uint32_t | m_state3 |
Number of times we enter drop state and drop the fist packet. More... | |
uint32_t | m_states |
Total number of times we are in state 1, state 2, or state 3. More... | |
Time | m_target |
5 ms target queue delay More... | |
Additional Inherited Members | |
![]() | |
enum | QueueMode { QUEUE_MODE_PACKETS, QUEUE_MODE_BYTES } |
Enumeration of the modes supported in the class. More... | |
![]() | |
void | Drop (Ptr< Packet > packet) |
Drop a packet. More... | |
![]() | |
Object (const Object &o) | |
Copy an Object. More... | |
virtual void | DoDispose (void) |
Destructor implementation. More... | |
virtual void | DoInitialize (void) |
Initialize() implementation. More... | |
virtual void | NotifyNewAggregate (void) |
Notify all Objects aggregated to this one of a new Object being aggregated. More... | |
![]() | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. More... | |
virtual void | NotifyConstructionCompleted (void) |
Notifier called once the ObjectBase is fully constructed. More... | |
![]() | |
uint32_t | m_nBytes |
Number of bytes in the queue. More... | |
uint32_t | m_nPackets |
Number of packets in the queue. More... | |
uint32_t | m_nTotalDroppedBytes |
Total dropped bytes. More... | |
uint32_t | m_nTotalDroppedPackets |
Total dropped packets. More... | |
uint32_t | m_nTotalReceivedBytes |
Total received bytes. More... | |
uint32_t | m_nTotalReceivedPackets |
Total received packets. More... | |
TracedCallback< Ptr< const Packet > > | m_traceDequeue |
Traced callback: fired when a packet is dequeued. More... | |
TracedCallback< Ptr< const Packet > > | m_traceDrop |
Traced callback: fired when a packet is dropped. More... | |
TracedCallback< Ptr< const Packet > > | m_traceEnqueue |
Traced callback: fired when a packet is enqueued. More... | |
![]() | |
static TypeId | GetObjectIid (void) |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
A CoDel packet queue.
ns3::CoDelQueue is accessible through the following paths with Config::Set and Config::Connect:
Size of this type is 416 bytes (on a 64-bit architecture).
Definition at line 63 of file codel-queue.h.
ns3::CoDelQueue::CoDelQueue | ( | ) |
CoDelQueue Constructor.
Creates a CoDel queue
Definition at line 217 of file codel-queue.cc.
References NS_LOG_FUNCTION.
|
virtual |
Definition at line 239 of file codel-queue.cc.
References NS_LOG_FUNCTION.
|
private |
Check if CoDel time a is successive to b.
a | left operand |
b | right operand |
Definition at line 575 of file codel-queue.cc.
Referenced by OkToDrop().
|
private |
Check if CoDel time a is successive or equal to b.
a | left operand |
b | right operand |
Definition at line 581 of file codel-queue.cc.
Referenced by DoDequeue().
|
private |
Check if CoDel time a is preceding b.
a | left operand |
b | right operand |
Definition at line 587 of file codel-queue.cc.
Referenced by DoDequeue(), and OkToDrop().
|
private |
Check if CoDel time a is preceding or equal to b.
a | left operand |
b | right operand |
Definition at line 593 of file codel-queue.cc.
|
private |
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
Here, we use m_recInvSqrt calculated by Newton's method in NewtonStep() to avoid both sqrt() and divide operations
t | Current next drop time |
Definition at line 258 of file codel-queue.cc.
References m_interval, m_recInvSqrt, NS_LOG_FUNCTION, REC_INV_SQRT_SHIFT, ns3::ReciprocalDivide(), and Time2CoDel().
Referenced by DoDequeue(), and CoDelQueueControlLawTest::DoRun().
Remove a packet from queue based on the current state If we are in dropping state, check if we could leave the dropping state or if we should perform next drop If we are not currently in dropping state, check if we need to enter the state and drop the first packet.
Implements ns3::Queue.
Definition at line 355 of file codel-queue.cc.
References ns3::CoDelGetTime(), CoDelTimeAfterEq(), CoDelTimeBefore(), ControlLaw(), ns3::Queue::Drop(), ns3::Packet::GetSize(), m_bytesInQueue, m_count, m_dropCount, m_dropNext, m_dropping, m_firstAboveTime, m_interval, m_lastCount, ns3::Queue::m_nBytes, ns3::Queue::m_nPackets, m_packets, m_recInvSqrt, m_state2, m_state3, m_states, ns3::Queue::m_traceDequeue, NewtonStep(), NS_LOG_FUNCTION, NS_LOG_LOGIC, OkToDrop(), REC_INV_SQRT_SHIFT, and Time2CoDel().
Add a packet to the queue.
p | The packet to be added |
Implements ns3::Queue.
Definition at line 279 of file codel-queue.cc.
References ns3::Packet::AddPacketTag(), ns3::Queue::Drop(), ns3::Packet::GetSize(), m_bytesInQueue, m_dropOverLimit, m_maxBytes, m_maxPackets, m_mode, m_packets, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::Queue::QUEUE_MODE_BYTES, and ns3::Queue::QUEUE_MODE_PACKETS.
Peek the front packet in the queue.
Implements ns3::Queue.
Definition at line 556 of file codel-queue.cc.
References m_bytesInQueue, m_packets, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
uint32_t ns3::CoDelQueue::GetDropCount | ( | void | ) |
Get the number of packets dropped according to CoDel algorithm.
Definition at line 532 of file codel-queue.cc.
References m_dropCount.
Referenced by CoDelQueueBasicDrop::Dequeue(), and CoDelQueueBasicEnqueueDequeue::DoRun().
uint32_t ns3::CoDelQueue::GetDropNext | ( | void | ) |
Get the time for next packet drop while in the dropping state.
Definition at line 550 of file codel-queue.cc.
References m_dropNext.
Referenced by CoDelQueueBasicDrop::Dequeue().
uint32_t ns3::CoDelQueue::GetDropOverLimit | ( | void | ) |
Get the number of packets dropped when packets arrive at a full queue and cannot be enqueued.
Definition at line 526 of file codel-queue.cc.
References m_dropOverLimit.
Referenced by CoDelQueueBasicEnqueueDequeue::DoRun(), and CoDelQueueBasicOverflow::DoRun().
Time ns3::CoDelQueue::GetInterval | ( | void | ) |
Get the interval.
Definition at line 544 of file codel-queue.cc.
References m_interval.
Referenced by CoDelQueueBasicDrop::Dequeue(), and CoDelQueueBasicDrop::DoRun().
CoDelQueue::QueueMode ns3::CoDelQueue::GetMode | ( | void | ) |
Get the encapsulation mode of this device.
Definition at line 272 of file codel-queue.cc.
References m_mode, and NS_LOG_FUNCTION.
Referenced by CoDelQueueBasicEnqueueDequeue::DoRun(), CoDelQueueBasicOverflow::DoRun(), CoDelQueueBasicDrop::DoRun(), GetQueueSize(), CoDelQueueBasicEnqueueDequeue::QueueTestSize(), CoDelQueueBasicOverflow::QueueTestSize(), and CoDelQueueBasicDrop::QueueTestSize().
uint32_t ns3::CoDelQueue::GetQueueSize | ( | void | ) |
Get the current value of the queue in bytes or packets.
Definition at line 508 of file codel-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 CoDelQueueBasicDrop::Dequeue(), CoDelQueueBasicDrop::DoRun(), CoDelQueueBasicEnqueueDequeue::QueueTestSize(), CoDelQueueBasicOverflow::QueueTestSize(), and CoDelQueueBasicDrop::QueueTestSize().
Time ns3::CoDelQueue::GetTarget | ( | void | ) |
Get the target queue delay.
Definition at line 538 of file codel-queue.cc.
References m_target.
Referenced by CoDelQueueBasicDrop::Dequeue(), and CoDelQueueBasicDrop::DoRun().
|
static |
Get the type ID.
Get the type ID.
Definition at line 147 of file codel-queue.cc.
References DEFAULT_CODEL_LIMIT, m_bytesInQueue, m_count, m_dropCount, m_dropNext, m_dropping, m_interval, m_lastCount, m_maxBytes, m_maxPackets, m_minBytes, m_sojourn, m_target, ns3::MakeEnumAccessor(), ns3::MakeEnumChecker(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::MakeUintegerAccessor(), ns3::Queue::QUEUE_MODE_BYTES, ns3::Queue::QUEUE_MODE_PACKETS, SetMode(), and ns3::TypeId::SetParent().
|
private |
Calculate the reciprocal square root of m_count by using Newton's method http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Iterative_methods_for_reciprocal_square_roots m_recInvSqrt (new) = (m_recInvSqrt (old) / 2) * (3 - m_count * m_recInvSqrt^2)
Definition at line 245 of file codel-queue.cc.
References m_count, m_recInvSqrt, NS_LOG_FUNCTION, and REC_INV_SQRT_SHIFT.
Referenced by DoDequeue(), and CoDelQueueNewtonStepTest::DoRun().
Determine whether a packet is OK to be dropped.
The packet may not be actually dropped (depending on the drop state)
p | The packet that is considered |
now | The current time represented as 32-bit unsigned integer (us) |
Definition at line 313 of file codel-queue.cc.
References CoDelTimeAfter(), CoDelTimeBefore(), ns3::Time::GetSeconds(), ns3::CoDelTimestampTag::GetTxTime(), m_bytesInQueue, m_firstAboveTime, m_interval, m_minBytes, m_sojourn, m_state1, m_target, ns3::Simulator::Now(), NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_INFO, NS_LOG_LOGIC, NS_UNUSED, ns3::Packet::RemovePacketTag(), and Time2CoDel().
Referenced by DoDequeue().
void ns3::CoDelQueue::SetMode | ( | CoDelQueue::QueueMode | mode | ) |
Set the operating mode of this device.
mode | The operating mode of this device. |
Definition at line 265 of file codel-queue.cc.
References m_mode, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
private |
returned unsigned 32-bit integer representation of the input Time object units are microseconds
Definition at line 599 of file codel-queue.cc.
References ns3::CODEL_SHIFT, and ns3::Time::GetNanoSeconds().
Referenced by CoDelQueueControlLawTest::_codel_control_law(), ControlLaw(), DoDequeue(), and OkToDrop().
|
private |
The total number of bytes in queue.
Definition at line 229 of file codel-queue.h.
Referenced by DoDequeue(), DoEnqueue(), DoPeek(), GetQueueSize(), GetTypeId(), and OkToDrop().
|
private |
Number of packets dropped since entering drop state.
Definition at line 233 of file codel-queue.h.
Referenced by DoDequeue(), CoDelQueueNewtonStepTest::DoRun(), GetTypeId(), and NewtonStep().
|
private |
Number of dropped packets according CoDel algorithm.
Definition at line 234 of file codel-queue.h.
Referenced by DoDequeue(), GetDropCount(), and GetTypeId().
|
private |
Time to drop next packet.
Definition at line 239 of file codel-queue.h.
Referenced by DoDequeue(), GetDropNext(), and GetTypeId().
|
private |
The number of packets dropped due to full queue.
Definition at line 244 of file codel-queue.h.
Referenced by DoEnqueue(), and GetDropOverLimit().
|
private |
True if in dropping state.
Definition at line 236 of file codel-queue.h.
Referenced by DoDequeue(), and GetTypeId().
|
private |
Time to declare sojourn time above target.
Definition at line 238 of file codel-queue.h.
Referenced by DoDequeue(), and OkToDrop().
|
private |
100 ms sliding minimum time window width
Definition at line 231 of file codel-queue.h.
Referenced by CoDelQueueControlLawTest::_codel_control_law(), ControlLaw(), DoDequeue(), GetInterval(), GetTypeId(), and OkToDrop().
|
private |
Last number of packets dropped since entering drop state.
Definition at line 235 of file codel-queue.h.
Referenced by DoDequeue(), and GetTypeId().
|
private |
Max # of bytes accepted by the queue.
Definition at line 228 of file codel-queue.h.
Referenced by DoEnqueue(), and GetTypeId().
|
private |
Max # of packets accepted by the queue.
Definition at line 227 of file codel-queue.h.
Referenced by DoEnqueue(), and GetTypeId().
|
private |
Minimum bytes in queue to allow a packet drop.
Definition at line 230 of file codel-queue.h.
Referenced by GetTypeId(), and OkToDrop().
|
private |
The operating mode (Bytes or packets)
Definition at line 245 of file codel-queue.h.
Referenced by DoEnqueue(), GetMode(), and SetMode().
The packet queue.
Definition at line 226 of file codel-queue.h.
Referenced by DoDequeue(), DoEnqueue(), DoPeek(), and GetQueueSize().
|
private |
Reciprocal inverse square root.
Definition at line 237 of file codel-queue.h.
Referenced by CoDelQueueControlLawTest::_codel_control_law(), ControlLaw(), DoDequeue(), CoDelQueueNewtonStepTest::DoRun(), and NewtonStep().
|
private |
Time in queue.
Definition at line 246 of file codel-queue.h.
Referenced by GetTypeId(), and OkToDrop().
|
private |
Number of times packet sojourn goes above target for interval.
Definition at line 240 of file codel-queue.h.
Referenced by OkToDrop().
|
private |
Number of times we perform next drop while in dropping state.
Definition at line 241 of file codel-queue.h.
Referenced by DoDequeue().
|
private |
Number of times we enter drop state and drop the fist packet.
Definition at line 242 of file codel-queue.h.
Referenced by DoDequeue().
|
private |
Total number of times we are in state 1, state 2, or state 3.
Definition at line 243 of file codel-queue.h.
Referenced by DoDequeue().
|
private |
5 ms target queue delay
Definition at line 232 of file codel-queue.h.
Referenced by GetTarget(), GetTypeId(), and OkToDrop().