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