|
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"
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);
132 double min (
double x,
double y)
134 return (
x < y) ?
x : y;
137 double max (
double x,
double y)
139 return (
x > y) ?
x : y;
159 m_uv = CreateObject<UniformRandomVariable> ();
197 return ((int64_t)(a) - (int64_t)(b) > 0);
203 return ((int64_t)(a) - (int64_t)(b) >= 0);
235 uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32;
236 uint64_t val = (3ll << 32) - ((uint64_t)
m_count * invsqrt2);
239 val = (val * invsqrt) >> (32 - 2 + 1);
317 NS_LOG_ERROR (
"CobaltQueueDisc cannot have packet filters");
331 NS_LOG_ERROR (
"CobaltQueueDisc needs 1 internal queue");
453 bool next_due =
m_count && schedule >= 0;
454 bool isMarked =
false;
462 if (item->GetUint8Value (
QueueItem::IP_DSFIELD, tosByte) && (((tosByte & 0x3) == 1) || (tosByte & 0x3) == 3))
464 if ((tosByte & 0x3) == 1)
466 NS_LOG_DEBUG (
"ECT1 packet " <<
static_cast<uint16_t
> (tosByte & 0x3));
470 NS_LOG_DEBUG (
"CE packet " <<
static_cast<uint16_t
> (tosByte & 0x3));
518 next_due =
m_count && schedule >= 0;
549 else if (schedule > 0 && !drop)
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define DEFAULT_COBALT_LIMIT
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
double GetPdrop() const
Get the drop probability of Blue.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Time m_blueThreshold
Threshold to enable blue enhancement.
AttributeValue implementation for Boolean.
Ptr< UniformRandomVariable > m_uv
Rng stream.
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.
void CacheInit(void)
There is a big difference in timing between the accurate values placed in the cache and the approxima...
virtual void DoDispose(void)
Dispose of the object.
static constexpr const char * FORCED_MARK
forced marks by Codel on ECN-enabled
double m_decrement
decrement value for marking probability
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.
bool m_useL4s
True if L4S is used (ECT1 packets are marked at CE threshold)
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
virtual Ptr< const QueueDiscItem > DoPeek(void)
Return a copy of the next packet the queue disc will extract.
Time m_target
target queue delay
Time GetTarget(void) const
Get the target queue delay.
virtual void InitializeParams(void)
Initialize the queue parameters.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
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.
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
Time m_interval
sliding minimum time window width
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
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.
uint32_t m_lastUpdateTimeBlue
Blue's last update time for drop probability.
int64_t Time2CoDel(Time t) const
Return the unsigned 32-bit integer representation of the input Time object.
Smart pointer class similar to boost::intrusive_ptr.
virtual void DoDispose(void)
Dispose of the object.
double min(double x, double y)
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
static constexpr const char * CE_THRESHOLD_EXCEEDED_MARK
Sojourn time above CE threshold.
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_recInvSqrt
Reciprocal inverse square root.
double m_pDrop
Drop 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...
TracedValue< bool > m_dropping
True if in dropping state.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
int64_t GetDropNext(void) const
Get the time for next packet drop while in the dropping state.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void CobaltQueueEmpty(int64_t now)
Called when the queue becomes empty to alter the drop probabilities of Blue.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
bool CoDelTimeAfter(int64_t a, int64_t b)
Check if CoDel time a is successive to b.
void CobaltQueueFull(int64_t now)
Called when the queue becomes full to alter the drop probabilities of Blue.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
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.
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.
Cobalt packet queue disc.
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.
Ptr< const AttributeAccessor > MakeDoubleAccessor(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.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
virtual ~CobaltQueueDisc()
Destructor.
int64_t ControlLaw(int64_t t)
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
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.
static int64_t CoDelGetTime(void)
Returns the current time translated in CoDel time representation.
@ BYTES
Use number of bytes for queue size.
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 ",...
CobaltQueueDisc()
CobaltQueueDisc Constructor.
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
TracedValue< int64_t > m_dropNext
Time to drop next packet.
#define REC_INV_SQRT_CACHE
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packet.
uint32_t m_recInvSqrtCache[REC_INV_SQRT_CACHE]
Cache to maintain some initial values of InvSqrt.
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
double max(double x, double y)
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.
static TypeId GetTypeId(void)
Get the type ID.
Class for representing queue sizes.
bool CoDelTimeAfterEq(int64_t a, int64_t b)
Check if CoDel time a is successive or equal to b.
double m_increment
increment value for marking probability
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.
Time GetInterval(void) const
Get the interval.
static constexpr const char * TARGET_EXCEEDED_DROP
Sojourn time above target.
Time m_ceThreshold
Threshold above which to CE mark.
void NewtonStep(void)
Calculate the reciprocal square root of m_count by using Newton's method http://en....