A Discrete-Event Network Simulator
API
cobalt-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) 2019 NITK Surathkal
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  * Cobalt, the CoDel - BLUE - Alternate Queueing discipline
19  * Based on linux code.
20  *
21  * Ported to ns-3 by: Vignesh Kannan <vignesh2496@gmail.com>
22  * Harsh Lara <harshapplefan@gmail.com>
23  * Jendaipou Palmei <jendaipoupalmei@gmail.com>
24  * Shefali Gupta <shefaligups11@gmail.com>
25  * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
26  *
27  */
28 
29 #ifndef COBALT_H
30 #define COBALT_H
31 
32 #include "ns3/queue-disc.h"
33 #include "ns3/nstime.h"
34 #include "ns3/boolean.h"
35 #include "ns3/data-rate.h"
36 #include "ns3/simulator.h"
37 #include "ns3/string.h"
38 #include "ns3/traced-value.h"
39 #include "ns3/random-variable-stream.h"
40 #include "ns3/trace-source-accessor.h"
41 
42 namespace ns3 {
43 
44 #define REC_INV_SQRT_CACHE (16)
45 #define DEFAULT_COBALT_LIMIT 1000
46 
47 class TraceContainer;
48 
59 class CobaltQueueDisc : public QueueDisc
60 {
61 public:
66  static TypeId GetTypeId (void);
67 
73  CobaltQueueDisc ();
74 
80  virtual ~CobaltQueueDisc ();
81 
87  Time GetTarget (void) const;
88 
94  Time GetInterval (void) const;
95 
101  int64_t GetDropNext (void) const;
102 
103  static constexpr const char* TARGET_EXCEEDED_DROP = "Target exceeded drop";
104  static constexpr const char* OVERLIMIT_DROP = "Overlimit drop";
105  static constexpr const char* FORCED_MARK = "forcedMark";
106  static constexpr const char* CE_THRESHOLD_EXCEEDED_MARK = "CE threshold exceeded mark";
107 
113  double GetPdrop () const;
114 
123  int64_t AssignStreams (int64_t stream);
124 
131  int64_t Time2CoDel (Time t) const;
132 
133 protected:
137  virtual void DoDispose (void);
138 
139 private:
140  virtual bool DoEnqueue (Ptr<QueueDiscItem> item);
141  virtual Ptr<QueueDiscItem> DoDequeue (void);
142  virtual Ptr<const QueueDiscItem> DoPeek (void);
143  virtual bool CheckConfig (void);
144 
148  virtual void InitializeParams (void);
149 
155  void NewtonStep (void);
156 
166  int64_t ControlLaw (int64_t t);
167 
168  void InvSqrt (void);
169 
180  void CacheInit (void);
181 
189  bool CoDelTimeAfter (int64_t a, int64_t b);
190 
197  bool CoDelTimeAfterEq (int64_t a, int64_t b);
198 
203  void CobaltQueueFull (int64_t now);
204 
209  void CobaltQueueEmpty (int64_t now);
210 
217  bool CobaltShouldDrop (Ptr<QueueDiscItem> item, int64_t now);
218 
219  // Common to CoDel and Blue
220  // Maintained by Cobalt
221  Stats m_stats;
222 
223  // Codel parameters
224  // Maintained by Cobalt
228  uint32_t m_recInvSqrt;
230 
231  // Supplied by user
234  bool m_useEcn;
236  bool m_useL4s;
238 
239  // Blue parameters
240  // Maintained by Cobalt
243 
244  // Supplied by user
245  double m_increment;
246  double m_decrement;
247  double m_pDrop;
248 
249 };
250 
251 } // namespace ns3
252 
253 #endif /* COBALT_H */
bool CoDelTimeAfter(int64_t a, int64_t b)
Check if CoDel time a is successive to b.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
CobaltQueueDisc()
CobaltQueueDisc Constructor.
double m_pDrop
Drop Probability.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
static TypeId GetTypeId(void)
Get the type ID.
bool CoDelTimeAfterEq(int64_t a, int64_t b)
Check if CoDel time a is successive or equal to b.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:181
void CobaltQueueFull(int64_t now)
Called when the queue becomes full to alter the drop probabilities of Blue.
TracedValue< int64_t > m_dropNext
Time to drop next packet.
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packet.
void NewtonStep(void)
Calculate the reciprocal square root of m_count by using Newton&#39;s method http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Iterative_methods_for_reciprocal_square_roots m_recInvSqrt (new) = (m_recInvSqrt (old) / 2) * (3 - m_count * m_recInvSqrt^2)
virtual ~CobaltQueueDisc()
Destructor.
int64_t ControlLaw(int64_t t)
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
void CobaltQueueEmpty(int64_t now)
Called when the queue becomes empty to alter the drop probabilities of Blue.
static constexpr const char * FORCED_MARK
forced marks by Codel on ECN-enabled
double m_increment
increment value for marking probability
Cobalt packet queue disc.
bool m_useL4s
True if L4S is used (ECT1 packets are marked at CE threshold)
Stats m_stats
Cobalt statistics.
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
static constexpr const char * TARGET_EXCEEDED_DROP
Sojourn time above target.
bool m_useEcn
True if ECN is used (packets are marked instead of being dropped)
Time GetTarget(void) const
Get the target queue delay.
double GetPdrop() const
Get the drop probability of Blue.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< UniformRandomVariable > m_uv
Rng stream.
TracedValue< bool > m_dropping
True if in dropping state.
int64_t GetDropNext(void) const
Get the time for next packet drop while in the dropping state.
virtual void DoDispose(void)
Dispose of the object.
int64_t Time2CoDel(Time t) const
Return the unsigned 32-bit integer representation of the input Time object.
Time GetInterval(void) const
Get the interval.
uint32_t m_recInvSqrtCache[REC_INV_SQRT_CACHE]
Cache to maintain some initial values of InvSqrt.
virtual Ptr< const QueueDiscItem > DoPeek(void)
Return a copy of the next packet the queue disc will extract.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
static constexpr const char * CE_THRESHOLD_EXCEEDED_MARK
Sojourn time above CE threshold.
Time m_target
target queue delay
virtual void InitializeParams(void)
Initialize the queue parameters.
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...
double m_decrement
decrement value for marking probability
uint32_t m_lastUpdateTimeBlue
Blue&#39;s last update time for drop probability.
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
Time m_ceThreshold
Threshold above which to CE mark.
#define REC_INV_SQRT_CACHE
uint32_t m_recInvSqrt
Reciprocal inverse square root.
a unique identifier for an interface.
Definition: type-id.h:58
Time m_blueThreshold
Threshold to enable blue enhancement.
void CacheInit(void)
There is a big difference in timing between the accurate values placed in the cache and the approxima...
Time m_interval
sliding minimum time window width