19#include "ns3/drop-tail-queue.h"
22#include "ns3/net-device-queue-interface.h"
23#include "ns3/object-factory.h"
24#include "ns3/uinteger.h"
39 TypeId(
"ns3::CobaltQueueDisc")
41 .SetGroupName(
"TrafficControl")
45 "The maximum number of packets/bytes accepted by this queue disc.",
49 .AddAttribute(
"Interval",
50 "The Cobalt algorithm interval",
54 .AddAttribute(
"Target",
55 "The Cobalt algorithm target queue delay",
59 .AddAttribute(
"UseEcn",
60 "True to use ECN (packets are marked instead of being dropped)",
64 .AddAttribute(
"Pdrop",
65 "Marking Probability",
69 .AddAttribute(
"Increment",
70 "Pdrop increment value",
74 .AddAttribute(
"Decrement",
75 "Pdrop decrement Value",
79 .AddAttribute(
"CeThreshold",
80 "The CoDel CE threshold for marking packets",
84 .AddAttribute(
"UseL4s",
85 "True to use L4S (only ECT1 packets are marked at CE threshold)",
89 .AddAttribute(
"BlueThreshold",
90 "The Threshold after which Blue is enabled",
94 .AddTraceSource(
"Count",
97 "ns3::TracedValueCallback::Uint32")
98 .AddTraceSource(
"DropState",
101 "ns3::TracedValueCallback::Bool")
102 .AddTraceSource(
"DropNext",
103 "Time until next packet drop",
105 "ns3::TracedValueCallback::Uint32");
121 return (
uint32_t)(((uint64_t)A * R) >> 32);
160 m_uv->SetStream(stream);
181 return ((int64_t)(a) - (int64_t)(b) > 0);
187 return ((int64_t)(a) - (int64_t)(b) >= 0);
219 uint32_t invsqrt2 = ((uint64_t)invsqrt * invsqrt) >> 32;
220 uint64_t val = (3LL << 32) - ((uint64_t)
m_count * invsqrt2);
223 val = (val * invsqrt) >> (32 - 2 + 1);
301 NS_LOG_ERROR(
"CobaltQueueDisc cannot have packet filters");
439 bool next_due =
m_count && schedule >= 0;
440 bool isMarked =
false;
449 (((tosByte & 0x3) == 1) || (tosByte & 0x3) == 3))
451 if ((tosByte & 0x3) == 1)
453 NS_LOG_DEBUG(
"ECT1 packet " <<
static_cast<uint16_t
>(tosByte & 0x3));
457 NS_LOG_DEBUG(
"CE packet " <<
static_cast<uint16_t
>(tosByte & 0x3));
507 next_due =
m_count && schedule >= 0;
533 double u =
m_uv->GetValue();
542 else if (schedule > 0 && !drop)
Cobalt packet queue disc.
Time m_ceThreshold
Threshold above which to CE mark.
uint32_t m_recInvSqrtCache[REC_INV_SQRT_CACHE]
Cache to maintain some initial values of InvSqrt.
Time m_target
target queue delay
static constexpr const char * CE_THRESHOLD_EXCEEDED_MARK
Sojourn time above CE threshold.
bool CheckConfig() override
Check whether the current configuration is correct.
void NewtonStep()
Calculate the reciprocal square root of m_count by using Newton's method http://en....
Time GetTarget() const
Get the target queue delay.
int64_t GetDropNext() const
Get the time for next packet drop while in the dropping state.
void InitializeParams() override
Initialize the queue parameters.
bool CoDelTimeAfterEq(int64_t a, int64_t b)
Check if CoDel time a is successive or equal to b.
void InvSqrt()
Updates the inverse square root.
double GetPdrop() const
Get the drop probability of Blue.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void DoDispose() override
Dispose of the object.
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
double m_increment
increment value for marking probability
void CobaltQueueFull(int64_t now)
Called when the queue becomes full to alter the drop probabilities of Blue.
Time m_interval
sliding minimum time window width
double m_decrement
decrement value for marking probability
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...
static TypeId GetTypeId()
Get the type ID.
Ptr< QueueDiscItem > DoDequeue() override
This function actually extracts a packet from the queue disc.
void CacheInit()
There is a big difference in timing between the accurate values placed in the cache and the approxima...
~CobaltQueueDisc() override
Destructor.
static constexpr const char * TARGET_EXCEEDED_DROP
Sojourn time above target.
int64_t Time2CoDel(Time t) const
Return the unsigned 32-bit integer representation of the input Time object.
bool CoDelTimeAfter(int64_t a, int64_t b)
Check if CoDel time a is successive to b.
Time GetInterval() const
Get the interval.
double m_pDrop
Drop Probability.
CobaltQueueDisc()
CobaltQueueDisc Constructor.
int64_t ControlLaw(int64_t t)
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
static constexpr const char * FORCED_MARK
forced marks by Codel on ECN-enabled
Time m_blueThreshold
Threshold to enable blue enhancement.
uint32_t m_recInvSqrt
Reciprocal inverse square root.
Ptr< UniformRandomVariable > m_uv
Rng stream.
uint32_t m_lastUpdateTimeBlue
Blue's last update time for drop probability.
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packet.
TracedValue< bool > m_dropping
True if in dropping state.
Ptr< const QueueDiscItem > DoPeek() override
Return a copy of the next packet the queue disc will extract.
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
bool DoEnqueue(Ptr< QueueDiscItem > item) override
This function actually enqueues a packet into the queue disc.
TracedValue< int64_t > m_dropNext
Time to drop next packet.
void CobaltQueueEmpty(int64_t now)
Called when the queue becomes empty to alter the drop probabilities of Blue.
bool m_useL4s
True if L4S is used (ECT1 packets are marked at CE threshold)
This class can be used to hold variables of floating point type such as 'double' or 'float'.
A FIFO packet queue that drops tail-end packets on overflow.
Smart pointer class similar to boost::intrusive_ptr.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
void AddInternalQueue(Ptr< InternalQueue > queue)
Add an internal queue to the tail of the list of queues.
uint32_t GetNPackets() const
Get the number of packets stored by the queue disc.
uint32_t GetNBytes() const
Get the amount of bytes stored by the queue disc.
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
QueueSize GetCurrentSize() const
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets,...
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.
std::size_t GetNQueueDiscClasses() const
Get the number of queue disc classes.
QueueSize GetMaxSize() const
Get the maximum size of the queue disc.
std::size_t GetNPacketFilters() const
Get the number of packet filters.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
std::size_t GetNInternalQueues() const
Get the number of internal queues.
void DoDispose() override
Dispose of the object.
bool Mark(Ptr< QueueDiscItem > item, const char *reason)
Marks the given packet and, if successful, updates the counters associated with the given reason.
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.
Class for representing queue sizes.
static Time Now()
Return the current simulation virtual time.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define DEFAULT_COBALT_LIMIT
#define REC_INV_SQRT_CACHE
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
@ BYTES
Use number of bytes for queue size.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeDoubleChecker()
static int64_t CoDelGetTime()
Returns the current time translated in CoDel time representation.
Ptr< const AttributeChecker > MakeQueueSizeChecker()
static uint32_t ReciprocalDivide(uint32_t A, uint32_t R)
Performs a reciprocal divide, similar to the Linux kernel reciprocal_divide function.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.