A Discrete-Event Network Simulator
API
tbf-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) 2017 Kungliga Tekniska Högskolan
4  * 2017 Universita' degli Studi di Napoli Federico II
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * TBF, The Token Bucket Filter Queueing discipline
20  *
21  * This implementation is based on linux kernel code by
22  * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
23  * Dmitry Torokhov <dtor@mail.ru> - allow attaching inner qdiscs -
24  * original idea by Martin Devera
25  *
26  * Implemented in ns-3 by: Surya Seetharaman <suryaseetharaman.9@gmail.com>
27  * Stefano Avallone <stavallo@unina.it>
28  */
29 #ifndef TBF_QUEUE_DISC_H
30 #define TBF_QUEUE_DISC_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/random-variable-stream.h"
37 #include "ns3/traced-value.h"
38 #include "ns3/trace-source-accessor.h"
39 #include "ns3/event-id.h"
40 
41 namespace ns3 {
42 
48 class TbfQueueDisc : public QueueDisc
49 {
50 public:
51 
56  static TypeId GetTypeId (void);
57 
63  TbfQueueDisc ();
64 
70  virtual ~TbfQueueDisc ();
71 
77  void SetBurst (uint32_t burst);
78 
84  uint32_t GetBurst (void) const;
85 
91  void SetMtu (uint32_t mtu);
92 
98  uint32_t GetMtu (void) const;
99 
105  void SetRate (DataRate rate);
106 
112  DataRate GetRate (void) const;
113 
119  void SetPeakRate (DataRate peakRate);
120 
126  DataRate GetPeakRate (void) const;
127 
133  uint32_t GetFirstBucketTokens (void) const;
134 
140  uint32_t GetSecondBucketTokens (void) const;
141 
142 protected:
146  virtual void DoDispose (void);
147 
148 private:
149 
150  virtual bool DoEnqueue (Ptr<QueueDiscItem> item);
151  virtual Ptr<QueueDiscItem> DoDequeue (void);
152  virtual bool CheckConfig (void);
153  virtual void InitializeParams (void);
154 
155  /* parameters for the TBF Queue Disc */
156  uint32_t m_burst;
157  uint32_t m_mtu;
160 
161  /* variables stored by TBF Queue Disc */
166 
167 };
168 
169 } // namespace ns3
170 
171 #endif /* TBF_QUEUE_DISC_H */
ns3::TbfQueueDisc::TbfQueueDisc
TbfQueueDisc()
TbfQueueDisc Constructor.
Definition: tbf-queue-disc.cc:93
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::TbfQueueDisc::DoEnqueue
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
This function actually enqueues a packet into the queue disc.
Definition: tbf-queue-disc.cc:182
ns3::TbfQueueDisc::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: tbf-queue-disc.cc:46
ns3::TbfQueueDisc::CheckConfig
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
Definition: tbf-queue-disc.cc:295
ns3::EventId
An identifier for simulation events.
Definition: event-id.h:54
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::QueueDisc
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:181
ns3::TbfQueueDisc::m_burst
uint32_t m_burst
Size of first bucket in bytes.
Definition: tbf-queue-disc.h:156
ns3::TbfQueueDisc::GetMtu
uint32_t GetMtu(void) const
Get the size of the second bucket in bytes.
Definition: tbf-queue-disc.cc:133
ns3::TbfQueueDisc::SetMtu
void SetMtu(uint32_t mtu)
Set the size of the second bucket in bytes.
Definition: tbf-queue-disc.cc:126
ns3::TbfQueueDisc::SetBurst
void SetBurst(uint32_t burst)
Set the size of the first bucket in bytes.
Definition: tbf-queue-disc.cc:112
ns3::TbfQueueDisc::DoDequeue
virtual Ptr< QueueDiscItem > DoDequeue(void)
This function actually extracts a packet from the queue disc.
Definition: tbf-queue-disc.cc:197
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::DataRate
Class for representing data rates.
Definition: data-rate.h:89
ns3::TbfQueueDisc::m_peakRate
DataRate m_peakRate
Rate at which tokens enter the second bucket.
Definition: tbf-queue-disc.h:159
ns3::TbfQueueDisc::m_ptokens
TracedValue< uint32_t > m_ptokens
Current number of tokens in second bucket.
Definition: tbf-queue-disc.h:163
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::TbfQueueDisc::DoDispose
virtual void DoDispose(void)
Dispose of the object.
Definition: tbf-queue-disc.cc:105
ns3::TbfQueueDisc::~TbfQueueDisc
virtual ~TbfQueueDisc()
Destructor.
Definition: tbf-queue-disc.cc:99
ns3::TbfQueueDisc::GetSecondBucketTokens
uint32_t GetSecondBucketTokens(void) const
Get the current number of tokens inside the second bucket in bytes.
Definition: tbf-queue-disc.cc:175
ns3::TbfQueueDisc::SetRate
void SetRate(DataRate rate)
Set the rate of the tokens entering the first bucket.
Definition: tbf-queue-disc.cc:140
ns3::TbfQueueDisc::GetFirstBucketTokens
uint32_t GetFirstBucketTokens(void) const
Get the current number of tokens inside the first bucket in bytes.
Definition: tbf-queue-disc.cc:168
ns3::TbfQueueDisc::m_rate
DataRate m_rate
Rate at which tokens enter the first bucket.
Definition: tbf-queue-disc.h:158
ns3::TbfQueueDisc::m_btokens
TracedValue< uint32_t > m_btokens
Current number of tokens in first bucket.
Definition: tbf-queue-disc.h:162
ns3::TracedValue< uint32_t >
ns3::TbfQueueDisc::m_mtu
uint32_t m_mtu
Size of second bucket in bytes.
Definition: tbf-queue-disc.h:157
ns3::TbfQueueDisc::GetPeakRate
DataRate GetPeakRate(void) const
Get the rate of the tokens entering the second bucket.
Definition: tbf-queue-disc.cc:161
ns3::TbfQueueDisc::m_id
EventId m_id
EventId of the scheduled queue waking event when enough tokens are available.
Definition: tbf-queue-disc.h:165
ns3::TbfQueueDisc::SetPeakRate
void SetPeakRate(DataRate peakRate)
Set the rate of the tokens entering the second bucket.
Definition: tbf-queue-disc.cc:154
ns3::TbfQueueDisc::GetRate
DataRate GetRate(void) const
Get the rate of the tokens entering the first bucket.
Definition: tbf-queue-disc.cc:147
ns3::TbfQueueDisc::m_timeCheckPoint
Time m_timeCheckPoint
Time check-point.
Definition: tbf-queue-disc.h:164
ns3::TbfQueueDisc::GetBurst
uint32_t GetBurst(void) const
Get the size of the first bucket in bytes.
Definition: tbf-queue-disc.cc:119
ns3::TbfQueueDisc::InitializeParams
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
Definition: tbf-queue-disc.cc:372
ns3::TbfQueueDisc
A TBF packet queue disc.
Definition: tbf-queue-disc.h:49