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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Pasquale Imputato <p.imputato@gmail.com>
7 * Stefano Avallone <stefano.avallone@unina.it>
8 */
9
10#ifndef FQ_CODEL_QUEUE_DISC
11#define FQ_CODEL_QUEUE_DISC
12
13#include "queue-disc.h"
14
15#include "ns3/object-factory.h"
16
17#include <list>
18#include <map>
19
20namespace ns3
21{
22
23/**
24 * \ingroup traffic-control
25 *
26 * \brief A flow queue used by the FqCoDel queue disc
27 */
28
30{
31 public:
32 /**
33 * \brief Get the type ID.
34 * \return the object TypeId
35 */
36 static TypeId GetTypeId();
37 /**
38 * \brief FqCoDelFlow constructor
39 */
41
42 ~FqCoDelFlow() override;
43
44 /**
45 * \enum FlowStatus
46 * \brief Used to determine the status of this flow queue
47 */
54
55 /**
56 * \brief Set the deficit for this flow
57 * \param deficit the deficit for this flow
58 */
59 void SetDeficit(uint32_t deficit);
60 /**
61 * \brief Get the deficit for this flow
62 * \return the deficit for this flow
63 */
64 int32_t GetDeficit() const;
65 /**
66 * \brief Increase the deficit for this flow
67 * \param deficit the amount by which the deficit is to be increased
68 */
69 void IncreaseDeficit(int32_t deficit);
70 /**
71 * \brief Set the status for this flow
72 * \param status the status for this flow
73 */
74 void SetStatus(FlowStatus status);
75 /**
76 * \brief Get the status of this flow
77 * \return the status of this flow
78 */
79 FlowStatus GetStatus() const;
80 /**
81 * \brief Set the index for this flow
82 * \param index the index for this flow
83 */
84 void SetIndex(uint32_t index);
85 /**
86 * \brief Get the index of this flow
87 * \return the index of this flow
88 */
89 uint32_t GetIndex() const;
90
91 private:
92 int32_t m_deficit; //!< the deficit for this flow
93 FlowStatus m_status; //!< the status of this flow
94 uint32_t m_index; //!< the index for this flow
95};
96
97/**
98 * \ingroup traffic-control
99 *
100 * \brief A FqCoDel packet queue disc
101 */
102
104{
105 public:
106 /**
107 * \brief Get the type ID.
108 * \return the object TypeId
109 */
110 static TypeId GetTypeId();
111 /**
112 * \brief FqCoDelQueueDisc constructor
113 */
115
116 ~FqCoDelQueueDisc() override;
117
118 /**
119 * \brief Set the quantum value.
120 *
121 * \param quantum The number of bytes each queue gets to dequeue on each round of the scheduling
122 * algorithm
123 */
124 void SetQuantum(uint32_t quantum);
125
126 /**
127 * \brief Get the quantum value.
128 *
129 * \returns The number of bytes each queue gets to dequeue on each round of the scheduling
130 * algorithm
131 */
132 uint32_t GetQuantum() const;
133
134 // Reasons for dropping packets
135 static constexpr const char* UNCLASSIFIED_DROP =
136 "Unclassified drop"; //!< No packet filter able to classify packet
137 static constexpr const char* OVERLIMIT_DROP = "Overlimit drop"; //!< Overlimit dropped packets
138
139 private:
140 bool DoEnqueue(Ptr<QueueDiscItem> item) override;
141 Ptr<QueueDiscItem> DoDequeue() override;
142 bool CheckConfig() override;
143 void InitializeParams() override;
144
145 /**
146 * \brief Drop a packet from the head of the queue with the largest current byte count
147 * \return the index of the queue with the largest current byte count
148 */
150
151 bool m_useEcn; //!< True if ECN is used (packets are marked instead of being dropped)
152 /**
153 * Compute the index of the queue for the flow having the given flowHash,
154 * according to the set associative hash approach.
155 *
156 * \param flowHash the hash of the flow 5-tuple
157 * \return the index of the queue for the given flow
158 */
160
161 std::string m_interval; //!< CoDel interval attribute
162 std::string m_target; //!< CoDel target attribute
163 uint32_t m_quantum; //!< Deficit assigned to flows at each round
164 uint32_t m_flows; //!< Number of flow queues
165 uint32_t m_setWays; //!< size of a set of queues (used by set associative hash)
166 uint32_t m_dropBatchSize; //!< Max number of packets dropped from the fat flow
167 uint32_t m_perturbation; //!< hash perturbation value
168 Time m_ceThreshold; //!< Threshold above which to CE mark
169 bool m_enableSetAssociativeHash; //!< whether to enable set associative hash
170 bool m_useL4s; //!< True if L4S is used (ECT1 packets are marked at CE threshold)
171
172 std::list<Ptr<FqCoDelFlow>> m_newFlows; //!< The list of new flows
173 std::list<Ptr<FqCoDelFlow>> m_oldFlows; //!< The list of old flows
174
175 std::map<uint32_t, uint32_t> m_flowsIndices; //!< Map with the index of class for each flow
176 std::map<uint32_t, uint32_t> m_tags; //!< Tags used by set associative hash
177
178 ObjectFactory m_flowFactory; //!< Factory to create a new flow
179 ObjectFactory m_queueDiscFactory; //!< Factory to create a new queue
180};
181
182} // namespace ns3
183
184#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.
QueueDiscClass is the base class for classes that are included in a queue disc.
Definition queue-disc.h:41
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.