A Discrete-Event Network Simulator
API
cobalt-queue-disc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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  * Cobalt, the CoDel - BLUE - Alternate Queueing discipline
18  * Based on linux code.
19  *
20  * Ported to ns-3 by: Vignesh Kannan <vignesh2496@gmail.com>
21  * Harsh Lara <harshapplefan@gmail.com>
22  * Jendaipou Palmei <jendaipoupalmei@gmail.com>
23  * Shefali Gupta <shefaligups11@gmail.com>
24  * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
25  *
26  */
27 
28 #ifndef COBALT_H
29 #define COBALT_H
30 
31 #include "queue-disc.h"
32 
33 #include "ns3/boolean.h"
34 #include "ns3/data-rate.h"
35 #include "ns3/nstime.h"
36 #include "ns3/random-variable-stream.h"
37 #include "ns3/simulator.h"
38 #include "ns3/string.h"
39 #include "ns3/trace-source-accessor.h"
40 #include "ns3/traced-value.h"
41 
42 namespace ns3
43 {
44 
45 #define REC_INV_SQRT_CACHE (16)
46 #define DEFAULT_COBALT_LIMIT 1000
47 
48 class TraceContainer;
49 
60 class CobaltQueueDisc : public QueueDisc
61 {
62  public:
67  static TypeId GetTypeId();
68 
75 
81  ~CobaltQueueDisc() override;
82 
88  Time GetTarget() const;
89 
95  Time GetInterval() const;
96 
102  int64_t GetDropNext() const;
103 
104  static constexpr const char* TARGET_EXCEEDED_DROP =
105  "Target exceeded drop";
106  static constexpr const char* OVERLIMIT_DROP = "Overlimit drop";
107  static constexpr const char* FORCED_MARK =
108  "forcedMark";
109  static constexpr const char* CE_THRESHOLD_EXCEEDED_MARK =
110  "CE threshold exceeded mark";
111 
117  double GetPdrop() const;
118 
127  int64_t AssignStreams(int64_t stream);
128 
135  int64_t Time2CoDel(Time t) const;
136 
137  protected:
141  void DoDispose() override;
142 
143  private:
144  bool DoEnqueue(Ptr<QueueDiscItem> item) override;
145  Ptr<QueueDiscItem> DoDequeue() override;
146  Ptr<const QueueDiscItem> DoPeek() override;
147  bool CheckConfig() override;
148 
152  void InitializeParams() override;
153 
159  void NewtonStep();
160 
170  int64_t ControlLaw(int64_t t);
171 
175  void InvSqrt();
176 
187  void CacheInit();
188 
196  bool CoDelTimeAfter(int64_t a, int64_t b);
197 
204  bool CoDelTimeAfterEq(int64_t a, int64_t b);
205 
210  void CobaltQueueFull(int64_t now);
211 
216  void CobaltQueueEmpty(int64_t now);
217 
226  bool CobaltShouldDrop(Ptr<QueueDiscItem> item, int64_t now);
227 
228  // Common to CoDel and Blue
229  // Maintained by Cobalt
231 
232  // Codel parameters
233  // Maintained by Cobalt
237  uint32_t m_recInvSqrt;
239  0};
240 
241  // Supplied by user
244  bool m_useEcn;
246  bool m_useL4s;
248 
249  // Blue parameters
250  // Maintained by Cobalt
253 
254  // Supplied by user
255  double m_increment;
256  double m_decrement;
257  double m_pDrop;
258 };
259 
260 } // namespace ns3
261 
262 #endif /* COBALT_H */
Cobalt packet queue disc.
Time m_ceThreshold
Threshold above which to CE mark.
uint32_t m_recInvSqrtCache[REC_INV_SQRT_CACHE]
Cache to maintain some initial values of InvSqrt.
Time m_target
target queue delay
static constexpr const char * CE_THRESHOLD_EXCEEDED_MARK
Sojourn time above CE threshold.
bool CheckConfig() override
Check whether the current configuration is correct.
void NewtonStep()
Calculate the reciprocal square root of m_count by using Newton's method http://en....
Time GetTarget() const
Get the target queue delay.
int64_t GetDropNext() const
Get the time for next packet drop while in the dropping state.
void InitializeParams() override
Initialize the queue parameters.
bool CoDelTimeAfterEq(int64_t a, int64_t b)
Check if CoDel time a is successive or equal to b.
void InvSqrt()
Updates the inverse square root.
double GetPdrop() const
Get the drop probability of Blue.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void DoDispose() override
Dispose of the object.
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
Stats m_stats
Cobalt statistics.
double m_increment
increment value for marking probability
void CobaltQueueFull(int64_t now)
Called when the queue becomes full to alter the drop probabilities of Blue.
Time m_interval
sliding minimum time window width
double m_decrement
decrement value for marking probability
bool CobaltShouldDrop(Ptr< QueueDiscItem > item, int64_t now)
Called to decide whether the current packet should be dropped based on decisions taken by Blue and Co...
static TypeId GetTypeId()
Get the type ID.
Ptr< QueueDiscItem > DoDequeue() override
This function actually extracts a packet from the queue disc.
void CacheInit()
There is a big difference in timing between the accurate values placed in the cache and the approxima...
~CobaltQueueDisc() override
Destructor.
static constexpr const char * TARGET_EXCEEDED_DROP
Sojourn time above target.
int64_t Time2CoDel(Time t) const
Return the unsigned 32-bit integer representation of the input Time object.
bool CoDelTimeAfter(int64_t a, int64_t b)
Check if CoDel time a is successive to b.
Time GetInterval() const
Get the interval.
double m_pDrop
Drop Probability.
CobaltQueueDisc()
CobaltQueueDisc Constructor.
int64_t ControlLaw(int64_t t)
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
static constexpr const char * FORCED_MARK
forced marks by Codel on ECN-enabled
Time m_blueThreshold
Threshold to enable blue enhancement.
uint32_t m_recInvSqrt
Reciprocal inverse square root.
Ptr< UniformRandomVariable > m_uv
Rng stream.
uint32_t m_lastUpdateTimeBlue
Blue's last update time for drop probability.
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packet.
TracedValue< bool > m_dropping
True if in dropping state.
Ptr< const QueueDiscItem > DoPeek() override
Return a copy of the next packet the queue disc will extract.
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
bool DoEnqueue(Ptr< QueueDiscItem > item) override
This function actually enqueues a packet into the queue disc.
TracedValue< int64_t > m_dropNext
Time to drop next packet.
void CobaltQueueEmpty(int64_t now)
Called when the queue becomes empty to alter the drop probabilities of Blue.
bool m_useL4s
True if L4S is used (ECT1 packets are marked at CE threshold)
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
#define REC_INV_SQRT_CACHE
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure that keeps the queue disc statistics.
Definition: queue-disc.h:188