This documentation is not the Latest Release.
A Discrete-Event Network Simulator
API
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 namespace ns3 {
69 
70 NS_LOG_COMPONENT_DEFINE ("RedQueue");
71 
73 
75 {
76  static TypeId tid = TypeId ("ns3::RedQueue")
77  .SetParent<Queue> ()
78  .SetGroupName("Network")
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),
90  MakeUintegerChecker<uint32_t> ())
91  .AddAttribute ("IdlePktSize",
92  "Average packet size used during idle times. Used when m_cautions = 3",
93  UintegerValue (0),
95  MakeUintegerChecker<uint32_t> ())
96  .AddAttribute ("Wait",
97  "True for waiting between dropped packets",
98  BooleanValue (true),
101  .AddAttribute ("Gentle",
102  "True to increases dropping probability slowly when average queue exceeds maxthresh",
103  BooleanValue (true),
106  .AddAttribute ("MinTh",
107  "Minimum average length threshold in packets/bytes",
108  DoubleValue (5),
110  MakeDoubleChecker<double> ())
111  .AddAttribute ("MaxTh",
112  "Maximum average length threshold in packets/bytes",
113  DoubleValue (15),
115  MakeDoubleChecker<double> ())
116  .AddAttribute ("QueueLimit",
117  "Queue limit in bytes/packets",
118  UintegerValue (25),
120  MakeUintegerChecker<uint32_t> ())
121  .AddAttribute ("QW",
122  "Queue weight related to the exponential weighted moving average (EWMA)",
123  DoubleValue (0.002),
125  MakeDoubleChecker <double> ())
126  .AddAttribute ("LInterm",
127  "The maximum probability of dropping a packet",
128  DoubleValue (50),
130  MakeDoubleChecker <double> ())
131  .AddAttribute ("Ns1Compat",
132  "NS-1 compatibility",
133  BooleanValue (false),
136  .AddAttribute ("LinkBandwidth",
137  "The RED link bandwidth",
138  DataRateValue (DataRate ("1.5Mbps")),
141  .AddAttribute ("LinkDelay",
142  "The RED link delay",
143  TimeValue (MilliSeconds (20)),
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
bytes in the queue
Definition: red-queue.h:238
uint32_t qLimDrop
Drops due to queue limits.
Definition: red-queue.h:111
Ptr< UniformRandomVariable > m_uv
rng stream
Definition: red-queue.h:280
QueueMode m_mode
Mode (Bytes or packets)
Definition: red-queue.h:243
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
An "unforced" (random) drop.
Definition: red-queue.h:121
uint32_t DropEarly(Ptr< Packet > p, uint32_t qSize)
Check if packet p needs to be dropped due to probability mark.
Definition: red-queue.cc:441
#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 this RNG stream.
AttributeValue implementation for Boolean.
Definition: boolean.h:34
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
virtual ~RedQueue()
Destructor.
Definition: red-queue.cc:161
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
void SetMode(RedQueue::QueueMode mode)
Set the operating mode of this queue.
Definition: red-queue.cc:167
Use number of bytes for maximum queue size.
Definition: queue.h:129
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: enum.h:209
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: boolean.h:81
double m_ptc
packet time constant in packets/second
Definition: red-queue.h:268
void SetQueueLimit(uint32_t lim)
Set the limit of the queue.
Definition: red-queue.cc:181
virtual Ptr< Packet > DoDequeue(void)
Pull a packet from the queue.
Definition: red-queue.cc:613
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
uint32_t m_cautious
0 for default RED 1 experimental (see red-queue.cc) 2 experimental (see red-queue.cc) 3 use Idle packet size in the ptc
Definition: red-queue.h:277
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:903
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:786
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
virtual bool DoEnqueue(Ptr< Packet > p)
Push a packet in the queue.
Definition: red-queue.cc:212
DataRate m_linkBandwidth
Link bandwidth.
Definition: red-queue.h:254
uint32_t m_queueLimit
Queue limit in bytes / packets.
Definition: red-queue.h:250
Stats m_stats
RED statistics.
Definition: red-queue.h:240
Ptr< const AttributeChecker > MakeDataRateChecker(void)
Definition: data-rate.cc:30
Abstract base class for packet Queues.
Definition: queue.h:45
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
Class for representing data rates.
Definition: data-rate.h:88
bool m_isGentle
True to increases dropping prob.
Definition: red-queue.h:247
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
Definition: red-queue.cc:595
double m_vProb
Prob.
Definition: red-queue.h:264
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
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
QueueMode
Enumeration of the modes supported in the class.
Definition: queue.h:126
Time m_linkDelay
Link delay.
Definition: red-queue.h:255
std::list< Ptr< Packet > > m_packets
packets in the queue
Definition: red-queue.h:236
double m_vA
1.0 / (m_maxTh - m_minTh)
Definition: red-queue.h:259
RedQueue::QueueMode GetMode(void)
Get the encapsulation mode of this queue.
Definition: red-queue.cc:174
Hold variables of type enum.
Definition: enum.h:54
Stats GetStats()
Get the RED statistics after running.
Definition: red-queue.cc:197
uint32_t m_countBytes
Number of bytes since last drop.
Definition: red-queue.h:265
AttributeValue implementation for Time.
Definition: nstime.h:957
virtual Ptr< const Packet > DoPeek(void) const
Peek the front packet in the queue.
Definition: red-queue.cc:642
uint32_t m_meanPktSize
Avg pkt size.
Definition: red-queue.h:244
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:919
Hold an unsigned integer type.
Definition: uinteger.h:44
RedQueue()
RedQueue Constructor.
Definition: red-queue.cc:151
bool m_isNs1Compat
Ns-1 compatibility.
Definition: red-queue.h:253
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: data-rate.h:241
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
double m_lInterm
The max probability of dropping a packet.
Definition: red-queue.h:252
static TypeId GetTypeId(void)
Get the type ID.
Definition: red-queue.cc:74
double Estimator(uint32_t nQueued, uint32_t m, double qAvg, double qW)
Compute the average queue size.
Definition: red-queue.cc:421
void SetTh(double minTh, double maxTh)
Set the thresh limits of RED.
Definition: red-queue.cc:188
double CalculatePNew(double qAvg, double, bool gentle, double vA, double vB, double vC, double vD, double maxP)
Returns a probability using these function parameters for the DropEarly function. ...
Definition: red-queue.cc:502
uint32_t m_count
Number of packets since last random number generation.
Definition: red-queue.h:270
uint32_t m_idle
0/1 idle status
Definition: red-queue.h:267
double ModifyP(double p, uint32_t count, uint32_t countBytes, uint32_t meanPktSize, bool wait, uint32_t size)
Returns a probability using these function parameters for the DropEarly function. ...
Definition: red-queue.cc:543
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void InitializeParams(void)
Initialize the queue parameters.
Definition: red-queue.cc:342
bool m_isWait
True for waiting between dropped packets.
Definition: red-queue.h:246
uint32_t m_old
0 when average queue first exceeds threshold
Definition: red-queue.h:266
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Definition: boolean.cc:121
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:249
bool m_hasRedStarted
True if RED has started.
Definition: red-queue.h:239
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:958
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
double m_vProb1
Prob.
Definition: red-queue.h:258
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)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.cc:184
uint32_t m_idlePktSize
Avg pkt size used during idle times.
Definition: red-queue.h:245
Time m_idleTime
Start of current idle period.
Definition: red-queue.h:278
uint32_t forcedDrop
Forced drops, qavg > max threshold.
Definition: red-queue.h:110
AttributeValue implementation for DataRate.
Definition: data-rate.h:241
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
A "forced" drop.
Definition: red-queue.h:120
A RED packet queue.
Definition: red-queue.h:82
double m_qW
Queue weight given to cur queue size sample.
Definition: red-queue.h:251
double m_qAvg
Average queue length.
Definition: red-queue.h:269
double m_vB
-m_minTh / (m_maxTh - m_minTh)
Definition: red-queue.h:260
uint32_t unforcedDrop
Early probability drops.
Definition: red-queue.h:109
double m_vC
(1.0 - m_curMaxP) / m_maxTh - used in "gentle" mode
Definition: red-queue.h:261
Use number of packets for maximum queue size.
Definition: queue.h:128
double m_maxTh
Max avg length threshold (bytes), should be >= 2*minTh.
Definition: red-queue.h:249
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
double m_curMaxP
Current max_p.
Definition: red-queue.h:263
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:826
double m_minTh
Min avg length threshold (bytes)
Definition: red-queue.h:248
void Drop(Ptr< Packet > packet)
Drop a packet.
Definition: queue.cc:195
double m_vD
2.0 * m_curMaxP - 1.0 - used in "gentle" mode
Definition: red-queue.h:262