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