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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Ankit Deepak <adadeepak8@gmail.com>
7 * Modified by: S B L Prateek <sblprateek@gmail.com>
8 *
9 */
10
11#ifndef TCP_LEDBAT_H
12#define TCP_LEDBAT_H
13
14#include "tcp-congestion-ops.h"
15
16#include <vector>
17
18namespace ns3
19{
20
21class TcpSocketState;
22
23/**
24 * @ingroup congestionOps
25 *
26 * @brief An implementation of LEDBAT
27 */
28
29class TcpLedbat : public TcpNewReno
30{
31 private:
32 /**
33 * @brief The slowstart types
34 */
36 {
37 DO_NOT_SLOWSTART, //!< Do not Slow Start
38 DO_SLOWSTART, //!< Do NewReno Slow Start
39 };
40
41 /**
42 * @brief The state of LEDBAT. If LEDBAT is not in VALID_OWD state, it falls to
43 * default congestion ops.
44 */
46 {
47 LEDBAT_VALID_OWD = (1 << 1), //!< If valid timestamps are present
48 LEDBAT_CAN_SS = (1 << 3) //!< If LEDBAT allows Slow Start
49 };
50
51 public:
52 /**
53 * @brief Get the type ID.
54 * @return the object TypeId
55 */
56 static TypeId GetTypeId();
57
58 /**
59 * Create an unbound tcp socket.
60 */
61 TcpLedbat();
62
63 /**
64 * @brief Copy constructor
65 * @param sock the object to copy
66 */
67 TcpLedbat(const TcpLedbat& sock);
68
69 /**
70 * @brief Destructor
71 */
72 ~TcpLedbat() override;
73
74 /**
75 * @brief Get the name of the TCP flavour
76 *
77 * @return The name of the TCP
78 */
79 std::string GetName() const override;
80
81 /**
82 * @brief Get information from the acked packet
83 *
84 * @param tcb internal congestion state
85 * @param segmentsAcked count of segments ACKed
86 * @param rtt The estimated rtt
87 */
88 void PktsAcked(Ptr<TcpSocketState> tcb, uint32_t segmentsAcked, const Time& rtt) override;
89
90 // Inherited
91 Ptr<TcpCongestionOps> Fork() override;
92
93 /**
94 * @brief Adjust cwnd following LEDBAT algorithm
95 *
96 * @param tcb internal congestion state
97 * @param segmentsAcked count of segments ACKed
98 */
99 void IncreaseWindow(Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) override;
100
101 /**
102 * @brief Change the Slow Start Capability
103 *
104 * @param doSS Slow Start Option
105 */
106 void SetDoSs(SlowStartType doSS);
107
108 protected:
109 /**
110 * @brief Reduce Congestion
111 *
112 * @param tcb internal congestion state
113 * @param segmentsAcked count of segments ACKed
114 */
115 void CongestionAvoidance(Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) override;
116
117 private:
118 /**
119 * @brief Buffer structure to store delays
120 */
122 {
123 std::vector<uint32_t> buffer; //!< Vector to store the delay
124 size_t min; //!< The index of minimum value
125 };
126
127 /**
128 * @brief Initialise a new buffer
129 *
130 * @param buffer The buffer to be initialised
131 */
132 void InitCircBuf(OwdCircBuf& buffer);
133
134 /// Filter function used by LEDBAT for current delay
136
137 /**
138 * @brief Return the minimum delay of the buffer
139 *
140 * @param b The buffer
141 * @return The minimum delay
142 */
143 static uint32_t MinCircBuf(OwdCircBuf& b);
144
145 /**
146 * @brief Return the value of current delay
147 *
148 * @param filter The filter function
149 * @return The current delay
150 */
152
153 /**
154 * @brief Return the value of base delay
155 *
156 * @return The base delay
157 */
159
160 /**
161 * @brief Add new delay to the buffers
162 *
163 * @param cb The buffer
164 * @param owd The new delay
165 * @param maxlen The maximum permitted length
166 */
167 void AddDelay(OwdCircBuf& cb, uint32_t owd, uint32_t maxlen);
168
169 /**
170 * @brief Update the base delay buffer
171 *
172 * @param owd The delay
173 */
174 void UpdateBaseDelay(uint32_t owd);
175
176 Time m_target; //!< Target Queue Delay
177 double m_gain; //!< GAIN value from RFC
178 SlowStartType m_doSs; //!< Permissible Slow Start State
179 uint32_t m_baseHistoLen; //!< Length of base delay history buffer
180 uint32_t m_noiseFilterLen; //!< Length of current delay buffer
181 Time m_lastRollover; //!< Timestamp of last added delay
182 double m_sndCwndCnt; //!< The congestion window addition parameter
183 OwdCircBuf m_baseHistory; //!< Buffer to store the base delay
184 OwdCircBuf m_noiseFilter; //!< Buffer to store the current delay
185 uint32_t m_flag; //!< LEDBAT Flag
186 uint32_t m_minCwnd; //!< Minimum cWnd value mentioned in RFC 6817
187 double m_allowedIncrease; //!< ALLOWED INCREASE value mentioned in RFC 6817
188};
189
190} // namespace ns3
191
192#endif /* TCP_LEDBAT_H */
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
An implementation of LEDBAT.
Definition tcp-ledbat.h:30
static TypeId GetTypeId()
Get the type ID.
Definition tcp-ledbat.cc:25
SlowStartType m_doSs
Permissible Slow Start State.
Definition tcp-ledbat.h:178
std::string GetName() const override
Get the name of the TCP flavour.
void UpdateBaseDelay(uint32_t owd)
Update the base delay buffer.
uint32_t m_minCwnd
Minimum cWnd value mentioned in RFC 6817.
Definition tcp-ledbat.h:186
void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
Adjust cwnd following LEDBAT algorithm.
uint32_t m_flag
LEDBAT Flag.
Definition tcp-ledbat.h:185
double m_allowedIncrease
ALLOWED INCREASE value mentioned in RFC 6817.
Definition tcp-ledbat.h:187
uint32_t BaseDelay()
Return the value of base delay.
void SetDoSs(SlowStartType doSS)
Change the Slow Start Capability.
Definition tcp-ledbat.cc:71
double m_gain
GAIN value from RFC.
Definition tcp-ledbat.h:177
State
The state of LEDBAT.
Definition tcp-ledbat.h:46
@ LEDBAT_CAN_SS
If LEDBAT allows Slow Start.
Definition tcp-ledbat.h:48
@ LEDBAT_VALID_OWD
If valid timestamps are present.
Definition tcp-ledbat.h:47
Ptr< TcpCongestionOps > Fork() override
Copy the congestion control algorithm across sockets.
double m_sndCwndCnt
The congestion window addition parameter.
Definition tcp-ledbat.h:182
void AddDelay(OwdCircBuf &cb, uint32_t owd, uint32_t maxlen)
Add new delay to the buffers.
OwdCircBuf m_noiseFilter
Buffer to store the current delay.
Definition tcp-ledbat.h:184
SlowStartType
The slowstart types.
Definition tcp-ledbat.h:36
@ DO_NOT_SLOWSTART
Do not Slow Start.
Definition tcp-ledbat.h:37
@ DO_SLOWSTART
Do NewReno Slow Start.
Definition tcp-ledbat.h:38
void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt) override
Get information from the acked packet.
TcpLedbat()
Create an unbound tcp socket.
Definition tcp-ledbat.cc:85
~TcpLedbat() override
Destructor.
void CongestionAvoidance(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
Reduce Congestion.
void InitCircBuf(OwdCircBuf &buffer)
Initialise a new buffer.
Definition tcp-ledbat.cc:97
static uint32_t MinCircBuf(OwdCircBuf &b)
Return the minimum delay of the buffer.
Time m_target
Target Queue Delay.
Definition tcp-ledbat.h:176
Time m_lastRollover
Timestamp of last added delay.
Definition tcp-ledbat.h:181
uint32_t m_baseHistoLen
Length of base delay history buffer.
Definition tcp-ledbat.h:179
uint32_t m_noiseFilterLen
Length of current delay buffer.
Definition tcp-ledbat.h:180
uint32_t(* FilterFunction)(OwdCircBuf &)
Filter function used by LEDBAT for current delay.
Definition tcp-ledbat.h:135
OwdCircBuf m_baseHistory
Buffer to store the base delay.
Definition tcp-ledbat.h:183
uint32_t CurrentDelay(FilterFunction filter)
Return the value of current delay.
Data structure that records the congestion state of a connection.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
a unique identifier for an interface.
Definition type-id.h:50
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Buffer structure to store delays.
Definition tcp-ledbat.h:122
size_t min
The index of minimum value.
Definition tcp-ledbat.h:124
std::vector< uint32_t > buffer
Vector to store the delay.
Definition tcp-ledbat.h:123