A Discrete-Event Network Simulator
API
tbf-queue-disc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Kungliga Tekniska Högskolan
3  * 2017 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  * TBF, The Token Bucket Filter Queueing discipline
19  *
20  * This implementation is based on linux kernel code by
21  * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
22  * Dmitry Torokhov <dtor@mail.ru> - allow attaching inner qdiscs -
23  * original idea by Martin Devera
24  *
25  * Implemented in ns-3 by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
26  * Stefano Avallone <stavallo@unina.it>
27  */
28 #ifndef TBF_QUEUE_DISC_H
29 #define TBF_QUEUE_DISC_H
30 
31 #include "queue-disc.h"
32 
33 #include "ns3/boolean.h"
34 #include "ns3/data-rate.h"
35 #include "ns3/event-id.h"
36 #include "ns3/nstime.h"
37 #include "ns3/random-variable-stream.h"
38 #include "ns3/trace-source-accessor.h"
39 #include "ns3/traced-value.h"
40 
41 namespace ns3
42 {
43 
49 class TbfQueueDisc : public QueueDisc
50 {
51  public:
56  static TypeId GetTypeId();
57 
63  TbfQueueDisc();
64 
70  ~TbfQueueDisc() override;
71 
77  void SetBurst(uint32_t burst);
78 
84  uint32_t GetBurst() const;
85 
91  void SetMtu(uint32_t mtu);
92 
98  uint32_t GetMtu() const;
99 
105  void SetRate(DataRate rate);
106 
112  DataRate GetRate() const;
113 
119  void SetPeakRate(DataRate peakRate);
120 
126  DataRate GetPeakRate() const;
127 
133  uint32_t GetFirstBucketTokens() const;
134 
140  uint32_t GetSecondBucketTokens() const;
141 
142  protected:
146  void DoDispose() override;
147 
148  private:
149  bool DoEnqueue(Ptr<QueueDiscItem> item) override;
150  Ptr<QueueDiscItem> DoDequeue() override;
151  bool CheckConfig() override;
152  void InitializeParams() override;
153 
154  /* parameters for the TBF Queue Disc */
155  uint32_t m_burst;
156  uint32_t m_mtu;
159 
160  /* variables stored by TBF Queue Disc */
165 };
166 
167 } // namespace ns3
168 
169 #endif /* TBF_QUEUE_DISC_H */
Class for representing data rates.
Definition: data-rate.h:89
An identifier for simulation events.
Definition: event-id.h:55
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
A TBF packet queue disc.
DataRate GetRate() const
Get the rate of the tokens entering the first bucket.
TbfQueueDisc()
TbfQueueDisc Constructor.
void SetBurst(uint32_t burst)
Set the size of the first bucket in bytes.
TracedValue< uint32_t > m_ptokens
Current number of tokens in second bucket.
Ptr< QueueDiscItem > DoDequeue() override
This function actually extracts a packet from the queue disc.
Time m_timeCheckPoint
Time check-point.
uint32_t m_mtu
Size of second bucket in bytes.
~TbfQueueDisc() override
Destructor.
void DoDispose() override
Dispose of the object.
bool DoEnqueue(Ptr< QueueDiscItem > item) override
This function actually enqueues a packet into the queue disc.
void SetPeakRate(DataRate peakRate)
Set the rate of the tokens entering the second bucket.
uint32_t m_burst
Size of first bucket in bytes.
DataRate m_rate
Rate at which tokens enter the first bucket.
EventId m_id
EventId of the scheduled queue waking event when enough tokens are available.
void InitializeParams() override
Initialize parameters (if any) before the first packet is enqueued.
DataRate GetPeakRate() const
Get the rate of the tokens entering the second bucket.
void SetRate(DataRate rate)
Set the rate of the tokens entering the first bucket.
void SetMtu(uint32_t mtu)
Set the size of the second bucket in bytes.
uint32_t GetBurst() const
Get the size of the first bucket in bytes.
uint32_t GetFirstBucketTokens() const
Get the current number of tokens inside the first bucket in bytes.
static TypeId GetTypeId()
Get the type ID.
bool CheckConfig() override
Check whether the current configuration is correct.
uint32_t GetSecondBucketTokens() const
Get the current number of tokens inside the second bucket in bytes.
uint32_t GetMtu() const
Get the size of the second bucket in bytes.
TracedValue< uint32_t > m_btokens
Current number of tokens in first bucket.
DataRate m_peakRate
Rate at which tokens enter the second bucket.
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.