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 .AddAttribute (
"CeThreshold",
88 "The CoDel CE threshold for marking packets",
92 .AddAttribute (
"UseL4s",
93 "True to use L4S (only ECT1 packets are marked at CE threshold)",
97 .AddAttribute (
"BlueThreshold",
98 "The Threshold after which Blue is enabled",
102 .AddTraceSource (
"Count",
105 "ns3::TracedValueCallback::Uint32")
106 .AddTraceSource (
"DropState",
109 "ns3::TracedValueCallback::Bool")
110 .AddTraceSource (
"DropNext",
111 "Time until next packet drop",
113 "ns3::TracedValueCallback::Uint32")
129 return (uint32_t)(((uint64_t)A * R) >> 32);
149 m_uv = CreateObject<UniformRandomVariable> ();
187 return ((int64_t)(a) - (int64_t)(b) > 0);
193 return ((int64_t)(a) - (int64_t)(b) >= 0);
225 uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32;
226 uint64_t val = (3ll << 32) - ((uint64_t)
m_count * invsqrt2);
229 val = (val * invsqrt) >> (32 - 2 + 1);
307 NS_LOG_ERROR (
"CobaltQueueDisc cannot have packet filters");
321 NS_LOG_ERROR (
"CobaltQueueDisc needs 1 internal queue");
443 bool next_due =
m_count && schedule >= 0;
444 bool isMarked =
false;
452 if (item->GetUint8Value (
QueueItem::IP_DSFIELD, tosByte) && (((tosByte & 0x3) == 1) || (tosByte & 0x3) == 3))
454 if ((tosByte & 0x3) == 1)
456 NS_LOG_DEBUG (
"ECT1 packet " <<
static_cast<uint16_t
> (tosByte & 0x3));
460 NS_LOG_DEBUG (
"CE packet " <<
static_cast<uint16_t
> (tosByte & 0x3));
508 next_due =
m_count && schedule >= 0;
539 else if (schedule > 0 && !drop)
AttributeValue implementation for Boolean.
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.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
bool CoDelTimeAfterEq(int64_t a, int64_t b)
Check if CoDel time a is successive or equal to b.
virtual Ptr< const QueueDiscItem > DoPeek(void)
Return a copy of the next packet the queue disc will extract.
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.
virtual void DoDispose(void)
Dispose of the object.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
int64_t GetDropNext(void) const
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.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
double m_increment
increment value for marking probability
void CacheInit(void)
There is a big difference in timing between the accurate values placed in the cache and the approxima...
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...
void InvSqrt(void)
Updates the inverse square root.
Time GetTarget(void) const
Get the target queue delay.
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.
double m_pDrop
Drop Probability.
virtual void InitializeParams(void)
Initialize the queue parameters.
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
virtual ~CobaltQueueDisc()
Destructor.
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.
Time GetInterval(void) const
Get the interval.
TracedValue< bool > m_dropping
True if in dropping state.
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
TracedValue< int64_t > m_dropNext
Time to drop next packet.
void NewtonStep(void)
Calculate the reciprocal square root of m_count by using Newton's method http://en....
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)
static TypeId GetTypeId(void)
Get the type ID.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Introspection did not find any typical Config paths.
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.
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets,...
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
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 GetNPacketFilters(void) const
Get the number of packet filters.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
virtual void DoDispose(void)
Dispose of the object.
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.
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.
AttributeValue implementation for QueueSize.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static Time Now(void)
Return the current simulation virtual time.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
double GetSeconds(void) 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).
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define DEFAULT_COBALT_LIMIT
#define REC_INV_SQRT_CACHE
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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 > 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.
static int64_t CoDelGetTime(void)
Returns the current time translated in CoDel time representation.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
static uint32_t ReciprocalDivide(uint32_t A, uint32_t R)
Performs a reciprocal divide, similar to the Linux kernel reciprocal_divide function.