A Discrete-Event Network Simulator
API
tcp-scalable.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2016 ResiliNets, ITTC, University of Kansas
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Truc Anh N. Nguyen <annguyen@ittc.ku.edu>
19  * Keerthi Ganta <keerthig@ittc.ku.edu>
20  * Md. Moshfequr Rahman <moshfequr@ittc.ku.edu>
21  * Amir Modarresi <amodarresi@ittc.ku.edu>
22  *
23  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
24  * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
25  * Information and Telecommunication Technology Center (ITTC)
26  * and Department of Electrical Engineering and Computer Science
27  * The University of Kansas Lawrence, KS USA.
28  */
29 
30 #include "tcp-scalable.h"
31 #include "ns3/log.h"
32 
33 namespace ns3 {
34 
35 NS_LOG_COMPONENT_DEFINE ("TcpScalable");
36 NS_OBJECT_ENSURE_REGISTERED (TcpScalable);
37 
38 TypeId
40 {
41  static TypeId tid = TypeId ("ns3::TcpScalable")
43  .AddConstructor<TcpScalable> ()
44  .SetGroupName ("Internet")
45  .AddAttribute ("AIFactor", "Additive Increase Factor",
46  UintegerValue (50),
48  MakeUintegerChecker<uint32_t> ())
49  .AddAttribute ("MDFactor", "Multiplicative Decrease Factor",
50  DoubleValue (0.125),
52  MakeDoubleChecker<double> ())
53  ;
54  return tid;
55 }
56 
58  : TcpNewReno (),
59  m_ackCnt (0),
60  m_aiFactor (50),
61  m_mdFactor (0.125)
62 {
63  NS_LOG_FUNCTION (this);
64 }
65 
67  : TcpNewReno (sock),
68  m_ackCnt (sock.m_ackCnt),
69  m_aiFactor (sock.m_aiFactor),
70  m_mdFactor (sock.m_mdFactor)
71 {
72  NS_LOG_FUNCTION (this);
73 }
74 
76 {
77  NS_LOG_FUNCTION (this);
78 }
79 
82 {
83  return CopyObject<TcpScalable> (this);
84 }
85 
86 void
88  uint32_t segmentsAcked)
89 {
90  NS_LOG_FUNCTION (this << tcb << segmentsAcked);
91 
92  uint32_t segCwnd = tcb->GetCwndInSegments ();
93  NS_ASSERT (segCwnd >= 1);
94 
95  uint32_t oldCwnd = segCwnd;
96  uint32_t w = std::min (segCwnd, m_aiFactor);
97 
98  if (m_ackCnt >= w)
99  {
100  m_ackCnt = 0;
101  segCwnd++;
102  }
103 
104  m_ackCnt += segmentsAcked;
105  if (m_ackCnt >= w)
106  {
107  uint32_t delta = m_ackCnt / w;
108  m_ackCnt = 0;
109  segCwnd += delta;
110  }
111 
112  if (segCwnd != oldCwnd)
113  {
114  tcb->m_cWnd = segCwnd * tcb->m_segmentSize;
115  NS_LOG_INFO ("In CongAvoid, updated to cwnd " << tcb->m_cWnd <<
116  " ssthresh " << tcb->m_ssThresh);
117  }
118 }
119 
120 std::string
122 {
123  return "TcpScalable";
124 }
125 
126 uint32_t
128  uint32_t bytesInFlight)
129 {
130  NS_LOG_FUNCTION (this << tcb << bytesInFlight);
131 
132  uint32_t segCwnd = bytesInFlight / tcb->m_segmentSize;
133 
134  double b = 1.0 - m_mdFactor;
135  uint32_t ssThresh = static_cast<uint32_t> (std::max (2.0, segCwnd * b));
136 
137  NS_LOG_DEBUG ("Calculated b(w) = " << b <<
138  " resulting (in segment) ssThresh=" << ssThresh);
139 
140  return ssThresh * tcb->m_segmentSize;
141 }
142 
143 } // namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
#define min(a, b)
Definition: 80211b.c:42
virtual ~TcpScalable(void)
Definition: tcp-scalable.cc:75
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
uint32_t m_segmentSize
Segment size.
double m_mdFactor
Multiplicative decrease factor.
Definition: tcp-scalable.h:112
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-scalable.cc:39
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:280
uint32_t m_aiFactor
Additive increase factor.
Definition: tcp-scalable.h:111
The NewReno implementation.
virtual void CongestionAvoidance(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Congestion avoidance of TcpScalable (Equation 1)
Definition: tcp-scalable.cc:87
#define max(a, b)
Definition: 80211b.c:43
Hold an unsigned integer type.
Definition: uinteger.h:44
virtual Ptr< TcpCongestionOps > Fork()
Copy the congestion control algorithm across sockets.
Definition: tcp-scalable.cc:81
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
An implementation of TCP Scalable.
Definition: tcp-scalable.h:63
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TracedValue< uint32_t > m_cWnd
Congestion window.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
TcpScalable(void)
Create an unbound tcp socket.
Definition: tcp-scalable.cc:57
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:272
virtual std::string GetName() const
Get the name of the congestion control algorithm.
uint32_t m_ackCnt
Number of received ACK.
Definition: tcp-scalable.h:110
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
virtual uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight)
Get slow start threshold following Scalable principle (Equation 2)
uint32_t GetCwndInSegments() const
Get cwnd in segments rather than bytes.