|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
61 #include "ns3/uinteger.h"
62 #include "ns3/double.h"
63 #include "ns3/simulator.h"
64 #include "ns3/abort.h"
66 #include "ns3/drop-tail-queue.h"
78 .SetGroupName(
"TrafficControl")
80 .AddAttribute (
"MeanPktSize",
81 "Average of packet size",
84 MakeUintegerChecker<uint32_t> ())
85 .AddAttribute (
"IdlePktSize",
86 "Average packet size used during idle times. Used when m_cautions = 3",
89 MakeUintegerChecker<uint32_t> ())
90 .AddAttribute (
"Wait",
91 "True for waiting between dropped packets",
95 .AddAttribute (
"Gentle",
96 "True to increases dropping probability slowly when average queue exceeds maxthresh",
100 .AddAttribute (
"ARED",
101 "True to enable ARED",
105 .AddAttribute (
"AdaptMaxP",
106 "True to adapt m_curMaxP",
110 .AddAttribute (
"FengAdaptive",
111 "True to enable Feng's Adaptive RED",
115 .AddAttribute (
"NLRED",
116 "True to enable Nonlinear RED",
120 .AddAttribute (
"MinTh",
121 "Minimum average length threshold in packets/bytes",
124 MakeDoubleChecker<double> ())
125 .AddAttribute (
"MaxTh",
126 "Maximum average length threshold in packets/bytes",
129 MakeDoubleChecker<double> ())
130 .AddAttribute (
"MaxSize",
131 "The maximum number of packets accepted by this queue disc",
137 "Queue weight related to the exponential weighted moving average (EWMA)",
140 MakeDoubleChecker <double> ())
141 .AddAttribute (
"LInterm",
142 "The maximum probability of dropping a packet",
145 MakeDoubleChecker <double> ())
146 .AddAttribute (
"TargetDelay",
147 "Target average queuing delay in ARED",
151 .AddAttribute (
"Interval",
152 "Time interval to update m_curMaxP",
156 .AddAttribute (
"Top",
157 "Upper bound for m_curMaxP in ARED",
160 MakeDoubleChecker <double> (0, 1))
161 .AddAttribute (
"Bottom",
162 "Lower bound for m_curMaxP in ARED",
165 MakeDoubleChecker <double> (0, 1))
166 .AddAttribute (
"Alpha",
167 "Increment parameter for m_curMaxP in ARED",
170 MakeDoubleChecker <double> (0, 1))
171 .AddAttribute (
"Beta",
172 "Decrement parameter for m_curMaxP in ARED",
175 MakeDoubleChecker <double> (0, 1))
176 .AddAttribute (
"FengAlpha",
177 "Decrement parameter for m_curMaxP in Feng's Adaptive RED",
180 MakeDoubleChecker <double> ())
181 .AddAttribute (
"FengBeta",
182 "Increment parameter for m_curMaxP in Feng's Adaptive RED",
185 MakeDoubleChecker <double> ())
186 .AddAttribute (
"LastSet",
187 "Store the last time m_curMaxP was updated",
191 .AddAttribute (
"Rtt",
192 "Round Trip Time to be considered while automatically setting m_bottom",
196 .AddAttribute (
"Ns1Compat",
197 "NS-1 compatibility",
201 .AddAttribute (
"LinkBandwidth",
202 "The RED link bandwidth",
206 .AddAttribute (
"LinkDelay",
207 "The RED link delay",
211 .AddAttribute (
"UseEcn",
212 "True to use ECN (packets are marked instead of being dropped)",
216 .AddAttribute (
"UseHardDrop",
217 "True to always drop packets above max threshold",
230 m_uv = CreateObject<UniformRandomVariable> ();
254 NS_LOG_WARN (
"Alpha value is above the recommended bound!");
273 NS_LOG_WARN (
"Beta value is below the recommended bound!");
292 NS_LOG_WARN (
"Alpha value does not follow the recommendations!");
311 NS_LOG_WARN (
"Beta value does not follow the recommendations!");
357 m = uint32_t (ptc * (now -
m_idleTime).GetSeconds ());
485 if (
m_minTh < targetqueue / 2.0 )
511 m_vA = 1.0 / th_diff;
539 else if (
m_qW == -1.0)
547 m_qW = 1.0 - std::exp (-1.0 / (10 * rtt *
m_ptc));
549 else if (
m_qW == -2.0)
570 <<
"; m_isGentle " <<
m_isGentle <<
"; th_diff " << th_diff
571 <<
"; lInterm " <<
m_lInterm <<
"; va " <<
m_vA <<
"; cur_max_p "
609 if (newAve < m_minTh + m_part && m_curMaxP >
m_bottom)
634 double newAve = qAvg * std::pow (1.0 - qW, m);
635 newAve += qW * nQueued;
667 double pkts =
m_ptc * 0.05;
668 double fraction = std::pow ((1 -
m_qW), pkts);
670 if ((
double) qSize < fraction *
m_qAvg)
687 double pkts =
m_ptc * 0.05;
688 double fraction = std::pow ((1 -
m_qW), pkts);
689 double ratio = qSize / (fraction *
m_qAvg);
763 double count1 = (double)
m_count;
772 if (count1 * p < 1.0)
776 else if (count1 * p < 2.0)
778 p /= (2.0 - count1 * p);
787 if (count1 * p < 1.0)
789 p /= (1.0 - count1 * p);
867 NS_LOG_ERROR (
"RedQueueDisc cannot have packet filters");
886 NS_LOG_ERROR (
"m_isAdaptMaxP and m_isFengAdaptive cannot be simultaneously true");
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time m_interval
Time interval to update m_curMaxP.
AttributeValue implementation for DataRate.
RedQueueDisc()
RedQueueDisc Constructor.
bool m_isNonlinear
True to enable Nonlinear RED.
uint32_t m_old
0 when average queue first exceeds threshold
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
AttributeValue implementation for Boolean.
double GetFengAdaptiveA(void)
Get the alpha value to adapt m_curMaxP in Feng's Adaptive RED.
double m_alpha
Increment parameter for m_curMaxP in ARED.
void UpdateMaxP(double newAve)
Update m_curMaxP.
bool m_isGentle
True to increase dropping prob.
double m_vC
(1.0 - m_curMaxP) / m_maxTh - used in "gentle" mode
double GetFengAdaptiveB(void)
Get the beta value to adapt m_curMaxP in Feng's Adaptive RED.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
@ DTYPE_UNFORCED
An "unforced" (random) drop.
@ DTYPE_FORCED
A "forced" drop.
double m_vB
-m_minTh / (m_maxTh - m_minTh)
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 SetAredAlpha(double alpha)
Set the alpha value to adapt m_curMaxP.
void SetFengAdaptiveB(double b)
Set the beta value to adapt m_curMaxP in Feng's Adaptive RED.
uint32_t m_idlePktSize
Avg pkt size used during idle times.
@ Below
When m_qAvg < m_minTh.
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
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.
virtual void DoDispose(void)
Dispose of the object.
static constexpr const char * UNFORCED_MARK
Early probability marks.
double m_beta
Decrement parameter for m_curMaxP in ARED.
double m_bottom
Lower bound for m_curMaxP in ARED.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
uint32_t m_cautious
0 for default RED 1 experimental (see red-queue-disc.cc) 2 experimental (see red-queue-disc....
uint32_t m_count
Number of packets since last random number generation.
void SetTh(double minTh, double maxTh)
Set the thresh limits of RED.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
double m_top
Upper bound for m_curMaxP in ARED.
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
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.
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
@ Above
When m_qAvg > m_maxTh.
double GetAredBeta(void)
Get the beta value to adapt m_curMaxP.
Smart pointer class similar to boost::intrusive_ptr.
double GetAredAlpha(void)
Get the alpha value to adapt m_curMaxP.
Class for representing data rates.
virtual void DoDispose(void)
Dispose of the object.
bool m_isWait
True for waiting between dropped packets.
uint32_t m_meanPktSize
Avg pkt size.
double CalculatePNew(void)
Returns a probability using these function parameters for the DropEarly function.
double Estimator(uint32_t nQueued, uint32_t m, double qAvg, double qW)
Compute the average queue size.
double m_vA
1.0 / (m_maxTh - m_minTh)
double m_maxTh
Maximum threshold for m_qAvg (bytes or packets), should be >= 2 * m_minTh.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< UniformRandomVariable > m_uv
rng stream
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
DataRate m_linkBandwidth
Link bandwidth.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
double ModifyP(double p, uint32_t size)
Returns a probability using these function parameters for the DropEarly function.
@ SINGLE_INTERNAL_QUEUE
Used by queue discs with single internal queue.
Time m_targetDelay
Target average queuing delay in ARED.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
double m_a
Decrement parameter for m_curMaxP in Feng's Adaptive RED.
Simulation virtual time values and global simulation resolution.
QueueSizeUnit GetUnit() const
Get the underlying unit.
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.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
bool m_isARED
True to enable Adaptive RED.
FengStatus m_fengStatus
For use in Feng's Adaptive RED.
double m_ptc
packet time constant in packets/second
void SetFengAdaptiveA(double a)
Set the alpha value to adapt m_curMaxP in Feng's Adaptive RED.
Introspection did not find any typical Config paths.
uint64_t GetBitRate() const
Get the underlying bitrate.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
virtual ~RedQueueDisc()
Destructor.
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.
@ Between
When m_maxTh < m_qAvg < m_minTh.
static constexpr const char * UNFORCED_DROP
Early probability drops.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
uint32_t m_countBytes
Number of bytes since last drop.
Time m_rtt
Rtt to be considered while automatically setting m_bottom in ARED.
double m_curMaxP
Current max_p.
Time m_idleTime
Start of current idle period.
double m_b
Increment parameter for m_curMaxP in Feng's Adaptive RED.
static constexpr const char * FORCED_MARK
Forced marks, m_qAvg > m_maxTh.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
double m_minTh
Minimum threshold for m_qAvg (bytes or packets)
Time Seconds(double value)
Construct a Time in the indicated unit.
@ 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 ",...
double m_vD
2.0 * m_curMaxP - 1.0 - used in "gentle" mode
static TypeId GetTypeId(void)
Get the type ID.
static constexpr const char * FORCED_DROP
Forced drops, m_qAvg > m_maxTh.
Time m_lastSet
Last time m_curMaxP was updated.
virtual void InitializeParams(void)
Initialize the queue parameters.
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
double m_qAvg
Average queue length.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
bool m_isNs1Compat
Ns-1 compatibility.
Hold an unsigned integer type.
bool m_isAdaptMaxP
True to adapt m_curMaxP.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
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.
uint32_t m_idle
0/1 idle status
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
uint32_t DropEarly(Ptr< QueueDiscItem > item, uint32_t qSize)
Check if a packet needs to be dropped due to probability mark.
void SetAredBeta(double beta)
Set the beta value to adapt m_curMaxP.
Class for representing queue sizes.
double m_qW
Queue weight given to cur queue size sample.
bool m_useHardDrop
True if packets are always dropped above max threshold.
Time m_linkDelay
Link delay.
Ptr< const AttributeChecker > MakeDataRateChecker(void)
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
virtual Ptr< const QueueDiscItem > DoPeek(void)
Return a copy of the next packet the queue disc will extract.
void UpdateMaxPFeng(double newAve)
Update m_curMaxP based on Feng's Adaptive RED.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
double m_lInterm
The max probability of dropping a packet.
bool m_isFengAdaptive
True to enable Feng's Adaptive RED.