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"
79 .AddConstructor<RedQueue> ()
80 .AddAttribute (
"Mode",
81 "Determines unit for QueueLimit",
86 .AddAttribute (
"MeanPktSize",
87 "Average of packet size",
90 MakeUintegerChecker<uint32_t> ())
91 .AddAttribute (
"IdlePktSize",
92 "Average packet size used during idle times. Used when m_cautions = 3",
95 MakeUintegerChecker<uint32_t> ())
96 .AddAttribute (
"Wait",
97 "True for waiting between dropped packets",
100 MakeBooleanChecker ())
101 .AddAttribute (
"Gentle",
102 "True to increases dropping probability slowly when average queue exceeds maxthresh",
105 MakeBooleanChecker ())
106 .AddAttribute (
"MinTh",
107 "Minimum average length threshold in packets/bytes",
110 MakeDoubleChecker<double> ())
111 .AddAttribute (
"MaxTh",
112 "Maximum average length threshold in packets/bytes",
115 MakeDoubleChecker<double> ())
116 .AddAttribute (
"QueueLimit",
117 "Queue limit in bytes/packets",
120 MakeUintegerChecker<uint32_t> ())
122 "Queue weight related to the exponential weighted moving average (EWMA)",
125 MakeDoubleChecker <double> ())
126 .AddAttribute (
"LInterm",
127 "The maximum probability of dropping a packet",
130 MakeDoubleChecker <double> ())
131 .AddAttribute (
"Ns1Compat",
132 "NS-1 compatibility",
135 MakeBooleanChecker ())
136 .AddAttribute (
"LinkBandwidth",
137 "The RED link bandwidth",
140 MakeDataRateChecker ())
141 .AddAttribute (
"LinkDelay",
142 "The RED link delay",
155 m_hasRedStarted (false)
158 m_uv = CreateObject<UniformRandomVariable> ();
223 uint32_t nQueued = 0;
247 m = uint32_t (ptc * (now -
m_idleTime).GetSeconds ());
301 NS_LOG_DEBUG (
"\t Dropping due to Queue Full " << nQueued);
365 m_vA = 1.0 / th_diff;
393 else if (
m_qW == -1.0)
401 m_qW = 1.0 - std::exp (-1.0 / (10 * rtt *
m_ptc));
403 else if (
m_qW == -2.0)
413 <<
"; m_isGentle " <<
m_isGentle <<
"; th_diff " << th_diff
414 <<
"; lInterm " <<
m_lInterm <<
"; va " <<
m_vA <<
"; cur_max_p "
432 newAve += qW * nQueued;
455 double pkts =
m_ptc * 0.05;
456 double fraction = std::pow ((1 -
m_qW), pkts);
458 if ((
double) qSize < fraction *
m_qAvg)
475 double pkts =
m_ptc * 0.05;
476 double fraction = std::pow ((1 -
m_qW), pkts);
477 double ratio = qSize / (fraction *
m_qAvg);
503 double vB,
double vC,
double vD,
double maxP)
505 NS_LOG_FUNCTION (
this << qAvg << maxTh << isGentle << vA << vB << vC << vD << maxP);
508 if (isGentle && qAvg >= maxTh)
514 else if (!isGentle && qAvg >= maxTh)
544 uint32_t meanPktSize,
bool isWait, uint32_t size)
546 NS_LOG_FUNCTION (
this << p << count << countBytes << meanPktSize << isWait << size);
547 double count1 = (double) count;
551 count1 = (double) (countBytes / meanPktSize);
556 if (count1 * p < 1.0)
560 else if (count1 * p < 2.0)
562 p /= (2.0 - count1 * p);
571 if (count1 * p < 1.0)
573 p /= (1.0 - count1 * p);
583 p = (p * size) / meanPktSize;
uint32_t qLimDrop
Forced drops, qavg > max threshold.
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)
virtual ~RedQueue()
Destructor.
void SetMode(RedQueue::QueueMode mode)
Set the operating mode of this queue.
void SetQueueLimit(uint32_t lim)
Set the limit of the queue.
virtual Ptr< Packet > DoDequeue(void)
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
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)
Get the current value of the queue in bytes or packets.
double GetSeconds(void) const
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
std::list< Ptr< Packet > > m_packets
RedQueue::QueueMode GetMode(void)
Get the encapsulation mode of this queue.
hold variables of type 'enum'
Stats GetStats()
Get the RED statistics after running.
hold objects of type ns3::Time
virtual Ptr< const Packet > DoPeek(void) const
Hold an unsigned integer type.
RedQueue()
RedQueue Constructor.
#define NS_LOG_LOGIC(msg)
static TypeId GetTypeId(void)
NS_LOG_COMPONENT_DEFINE("RedQueue")
double Estimator(uint32_t nQueued, uint32_t m, double qAvg, double qW)
void SetTh(double minTh, double maxTh)
Set the thresh limits of RED.
Use number of bytes for maximum queue size.
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
Get the underlying bitrate.
double CalculatePNew(double qAvg, double maxTh, bool gentle, double vA, double vB, double vC, double vD, double maxP)
static Time Now(void)
Return the "current simulation time".
QueueMode
Enumeration of the modes supported in the class.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Use number of packets for maximum queue size.
#define NS_ABORT_MSG(msg)
Abnormal program termination.
uint32_t forcedDrop
Early probability drops.
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.
Hold a floating point type.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void Drop(Ptr< Packet > packet)
Drop a packet.