30 #include "ns3/uinteger.h" 31 #include "ns3/abort.h" 33 #include "ns3/object-factory.h" 34 #include "ns3/drop-tail-queue.h" 35 #include "ns3/net-device-queue-interface.h" 51 return (uint32_t)(((uint64_t)A * R) >> 32);
75 .SetGroupName (
"TrafficControl")
77 .AddAttribute (
"MaxSize",
78 "The maximum number of packets/bytes accepted by this queue disc.",
83 .AddAttribute (
"MinBytes",
84 "The CoDel algorithm minbytes parameter.",
87 MakeUintegerChecker<uint32_t> ())
88 .AddAttribute (
"Interval",
89 "The CoDel algorithm interval",
93 .AddAttribute (
"Target",
94 "The CoDel algorithm target queue delay",
98 .AddTraceSource (
"Count",
101 "ns3::TracedValueCallback::Uint32")
102 .AddTraceSource (
"LastCount",
105 "ns3::TracedValueCallback::Uint32")
106 .AddTraceSource (
"DropState",
109 "ns3::TracedValueCallback::Bool")
110 .AddTraceSource (
"DropNext",
111 "Time until next packet drop",
113 "ns3::TracedValueCallback::Uint32")
125 m_firstAboveTime (0),
145 uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32;
146 uint64_t val = (3ll << 32) - ((uint64_t)
m_count * invsqrt2);
149 val = (val * invsqrt) >> (32 - 2 + 1);
203 NS_LOG_LOGIC (
"Sojourn time is below target or number of bytes in queue is less than minBytes; packet should not be dropped");
213 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. ");
218 NS_LOG_LOGIC (
"Sojourn time has been above target for at least q->interval; it's OK to (possibly) drop packet.");
245 bool okToDrop =
OkToDrop (item, now);
250 NS_LOG_LOGIC (
"In dropping state, check if it's OK to leave or next drop should occur");
254 NS_LOG_LOGIC (
"Sojourn time goes below target, it's OK to leave dropping state.");
268 NS_LOG_LOGIC (
"Sojourn time is still above target and it's time for next drop; dropping " << item);
302 NS_LOG_LOGIC (
"Not in dropping state; decide if we have to enter the state and drop the first packet");
306 NS_LOG_LOGIC (
"Sojourn time goes above target, dropping the first packet " << item <<
" and entering the dropping state");
338 NS_LOG_LOGIC (
"Running ControlLaw for input now: " << (
double)now);
340 NS_LOG_LOGIC (
"Scheduled next drop at " << (
double)
m_dropNext / 1000000 <<
" now " << (
double)now / 1000000);
368 return ((
int)(a) - (
int)(b) > 0);
374 return ((
int)(a) - (
int)(b) >= 0);
380 return ((
int)(a) - (
int)(b) < 0);
386 return ((
int)(a) - (
int)(b) <= 0);
407 NS_LOG_ERROR (
"CoDelQueueDisc cannot have packet filters");
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
Simulation virtual time values and global simulation resolution.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
Add a packet to the queue.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static constexpr const char * TARGET_EXCEEDED_DROP
Sojourn time above target.
Class for representing queue sizes.
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...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Hold variables of type string.
uint32_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise.
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packet.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
Time GetInterval(void)
Get the interval.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
double ToDouble(enum Unit unit) const
Get the Time value expressed in a particular unit.
bool CoDelTimeAfterEq(uint32_t a, uint32_t b)
Check if CoDel time a is successive or equal to b.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
uint32_t ControlLaw(uint32_t t)
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
bool CoDelTimeAfter(uint32_t a, uint32_t b)
Check if CoDel time a is successive to b.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
TracedValue< bool > m_dropping
True if in dropping state.
bool OkToDrop(Ptr< QueueDiscItem > item, uint32_t now)
Determine whether a packet is OK to be dropped.
void AddInternalQueue(Ptr< InternalQueue > queue)
Add an internal queue to the tail of the list of queues.
Ptr< T > CreateObjectWithAttributes(std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
Allocate an Object on the heap and initialize with a set of attributes.
uint32_t m_states
Total number of times we are in state 1, state 2, or state 3.
uint32_t m_firstAboveTime
Time to declare sojourn time above target.
uint32_t m_state2
Number of times we perform next drop while in dropping state.
bool CoDelTimeBefore(uint32_t a, uint32_t b)
Check if CoDel time a is preceding b.
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
Hold an unsigned integer type.
Time m_target
5 ms target queue delay
CoDelQueueDisc()
CoDelQueueDisc Constructor.
virtual ~CoDelQueueDisc()
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
TracedValue< uint32_t > m_lastCount
Last number of packets dropped since entering drop state.
Time m_interval
100 ms sliding minimum time window width
Introspection did not find any typical Config paths.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
virtual Ptr< QueueDiscItem > 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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t m_recInvSqrt
Reciprocal inverse square root.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
#define REC_INV_SQRT_SHIFT
Time GetTarget(void)
Get the target queue delay.
#define DEFAULT_CODEL_LIMIT
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)
A CoDel packet queue disc.
static const int CODEL_SHIFT
Number of bits discarded from the time representation.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static Time Now(void)
Return the current simulation virtual time.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
uint32_t m_state3
Number of times we enter drop state and drop the fist packet.
uint32_t Time2CoDel(Time t)
Return the unsigned 32-bit integer representation of the input Time object.
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
static TypeId GetTypeId(void)
Get the type ID.
bool CoDelTimeBeforeEq(uint32_t a, uint32_t b)
Check if CoDel time a is preceding or equal to b.
Used by queue discs with single internal queue.
uint32_t m_minBytes
Minimum bytes in queue to allow a packet drop.
static uint32_t ReciprocalDivide(uint32_t A, uint32_t R)
Performs a reciprocal divide, similar to the Linux kernel reciprocal_divide function.
static uint32_t CoDelGetTime(void)
Returns the current time translated in CoDel time representation.
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
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...
uint32_t m_state1
Number of times packet sojourn goes above target for interval.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Use number of bytes for queue size.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
TracedValue< uint32_t > m_dropNext
Time to drop next packet.
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.