A Discrete-Event Network Simulator
API
fq-codel-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 Universita' degli Studi di Napoli Federico II
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: Pasquale Imputato <p.imputato@gmail.com>
19  * Stefano Avallone <stefano.avallone@unina.it>
20  */
21 
22 #ifndef FQ_CODEL_QUEUE_DISC
23 #define FQ_CODEL_QUEUE_DISC
24 
25 #include "ns3/queue-disc.h"
26 #include "ns3/object-factory.h"
27 #include <list>
28 #include <map>
29 
30 namespace ns3 {
31 
38 class FqCoDelFlow : public QueueDiscClass {
39 public:
44  static TypeId GetTypeId (void);
48  FqCoDelFlow ();
49 
50  virtual ~FqCoDelFlow ();
51 
57  {
61  };
62 
67  void SetDeficit (uint32_t deficit);
72  int32_t GetDeficit (void) const;
77  void IncreaseDeficit (int32_t deficit);
82  void SetStatus (FlowStatus status);
87  FlowStatus GetStatus (void) const;
92  void SetIndex (uint32_t index);
97  uint32_t GetIndex (void) const;
98 
99 private:
100  int32_t m_deficit;
102  uint32_t m_index;
103 };
104 
105 
112 class FqCoDelQueueDisc : public QueueDisc {
113 public:
118  static TypeId GetTypeId (void);
122  FqCoDelQueueDisc ();
123 
124  virtual ~FqCoDelQueueDisc ();
125 
131  void SetQuantum (uint32_t quantum);
132 
138  uint32_t GetQuantum (void) const;
139 
140  // Reasons for dropping packets
141  static constexpr const char* UNCLASSIFIED_DROP = "Unclassified drop";
142  static constexpr const char* OVERLIMIT_DROP = "Overlimit drop";
143 
144 private:
145  virtual bool DoEnqueue (Ptr<QueueDiscItem> item);
146  virtual Ptr<QueueDiscItem> DoDequeue (void);
147  virtual bool CheckConfig (void);
148  virtual void InitializeParams (void);
149 
154  uint32_t FqCoDelDrop (void);
155 
156  bool m_useEcn;
157 
164  uint32_t SetAssociativeHash (uint32_t flowHash);
165 
166  std::string m_interval;
167  std::string m_target;
168  uint32_t m_quantum;
169  uint32_t m_flows;
170  uint32_t m_setWays;
171  uint32_t m_dropBatchSize;
172  uint32_t m_perturbation;
175  bool m_useL4s;
176 
177  std::list<Ptr<FqCoDelFlow> > m_newFlows;
178  std::list<Ptr<FqCoDelFlow> > m_oldFlows;
179 
180  std::map<uint32_t, uint32_t> m_flowsIndices;
181  std::map<uint32_t, uint32_t> m_tags;
182 
185 };
186 
187 } // namespace ns3
188 
189 #endif /* FQ_CODEL_QUEUE_DISC */
190 
void SetDeficit(uint32_t deficit)
Set the deficit for this flow.
A FqCoDel packet queue disc.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
FlowStatus
Used to determine the status of this flow queue.
uint32_t m_quantum
Deficit assigned to flows at each round.
uint32_t FqCoDelDrop(void)
Drop a packet from the head of the queue with the largest current byte count.
uint32_t m_dropBatchSize
Max number of packets dropped from the fat flow.
int32_t GetDeficit(void) const
Get the deficit for this flow.
static TypeId GetTypeId(void)
Get the type ID.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:181
uint32_t m_setWays
size of a set of queues (used by set associative hash)
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
bool m_useL4s
True if L4S is used (ECT1 packets are marked at CE threshold)
FqCoDelFlow()
FqCoDelFlow constructor.
void SetStatus(FlowStatus status)
Set the status for this flow.
A flow queue used by the FqCoDel queue disc.
int32_t m_deficit
the deficit for this flow
uint32_t m_flows
Number of flow queues.
bool m_enableSetAssociativeHash
whether to enable set associative hash
uint32_t SetAssociativeHash(uint32_t flowHash)
Compute the index of the queue for the flow having the given flowHash, according to the set associati...
uint32_t GetQuantum(void) const
Get the quantum value.
uint32_t m_perturbation
hash perturbation value
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
uint32_t GetIndex(void) const
Get the index of this flow.
uint32_t m_index
the index for this flow
Time m_ceThreshold
Threshold above which to CE mark.
static constexpr const char * UNCLASSIFIED_DROP
No packet filter able to classify packet.
QueueDiscClass is the base class for classes that are included in a queue disc.
Definition: queue-disc.h:49
std::list< Ptr< FqCoDelFlow > > m_newFlows
The list of new flows.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string m_interval
CoDel interval attribute.
std::string m_target
CoDel target attribute.
void SetQuantum(uint32_t quantum)
Set the quantum value.
std::map< uint32_t, uint32_t > m_tags
Tags used by set associative hash.
ObjectFactory m_queueDiscFactory
Factory to create a new queue.
static TypeId GetTypeId(void)
Get the type ID.
std::map< uint32_t, uint32_t > m_flowsIndices
Map with the index of class for each flow.
void SetIndex(uint32_t index)
Set the index for this flow.
FqCoDelQueueDisc()
FqCoDelQueueDisc constructor.
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
Instantiate subclasses of ns3::Object.
FlowStatus GetStatus(void) const
Get the status of this flow.
std::list< Ptr< FqCoDelFlow > > m_oldFlows
The list of old flows.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packets.
void IncreaseDeficit(int32_t deficit)
Increase the deficit for this flow.
FlowStatus m_status
the status of this flow
a unique identifier for an interface.
Definition: type-id.h:58
ObjectFactory m_flowFactory
Factory to create a new flow.