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" 67 #include "ns3/net-device-queue-interface.h" 79 .SetGroupName(
"TrafficControl")
81 .AddAttribute (
"MeanPktSize",
82 "Average of packet size",
85 MakeUintegerChecker<uint32_t> ())
86 .AddAttribute (
"IdlePktSize",
87 "Average packet size used during idle times. Used when m_cautions = 3",
90 MakeUintegerChecker<uint32_t> ())
91 .AddAttribute (
"Wait",
92 "True for waiting between dropped packets",
96 .AddAttribute (
"Gentle",
97 "True to increases dropping probability slowly when average queue exceeds maxthresh",
101 .AddAttribute (
"ARED",
102 "True to enable ARED",
106 .AddAttribute (
"AdaptMaxP",
107 "True to adapt m_curMaxP",
111 .AddAttribute (
"FengAdaptive",
112 "True to enable Feng's Adaptive RED",
116 .AddAttribute (
"NLRED",
117 "True to enable Nonlinear RED",
121 .AddAttribute (
"MinTh",
122 "Minimum average length threshold in packets/bytes",
125 MakeDoubleChecker<double> ())
126 .AddAttribute (
"MaxTh",
127 "Maximum average length threshold in packets/bytes",
130 MakeDoubleChecker<double> ())
131 .AddAttribute (
"MaxSize",
132 "The maximum number of packets accepted by this queue disc",
138 "Queue weight related to the exponential weighted moving average (EWMA)",
141 MakeDoubleChecker <double> ())
142 .AddAttribute (
"LInterm",
143 "The maximum probability of dropping a packet",
146 MakeDoubleChecker <double> ())
147 .AddAttribute (
"TargetDelay",
148 "Target average queuing delay in ARED",
152 .AddAttribute (
"Interval",
153 "Time interval to update m_curMaxP",
157 .AddAttribute (
"Top",
158 "Upper bound for m_curMaxP in ARED",
161 MakeDoubleChecker <double> (0, 1))
162 .AddAttribute (
"Bottom",
163 "Lower bound for m_curMaxP in ARED",
166 MakeDoubleChecker <double> (0, 1))
167 .AddAttribute (
"Alpha",
168 "Increment parameter for m_curMaxP in ARED",
171 MakeDoubleChecker <double> (0, 1))
172 .AddAttribute (
"Beta",
173 "Decrement parameter for m_curMaxP in ARED",
176 MakeDoubleChecker <double> (0, 1))
177 .AddAttribute (
"FengAlpha",
178 "Decrement parameter for m_curMaxP in Feng's Adaptive RED",
181 MakeDoubleChecker <double> ())
182 .AddAttribute (
"FengBeta",
183 "Increment parameter for m_curMaxP in Feng's Adaptive RED",
186 MakeDoubleChecker <double> ())
187 .AddAttribute (
"LastSet",
188 "Store the last time m_curMaxP was updated",
192 .AddAttribute (
"Rtt",
193 "Round Trip Time to be considered while automatically setting m_bottom",
197 .AddAttribute (
"Ns1Compat",
198 "NS-1 compatibility",
202 .AddAttribute (
"LinkBandwidth",
203 "The RED link bandwidth",
207 .AddAttribute (
"LinkDelay",
208 "The RED link delay",
212 .AddAttribute (
"UseEcn",
213 "True to use ECN (packets are marked instead of being dropped)",
217 .AddAttribute (
"UseHardDrop",
218 "True to always drop packets above max threshold",
231 m_uv = CreateObject<UniformRandomVariable> ();
255 NS_LOG_WARN (
"Alpha value is above the recommended bound!");
274 NS_LOG_WARN (
"Beta value is below the recommended bound!");
293 NS_LOG_WARN (
"Alpha value does not follow the recommendations!");
312 NS_LOG_WARN (
"Beta value does not follow the recommendations!");
358 m = uint32_t (ptc * (now -
m_idleTime).GetSeconds ());
486 if (
m_minTh < targetqueue / 2.0 )
512 m_vA = 1.0 / th_diff;
540 else if (
m_qW == -1.0)
548 m_qW = 1.0 - std::exp (-1.0 / (10 * rtt *
m_ptc));
550 else if (
m_qW == -2.0)
571 <<
"; m_isGentle " <<
m_isGentle <<
"; th_diff " << th_diff
572 <<
"; lInterm " <<
m_lInterm <<
"; va " <<
m_vA <<
"; cur_max_p " 610 if (newAve < m_minTh + m_part && m_curMaxP >
m_bottom)
635 double newAve = qAvg * std::pow (1.0 - qW, m);
636 newAve += qW * nQueued;
668 double pkts =
m_ptc * 0.05;
669 double fraction = std::pow ((1 -
m_qW), pkts);
671 if ((
double) qSize < fraction *
m_qAvg)
688 double pkts =
m_ptc * 0.05;
689 double fraction = std::pow ((1 -
m_qW), pkts);
690 double ratio = qSize / (fraction *
m_qAvg);
764 double count1 = (double)
m_count;
773 if (count1 * p < 1.0)
777 else if (count1 * p < 2.0)
779 p /= (2.0 - count1 * p);
788 if (count1 * p < 1.0)
790 p /= (1.0 - count1 * p);
868 NS_LOG_ERROR (
"RedQueueDisc cannot have packet filters");
887 NS_LOG_ERROR (
"m_isAdaptMaxP and m_isFengAdaptive cannot be simultaneously true");
bool m_isGentle
True to increase dropping prob.
Simulation virtual time values and global simulation resolution.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
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.
double m_beta
Decrement parameter for m_curMaxP in ARED.
AttributeValue implementation for Boolean.
uint32_t m_count
Number of packets since last random number generation.
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.
bool m_isARED
True to enable Adaptive RED.
void SetTh(double minTh, double maxTh)
Set the thresh limits of RED.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
double GetFengAdaptiveA(void)
Get the alpha value to adapt m_curMaxP in Feng's Adaptive RED.
double m_qAvg
Average queue length.
bool Mark(Ptr< QueueDiscItem > item, const char *reason)
Marks the given packet and, if successful, updates the counters associated with the given reason...
Time m_linkDelay
Link delay.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void SetAredBeta(double beta)
Set the beta value to adapt m_curMaxP.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
uint32_t m_idle
0/1 idle status
FengStatus m_fengStatus
For use in Feng's Adaptive RED.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
double m_vD
2.0 * m_curMaxP - 1.0 - used in "gentle" mode
void SetFengAdaptiveB(double b)
Set the beta value to adapt m_curMaxP in Feng's Adaptive RED.
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.
double m_vC
(1.0 - m_curMaxP) / m_maxTh - used in "gentle" mode
bool m_useHardDrop
True if packets are always dropped above max threshold.
double m_qW
Queue weight given to cur queue size sample.
static constexpr const char * FORCED_MARK
Forced marks, m_qAvg > m_maxTh.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
double m_b
Increment parameter for m_curMaxP in Feng's Adaptive RED.
static constexpr const char * FORCED_DROP
Forced drops, m_qAvg > m_maxTh.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
double GetAredAlpha(void)
Get the alpha value to adapt m_curMaxP.
Time m_rtt
Rtt to be considered while automatically setting m_bottom in ARED.
uint64_t GetBitRate() const
Get the underlying bitrate.
static constexpr const char * UNFORCED_DROP
Early probability drops.
double m_alpha
Increment parameter for m_curMaxP in ARED.
Time m_lastSet
Last time m_curMaxP was updated.
bool m_isAdaptMaxP
True to adapt m_curMaxP.
Ptr< const AttributeChecker > MakeDataRateChecker(void)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
static TypeId GetTypeId(void)
Get the type ID.
Class for representing data rates.
double m_curMaxP
Current max_p.
void AddInternalQueue(Ptr< InternalQueue > queue)
Add an internal queue to the tail of the list of queues.
Time m_idleTime
Start of current idle period.
Ptr< T > CreateObjectWithAttributes(std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
Allocate an Object on the heap and initialize with a set of attributes.
AttributeValue implementation for Time.
double GetFengAdaptiveB(void)
Get the beta value to adapt m_curMaxP in Feng's Adaptive RED.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
Hold an unsigned integer type.
virtual void InitializeParams(void)
Initialize the queue parameters.
uint32_t m_cautious
0 for default RED 1 experimental (see red-queue-disc.cc) 2 experimental (see red-queue-disc.cc) 3 use Idle packet size in the ptc
Ptr< UniformRandomVariable > m_uv
rng stream
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
double m_vB
-m_minTh / (m_maxTh - m_minTh)
virtual void DoDispose(void)
Dispose of the object.
bool m_isNonlinear
True to enable Nonlinear RED.
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
double m_minTh
Minimum threshold for m_qAvg (bytes or packets)
virtual Ptr< const QueueDiscItem > DoPeek(void)
Return a copy of the next packet the queue disc will extract.
uint32_t m_idlePktSize
Avg pkt size used during idle times.
Introspection did not find any typical Config paths.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
An "unforced" (random) drop.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double m_vA
1.0 / (m_maxTh - m_minTh)
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
uint32_t m_countBytes
Number of bytes since last drop.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
double m_lInterm
The max probability of dropping a packet.
static constexpr const char * UNFORCED_MARK
Early probability marks.
uint32_t DropEarly(Ptr< QueueDiscItem > item, uint32_t qSize)
Check if a packet needs to be dropped due to probability mark.
RedQueueDisc()
RedQueueDisc Constructor.
double m_bottom
Lower bound for m_curMaxP in ARED.
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.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
void UpdateMaxP(double newAve)
Update m_curMaxP.
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
QueueSizeUnit GetUnit() const
Get the underlying unit.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
uint32_t m_old
0 when average queue first exceeds threshold
When m_maxTh < m_qAvg < m_minTh.
Used by queue discs with single internal queue.
void SetFengAdaptiveA(double a)
Set the alpha value to adapt m_curMaxP in Feng's Adaptive RED.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
AttributeValue implementation for DataRate.
DataRate m_linkBandwidth
Link bandwidth.
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time m_interval
Time interval to update m_curMaxP.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
bool m_isWait
True for waiting between dropped packets.
Time m_targetDelay
Target average queuing delay in ARED.
double GetAredBeta(void)
Get the beta value to adapt m_curMaxP.
double m_ptc
packet time constant in packets/second
virtual ~RedQueueDisc()
Destructor.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
double m_top
Upper bound for m_curMaxP in ARED.
double Estimator(uint32_t nQueued, uint32_t m, double qAvg, double qW)
Compute the average queue size.
uint32_t m_meanPktSize
Avg pkt size.
void UpdateMaxPFeng(double newAve)
Update m_curMaxP based on Feng's Adaptive RED.
bool m_isFengAdaptive
True to enable Feng's Adaptive RED.
double CalculatePNew(void)
Returns a probability using these function parameters for the DropEarly function. ...
void SetAredAlpha(double alpha)
Set the alpha value to adapt m_curMaxP.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
virtual void DoDispose(void)
Dispose of the object.
double ModifyP(double p, uint32_t size)
Returns a probability using these function parameters for the DropEarly function. ...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Use number of bytes for queue size.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
double m_maxTh
Maximum threshold for m_qAvg (bytes or packets), should be >= 2 * m_minTh.
double m_a
Decrement parameter for m_curMaxP in Feng's Adaptive RED.
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.
bool m_isNs1Compat
Ns-1 compatibility.