A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 "ns3/boolean.h"
32#include "ns3/data-rate.h"
33#include "ns3/event-id.h"
34#include "ns3/nstime.h"
35#include "ns3/queue-disc.h"
36#include "ns3/random-variable-stream.h"
37#include "ns3/trace-source-accessor.h"
38#include "ns3/traced-value.h"
39
40namespace ns3
41{
42
48class TbfQueueDisc : public QueueDisc
49{
50 public:
55 static TypeId GetTypeId();
56
63
69 ~TbfQueueDisc() override;
70
76 void SetBurst(uint32_t burst);
77
83 uint32_t GetBurst() const;
84
90 void SetMtu(uint32_t mtu);
91
97 uint32_t GetMtu() const;
98
104 void SetRate(DataRate rate);
105
111 DataRate GetRate() const;
112
118 void SetPeakRate(DataRate peakRate);
119
125 DataRate GetPeakRate() const;
126
133
140
141 protected:
145 void DoDispose() override;
146
147 private:
148 bool DoEnqueue(Ptr<QueueDiscItem> item) override;
149 Ptr<QueueDiscItem> DoDequeue() override;
150 bool CheckConfig() override;
151 void InitializeParams() override;
152
153 /* parameters for the TBF Queue Disc */
158
159 /* variables stored by TBF Queue Disc */
164};
165
166} // namespace ns3
167
168#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:78
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
Trace classes with value semantics.
Definition: traced-value.h:116
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.