A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-ledbat.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 NITK Surathkal
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Ankit Deepak <adadeepak8@gmail.com>
18 *
19 */
20
21#ifndef TCP_LEDBAT_H
22#define TCP_LEDBAT_H
23
24#include "tcp-congestion-ops.h"
25
26#include <vector>
27
28namespace ns3
29{
30
31class TcpSocketState;
32
33/**
34 * \ingroup congestionOps
35 *
36 * \brief An implementation of LEDBAT
37 */
38
39class TcpLedbat : public TcpNewReno
40{
41 private:
42 /**
43 * \brief The slowstart types
44 */
46 {
47 DO_NOT_SLOWSTART, //!< Do not Slow Start
48 DO_SLOWSTART, //!< Do NewReno Slow Start
49 };
50
51 /**
52 * \brief The state of LEDBAT. If LEDBAT is not in VALID_OWD state, it falls to
53 * default congestion ops.
54 */
56 {
57 LEDBAT_VALID_OWD = (1 << 1), //!< If valid timestamps are present
58 LEDBAT_CAN_SS = (1 << 3) //!< If LEDBAT allows Slow Start
59 };
60
61 public:
62 /**
63 * \brief Get the type ID.
64 * \return the object TypeId
65 */
66 static TypeId GetTypeId();
67
68 /**
69 * Create an unbound tcp socket.
70 */
71 TcpLedbat();
72
73 /**
74 * \brief Copy constructor
75 * \param sock the object to copy
76 */
77 TcpLedbat(const TcpLedbat& sock);
78
79 /**
80 * \brief Destructor
81 */
82 ~TcpLedbat() override;
83
84 /**
85 * \brief Get the name of the TCP flavour
86 *
87 * \return The name of the TCP
88 */
89 std::string GetName() const override;
90
91 /**
92 * \brief Get information from the acked packet
93 *
94 * \param tcb internal congestion state
95 * \param segmentsAcked count of segments ACKed
96 * \param rtt The estimated rtt
97 */
98 void PktsAcked(Ptr<TcpSocketState> tcb, uint32_t segmentsAcked, const Time& rtt) override;
99
100 // Inherited
101 Ptr<TcpCongestionOps> Fork() override;
102
103 /**
104 * \brief Adjust cwnd following LEDBAT algorithm
105 *
106 * \param tcb internal congestion state
107 * \param segmentsAcked count of segments ACKed
108 */
109 void IncreaseWindow(Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) override;
110
111 /**
112 * \brief Change the Slow Start Capability
113 *
114 * \param doSS Slow Start Option
115 */
116 void SetDoSs(SlowStartType doSS);
117
118 protected:
119 /**
120 * \brief Reduce Congestion
121 *
122 * \param tcb internal congestion state
123 * \param segmentsAcked count of segments ACKed
124 */
125 void CongestionAvoidance(Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) override;
126
127 private:
128 /**
129 *\brief Buffer structure to store delays
130 */
132 {
133 std::vector<uint32_t> buffer; //!< Vector to store the delay
134 uint32_t min; //!< The index of minimum value
135 };
136
137 /**
138 * \brief Initialise a new buffer
139 *
140 * \param buffer The buffer to be initialised
141 */
142 void InitCircBuf(OwdCircBuf& buffer);
143
144 /// Filter function used by LEDBAT for current delay
146
147 /**
148 * \brief Return the minimum delay of the buffer
149 *
150 * \param b The buffer
151 * \return The minimum delay
152 */
153 static uint32_t MinCircBuf(OwdCircBuf& b);
154
155 /**
156 * \brief Return the value of current delay
157 *
158 * \param filter The filter function
159 * \return The current delay
160 */
162
163 /**
164 * \brief Return the value of base delay
165 *
166 * \return The base delay
167 */
169
170 /**
171 * \brief Add new delay to the buffers
172 *
173 * \param cb The buffer
174 * \param owd The new delay
175 * \param maxlen The maximum permitted length
176 */
177 void AddDelay(OwdCircBuf& cb, uint32_t owd, uint32_t maxlen);
178
179 /**
180 * \brief Update the base delay buffer
181 *
182 * \param owd The delay
183 */
184 void UpdateBaseDelay(uint32_t owd);
185
186 Time m_target; //!< Target Queue Delay
187 double m_gain; //!< GAIN value from RFC
188 SlowStartType m_doSs; //!< Permissible Slow Start State
189 uint32_t m_baseHistoLen; //!< Length of base delay history buffer
190 uint32_t m_noiseFilterLen; //!< Length of current delay buffer
191 uint64_t m_lastRollover; //!< Timestamp of last added delay
192 int32_t m_sndCwndCnt; //!< The congestion window addition parameter
193 OwdCircBuf m_baseHistory; //!< Buffer to store the base delay
194 OwdCircBuf m_noiseFilter; //!< Buffer to store the current delay
195 uint32_t m_flag; //!< LEDBAT Flag
196 uint32_t m_minCwnd; //!< Minimum cWnd value mentioned in RFC 6817
197};
198
199} // namespace ns3
200
201#endif /* TCP_LEDBAT_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
An implementation of LEDBAT.
Definition: tcp-ledbat.h:40
static TypeId GetTypeId()
Get the type ID.
Definition: tcp-ledbat.cc:35
SlowStartType m_doSs
Permissible Slow Start State.
Definition: tcp-ledbat.h:188
std::string GetName() const override
Get the name of the TCP flavour.
Definition: tcp-ledbat.cc:144
void UpdateBaseDelay(uint32_t owd)
Update the base delay buffer.
Definition: tcp-ledbat.cc:274
uint32_t m_minCwnd
Minimum cWnd value mentioned in RFC 6817.
Definition: tcp-ledbat.h:196
void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
Adjust cwnd following LEDBAT algorithm.
Definition: tcp-ledbat.cc:178
uint32_t m_flag
LEDBAT Flag.
Definition: tcp-ledbat.h:195
uint32_t BaseDelay()
Return the value of base delay.
Definition: tcp-ledbat.cc:171
void SetDoSs(SlowStartType doSS)
Change the Slow Start Capability.
Definition: tcp-ledbat.cc:76
double m_gain
GAIN value from RFC.
Definition: tcp-ledbat.h:187
State
The state of LEDBAT.
Definition: tcp-ledbat.h:56
@ LEDBAT_CAN_SS
If LEDBAT allows Slow Start.
Definition: tcp-ledbat.h:58
@ LEDBAT_VALID_OWD
If valid timestamps are present.
Definition: tcp-ledbat.h:57
Ptr< TcpCongestionOps > Fork() override
Copy the congestion control algorithm across sockets.
Definition: tcp-ledbat.cc:138
void AddDelay(OwdCircBuf &cb, uint32_t owd, uint32_t maxlen)
Add new delay to the buffers.
Definition: tcp-ledbat.cc:242
OwdCircBuf m_noiseFilter
Buffer to store the current delay.
Definition: tcp-ledbat.h:194
SlowStartType
The slowstart types.
Definition: tcp-ledbat.h:46
@ DO_NOT_SLOWSTART
Do not Slow Start.
Definition: tcp-ledbat.h:47
@ DO_SLOWSTART
Do NewReno Slow Start.
Definition: tcp-ledbat.h:48
void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt) override
Get information from the acked packet.
Definition: tcp-ledbat.cc:304
TcpLedbat()
Create an unbound tcp socket.
Definition: tcp-ledbat.cc:90
~TcpLedbat() override
Destructor.
Definition: tcp-ledbat.cc:132
void CongestionAvoidance(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
Reduce Congestion.
Definition: tcp-ledbat.cc:197
void InitCircBuf(OwdCircBuf &buffer)
Initialise a new buffer.
Definition: tcp-ledbat.cc:108
static uint32_t MinCircBuf(OwdCircBuf &b)
Return the minimum delay of the buffer.
Definition: tcp-ledbat.cc:150
Time m_target
Target Queue Delay.
Definition: tcp-ledbat.h:186
int32_t m_sndCwndCnt
The congestion window addition parameter.
Definition: tcp-ledbat.h:192
uint32_t m_baseHistoLen
Length of base delay history buffer.
Definition: tcp-ledbat.h:189
uint32_t m_noiseFilterLen
Length of current delay buffer.
Definition: tcp-ledbat.h:190
uint64_t m_lastRollover
Timestamp of last added delay.
Definition: tcp-ledbat.h:191
uint32_t(* FilterFunction)(OwdCircBuf &)
Filter function used by LEDBAT for current delay.
Definition: tcp-ledbat.h:145
OwdCircBuf m_baseHistory
Buffer to store the base delay.
Definition: tcp-ledbat.h:193
uint32_t CurrentDelay(FilterFunction filter)
Return the value of current delay.
Definition: tcp-ledbat.cc:164
The NewReno implementation.
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.
Buffer structure to store delays.
Definition: tcp-ledbat.h:132
uint32_t min
The index of minimum value.
Definition: tcp-ledbat.h:134
std::vector< uint32_t > buffer
Vector to store the delay.
Definition: tcp-ledbat.h:133