A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
red-queue.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright © 2011 Marcos Talau
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Marcos Talau (talau@users.sourceforge.net)
19  *
20  * Thanks to: Duy Nguyen<duy@soe.ucsc.edu> by RED efforts in NS3
21  *
22  *
23  * This file incorporates work covered by the following copyright and
24  * permission notice:
25  *
26  * Copyright (c) 1990-1997 Regents of the University of California.
27  * All rights reserved.
28  *
29  * Redistribution and use in source and binary forms, with or without
30  * modification, are permitted provided that the following conditions
31  * are met:
32  * 1. Redistributions of source code must retain the above copyright
33  * notice, this list of conditions and the following disclaimer.
34  * 2. Redistributions in binary form must reproduce the above copyright
35  * notice, this list of conditions and the following disclaimer in the
36  * documentation and/or other materials provided with the distribution.
37  * 3. Neither the name of the University nor of the Laboratory may be used
38  * to endorse or promote products derived from this software without
39  * specific prior written permission.
40  *
41  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
42  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
45  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  */
53 
54 /*
55  * PORT NOTE: This code was ported from ns-2 (queue/red.cc). Almost all
56  * comments have also been ported from NS-2
57  */
58 
59 #include "ns3/log.h"
60 #include "ns3/enum.h"
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"
66 #include "red-queue.h"
67 
68 NS_LOG_COMPONENT_DEFINE ("RedQueue");
69 
70 namespace ns3 {
71 
73  ;
74 
76 {
77  static TypeId tid = TypeId ("ns3::RedQueue")
78  .SetParent<Queue> ()
79  .AddConstructor<RedQueue> ()
80  .AddAttribute ("Mode",
81  "Determines unit for QueueLimit",
84  MakeEnumChecker (QUEUE_MODE_BYTES, "QUEUE_MODE_BYTES",
85  QUEUE_MODE_PACKETS, "QUEUE_MODE_PACKETS"))
86  .AddAttribute ("MeanPktSize",
87  "Average of packet size",
88  UintegerValue (500),
89  MakeUintegerAccessor (&RedQueue::m_meanPktSize),
90  MakeUintegerChecker<uint32_t> ())
91  .AddAttribute ("IdlePktSize",
92  "Average packet size used during idle times. Used when m_cautions = 3",
93  UintegerValue (0),
94  MakeUintegerAccessor (&RedQueue::m_idlePktSize),
95  MakeUintegerChecker<uint32_t> ())
96  .AddAttribute ("Wait",
97  "True for waiting between dropped packets",
98  BooleanValue (true),
99  MakeBooleanAccessor (&RedQueue::m_isWait),
100  MakeBooleanChecker ())
101  .AddAttribute ("Gentle",
102  "True to increases dropping probability slowly when average queue exceeds maxthresh",
103  BooleanValue (true),
104  MakeBooleanAccessor (&RedQueue::m_isGentle),
105  MakeBooleanChecker ())
106  .AddAttribute ("MinTh",
107  "Minimum average length threshold in packets/bytes",
108  DoubleValue (5),
109  MakeDoubleAccessor (&RedQueue::m_minTh),
110  MakeDoubleChecker<double> ())
111  .AddAttribute ("MaxTh",
112  "Maximum average length threshold in packets/bytes",
113  DoubleValue (15),
114  MakeDoubleAccessor (&RedQueue::m_maxTh),
115  MakeDoubleChecker<double> ())
116  .AddAttribute ("QueueLimit",
117  "Queue limit in bytes/packets",
118  UintegerValue (25),
119  MakeUintegerAccessor (&RedQueue::m_queueLimit),
120  MakeUintegerChecker<uint32_t> ())
121  .AddAttribute ("QW",
122  "Queue weight related to the exponential weighted moving average (EWMA)",
123  DoubleValue (0.002),
124  MakeDoubleAccessor (&RedQueue::m_qW),
125  MakeDoubleChecker <double> ())
126  .AddAttribute ("LInterm",
127  "The maximum probability of dropping a packet",
128  DoubleValue (50),
129  MakeDoubleAccessor (&RedQueue::m_lInterm),
130  MakeDoubleChecker <double> ())
131  .AddAttribute ("Ns1Compat",
132  "NS-1 compatibility",
133  BooleanValue (false),
134  MakeBooleanAccessor (&RedQueue::m_isNs1Compat),
135  MakeBooleanChecker ())
136  .AddAttribute ("LinkBandwidth",
137  "The RED link bandwidth",
138  DataRateValue (DataRate ("1.5Mbps")),
139  MakeDataRateAccessor (&RedQueue::m_linkBandwidth),
140  MakeDataRateChecker ())
141  .AddAttribute ("LinkDelay",
142  "The RED link delay",
143  TimeValue (MilliSeconds (20)),
144  MakeTimeAccessor (&RedQueue::m_linkDelay),
145  MakeTimeChecker ())
146  ;
147 
148  return tid;
149 }
150 
152  Queue (),
153  m_packets (),
154  m_bytesInQueue (0),
155  m_hasRedStarted (false)
156 {
157  NS_LOG_FUNCTION (this);
158  m_uv = CreateObject<UniformRandomVariable> ();
159 }
160 
162 {
163  NS_LOG_FUNCTION (this);
164 }
165 
166 void
168 {
169  NS_LOG_FUNCTION (this << mode);
170  m_mode = mode;
171 }
172 
175 {
176  NS_LOG_FUNCTION (this);
177  return m_mode;
178 }
179 
180 void
182 {
183  NS_LOG_FUNCTION (this <<lim);
184  m_queueLimit = lim;
185 }
186 
187 void
188 RedQueue::SetTh (double minTh, double maxTh)
189 {
190  NS_LOG_FUNCTION (this << minTh << maxTh);
191  NS_ASSERT (minTh <= maxTh);
192  m_minTh = minTh;
193  m_maxTh = maxTh;
194 }
195 
198 {
199  NS_LOG_FUNCTION (this);
200  return m_stats;
201 }
202 
203 int64_t
204 RedQueue::AssignStreams (int64_t stream)
205 {
206  NS_LOG_FUNCTION (this << stream);
207  m_uv->SetStream (stream);
208  return 1;
209 }
210 
211 bool
213 {
214  NS_LOG_FUNCTION (this << p);
215 
216  if (!m_hasRedStarted )
217  {
218  NS_LOG_INFO ("Initializing RED params.");
219  InitializeParams ();
220  m_hasRedStarted = true;
221  }
222 
223  uint32_t nQueued = 0;
224 
225  if (GetMode () == QUEUE_MODE_BYTES)
226  {
227  NS_LOG_DEBUG ("Enqueue in bytes mode");
228  nQueued = m_bytesInQueue;
229  }
230  else if (GetMode () == QUEUE_MODE_PACKETS)
231  {
232  NS_LOG_DEBUG ("Enqueue in packets mode");
233  nQueued = m_packets.size ();
234  }
235 
236  // simulate number of packets arrival during idle period
237  uint32_t m = 0;
238 
239  if (m_idle == 1)
240  {
241  NS_LOG_DEBUG ("RED Queue is idle.");
242  Time now = Simulator::Now ();
243 
244  if (m_cautious == 3)
245  {
246  double ptc = m_ptc * m_meanPktSize / m_idlePktSize;
247  m = uint32_t (ptc * (now - m_idleTime).GetSeconds ());
248  }
249  else
250  {
251  m = uint32_t (m_ptc * (now - m_idleTime).GetSeconds ());
252  }
253 
254  m_idle = 0;
255  }
256 
257  m_qAvg = Estimator (nQueued, m + 1, m_qAvg, m_qW);
258 
259  NS_LOG_DEBUG ("\t bytesInQueue " << m_bytesInQueue << "\tQavg " << m_qAvg);
260  NS_LOG_DEBUG ("\t packetsInQueue " << m_packets.size () << "\tQavg " << m_qAvg);
261 
262  m_count++;
263  m_countBytes += p->GetSize ();
264 
265  uint32_t dropType = DTYPE_NONE;
266  if (m_qAvg >= m_minTh && nQueued > 1)
267  {
268  if ((!m_isGentle && m_qAvg >= m_maxTh) ||
269  (m_isGentle && m_qAvg >= 2 * m_maxTh))
270  {
271  NS_LOG_DEBUG ("adding DROP FORCED MARK");
272  dropType = DTYPE_FORCED;
273  }
274  else if (m_old == 0)
275  {
276  /*
277  * The average queue size has just crossed the
278  * threshold from below to above "minthresh", or
279  * from above "minthresh" with an empty queue to
280  * above "minthresh" with a nonempty queue.
281  */
282  m_count = 1;
283  m_countBytes = p->GetSize ();
284  m_old = 1;
285  }
286  else if (DropEarly (p, nQueued))
287  {
288  NS_LOG_LOGIC ("DropEarly returns 1");
289  dropType = DTYPE_UNFORCED;
290  }
291  }
292  else
293  {
294  // No packets are being dropped
295  m_vProb = 0.0;
296  m_old = 0;
297  }
298 
299  if (nQueued >= m_queueLimit)
300  {
301  NS_LOG_DEBUG ("\t Dropping due to Queue Full " << nQueued);
302  dropType = DTYPE_FORCED;
303  m_stats.qLimDrop++;
304  }
305 
306  if (dropType == DTYPE_UNFORCED)
307  {
308  NS_LOG_DEBUG ("\t Dropping due to Prob Mark " << m_qAvg);
310  Drop (p);
311  return false;
312  }
313  else if (dropType == DTYPE_FORCED)
314  {
315  NS_LOG_DEBUG ("\t Dropping due to Hard Mark " << m_qAvg);
317  Drop (p);
318  if (m_isNs1Compat)
319  {
320  m_count = 0;
321  m_countBytes = 0;
322  }
323  return false;
324  }
325 
326  m_bytesInQueue += p->GetSize ();
327  m_packets.push_back (p);
328 
329  NS_LOG_LOGIC ("Number packets " << m_packets.size ());
330  NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
331 
332  return true;
333 }
334 
335 /*
336  * Note: if the link bandwidth changes in the course of the
337  * simulation, the bandwidth-dependent RED parameters do not change.
338  * This should be fixed, but it would require some extra parameters,
339  * and didn't seem worth the trouble...
340  */
341 void
343 {
344  NS_LOG_FUNCTION (this);
345 
347  m_stats.forcedDrop = 0;
348  m_stats.unforcedDrop = 0;
349  m_stats.qLimDrop = 0;
350 
351  m_cautious = 0;
353 
354  m_qAvg = 0.0;
355  m_count = 0;
356  m_countBytes = 0;
357  m_old = 0;
358  m_idle = 1;
359 
360  double th_diff = (m_maxTh - m_minTh);
361  if (th_diff == 0)
362  {
363  th_diff = 1.0;
364  }
365  m_vA = 1.0 / th_diff;
366  m_curMaxP = 1.0 / m_lInterm;
367  m_vB = -m_minTh / th_diff;
368 
369  if (m_isGentle)
370  {
371  m_vC = (1.0 - m_curMaxP) / m_maxTh;
372  m_vD = 2.0 * m_curMaxP - 1.0;
373  }
374  m_idleTime = NanoSeconds (0);
375 
376 /*
377  * If m_qW=0, set it to a reasonable value of 1-exp(-1/C)
378  * This corresponds to choosing m_qW to be of that value for
379  * which the packet time constant -1/ln(1-m)qW) per default RTT
380  * of 100ms is an order of magnitude more than the link capacity, C.
381  *
382  * If m_qW=-1, then the queue weight is set to be a function of
383  * the bandwidth and the link propagation delay. In particular,
384  * the default RTT is assumed to be three times the link delay and
385  * transmission delay, if this gives a default RTT greater than 100 ms.
386  *
387  * If m_qW=-2, set it to a reasonable value of 1-exp(-10/C).
388  */
389  if (m_qW == 0.0)
390  {
391  m_qW = 1.0 - std::exp (-1.0 / m_ptc);
392  }
393  else if (m_qW == -1.0)
394  {
395  double rtt = 3.0 * (m_linkDelay.GetSeconds () + 1.0 / m_ptc);
396 
397  if (rtt < 0.1)
398  {
399  rtt = 0.1;
400  }
401  m_qW = 1.0 - std::exp (-1.0 / (10 * rtt * m_ptc));
402  }
403  else if (m_qW == -2.0)
404  {
405  m_qW = 1.0 - std::exp (-10.0 / m_ptc);
406  }
407 
409 
410  NS_LOG_DEBUG ("\tm_delay " << m_linkDelay.GetSeconds () << "; m_isWait "
411  << m_isWait << "; m_qW " << m_qW << "; m_ptc " << m_ptc
412  << "; m_minTh " << m_minTh << "; m_maxTh " << m_maxTh
413  << "; m_isGentle " << m_isGentle << "; th_diff " << th_diff
414  << "; lInterm " << m_lInterm << "; va " << m_vA << "; cur_max_p "
415  << m_curMaxP << "; v_b " << m_vB << "; m_vC "
416  << m_vC << "; m_vD " << m_vD);
417 }
418 
419 // Compute the average queue size
420 double
421 RedQueue::Estimator (uint32_t nQueued, uint32_t m, double qAvg, double qW)
422 {
423  NS_LOG_FUNCTION (this << nQueued << m << qAvg << qW);
424  double newAve;
425 
426  newAve = qAvg;
427  while (--m >= 1)
428  {
429  newAve *= 1.0 - qW;
430  }
431  newAve *= 1.0 - qW;
432  newAve += qW * nQueued;
433 
434  // implement adaptive RED
435 
436  return newAve;
437 }
438 
439 // Check if packet p needs to be dropped due to probability mark
440 uint32_t
441 RedQueue::DropEarly (Ptr<Packet> p, uint32_t qSize)
442 {
443  NS_LOG_FUNCTION (this << p << qSize);
446 
447  // Drop probability is computed, pick random number and act
448  if (m_cautious == 1)
449  {
450  /*
451  * Don't drop/mark if the instantaneous queue is much below the average.
452  * For experimental purposes only.
453  * pkts: the number of packets arriving in 50 ms
454  */
455  double pkts = m_ptc * 0.05;
456  double fraction = std::pow ((1 - m_qW), pkts);
457 
458  if ((double) qSize < fraction * m_qAvg)
459  {
460  // Queue could have been empty for 0.05 seconds
461  return 0;
462  }
463  }
464 
465  double u = m_uv->GetValue ();
466 
467  if (m_cautious == 2)
468  {
469  /*
470  * Decrease the drop probability if the instantaneous
471  * queue is much below the average.
472  * For experimental purposes only.
473  * pkts: the number of packets arriving in 50 ms
474  */
475  double pkts = m_ptc * 0.05;
476  double fraction = std::pow ((1 - m_qW), pkts);
477  double ratio = qSize / (fraction * m_qAvg);
478 
479  if (ratio < 1.0)
480  {
481  u *= 1.0 / ratio;
482  }
483  }
484 
485  if (u <= m_vProb)
486  {
487  NS_LOG_LOGIC ("u <= m_vProb; u " << u << "; m_vProb " << m_vProb);
488 
489  // DROP or MARK
490  m_count = 0;
491  m_countBytes = 0;
493 
494  return 1; // drop
495  }
496 
497  return 0; // no drop/mark
498 }
499 
500 // Returns a probability using these function parameters for the DropEarly funtion
501 double
502 RedQueue::CalculatePNew (double qAvg, double maxTh, bool isGentle, double vA,
503  double vB, double vC, double vD, double maxP)
504 {
505  NS_LOG_FUNCTION (this << qAvg << maxTh << isGentle << vA << vB << vC << vD << maxP);
506  double p;
507 
508  if (isGentle && qAvg >= maxTh)
509  {
510  // p ranges from maxP to 1 as the average queue
511  // Size ranges from maxTh to twice maxTh
512  p = vC * qAvg + vD;
513  }
514  else if (!isGentle && qAvg >= maxTh)
515  {
516  /*
517  * OLD: p continues to range linearly above max_p as
518  * the average queue size ranges above th_max.
519  * NEW: p is set to 1.0
520  */
521  p = 1.0;
522  }
523  else
524  {
525  /*
526  * p ranges from 0 to max_p as the average queue size ranges from
527  * th_min to th_max
528  */
529  p = vA * qAvg + vB;
530  p *= maxP;
531  }
532 
533  if (p > 1.0)
534  {
535  p = 1.0;
536  }
537 
538  return p;
539 }
540 
541 // Returns a probability using these function parameters for the DropEarly funtion
542 double
543 RedQueue::ModifyP (double p, uint32_t count, uint32_t countBytes,
544  uint32_t meanPktSize, bool isWait, uint32_t size)
545 {
546  NS_LOG_FUNCTION (this << p << count << countBytes << meanPktSize << isWait << size);
547  double count1 = (double) count;
548 
549  if (GetMode () == QUEUE_MODE_BYTES)
550  {
551  count1 = (double) (countBytes / meanPktSize);
552  }
553 
554  if (isWait)
555  {
556  if (count1 * p < 1.0)
557  {
558  p = 0.0;
559  }
560  else if (count1 * p < 2.0)
561  {
562  p /= (2.0 - count1 * p);
563  }
564  else
565  {
566  p = 1.0;
567  }
568  }
569  else
570  {
571  if (count1 * p < 1.0)
572  {
573  p /= (1.0 - count1 * p);
574  }
575  else
576  {
577  p = 1.0;
578  }
579  }
580 
581  if ((GetMode () == QUEUE_MODE_BYTES) && (p < 1.0))
582  {
583  p = (p * size) / meanPktSize;
584  }
585 
586  if (p > 1.0)
587  {
588  p = 1.0;
589  }
590 
591  return p;
592 }
593 
594 uint32_t
596 {
597  NS_LOG_FUNCTION (this);
598  if (GetMode () == QUEUE_MODE_BYTES)
599  {
600  return m_bytesInQueue;
601  }
602  else if (GetMode () == QUEUE_MODE_PACKETS)
603  {
604  return m_packets.size ();
605  }
606  else
607  {
608  NS_ABORT_MSG ("Unknown RED mode.");
609  }
610 }
611 
614 {
615  NS_LOG_FUNCTION (this);
616 
617  if (m_packets.empty ())
618  {
619  NS_LOG_LOGIC ("Queue empty");
620  m_idle = 1;
622 
623  return 0;
624  }
625  else
626  {
627  m_idle = 0;
628  Ptr<Packet> p = m_packets.front ();
629  m_packets.pop_front ();
630  m_bytesInQueue -= p->GetSize ();
631 
632  NS_LOG_LOGIC ("Popped " << p);
633 
634  NS_LOG_LOGIC ("Number packets " << m_packets.size ());
635  NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
636 
637  return p;
638  }
639 }
640 
642 RedQueue::DoPeek (void) const
643 {
644  NS_LOG_FUNCTION (this);
645  if (m_packets.empty ())
646  {
647  NS_LOG_LOGIC ("Queue empty");
648  return 0;
649  }
650 
651  Ptr<Packet> p = m_packets.front ();
652 
653  NS_LOG_LOGIC ("Number packets " << m_packets.size ());
654  NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
655 
656  return p;
657 }
658 
659 } // namespace ns3
uint32_t m_bytesInQueue
Definition: red-queue.h:197
uint32_t qLimDrop
Forced drops, qavg > max threshold.
Definition: red-queue.h:108
Ptr< UniformRandomVariable > m_uv
Definition: red-queue.h:265
QueueMode m_mode
Definition: red-queue.h:203
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
uint32_t DropEarly(Ptr< Packet > p, uint32_t qSize)
Definition: red-queue.cc:441
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
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)
Definition: enum.cc:178
Hold a bool native type.
Definition: boolean.h:38
virtual ~RedQueue()
Destructor.
Definition: red-queue.cc:161
void SetMode(RedQueue::QueueMode mode)
Set the operating mode of this queue.
Definition: red-queue.cc:167
double m_ptc
Definition: red-queue.h:250
void SetQueueLimit(uint32_t lim)
Set the limit of the queue.
Definition: red-queue.cc:181
virtual Ptr< Packet > DoDequeue(void)
Definition: red-queue.cc:613
#define NS_ASSERT(condition)
Definition: assert.h:64
uint32_t m_cautious
Definition: red-queue.h:261
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
uint32_t GetSize(void) const
Definition: packet.h:650
#define NS_LOG_INFO(msg)
Definition: log.h:298
virtual bool DoEnqueue(Ptr< Packet > p)
Definition: red-queue.cc:212
DataRate m_linkBandwidth
Definition: red-queue.h:225
uint32_t m_queueLimit
Definition: red-queue.h:217
Stats m_stats
Definition: red-queue.h:199
Abstract base class for packet Queues.
Definition: queue.h:45
Class for representing data rates.
Definition: data-rate.h:71
bool m_isGentle
Definition: red-queue.h:211
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
Definition: red-queue.cc:595
double m_vProb
Definition: red-queue.h:242
double GetSeconds(void) const
Definition: nstime.h:274
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: red-queue.cc:204
Time m_linkDelay
Definition: red-queue.h:227
std::list< Ptr< Packet > > m_packets
Definition: red-queue.h:195
double m_vA
Definition: red-queue.h:233
RedQueue::QueueMode GetMode(void)
Get the encapsulation mode of this queue.
Definition: red-queue.cc:174
hold variables of type 'enum'
Definition: enum.h:37
Stats GetStats()
Get the RED statistics after running.
Definition: red-queue.cc:197
uint32_t m_countBytes
Definition: red-queue.h:244
hold objects of type ns3::Time
Definition: nstime.h:961
virtual Ptr< const Packet > DoPeek(void) const
Definition: red-queue.cc:642
uint32_t m_meanPktSize
Definition: red-queue.h:205
Hold an unsigned integer type.
Definition: uinteger.h:46
RedQueue()
RedQueue Constructor.
Definition: red-queue.cc:151
bool m_isNs1Compat
Definition: red-queue.h:223
#define NS_LOG_LOGIC(msg)
Definition: log.h:368
double m_lInterm
Definition: red-queue.h:221
static TypeId GetTypeId(void)
Definition: red-queue.cc:75
NS_LOG_COMPONENT_DEFINE("RedQueue")
double Estimator(uint32_t nQueued, uint32_t m, double qAvg, double qW)
Definition: red-queue.cc:421
void SetTh(double minTh, double maxTh)
Set the thresh limits of RED.
Definition: red-queue.cc:188
uint32_t m_count
Definition: red-queue.h:254
uint32_t m_idle
Definition: red-queue.h:248
Use number of bytes for maximum queue size.
Definition: queue.h:125
double ModifyP(double p, uint32_t count, uint32_t countBytes, uint32_t meanPktSize, bool wait, uint32_t size)
Definition: red-queue.cc:543
void InitializeParams(void)
Definition: red-queue.cc:342
uint32_t m_old
Definition: red-queue.h:246
double GetValue(double min, double max)
Returns a random double from the uniform distribution with the specified range.
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:235
bool m_hasRedStarted
Definition: red-queue.h:198
double CalculatePNew(double qAvg, double maxTh, bool gentle, double vA, double vB, double vC, double vD, double maxP)
Definition: red-queue.cc:502
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
QueueMode
Enumeration of the modes supported in the class.
Definition: queue.h:122
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:118
double m_vProb1
Definition: red-queue.h:231
Use number of packets for maximum queue size.
Definition: queue.h:124
uint32_t m_idlePktSize
Definition: red-queue.h:207
#define NS_ABORT_MSG(msg)
Abnormal program termination.
Definition: abort.h:43
Time m_idleTime
Definition: red-queue.h:263
uint32_t forcedDrop
Early probability drops.
Definition: red-queue.h:107
hold objects of type ns3::DataRate
#define NS_LOG_DEBUG(msg)
Definition: log.h:289
double m_qW
Definition: red-queue.h:219
double m_qAvg
Definition: red-queue.h:252
double m_vB
Definition: red-queue.h:234
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:452
uint32_t unforcedDrop
Definition: red-queue.h:106
double m_vC
Definition: red-queue.h:236
double m_maxTh
Definition: red-queue.h:215
Hold a floating point type.
Definition: double.h:41
double m_curMaxP
Definition: red-queue.h:240
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
double m_minTh
Definition: red-queue.h:213
void Drop(Ptr< Packet > packet)
Drop a packet.
Definition: queue.cc:192
double m_vD
Definition: red-queue.h:238