A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-scalable.cc
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 * Authors: Truc Anh N. Nguyen <annguyen@ittc.ku.edu>
18 * Keerthi Ganta <keerthig@ittc.ku.edu>
19 * Md. Moshfequr Rahman <moshfequr@ittc.ku.edu>
20 * Amir Modarresi <amodarresi@ittc.ku.edu>
21 *
22 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
23 * ResiliNets Research Group https://resilinets.org/
24 * Information and Telecommunication Technology Center (ITTC)
25 * and Department of Electrical Engineering and Computer Science
26 * The University of Kansas Lawrence, KS USA.
27 */
28
29#include "tcp-scalable.h"
30
31#include "tcp-socket-state.h"
32
33#include "ns3/log.h"
34
35namespace ns3
36{
37
38NS_LOG_COMPONENT_DEFINE("TcpScalable");
40
41TypeId
43{
44 static TypeId tid = TypeId("ns3::TcpScalable")
46 .AddConstructor<TcpScalable>()
47 .SetGroupName("Internet")
48 .AddAttribute("AIFactor",
49 "Additive Increase Factor",
50 UintegerValue(50),
52 MakeUintegerChecker<uint32_t>())
53 .AddAttribute("MDFactor",
54 "Multiplicative Decrease Factor",
55 DoubleValue(0.125),
57 MakeDoubleChecker<double>());
58 return tid;
59}
60
62 : TcpNewReno(),
63 m_ackCnt(0),
64 m_aiFactor(50),
65 m_mdFactor(0.125)
66{
67 NS_LOG_FUNCTION(this);
68}
69
71 : TcpNewReno(sock),
72 m_ackCnt(sock.m_ackCnt),
73 m_aiFactor(sock.m_aiFactor),
74 m_mdFactor(sock.m_mdFactor)
75{
76 NS_LOG_FUNCTION(this);
77}
78
80{
81 NS_LOG_FUNCTION(this);
82}
83
86{
87 return CopyObject<TcpScalable>(this);
88}
89
90void
92{
93 NS_LOG_FUNCTION(this << tcb << segmentsAcked);
94
95 uint32_t segCwnd = tcb->GetCwndInSegments();
96 NS_ASSERT(segCwnd >= 1);
97
98 uint32_t oldCwnd = segCwnd;
99 uint32_t w = std::min(segCwnd, m_aiFactor);
100
101 if (m_ackCnt >= w)
102 {
103 m_ackCnt = 0;
104 segCwnd++;
105 }
106
107 m_ackCnt += segmentsAcked;
108 if (m_ackCnt >= w)
109 {
110 uint32_t delta = m_ackCnt / w;
111 m_ackCnt = 0;
112 segCwnd += delta;
113 }
114
115 if (segCwnd != oldCwnd)
116 {
117 tcb->m_cWnd = segCwnd * tcb->m_segmentSize;
118 NS_LOG_INFO("In CongAvoid, updated to cwnd " << tcb->m_cWnd << " ssthresh "
119 << tcb->m_ssThresh);
120 }
121}
122
123std::string
125{
126 return "TcpScalable";
127}
128
131{
132 NS_LOG_FUNCTION(this << tcb << bytesInFlight);
133
134 uint32_t segCwnd = bytesInFlight / tcb->m_segmentSize;
135
136 double b = 1.0 - m_mdFactor;
137 uint32_t ssThresh = static_cast<uint32_t>(std::max(2.0, segCwnd * b));
138
139 NS_LOG_DEBUG("Calculated b(w) = " << b << " resulting (in segment) ssThresh=" << ssThresh);
140
141 return ssThresh * tcb->m_segmentSize;
142}
143
144} // namespace ns3
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
The NewReno implementation.
An implementation of TCP Scalable.
Definition: tcp-scalable.h:65
Ptr< TcpCongestionOps > Fork() override
Copy the congestion control algorithm across sockets.
Definition: tcp-scalable.cc:85
uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight) override
Get slow start threshold following Scalable principle (Equation 2)
~TcpScalable() override
Definition: tcp-scalable.cc:79
static TypeId GetTypeId()
Get the type ID.
Definition: tcp-scalable.cc:42
uint32_t m_ackCnt
Number of received ACK.
Definition: tcp-scalable.h:109
void CongestionAvoidance(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
Congestion avoidance of TcpScalable (Equation 1)
Definition: tcp-scalable.cc:91
TcpScalable()
Create an unbound tcp socket.
Definition: tcp-scalable.cc:61
uint32_t m_aiFactor
Additive increase factor.
Definition: tcp-scalable.h:110
std::string GetName() const override
Get the name of the congestion control algorithm.
double m_mdFactor
Multiplicative decrease factor.
Definition: tcp-scalable.h:111
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.