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