61 #include "ns3/uinteger.h"
62 #include "ns3/double.h"
63 #include "ns3/simulator.h"
64 #include "ns3/abort.h"
65 #include "ns3/random-variable-stream.h"
78 .AddConstructor<RedQueue> ()
79 .AddAttribute (
"Mode",
80 "Determines unit for QueueLimit",
85 .AddAttribute (
"MeanPktSize",
86 "Average of packet size",
89 MakeUintegerChecker<uint32_t> ())
90 .AddAttribute (
"IdlePktSize",
91 "Average packet size used during idle times. Used when m_cautions = 3",
94 MakeUintegerChecker<uint32_t> ())
95 .AddAttribute (
"Wait",
96 "True for waiting between dropped packets",
99 MakeBooleanChecker ())
100 .AddAttribute (
"Gentle",
101 "True to increases dropping probability slowly when average queue exceeds maxthresh",
104 MakeBooleanChecker ())
105 .AddAttribute (
"MinTh",
106 "Minimum average length threshold in packets/bytes",
109 MakeDoubleChecker<double> ())
110 .AddAttribute (
"MaxTh",
111 "Maximum average length threshold in packets/bytes",
114 MakeDoubleChecker<double> ())
115 .AddAttribute (
"QueueLimit",
116 "Queue limit in bytes/packets",
119 MakeUintegerChecker<uint32_t> ())
121 "Queue weight related to the exponential weighted moving average (EWMA)",
124 MakeDoubleChecker <double> ())
125 .AddAttribute (
"LInterm",
126 "The maximum probability of dropping a packet",
129 MakeDoubleChecker <double> ())
130 .AddAttribute (
"Ns1Compat",
131 "NS-1 compatibility",
134 MakeBooleanChecker ())
135 .AddAttribute (
"LinkBandwidth",
136 "The RED link bandwidth",
139 MakeDataRateChecker ())
140 .AddAttribute (
"LinkDelay",
141 "The RED link delay",
154 m_hasRedStarted (false)
157 m_uv = CreateObject<UniformRandomVariable> ();
222 uint32_t nQueued = 0;
246 m = uint32_t (ptc * (now -
m_idleTime).GetSeconds ());
300 NS_LOG_DEBUG (
"\t Dropping due to Queue Full " << nQueued);
364 m_vA = 1.0 / th_diff;
392 else if (
m_qW == -1.0)
400 m_qW = 1.0 - std::exp (-1.0 / (10 * rtt *
m_ptc));
402 else if (
m_qW == -2.0)
412 <<
"; m_isGentle " <<
m_isGentle <<
"; th_diff " << th_diff
413 <<
"; lInterm " <<
m_lInterm <<
"; va " <<
m_vA <<
"; cur_max_p "
431 newAve += qW * nQueued;
454 double pkts =
m_ptc * 0.05;
455 double fraction = std::pow ((1 -
m_qW), pkts);
457 if ((
double) qSize < fraction *
m_qAvg)
474 double pkts =
m_ptc * 0.05;
475 double fraction = std::pow ((1 -
m_qW), pkts);
476 double ratio = qSize / (fraction *
m_qAvg);
502 double vB,
double vC,
double vD,
double maxP)
504 NS_LOG_FUNCTION (
this << qAvg << maxTh << isGentle << vA << vB << vC << vD << maxP);
507 if (isGentle && qAvg >= maxTh)
513 else if (!isGentle && qAvg >= maxTh)
543 uint32_t meanPktSize,
bool isWait, uint32_t size)
545 NS_LOG_FUNCTION (
this << p << count << countBytes << meanPktSize << isWait << size);
546 double count1 = (double) count;
550 count1 = (double) (countBytes / meanPktSize);
555 if (count1 * p < 1.0)
559 else if (count1 * p < 2.0)
561 p /= (2.0 - count1 * p);
570 if (count1 * p < 1.0)
572 p /= (1.0 - count1 * p);
582 p = (p * size) / meanPktSize;
Ptr< UniformRandomVariable > m_uv
keep track of time values and allow control of global simulation resolution
uint32_t DropEarly(Ptr< Packet > p, uint32_t qSize)
#define NS_LOG_FUNCTION(parameters)
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
void SetMode(RedQueue::QueueMode mode)
void SetQueueLimit(uint32_t lim)
virtual Ptr< Packet > DoDequeue(void)
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t GetSize(void) const
virtual bool DoEnqueue(Ptr< Packet > p)
Abstract base class for packet Queues.
Class for representing data rates.
uint32_t GetQueueSize(void)
double GetSeconds(void) const
int64_t AssignStreams(int64_t stream)
std::list< Ptr< Packet > > m_packets
RedQueue::QueueMode GetMode(void)
hold variables of type 'enum'
hold objects of type ns3::Time
virtual Ptr< const Packet > DoPeek(void) const
Hold an unsigned integer type.
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
#define NS_LOG_LOGIC(msg)
static TypeId GetTypeId(void)
double Estimator(uint32_t nQueued, uint32_t m, double qAvg, double qW)
void SetTh(double minTh, double maxTh)
double ModifyP(double p, uint32_t count, uint32_t countBytes, uint32_t meanPktSize, bool wait, uint32_t size)
void InitializeParams(void)
uint64_t GetBitRate() const
double CalculatePNew(double qAvg, double maxTh, bool gentle, double vA, double vB, double vC, double vD, double maxP)
QueueMode
Enumeration of the modes supported in the class.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
#define NS_ABORT_MSG(msg)
Abnormal program termination.
hold objects of type ns3::DataRate
#define NS_LOG_DEBUG(msg)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive.
Hold an floating point type.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void Drop(Ptr< Packet > packet)