A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-cubic.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Natale Patriciello <natale.patriciello@gmail.com>
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 */
18
19#ifndef TCPCUBIC_H
20#define TCPCUBIC_H
21
22#include "tcp-congestion-ops.h"
23#include "tcp-socket-base.h"
24
25namespace ns3
26{
27
28/**
29 * \brief The Cubic Congestion Control Algorithm
30 *
31 * TCP Cubic is a protocol that enhances the fairness property
32 * of Bic while retaining its scalability and stability. The main feature is
33 * that the window growth function is defined in real time in order to be independent
34 * from the RTT. More specifically, the congestion window of Cubic is determined
35 * by a function of the elapsed time from the last window reduction.
36 *
37 * The Cubic code is quite similar to that of Bic.
38 * The main difference is located in the method Update, an edit
39 * necessary for satisfying the Cubic window growth, that can be tuned with
40 * the attribute C (the Cubic scaling factor).
41 *
42 * Following the Linux implementation, we included the Hybrid Slow Start,
43 * that effectively prevents the overshooting of slow start
44 * while maintaining a full utilization of the network. This new type of slow
45 * start can be disabled through the HyStart attribute.
46 *
47 * CUBIC TCP is implemented and used by default in Linux kernels 2.6.19
48 * and above; this version follows the implementation in Linux 3.14, which
49 * slightly differ from the CUBIC paper. It also features HyStart.
50 *
51 * Home page:
52 * https://web.archive.org/web/20080607093013/http://netsrv.csc.ncsu.edu/twiki/bin/view/Main/BIC
53 * The work starts from the implementation of CUBIC TCP in
54 * Sangtae Ha, Injong Rhee and Lisong Xu,
55 * "CUBIC: A New TCP-Friendly High-Speed TCP Variant"
56 * in ACM SIGOPS Operating System Review, July 2008.
57 * Available from:
58 * https://web.archive.org/web/20160505194415/http://netsrv.csc.ncsu.edu/export/cubic_a_new_tcp_2008.pdf
59 *
60 * CUBIC integrates a new slow start algorithm, called HyStart.
61 * The details of HyStart are presented in
62 * Sangtae Ha and Injong Rhee,
63 * "Taming the Elephants: New TCP Slow Start", NCSU TechReport 2008.
64 * Available from:
65 * https://web.archive.org/web/20160528233754/http://netsrv.csc.ncsu.edu/export/hystart_techreport_2008.pdf
66 *
67 * More information on this implementation: http://dl.acm.org/citation.cfm?id=2756518
68 */
70{
71 public:
72 /**
73 * \brief Values to detect the Slow Start mode of HyStart
74 */
76 {
77 PACKET_TRAIN = 1, //!< Detection by trains of packet
78 DELAY = 2, //!< Detection by delay value
79 BOTH = 3, //!< Detection by both
80 };
81
82 /**
83 * \brief Get the type ID.
84 * \return the object TypeId
85 */
86 static TypeId GetTypeId();
87
88 TcpCubic();
89
90 /**
91 * Copy constructor
92 * \param sock Socket to copy
93 */
94 TcpCubic(const TcpCubic& sock);
95
96 std::string GetName() const override;
97 void PktsAcked(Ptr<TcpSocketState> tcb, uint32_t segmentsAcked, const Time& rtt) override;
98 void IncreaseWindow(Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) override;
99 uint32_t GetSsThresh(Ptr<const TcpSocketState> tcb, uint32_t bytesInFlight) override;
101 const TcpSocketState::TcpCongState_t newState) override;
102
103 Ptr<TcpCongestionOps> Fork() override;
104
105 private:
106 bool m_fastConvergence; //!< Enable or disable fast convergence algorithm
107 bool m_tcpFriendliness; //!< Enable or disable TCP-friendliness heuristic
108 double m_beta; //!< Beta for cubic multiplicative increase
109
110 bool m_hystart; //!< Enable or disable HyStart algorithm
111 HybridSSDetectionMode m_hystartDetect; //!< Detect way for HyStart algorithm
112 uint32_t m_hystartLowWindow; //!< Lower bound cWnd for hybrid slow start (segments)
113 Time m_hystartAckDelta; //!< Spacing between ack's indicating train
114 Time m_hystartDelayMin; //!< Minimum time for hystart algorithm
115 Time m_hystartDelayMax; //!< Maximum time for hystart algorithm
116 uint8_t m_hystartMinSamples; //!< Number of delay samples for detecting the increase of delay
117
118 uint32_t m_initialCwnd; //!< Initial cWnd
119 uint8_t m_cntClamp; //!< Modulo of the (avoided) float division for cWnd
120
121 double m_c; //!< Cubic Scaling factor
122
123 // Cubic parameters
124 uint32_t m_cWndCnt; //!< cWnd integer-to-float counter
125 uint32_t m_lastMaxCwnd; //!< Last maximum cWnd
126 uint32_t m_bicOriginPoint; //!< Origin point of bic function
127 double m_bicK; //!< Time to origin point from the beginning
128 // of the current epoch (in s)
129 Time m_delayMin; //!< Min delay
130 Time m_epochStart; //!< Beginning of an epoch
131 bool m_found; //!< The exit point is found?
132 Time m_roundStart; //!< Beginning of each round
133 SequenceNumber32 m_endSeq; //!< End sequence of the round
134 Time m_lastAck; //!< Last time when the ACK spacing is close
135 Time m_cubicDelta; //!< Time to wait after recovery before update
136 Time m_currRtt; //!< Current Rtt
137 uint32_t m_sampleCnt; //!< Count of samples for HyStart
138 uint32_t m_ackCnt; //!< Count the number of ACKed packets
139 uint32_t m_tcpCwnd; //!< Estimated tcp cwnd (for Reno-friendliness)
140
141 private:
142 /**
143 * \brief Reset HyStart parameters
144 * \param tcb Transmission Control Block of the connection
145 */
147
148 /**
149 * \brief Reset Cubic parameters
150 * \param tcb Transmission Control Block of the connection
151 */
153
154 /**
155 * \brief Cubic window update after a new ack received
156 * \param tcb Transmission Control Block of the connection
157 * \param segmentsAcked Segments acked
158 * \returns the congestion window update counter
159 */
160 uint32_t Update(Ptr<TcpSocketState> tcb, uint32_t segmentsAcked);
161
162 /**
163 * \brief Update HyStart parameters
164 *
165 * \param tcb Transmission Control Block of the connection
166 * \param delay Delay for HyStart algorithm
167 */
168 void HystartUpdate(Ptr<TcpSocketState> tcb, const Time& delay);
169
170 /**
171 * \brief Clamp time value in a range
172 *
173 * The returned value is t, clamped in a range specified
174 * by attributes (HystartDelayMin < t < HystartDelayMax)
175 *
176 * \param t Time value to clamp
177 * \return t itself if it is in range, otherwise the min or max
178 * value
179 */
180 Time HystartDelayThresh(const Time& t) const;
181};
182
183} // namespace ns3
184
185#endif // TCPCUBIC_H
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Congestion control abstract class.
The Cubic Congestion Control Algorithm.
Definition: tcp-cubic.h:70
Time m_currRtt
Current Rtt.
Definition: tcp-cubic.h:136
void HystartReset(Ptr< const TcpSocketState > tcb)
Reset HyStart parameters.
Definition: tcp-cubic.cc:177
uint32_t m_ackCnt
Count the number of ACKed packets.
Definition: tcp-cubic.h:138
Time m_hystartDelayMax
Maximum time for hystart algorithm.
Definition: tcp-cubic.h:115
Time m_cubicDelta
Time to wait after recovery before update.
Definition: tcp-cubic.h:135
uint32_t m_bicOriginPoint
Origin point of bic function.
Definition: tcp-cubic.h:126
uint32_t m_sampleCnt
Count of samples for HyStart.
Definition: tcp-cubic.h:137
uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight) override
Get the slow start threshold after a loss event.
Definition: tcp-cubic.cc:448
std::string GetName() const override
Get the name of the congestion control algorithm.
Definition: tcp-cubic.cc:171
uint32_t Update(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Cubic window update after a new ack received.
Definition: tcp-cubic.cc:240
Ptr< TcpCongestionOps > Fork() override
Copy the congestion control algorithm across sockets.
Definition: tcp-cubic.cc:503
bool m_hystart
Enable or disable HyStart algorithm.
Definition: tcp-cubic.h:110
double m_bicK
Time to origin point from the beginning.
Definition: tcp-cubic.h:127
uint32_t m_tcpCwnd
Estimated tcp cwnd (for Reno-friendliness)
Definition: tcp-cubic.h:139
void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt) override
Timing information on received ACK.
Definition: tcp-cubic.cc:350
uint32_t m_cWndCnt
cWnd integer-to-float counter
Definition: tcp-cubic.h:124
Time m_hystartDelayMin
Minimum time for hystart algorithm.
Definition: tcp-cubic.h:114
bool m_found
The exit point is found?
Definition: tcp-cubic.h:131
SequenceNumber32 m_endSeq
End sequence of the round.
Definition: tcp-cubic.h:133
void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
Congestion avoidance algorithm implementation.
Definition: tcp-cubic.cc:188
double m_beta
Beta for cubic multiplicative increase.
Definition: tcp-cubic.h:108
Time m_lastAck
Last time when the ACK spacing is close.
Definition: tcp-cubic.h:134
void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState) override
Trigger events/calculations specific to a congestion state.
Definition: tcp-cubic.cc:477
static TypeId GetTypeId()
Get the type ID.
Definition: tcp-cubic.cc:36
bool m_tcpFriendliness
Enable or disable TCP-friendliness heuristic.
Definition: tcp-cubic.h:107
Time m_hystartAckDelta
Spacing between ack's indicating train.
Definition: tcp-cubic.h:113
bool m_fastConvergence
Enable or disable fast convergence algorithm.
Definition: tcp-cubic.h:106
Time m_delayMin
Min delay.
Definition: tcp-cubic.h:129
Time m_roundStart
Beginning of each round.
Definition: tcp-cubic.h:132
Time m_epochStart
Beginning of an epoch.
Definition: tcp-cubic.h:130
HybridSSDetectionMode m_hystartDetect
Detect way for HyStart algorithm.
Definition: tcp-cubic.h:111
uint8_t m_cntClamp
Modulo of the (avoided) float division for cWnd.
Definition: tcp-cubic.h:119
void HystartUpdate(Ptr< TcpSocketState > tcb, const Time &delay)
Update HyStart parameters.
Definition: tcp-cubic.cc:375
double m_c
Cubic Scaling factor.
Definition: tcp-cubic.h:121
void CubicReset(Ptr< const TcpSocketState > tcb)
Reset Cubic parameters.
Definition: tcp-cubic.cc:489
HybridSSDetectionMode
Values to detect the Slow Start mode of HyStart.
Definition: tcp-cubic.h:76
@ DELAY
Detection by delay value.
Definition: tcp-cubic.h:78
@ PACKET_TRAIN
Detection by trains of packet.
Definition: tcp-cubic.h:77
@ BOTH
Detection by both.
Definition: tcp-cubic.h:79
uint32_t m_lastMaxCwnd
Last maximum cWnd.
Definition: tcp-cubic.h:125
Time HystartDelayThresh(const Time &t) const
Clamp time value in a range.
Definition: tcp-cubic.cc:430
uint32_t m_initialCwnd
Initial cWnd.
Definition: tcp-cubic.h:118
uint8_t m_hystartMinSamples
Number of delay samples for detecting the increase of delay.
Definition: tcp-cubic.h:116
uint32_t m_hystartLowWindow
Lower bound cWnd for hybrid slow start (segments)
Definition: tcp-cubic.h:112
TcpCongState_t
Definition of the Congestion state machine.
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.