A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
pie-queue-disc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 NITK Surathkal
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Shravya Ks <shravya.ks0@gmail.com>
18 * Smriti Murali <m.smriti.95@gmail.com>
19 * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
20 */
21
22/*
23 * PORT NOTE: This code was ported from ns-2.36rc1 (queue/pie.h).
24 * Most of the comments are also ported from the same.
25 */
26
27#ifndef PIE_QUEUE_DISC_H
28#define PIE_QUEUE_DISC_H
29
30#include "queue-disc.h"
31
32#include "ns3/boolean.h"
33#include "ns3/data-rate.h"
34#include "ns3/event-id.h"
35#include "ns3/nstime.h"
36#include "ns3/random-variable-stream.h"
37#include "ns3/timer.h"
38
39#define BURST_RESET_TIMEOUT 1.5
40
41class PieQueueDiscTestCase; // Forward declaration for unit test
42
43namespace ns3
44{
45
46class TraceContainer;
47class UniformRandomVariable;
48
49/**
50 * \ingroup traffic-control
51 *
52 * \brief Implements PIE Active Queue Management discipline
53 */
54class PieQueueDisc : public QueueDisc
55{
56 public:
57 /**
58 * \brief Get the type ID.
59 * \return the object TypeId
60 */
61 static TypeId GetTypeId();
62
63 /**
64 * \brief PieQueueDisc Constructor
65 */
67
68 /**
69 * \brief PieQueueDisc Destructor
70 */
71 ~PieQueueDisc() override;
72
73 /**
74 * \brief Burst types
75 */
77 {
81 };
82
83 /**
84 * \brief Get queue delay.
85 *
86 * \returns The current queue delay.
87 */
89 /**
90 * Assign a fixed random variable stream number to the random variables
91 * used by this model. Return the number of streams (possibly zero) that
92 * have been assigned.
93 *
94 * \param stream first stream index to use
95 * \return the number of stream indices assigned by this model
96 */
97 int64_t AssignStreams(int64_t stream);
98
99 // Reasons for dropping packets
100 static constexpr const char* UNFORCED_DROP =
101 "Unforced drop"; //!< Early probability drops: proactive
102 static constexpr const char* FORCED_DROP =
103 "Forced drop"; //!< Drops due to queue limit: reactive
104 static constexpr const char* UNFORCED_MARK =
105 "Unforced mark"; //!< Early probability marks: proactive
106 static constexpr const char* CE_THRESHOLD_EXCEEDED_MARK =
107 "CE threshold exceeded mark"; //!< Early probability marks: proactive
108
109 protected:
110 /**
111 * \brief Dispose of the object
112 */
113 void DoDispose() override;
114
115 private:
116 friend class ::PieQueueDiscTestCase; // Test code
117 bool DoEnqueue(Ptr<QueueDiscItem> item) override;
118 Ptr<QueueDiscItem> DoDequeue() override;
119 bool CheckConfig() override;
120
121 /**
122 * \brief Initialize the queue parameters.
123 */
124 void InitializeParams() override;
125
126 /**
127 * \brief Check if a packet needs to be dropped due to probability drop
128 * \param item queue item
129 * \param qSize queue size
130 * \returns 0 for no drop, 1 for drop
131 */
132 bool DropEarly(Ptr<QueueDiscItem> item, uint32_t qSize);
133
134 /**
135 * Periodically update the drop probability based on the delay samples:
136 * not only the current delay sample but also the trend where the delay
137 * is going, up or down
138 */
139 void CalculateP();
140
141 static const uint64_t DQCOUNT_INVALID =
142 std::numeric_limits<uint64_t>::max(); //!< Invalid dqCount value
143
144 // ** Variables supplied by user
145 Time m_sUpdate; //!< Start time of the update timer
146 Time m_tUpdate; //!< Time period after which CalculateP () is called
147 Time m_qDelayRef; //!< Desired queue delay
148 uint32_t m_meanPktSize; //!< Average packet size in bytes
149 Time m_maxBurst; //!< Maximum burst allowed before random early dropping kicks in
150 double m_a; //!< Parameter to pie controller
151 double m_b; //!< Parameter to pie controller
152 uint32_t m_dqThreshold; //!< Minimum queue size in bytes before dequeue rate is measured
153 bool m_useDqRateEstimator; //!< Enable/Disable usage of dequeue rate estimator for queue delay
154 //!< calculation
155 bool
156 m_isCapDropAdjustment; //!< Enable/Disable Cap Drop Adjustment feature mentioned in RFC 8033
157 bool m_useEcn; //!< Enable ECN Marking functionality
158 bool m_useDerandomization; //!< Enable Derandomization feature mentioned in RFC 8033
159 double m_markEcnTh; //!< ECN marking threshold (default 10% as suggested in RFC 8033)
160 Time m_activeThreshold; //!< Threshold for activating PIE (disabled by default)
161 Time m_ceThreshold; //!< Threshold above which to CE mark
162 bool m_useL4s; //!< True if L4S is used (ECT1 packets are marked at CE threshold)
163
164 // ** Variables maintained by PIE
165 double m_dropProb; //!< Variable used in calculation of drop probability
166 Time m_qDelayOld; //!< Old value of queue delay
167 Time m_qDelay; //!< Current value of queue delay
168 Time m_burstAllowance; //!< Current max burst value in seconds that is allowed before random
169 //!< drops kick in
170 uint32_t m_burstReset; //!< Used to reset value of burst allowance
171 BurstStateT m_burstState; //!< Used to determine the current state of burst
172 bool m_inMeasurement; //!< Indicates whether we are in a measurement cycle
173 double m_avgDqRate; //!< Time averaged dequeue rate
174 Time m_dqStart; //!< Start timestamp of current measurement cycle
175 uint64_t m_dqCount; //!< Number of bytes departed since current measurement cycle starts
176 EventId m_rtrsEvent; //!< Event used to decide the decision of interval of drop probability
177 //!< calculation
179 double m_accuProb; //!< Accumulated drop probability
180 bool m_active; //!< Indicates whether PIE is in active state or not
181};
182
183}; // namespace ns3
184
185#endif
Pie Queue Disc Test Case.
An identifier for simulation events.
Definition: event-id.h:55
Implements PIE Active Queue Management discipline.
uint32_t m_dqThreshold
Minimum queue size in bytes before dequeue rate is measured.
uint32_t m_meanPktSize
Average packet size in bytes.
double m_markEcnTh
ECN marking threshold (default 10% as suggested in RFC 8033)
bool m_useDqRateEstimator
Enable/Disable usage of dequeue rate estimator for queue delay calculation.
bool DoEnqueue(Ptr< QueueDiscItem > item) override
This function actually enqueues a packet into the queue disc.
void DoDispose() override
Dispose of the object.
bool m_useL4s
True if L4S is used (ECT1 packets are marked at CE threshold)
Time m_sUpdate
Start time of the update timer.
Time m_dqStart
Start timestamp of current measurement cycle.
bool m_useDerandomization
Enable Derandomization feature mentioned in RFC 8033.
static constexpr const char * UNFORCED_DROP
Early probability drops: proactive.
Time m_maxBurst
Maximum burst allowed before random early dropping kicks in.
EventId m_rtrsEvent
Event used to decide the decision of interval of drop probability calculation.
void CalculateP()
Periodically update the drop probability based on the delay samples: not only the current delay sampl...
Time m_ceThreshold
Threshold above which to CE mark.
Time m_qDelayOld
Old value of queue delay.
double m_dropProb
Variable used in calculation of drop probability.
Time m_burstAllowance
Current max burst value in seconds that is allowed before random drops kick in.
BurstStateT m_burstState
Used to determine the current state of burst.
Time GetQueueDelay()
Get queue delay.
Ptr< QueueDiscItem > DoDequeue() override
This function actually extracts a packet from the queue disc.
bool DropEarly(Ptr< QueueDiscItem > item, uint32_t qSize)
Check if a packet needs to be dropped due to probability drop.
bool m_active
Indicates whether PIE is in active state or not.
double m_avgDqRate
Time averaged dequeue rate.
static const uint64_t DQCOUNT_INVALID
Invalid dqCount value.
uint32_t m_burstReset
Used to reset value of burst allowance.
void InitializeParams() override
Initialize the queue parameters.
bool m_inMeasurement
Indicates whether we are in a measurement cycle.
static constexpr const char * FORCED_DROP
Drops due to queue limit: reactive.
Time m_qDelayRef
Desired queue delay.
~PieQueueDisc() override
PieQueueDisc Destructor.
double m_a
Parameter to pie controller.
static constexpr const char * CE_THRESHOLD_EXCEEDED_MARK
Early probability marks: proactive.
Time m_activeThreshold
Threshold for activating PIE (disabled by default)
bool m_isCapDropAdjustment
Enable/Disable Cap Drop Adjustment feature mentioned in RFC 8033.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
double m_accuProb
Accumulated drop probability.
Ptr< UniformRandomVariable > m_uv
Rng stream.
bool m_useEcn
Enable ECN Marking functionality.
Time m_tUpdate
Time period after which CalculateP () is called.
BurstStateT
Burst types.
PieQueueDisc()
PieQueueDisc Constructor.
bool CheckConfig() override
Check whether the current configuration is correct.
Time m_qDelay
Current value of queue delay.
uint64_t m_dqCount
Number of bytes departed since current measurement cycle starts.
static TypeId GetTypeId()
Get the type ID.
double m_b
Parameter to pie controller.
static constexpr const char * UNFORCED_MARK
Early probability marks: proactive.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:184
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.