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