|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
30 #include "ns3/uinteger.h"
31 #include "ns3/abort.h"
33 #include "ns3/object-factory.h"
34 #include "ns3/drop-tail-queue.h"
50 return (uint32_t)(((uint64_t)A * R) >> 32);
74 .SetGroupName (
"TrafficControl")
76 .AddAttribute (
"UseEcn",
77 "True to use ECN (packets are marked instead of being dropped)",
81 .AddAttribute (
"UseL4s",
82 "True to use L4S (only ECT1 packets are marked at CE threshold)",
86 .AddAttribute (
"MaxSize",
87 "The maximum number of packets/bytes accepted by this queue disc.",
92 .AddAttribute (
"MinBytes",
93 "The CoDel algorithm minbytes parameter.",
96 MakeUintegerChecker<uint32_t> ())
97 .AddAttribute (
"Interval",
98 "The CoDel algorithm interval",
102 .AddAttribute (
"Target",
103 "The CoDel algorithm target queue delay",
107 .AddAttribute (
"CeThreshold",
108 "The CoDel CE threshold for marking packets",
112 .AddTraceSource (
"Count",
115 "ns3::TracedValueCallback::Uint32")
116 .AddTraceSource (
"LastCount",
119 "ns3::TracedValueCallback::Uint32")
120 .AddTraceSource (
"DropState",
123 "ns3::TracedValueCallback::Bool")
124 .AddTraceSource (
"DropNext",
125 "Time until next packet drop",
127 "ns3::TracedValueCallback::Uint32")
139 m_firstAboveTime (0),
155 uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32;
156 uint64_t val = (3ll << 32) - ((uint64_t) count * invsqrt2);
159 val = (val * invsqrt) >> (32 - 2 + 1);
213 NS_LOG_LOGIC (
"Sojourn time is below target or number of bytes in queue is less than minBytes; packet should not be dropped");
223 NS_LOG_LOGIC (
"Sojourn time has just gone above target from below, need to stay above for at least q->interval before packet can be dropped. ");
228 NS_LOG_LOGIC (
"Sojourn time has been above target for at least q->interval; it's OK to (possibly) drop packet.");
251 if (item->GetUint8Value (
QueueItem::IP_DSFIELD, tosByte) && (((tosByte & 0x3) == 1) || (tosByte & 0x3) == 3))
253 if ((tosByte & 0x3) == 1)
255 NS_LOG_DEBUG (
"ECT1 packet " <<
static_cast<uint16_t
> (tosByte & 0x3));
259 NS_LOG_DEBUG (
"CE packet " <<
static_cast<uint16_t
> (tosByte & 0x3));
277 bool okToDrop =
OkToDrop (item, now);
278 bool isMarked =
false;
283 NS_LOG_LOGIC (
"In dropping state, check if it's OK to leave or next drop should occur");
287 NS_LOG_LOGIC (
"Sojourn time goes below target, it's OK to leave dropping state.");
305 NS_LOG_LOGIC (
"Sojourn time is still above target and it's time for next drop or mark; marking " << item);
311 NS_LOG_LOGIC (
"Sojourn time is still above target and it's time for next drop; dropping " << item);
343 NS_LOG_LOGIC (
"Not in dropping state; decide if we have to enter the state and drop the first packet");
349 NS_LOG_LOGIC (
"Sojourn time goes above target, marking the first packet " << item <<
" and entering the dropping state");
354 NS_LOG_LOGIC (
"Sojourn time goes above target, dropping the first packet " << item <<
" and entering the dropping state");
383 NS_LOG_LOGIC (
"Running ControlLaw for input now: " << (
double)now);
385 NS_LOG_LOGIC (
"Scheduled next drop at " << (
double)
m_dropNext / 1000000 <<
" now " << (
double)now / 1000000);
422 return ((int64_t)(a) - (int64_t)(b) > 0);
428 return ((int64_t)(a) - (int64_t)(b) >= 0);
434 return ((int64_t)(a) - (int64_t)(b) < 0);
440 return ((int64_t)(a) - (int64_t)(b) <= 0);
461 NS_LOG_ERROR (
"CoDelQueueDisc cannot have packet filters");
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
static const int CODEL_SHIFT
Number of bits discarded from the time representation.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time m_ceThreshold
Threshold above which to CE mark.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
AttributeValue implementation for Boolean.
static Time Now(void)
Return the current simulation virtual time.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
#define DEFAULT_CODEL_LIMIT
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
A CoDel packet queue disc.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
virtual Ptr< QueueDiscItem > DoDequeue(void)
Remove a packet from queue based on the current state If we are in dropping state,...
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
static uint32_t ControlLaw(uint32_t t, uint32_t interval, uint32_t recInvSqrt)
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
TracedValue< uint32_t > m_lastCount
Last number of packets dropped since entering drop state.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
Add a packet to the queue.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
static constexpr const char * TARGET_EXCEEDED_DROP
Sojourn time above target.
bool CoDelTimeBefore(uint32_t a, uint32_t b)
Check if CoDel time a is preceding b.
TracedValue< uint32_t > m_dropNext
Time to drop next packet.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual ~CoDelQueueDisc()
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
bool Mark(Ptr< QueueDiscItem > item, const char *reason)
Marks the given packet and, if successful, updates the counters associated with the given reason.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Time GetInterval(void)
Get the interval.
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packet.
Smart pointer class similar to boost::intrusive_ptr.
Time GetTarget(void)
Get the target queue delay.
static uint32_t ReciprocalDivide(uint32_t A, uint32_t R)
Performs a reciprocal divide, similar to the Linux kernel reciprocal_divide function.
uint32_t m_firstAboveTime
Time to declare sojourn time above target.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
@ SINGLE_INTERNAL_QUEUE
Used by queue discs with single internal queue.
CoDelQueueDisc()
CoDelQueueDisc Constructor.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
bool CoDelTimeBeforeEq(uint32_t a, uint32_t b)
Check if CoDel time a is preceding or equal to b.
Simulation virtual time values and global simulation resolution.
void AddInternalQueue(Ptr< InternalQueue > queue)
Add an internal queue to the tail of the list of queues.
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.
static uint16_t NewtonStep(uint16_t recInvSqrt, uint32_t count)
Calculate the reciprocal square root of m_count by using Newton's method http://en....
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets,...
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Time m_interval
100 ms sliding minimum time window width
Introspection did not find any typical Config paths.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Hold variables of type string.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
static constexpr const char * TARGET_EXCEEDED_MARK
Sojourn time above target.
Time m_target
5 ms target queue delay
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
uint32_t Time2CoDel(Time t)
Return the unsigned 32-bit integer representation of the input Time object.
bool OkToDrop(Ptr< QueueDiscItem > item, uint32_t now)
Determine whether a packet is OK to be dropped.
void DropAfterDequeue(Ptr< const QueueDiscItem > item, const char *reason)
Perform the actions required when the queue disc is notified of a packet dropped after dequeue.
uint16_t m_recInvSqrt
Reciprocal inverse square root.
static int64_t CoDelGetTime(void)
Returns the current time translated in CoDel time representation.
uint32_t m_minBytes
Minimum bytes in queue to allow a packet drop.
@ BYTES
Use number of bytes for queue size.
TracedValue< bool > m_dropping
True if in dropping state.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
bool m_useL4s
True if L4S is used (ECT1 packets are marked at CE threshold)
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
static constexpr const char * CE_THRESHOLD_EXCEEDED_MARK
Sojourn time above CE threshold.
Hold an unsigned integer type.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
void DropBeforeEnqueue(Ptr< const QueueDiscItem > item, const char *reason)
Perform the actions required when the queue disc is notified of a packet dropped before enqueue.
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
Class for representing queue sizes.
bool CoDelTimeAfter(uint32_t a, uint32_t b)
Check if CoDel time a is successive to b.
static TypeId GetTypeId(void)
Get the type ID.
#define REC_INV_SQRT_SHIFT
bool CoDelTimeAfterEq(uint32_t a, uint32_t b)
Check if CoDel time a is successive or equal to b.
uint32_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)