A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-vegas.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 ResiliNets, ITTC, University of Kansas
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: Truc Anh N. Nguyen <annguyen@ittc.ku.edu>
18 *
19 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
20 * ResiliNets Research Group https://resilinets.org/
21 * Information and Telecommunication Technology Center (ITTC)
22 * and Department of Electrical Engineering and Computer Science
23 * The University of Kansas Lawrence, KS USA.
24 */
25
26#ifndef TCPVEGAS_H
27#define TCPVEGAS_H
28
29#include "tcp-congestion-ops.h"
30
31namespace ns3
32{
33
34class TcpSocketState;
35
36/**
37 * \ingroup congestionOps
38 *
39 * \brief An implementation of TCP Vegas
40 *
41 * TCP Vegas is a pure delay-based congestion control algorithm implementing a proactive
42 * scheme that tries to prevent packet drops by maintaining a small backlog at the
43 * bottleneck queue.
44 *
45 * Vegas continuously measures the actual throughput a connection achieves as shown in
46 * Equation (1) and compares it with the expected throughput calculated in Equation (2).
47 * The difference between these 2 sending rates in Equation (3) reflects the amount of
48 * extra packets being queued at the bottleneck.
49 *
50 * actual = cwnd / RTT (1)
51 * expected = cwnd / BaseRTT (2)
52 * diff = expected - actual (3)
53 *
54 * To avoid congestion, Vegas linearly increases/decreases its congestion window to ensure
55 * the diff value fall between the 2 predefined thresholds, alpha and beta.
56 * diff and another threshold, gamma, are used to determine when Vegas should change from
57 * its slow-start mode to linear increase/decrease mode.
58 *
59 * Following the implementation of Vegas in Linux, we use 2, 4, and 1 as the default values
60 * of alpha, beta, and gamma, respectively.
61 *
62 * More information: http://dx.doi.org/10.1109/49.464716
63 */
64
65class TcpVegas : public TcpNewReno
66{
67 public:
68 /**
69 * \brief Get the type ID.
70 * \return the object TypeId
71 */
72 static TypeId GetTypeId();
73
74 /**
75 * Create an unbound tcp socket.
76 */
77 TcpVegas();
78
79 /**
80 * \brief Copy constructor
81 * \param sock the object to copy
82 */
83 TcpVegas(const TcpVegas& sock);
84 ~TcpVegas() override;
85
86 std::string GetName() const override;
87
88 /**
89 * \brief Compute RTTs needed to execute Vegas algorithm
90 *
91 * The function filters RTT samples from the last RTT to find
92 * the current smallest propagation delay + queueing delay (minRtt).
93 * We take the minimum to avoid the effects of delayed ACKs.
94 *
95 * The function also min-filters all RTT measurements seen to find the
96 * propagation delay (baseRtt).
97 *
98 * \param tcb internal congestion state
99 * \param segmentsAcked count of segments ACKed
100 * \param rtt last RTT
101 *
102 */
103 void PktsAcked(Ptr<TcpSocketState> tcb, uint32_t segmentsAcked, const Time& rtt) override;
104
105 /**
106 * \brief Enable/disable Vegas algorithm depending on the congestion state
107 *
108 * We only start a Vegas cycle when we are in normal congestion state (CA_OPEN state).
109 *
110 * \param tcb internal congestion state
111 * \param newState new congestion state to which the TCP is going to switch
112 */
114 const TcpSocketState::TcpCongState_t newState) override;
115
116 /**
117 * \brief Adjust cwnd following Vegas linear increase/decrease algorithm
118 *
119 * \param tcb internal congestion state
120 * \param segmentsAcked count of segments ACKed
121 */
122 void IncreaseWindow(Ptr<TcpSocketState> tcb, uint32_t segmentsAcked) override;
123
124 /**
125 * \brief Get slow start threshold following Vegas principle
126 *
127 * \param tcb internal congestion state
128 * \param bytesInFlight bytes in flight
129 *
130 * \return the slow start threshold value
131 */
132 uint32_t GetSsThresh(Ptr<const TcpSocketState> tcb, uint32_t bytesInFlight) override;
133
134 Ptr<TcpCongestionOps> Fork() override;
135
136 protected:
137 private:
138 /**
139 * \brief Enable Vegas algorithm to start taking Vegas samples
140 *
141 * Vegas algorithm is enabled in the following situations:
142 * 1. at the establishment of a connection
143 * 2. after an RTO
144 * 3. after fast recovery
145 * 4. when an idle connection is restarted
146 *
147 * \param tcb internal congestion state
148 */
150
151 /**
152 * \brief Stop taking Vegas samples
153 */
154 void DisableVegas();
155
156 private:
157 uint32_t m_alpha; //!< Alpha threshold, lower bound of packets in network
158 uint32_t m_beta; //!< Beta threshold, upper bound of packets in network
159 uint32_t m_gamma; //!< Gamma threshold, limit on increase
160 Time m_baseRtt; //!< Minimum of all Vegas RTT measurements seen during connection
161 Time m_minRtt; //!< Minimum of all RTT measurements within last RTT
162 uint32_t m_cntRtt; //!< Number of RTT measurements during last RTT
163 bool m_doingVegasNow; //!< If true, do Vegas for this RTT
164 SequenceNumber32 m_begSndNxt; //!< Right edge during last RTT
165};
166
167} // namespace ns3
168
169#endif // TCPVEGAS_H
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
The NewReno implementation.
TcpCongState_t
Definition of the Congestion state machine.
An implementation of TCP Vegas.
Definition: tcp-vegas.h:66
uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight) override
Get slow start threshold following Vegas principle.
Definition: tcp-vegas.cc:290
void DisableVegas()
Stop taking Vegas samples.
Definition: tcp-vegas.cc:135
~TcpVegas() override
Definition: tcp-vegas.cc:91
uint32_t m_cntRtt
Number of RTT measurements during last RTT.
Definition: tcp-vegas.h:162
std::string GetName() const override
Get the name of the congestion control algorithm.
Definition: tcp-vegas.cc:284
Ptr< TcpCongestionOps > Fork() override
Copy the congestion control algorithm across sockets.
Definition: tcp-vegas.cc:97
uint32_t m_alpha
Alpha threshold, lower bound of packets in network.
Definition: tcp-vegas.h:157
uint32_t m_beta
Beta threshold, upper bound of packets in network.
Definition: tcp-vegas.h:158
void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
Adjust cwnd following Vegas linear increase/decrease algorithm.
Definition: tcp-vegas.cc:157
bool m_doingVegasNow
If true, do Vegas for this RTT.
Definition: tcp-vegas.h:163
void EnableVegas(Ptr< TcpSocketState > tcb)
Enable Vegas algorithm to start taking Vegas samples.
Definition: tcp-vegas.cc:124
Time m_minRtt
Minimum of all RTT measurements within last RTT.
Definition: tcp-vegas.h:161
void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt) override
Compute RTTs needed to execute Vegas algorithm.
Definition: tcp-vegas.cc:103
void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState) override
Enable/disable Vegas algorithm depending on the congestion state.
Definition: tcp-vegas.cc:143
TcpVegas()
Create an unbound tcp socket.
Definition: tcp-vegas.cc:63
Time m_baseRtt
Minimum of all Vegas RTT measurements seen during connection.
Definition: tcp-vegas.h:160
uint32_t m_gamma
Gamma threshold, limit on increase.
Definition: tcp-vegas.h:159
static TypeId GetTypeId()
Get the type ID.
Definition: tcp-vegas.cc:39
SequenceNumber32 m_begSndNxt
Right edge during last RTT.
Definition: tcp-vegas.h:164
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.