-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtbf-queue-disc.h
168 lines (147 loc) · 4.72 KB
/
tbf-queue-disc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
* Copyright (c) 2017 Kungliga Tekniska Högskolan
* 2017 Universita' degli Studi di Napoli Federico II
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* TBF, The Token Bucket Filter Queueing discipline
*
* This implementation is based on linux kernel code by
* Authors: Alexey Kuznetsov, <[email protected]>
* Dmitry Torokhov <[email protected]> - allow attaching inner qdiscs -
* original idea by Martin Devera
*
* Implemented in ns-3 by: Surya Seetharaman <[email protected]>
* Stefano Avallone <[email protected]>
*/
#ifndef TBF_QUEUE_DISC_H
#define TBF_QUEUE_DISC_H
#include "ns3/boolean.h"
#include "ns3/data-rate.h"
#include "ns3/event-id.h"
#include "ns3/nstime.h"
#include "ns3/queue-disc.h"
#include "ns3/random-variable-stream.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/traced-value.h"
namespace ns3
{
/**
* \ingroup traffic-control
*
* \brief A TBF packet queue disc
*/
class TbfQueueDisc : public QueueDisc
{
public:
/**
* \brief Get the type ID.
* \return the object TypeId
*/
static TypeId GetTypeId();
/**
* \brief TbfQueueDisc Constructor
*
* Create a TBF queue disc
*/
TbfQueueDisc();
/**
* \brief Destructor
*
* Destructor
*/
~TbfQueueDisc() override;
/**
* \brief Set the size of the first bucket in bytes.
*
* \param burst The size of first bucket in bytes.
*/
void SetBurst(uint32_t burst);
/**
* \brief Get the size of the first bucket in bytes.
*
* \returns The size of the first bucket in bytes.
*/
uint32_t GetBurst() const;
/**
* \brief Set the size of the second bucket in bytes.
*
* \param mtu The size of second bucket in bytes.
*/
void SetMtu(uint32_t mtu);
/**
* \brief Get the size of the second bucket in bytes.
*
* \returns The size of the second bucket in bytes.
*/
uint32_t GetMtu() const;
/**
* \brief Set the rate of the tokens entering the first bucket.
*
* \param rate The rate of first bucket tokens.
*/
void SetRate(DataRate rate);
/**
* \brief Get the rate of the tokens entering the first bucket.
*
* \returns The rate of first bucket tokens.
*/
DataRate GetRate() const;
/**
* \brief Set the rate of the tokens entering the second bucket.
*
* \param peakRate The rate of second bucket tokens.
*/
void SetPeakRate(DataRate peakRate);
/**
* \brief Get the rate of the tokens entering the second bucket.
*
* \returns The rate of second bucket tokens.
*/
DataRate GetPeakRate() const;
/**
* \brief Get the current number of tokens inside the first bucket in bytes.
*
* \returns The number of first bucket tokens in bytes.
*/
uint32_t GetFirstBucketTokens() const;
/**
* \brief Get the current number of tokens inside the second bucket in bytes.
*
* \returns The number of second bucket tokens in bytes.
*/
uint32_t GetSecondBucketTokens() const;
protected:
/**
* \brief Dispose of the object
*/
void DoDispose() override;
private:
bool DoEnqueue(Ptr<QueueDiscItem> item) override;
Ptr<QueueDiscItem> DoDequeue() override;
bool CheckConfig() override;
void InitializeParams() override;
/* parameters for the TBF Queue Disc */
uint32_t m_burst; //!< Size of first bucket in bytes
uint32_t m_mtu; //!< Size of second bucket in bytes
DataRate m_rate; //!< Rate at which tokens enter the first bucket
DataRate m_peakRate; //!< Rate at which tokens enter the second bucket
/* variables stored by TBF Queue Disc */
TracedValue<uint32_t> m_btokens; //!< Current number of tokens in first bucket
TracedValue<uint32_t> m_ptokens; //!< Current number of tokens in second bucket
Time m_timeCheckPoint; //!< Time check-point
EventId m_id; //!< EventId of the scheduled queue waking event when enough tokens are available
};
} // namespace ns3
#endif /* TBF_QUEUE_DISC_H */