A Discrete-Event Network Simulator
API
pie-queue-disc.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2016 NITK Surathkal
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  * Authors: Shravya Ks <shravya.ks0@gmail.com>
19  * Smriti Murali <m.smriti.95@gmail.com>
20  * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
21  */
22 
23 /*
24  * PORT NOTE: This code was ported from ns-2.36rc1 (queue/pie.h).
25  * Most of the comments are also ported from the same.
26  */
27 
28 #ifndef PIE_QUEUE_DISC_H
29 #define PIE_QUEUE_DISC_H
30 
31 #include <queue>
32 #include "ns3/packet.h"
33 #include "ns3/queue-disc.h"
34 #include "ns3/nstime.h"
35 #include "ns3/boolean.h"
36 #include "ns3/data-rate.h"
37 #include "ns3/timer.h"
38 #include "ns3/event-id.h"
39 #include "ns3/random-variable-stream.h"
40 
41 #define BURST_RESET_TIMEOUT 1.5
42 
43 namespace ns3 {
44 
45 class TraceContainer;
46 class UniformRandomVariable;
47 
53 class PieQueueDisc : public QueueDisc
54 {
55 public:
60  static TypeId GetTypeId (void);
61 
65  PieQueueDisc ();
66 
70  virtual ~PieQueueDisc ();
71 
75  typedef struct
76  {
77  uint32_t unforcedDrop;
78  uint32_t forcedDrop;
79  } Stats;
80 
85  {
89  };
90 
96  void SetMode (Queue::QueueMode mode);
97 
103  Queue::QueueMode GetMode (void);
104 
110  uint32_t GetQueueSize (void);
111 
117  void SetQueueLimit (uint32_t lim);
118 
122  Time GetQueueDelay (void);
123 
129  Stats GetStats ();
130 
139  int64_t AssignStreams (int64_t stream);
140 
141 protected:
145  virtual void DoDispose (void);
146 
147 private:
148  virtual bool DoEnqueue (Ptr<QueueDiscItem> item);
149  virtual Ptr<QueueDiscItem> DoDequeue (void);
150  virtual Ptr<const QueueDiscItem> DoPeek (void) const;
151  virtual bool CheckConfig (void);
152 
156  virtual void InitializeParams (void);
157 
164  bool DropEarly (Ptr<QueueDiscItem> item, uint32_t qSize);
165 
171  void CalculateP ();
172 
174 
175  // ** Variables supplied by user
177  uint32_t m_queueLimit;
181  uint32_t m_meanPktSize;
183  double m_a;
184  double m_b;
185  uint32_t m_dqThreshold;
186 
187  // ** Variables maintained by PIE
188  double m_dropProb;
192  uint32_t m_burstReset;
195  double m_avgDqRate;
196  double m_dqStart;
197  uint32_t m_dqCount;
200 };
201 
202 }; // namespace ns3
203 
204 #endif
205 
Stats GetStats()
Get PIE statistics after running.
uint32_t m_dqCount
Number of bytes departed since current measurement cycle starts.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Time m_tUpdate
Time period after which CalculateP () is called.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
uint32_t unforcedDrop
Early probability drops: proactive.
double m_avgDqRate
Time averaged dequeue rate.
Queue::QueueMode m_mode
Mode (bytes or packets)
Time m_maxBurst
Maximum burst allowed before random early dropping kicks in.
virtual Ptr< const QueueDiscItem > DoPeek(void) const
This function returns a copy of the next packet the queue disc will extract.
double m_a
Parameter to pie controller.
virtual void InitializeParams(void)
Initialize the queue parameters.
uint32_t m_burstReset
Used to reset value of burst allowance.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:205
Implements PIE Active Queue Management discipline.
Time m_qDelayRef
Desired queue delay.
double m_dropProb
Variable used in calculation of drop probability.
uint32_t m_meanPktSize
Average packet size in bytes.
Queue::QueueMode GetMode(void)
Get the encapsulation mode of this queue.
void SetQueueLimit(uint32_t lim)
Set the limit of the queue in bytes or packets.
QueueMode
Enumeration of the modes supported in the class.
Definition: queue.h:130
Time GetQueueDelay(void)
Get queue delay.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
uint32_t forcedDrop
Drops due to queue limit: reactive.
Time m_sUpdate
Start time of the update timer.
uint32_t m_dqThreshold
Minimum queue size in bytes before dequeue rate is measured.
Time m_qDelayOld
Old value of queue delay.
BurstStateT
Burst types.
double m_dqStart
Start timestamp of current measurement cycle.
bool DropEarly(Ptr< QueueDiscItem > item, uint32_t qSize)
Check if a packet needs to be dropped due to probability drop.
void SetMode(Queue::QueueMode mode)
Set the operating mode of this queue.
virtual void DoDispose(void)
Dispose of the object.
void CalculateP()
Periodically update the drop probability based on the delay samples: not only the current delay sampl...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Stats m_stats
PIE statistics.
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
EventId m_rtrsEvent
Event used to decide the decision of interval of drop probability calculation.
Ptr< UniformRandomVariable > m_uv
Rng stream.
PieQueueDisc()
PieQueueDisc Constructor.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Time m_qDelay
Current value of queue delay.
An identifier for simulation events.
Definition: event-id.h:53
static TypeId GetTypeId(void)
Get the type ID.
BurstStateT m_burstState
Used to determine the current state of burst.
Time m_burstAllowance
Current max burst value in seconds that is allowed before random drops kick in.
virtual ~PieQueueDisc()
PieQueueDisc Destructor.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
uint32_t m_queueLimit
Queue limit in bytes / packets.
double m_b
Parameter to pie controller.
a unique identifier for an interface.
Definition: type-id.h:58
bool m_inMeasurement
Indicates whether we are in a measurement cycle.