A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
fq-codel-queue-disc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Universita' degli Studi di Napoli Federico II
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: Pasquale Imputato <p.imputato@gmail.com>
18 * Stefano Avallone <stefano.avallone@unina.it>
19 */
20
21#ifndef FQ_CODEL_QUEUE_DISC
22#define FQ_CODEL_QUEUE_DISC
23
24#include "queue-disc.h"
25
26#include "ns3/object-factory.h"
27
28#include <list>
29#include <map>
30
31namespace ns3
32{
33
34/**
35 * \ingroup traffic-control
36 *
37 * \brief A flow queue used by the FqCoDel queue disc
38 */
39
41{
42 public:
43 /**
44 * \brief Get the type ID.
45 * \return the object TypeId
46 */
47 static TypeId GetTypeId();
48 /**
49 * \brief FqCoDelFlow constructor
50 */
52
53 ~FqCoDelFlow() override;
54
55 /**
56 * \enum FlowStatus
57 * \brief Used to determine the status of this flow queue
58 */
60 {
64 };
65
66 /**
67 * \brief Set the deficit for this flow
68 * \param deficit the deficit for this flow
69 */
70 void SetDeficit(uint32_t deficit);
71 /**
72 * \brief Get the deficit for this flow
73 * \return the deficit for this flow
74 */
75 int32_t GetDeficit() const;
76 /**
77 * \brief Increase the deficit for this flow
78 * \param deficit the amount by which the deficit is to be increased
79 */
80 void IncreaseDeficit(int32_t deficit);
81 /**
82 * \brief Set the status for this flow
83 * \param status the status for this flow
84 */
85 void SetStatus(FlowStatus status);
86 /**
87 * \brief Get the status of this flow
88 * \return the status of this flow
89 */
90 FlowStatus GetStatus() const;
91 /**
92 * \brief Set the index for this flow
93 * \param index the index for this flow
94 */
95 void SetIndex(uint32_t index);
96 /**
97 * \brief Get the index of this flow
98 * \return the index of this flow
99 */
100 uint32_t GetIndex() const;
101
102 private:
103 int32_t m_deficit; //!< the deficit for this flow
104 FlowStatus m_status; //!< the status of this flow
105 uint32_t m_index; //!< the index for this flow
106};
107
108/**
109 * \ingroup traffic-control
110 *
111 * \brief A FqCoDel packet queue disc
112 */
113
115{
116 public:
117 /**
118 * \brief Get the type ID.
119 * \return the object TypeId
120 */
121 static TypeId GetTypeId();
122 /**
123 * \brief FqCoDelQueueDisc constructor
124 */
126
127 ~FqCoDelQueueDisc() override;
128
129 /**
130 * \brief Set the quantum value.
131 *
132 * \param quantum The number of bytes each queue gets to dequeue on each round of the scheduling
133 * algorithm
134 */
135 void SetQuantum(uint32_t quantum);
136
137 /**
138 * \brief Get the quantum value.
139 *
140 * \returns The number of bytes each queue gets to dequeue on each round of the scheduling
141 * algorithm
142 */
143 uint32_t GetQuantum() const;
144
145 // Reasons for dropping packets
146 static constexpr const char* UNCLASSIFIED_DROP =
147 "Unclassified drop"; //!< No packet filter able to classify packet
148 static constexpr const char* OVERLIMIT_DROP = "Overlimit drop"; //!< Overlimit dropped packets
149
150 private:
151 bool DoEnqueue(Ptr<QueueDiscItem> item) override;
152 Ptr<QueueDiscItem> DoDequeue() override;
153 bool CheckConfig() override;
154 void InitializeParams() override;
155
156 /**
157 * \brief Drop a packet from the head of the queue with the largest current byte count
158 * \return the index of the queue with the largest current byte count
159 */
161
162 bool m_useEcn; //!< True if ECN is used (packets are marked instead of being dropped)
163 /**
164 * Compute the index of the queue for the flow having the given flowHash,
165 * according to the set associative hash approach.
166 *
167 * \param flowHash the hash of the flow 5-tuple
168 * \return the index of the queue for the given flow
169 */
171
172 std::string m_interval; //!< CoDel interval attribute
173 std::string m_target; //!< CoDel target attribute
174 uint32_t m_quantum; //!< Deficit assigned to flows at each round
175 uint32_t m_flows; //!< Number of flow queues
176 uint32_t m_setWays; //!< size of a set of queues (used by set associative hash)
177 uint32_t m_dropBatchSize; //!< Max number of packets dropped from the fat flow
178 uint32_t m_perturbation; //!< hash perturbation value
179 Time m_ceThreshold; //!< Threshold above which to CE mark
180 bool m_enableSetAssociativeHash; //!< whether to enable set associative hash
181 bool m_useL4s; //!< True if L4S is used (ECT1 packets are marked at CE threshold)
182
183 std::list<Ptr<FqCoDelFlow>> m_newFlows; //!< The list of new flows
184 std::list<Ptr<FqCoDelFlow>> m_oldFlows; //!< The list of old flows
185
186 std::map<uint32_t, uint32_t> m_flowsIndices; //!< Map with the index of class for each flow
187 std::map<uint32_t, uint32_t> m_tags; //!< Tags used by set associative hash
188
189 ObjectFactory m_flowFactory; //!< Factory to create a new flow
190 ObjectFactory m_queueDiscFactory; //!< Factory to create a new queue
191};
192
193} // namespace ns3
194
195#endif /* FQ_CODEL_QUEUE_DISC */
A flow queue used by the FqCoDel queue disc.
FqCoDelFlow()
FqCoDelFlow constructor.
FlowStatus GetStatus() const
Get the status of this flow.
void SetIndex(uint32_t index)
Set the index for this flow.
uint32_t GetIndex() const
Get the index of this flow.
static TypeId GetTypeId()
Get the type ID.
void SetDeficit(uint32_t deficit)
Set the deficit for this flow.
int32_t m_deficit
the deficit for this flow
FlowStatus m_status
the status of this flow
int32_t GetDeficit() const
Get the deficit for this flow.
uint32_t m_index
the index for this flow
void IncreaseDeficit(int32_t deficit)
Increase the deficit for this flow.
void SetStatus(FlowStatus status)
Set the status for this flow.
FlowStatus
Used to determine the status of this flow queue.
A FqCoDel packet queue disc.
std::list< Ptr< FqCoDelFlow > > m_oldFlows
The list of old flows.
Time m_ceThreshold
Threshold above which to CE mark.
uint32_t m_setWays
size of a set of queues (used by set associative hash)
void InitializeParams() override
Initialize parameters (if any) before the first packet is enqueued.
ObjectFactory m_queueDiscFactory
Factory to create a new queue.
static constexpr const char * UNCLASSIFIED_DROP
No packet filter able to classify packet.
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packets.
ObjectFactory m_flowFactory
Factory to create a new flow.
uint32_t FqCoDelDrop()
Drop a packet from the head of the queue with the largest current byte count.
Ptr< QueueDiscItem > DoDequeue() override
This function actually extracts a packet from the queue disc.
void SetQuantum(uint32_t quantum)
Set the quantum value.
std::string m_interval
CoDel interval attribute.
uint32_t m_dropBatchSize
Max number of packets dropped from the fat flow.
bool DoEnqueue(Ptr< QueueDiscItem > item) override
This function actually enqueues a packet into the queue disc.
std::string m_target
CoDel target attribute.
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
FqCoDelQueueDisc()
FqCoDelQueueDisc constructor.
uint32_t m_perturbation
hash perturbation value
std::map< uint32_t, uint32_t > m_flowsIndices
Map with the index of class for each flow.
std::map< uint32_t, uint32_t > m_tags
Tags used by set associative hash.
bool CheckConfig() override
Check whether the current configuration is correct.
uint32_t SetAssociativeHash(uint32_t flowHash)
Compute the index of the queue for the flow having the given flowHash, according to the set associati...
bool m_useL4s
True if L4S is used (ECT1 packets are marked at CE threshold)
bool m_enableSetAssociativeHash
whether to enable set associative hash
uint32_t m_quantum
Deficit assigned to flows at each round.
std::list< Ptr< FqCoDelFlow > > m_newFlows
The list of new flows.
static TypeId GetTypeId()
Get the type ID.
uint32_t m_flows
Number of flow queues.
uint32_t GetQuantum() const
Get the quantum value.
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
QueueDiscClass is the base class for classes that are included in a queue disc.
Definition: queue-disc.h:52
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.