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" 49 .SetGroupName (
"TrafficControl")
51 .AddAttribute (
"MaxSize",
52 "The maximum number of packets/bytes accepted by this queue disc.",
57 .AddAttribute (
"Interval",
58 "The Cobalt algorithm interval",
62 .AddAttribute (
"Target",
63 "The Cobalt algorithm target queue delay",
67 .AddAttribute (
"UseEcn",
68 "True to use ECN (packets are marked instead of being dropped)",
72 .AddAttribute (
"Pdrop",
73 "Marking Probability",
76 MakeDoubleChecker<double> ())
77 .AddAttribute (
"Increment",
78 "Pdrop increment value",
81 MakeDoubleChecker<double> ())
82 .AddAttribute (
"Decrement",
83 "Pdrop decrement Value",
86 MakeDoubleChecker<double> ())
87 .AddTraceSource (
"Count",
90 "ns3::TracedValueCallback::Uint32")
91 .AddTraceSource (
"DropState",
94 "ns3::TracedValueCallback::Bool")
95 .AddTraceSource (
"DropNext",
96 "Time until next packet drop",
98 "ns3::TracedValueCallback::Uint32")
114 return (uint32_t)(((uint64_t)A * R) >> 32);
117 double min (
double x,
double y)
119 return (
x < y) ?
x : y;
122 double max (
double x,
double y)
124 return (
x > y) ?
x : y;
144 m_uv = CreateObject<UniformRandomVariable> ();
182 return ((int64_t)(a) - (int64_t)(b) > 0);
188 return ((int64_t)(a) - (int64_t)(b) >= 0);
220 uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32;
221 uint64_t val = (3ll << 32) - ((uint64_t)
m_count * invsqrt2);
224 val = (val * invsqrt) >> (32 - 2 + 1);
302 NS_LOG_ERROR (
"CobaltQueueDisc cannot have packet filters");
316 NS_LOG_ERROR (
"CobaltQueueDisc needs 1 internal queue");
438 bool next_due =
m_count && schedule >= 0;
477 next_due =
m_count && schedule >= 0;
492 else if (schedule > 0 && !drop)
bool CoDelTimeAfter(int64_t a, int64_t b)
Check if CoDel time a is successive to b.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Simulation virtual time values and global simulation resolution.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
double m_Pdrop
Drop Probability.
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 "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
AttributeValue implementation for Boolean.
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.
CobaltQueueDisc()
CobaltQueueDisc Constructor.
Hold variables of type string.
bool Mark(Ptr< QueueDiscItem > item, const char *reason)
Marks the given packet and, if successful, updates the counters associated with the given reason...
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
int64_t Time2CoDel(Time t)
Return the unsigned 32-bit integer representation of the input Time object.
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.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
static TypeId GetTypeId(void)
Get the type ID.
bool CoDelTimeAfterEq(int64_t a, int64_t b)
Check if CoDel time a is successive or equal to b.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
void CobaltQueueFull(int64_t now)
Called when the queue becomes full to alter the drop probabilities of Blue.
Time GetInterval(void)
Get the interval.
TracedValue< int64_t > m_dropNext
Time to drop next packet.
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packet.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
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)
#define DEFAULT_COBALT_LIMIT
int64_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
virtual ~CobaltQueueDisc()
Destructor.
void AddInternalQueue(Ptr< InternalQueue > queue)
Add an internal queue to the tail of the list of queues.
int64_t ControlLaw(int64_t t)
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
void CobaltQueueEmpty(int64_t now)
Called when the queue becomes empty to alter the drop probabilities of Blue.
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
static constexpr const char * FORCED_MARK
forced marks by Codel on ECN-enabled
double m_increment
increment value for marking probability
Cobalt packet queue disc.
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
virtual void DoDispose(void)
Dispose of the object.
static constexpr const char * TARGET_EXCEEDED_DROP
Sojourn time above target.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
Introspection did not find any typical Config paths.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< UniformRandomVariable > m_uv
Rng stream.
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.
TracedValue< bool > m_dropping
True if in dropping state.
virtual void DoDispose(void)
Dispose of the object.
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.
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
uint32_t m_recInvSqrtCache[REC_INV_SQRT_CACHE]
Cache to maintain some initial values of InvSqrt.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
double max(double x, double y)
virtual Ptr< const QueueDiscItem > DoPeek(void)
Return a copy of the next packet the queue disc will extract.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
Time m_target
5 ms target queue delay
virtual void InitializeParams(void)
Initialize the queue parameters.
static uint32_t ReciprocalDivide(uint32_t A, uint32_t R)
Performs a reciprocal divide, similar to the Linux kernel reciprocal_divide function.
bool CobaltShouldDrop(Ptr< QueueDiscItem > item, int64_t now)
Called to decide whether the current packet should be dropped based on decisions taken by Blue and Co...
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
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...
double min(double x, double y)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
double m_decrement
decrement value for marking probability
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
double GetPdrop()
Get the drop probability of Blue.
uint32_t m_lastUpdateTimeBlue
Blue's last update time for drop probability.
static int64_t CoDelGetTime(void)
Returns the current time translated in CoDel time representation.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
#define REC_INV_SQRT_CACHE
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Time GetTarget(void)
Get the target queue delay.
uint32_t m_recInvSqrt
Reciprocal inverse square root.
Use number of bytes for queue size.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.
void CacheInit(void)
There is a big difference in timing between the accurate values placed in the cache and the approxima...
Time m_interval
100 ms sliding minimum time window width