A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
tcp-scalable-test.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
20
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21
* ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22
* Information and Telecommunication Technology Center (ITTC)
23
* and Department of Electrical Engineering and Computer Science
24
* The University of Kansas Lawrence, KS USA.
25
*
26
*/
27
28
#include "ns3/test.h"
29
#include "ns3/log.h"
30
#include "ns3/tcp-congestion-ops.h"
31
#include "ns3/tcp-socket-base.h"
32
#include "ns3/tcp-scalable.h"
33
34
using namespace
ns3
;
35
36
NS_LOG_COMPONENT_DEFINE
(
"TcpScalableTestSuite"
);
37
44
class
TcpScalableIncrementTest
:
public
TestCase
45
{
46
public
:
54
TcpScalableIncrementTest
(uint32_t cWnd, uint32_t
segmentSize
,
55
uint32_t segmentsAcked,
56
const
std::string &name);
57
58
private
:
59
virtual
void
DoRun (
void
);
60
61
uint32_t
m_cWnd
;
62
uint32_t
m_segmentSize
;
63
uint32_t
m_segmentsAcked
;
64
Ptr<TcpSocketState>
m_state
;
65
};
66
67
TcpScalableIncrementTest::TcpScalableIncrementTest
(uint32_t cWnd,
68
uint32_t
segmentSize
,
69
uint32_t segmentsAcked,
70
const
std::string &name)
71
:
TestCase
(name),
72
m_cWnd (cWnd),
73
m_segmentSize (
segmentSize
),
74
m_segmentsAcked (segmentsAcked)
75
{
76
}
77
78
void
79
TcpScalableIncrementTest::DoRun
()
80
{
81
m_state
= CreateObject<TcpSocketState> ();
82
83
m_state
->
m_cWnd
=
m_cWnd
;
84
m_state
->
m_segmentSize
=
m_segmentSize
;
85
86
Ptr<TcpScalable>
cong = CreateObject <TcpScalable> ();
87
88
uint32_t segCwnd =
m_cWnd
/
m_segmentSize
;
89
90
// Get default value of additive increase factor
91
UintegerValue
aiFactor;
92
cong->
GetAttribute
(
"AIFactor"
, aiFactor);
93
94
// To see an increase of 1 MSS, the number of segments ACKed has to be at least
95
// min (segCwnd, aiFactor).
96
97
uint32_t w =
std::min
(segCwnd, (uint32_t) aiFactor.
Get
());
98
uint32_t delta =
m_segmentsAcked
/ w;
99
100
cong->
IncreaseWindow
(
m_state
,
m_segmentsAcked
);
101
102
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWnd
.
Get
(),
m_cWnd
+ delta *
m_segmentSize
,
103
"CWnd has not increased"
);
104
}
105
112
class
TcpScalableDecrementTest
:
public
TestCase
113
{
114
public
:
121
TcpScalableDecrementTest
(uint32_t cWnd, uint32_t
segmentSize
,
122
const
std::string &name);
123
124
private
:
125
virtual
void
DoRun
(
void
);
126
127
uint32_t
m_cWnd
;
128
uint32_t
m_segmentSize
;
129
Ptr<TcpSocketState>
m_state
;
130
};
131
132
TcpScalableDecrementTest::TcpScalableDecrementTest
(uint32_t cWnd,
133
uint32_t
segmentSize
,
134
const
std::string &name)
135
:
TestCase
(name),
136
m_cWnd (cWnd),
137
m_segmentSize (
segmentSize
)
138
{
139
}
140
141
void
142
TcpScalableDecrementTest::DoRun
()
143
{
144
m_state
= CreateObject<TcpSocketState> ();
145
146
m_state
->
m_cWnd
=
m_cWnd
;
147
m_state
->
m_segmentSize
=
m_segmentSize
;
148
149
Ptr<TcpScalable>
cong = CreateObject <TcpScalable> ();
150
151
uint32_t segCwnd =
m_cWnd
/
m_segmentSize
;
152
153
// Get default value of multiplicative decrease factor
154
DoubleValue
mdFactor;
155
cong->
GetAttribute
(
"MDFactor"
, mdFactor);
156
157
double
b = 1.0 - mdFactor.
Get
();
158
159
uint32_t ssThresh =
std::max
(2.0, segCwnd * b);
160
161
uint32_t ssThreshInSegments = cong->
GetSsThresh
(
m_state
,
m_state
->
m_cWnd
) /
m_segmentSize
;
162
163
NS_TEST_ASSERT_MSG_EQ
(ssThreshInSegments, ssThresh,
164
"Scalable decrement fn not used"
);
165
}
166
167
174
class
TcpScalableTestSuite
:
public
TestSuite
175
{
176
public
:
177
TcpScalableTestSuite
() :
TestSuite
(
"tcp-scalable-test"
,
UNIT
)
178
{
179
AddTestCase
(
new
TcpScalableIncrementTest
(38 * 536, 536, 38,
180
"Scalable increment test on cWnd = 38 segments and segmentSize = 536 bytes"
),
181
TestCase::QUICK);
182
AddTestCase
(
new
TcpScalableIncrementTest
(38, 1, 100,
183
"Scalable increment test on cWnd = 38 segments and segmentSize = 1 byte"
),
184
TestCase::QUICK);
185
AddTestCase
(
new
TcpScalableIncrementTest
(53 * 1446, 1446, 50,
186
"Scalable increment test on cWnd = 53 segments and segmentSize = 1446 bytes"
),
187
TestCase::QUICK);
188
189
AddTestCase
(
new
TcpScalableDecrementTest
(38, 1,
190
"Scalable decrement test on cWnd = 38 segments and segmentSize = 1 byte"
),
191
TestCase::QUICK);
192
AddTestCase
(
new
TcpScalableDecrementTest
(100 * 536, 536,
193
"Scalable decrement test on cWnd = 100 segments and segmentSize = 536 bytes"
),
194
TestCase::QUICK);
195
AddTestCase
(
new
TcpScalableDecrementTest
(40 * 1446, 1446,
196
"Scalable decrement test on cWnd = 40 segments and segmentSize = 1446 bytes"
),
197
TestCase::QUICK);
198
199
}
200
};
201
202
static
TcpScalableTestSuite
g_tcpScalableTest
;
203
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:299
ns3::TracedValue::Get
T Get(void) const
Get the underlying value.
Definition:
traced-value.h:229
TcpScalableDecrementTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition:
tcp-scalable-test.cc:127
min
#define min(a, b)
Definition:
80211b.c:42
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TcpScalableIncrementTest::m_segmentsAcked
uint32_t m_segmentsAcked
Segments ACKed.
Definition:
tcp-scalable-test.cc:63
ns3::TcpScalable::GetSsThresh
virtual uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight)
Get slow start threshold following Scalable principle (Equation 2)
Definition:
tcp-scalable.cc:129
ns3::TcpSocketState::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-socket-state.h:177
TcpScalableIncrementTest
Testing the congestion avoidance increment on TcpScalable.
Definition:
tcp-scalable-test.cc:45
g_tcpScalableTest
static TcpScalableTestSuite g_tcpScalableTest
Static variable for test initialization.
Definition:
tcp-scalable-test.cc:202
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:41
ns3::TestCase
encapsulates test code
Definition:
test.h:1154
TcpScalableTestSuite
TcpScalable TestSuite.
Definition:
tcp-scalable-test.cc:175
ns3::Ptr< TcpSocketState >
max
#define max(a, b)
Definition:
80211b.c:43
TcpScalableDecrementTest
Testing the multiplicative decrease on TcpScalable.
Definition:
tcp-scalable-test.cc:113
ns3::ObjectBase::GetAttribute
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition:
object-base.cc:223
TcpScalableIncrementTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition:
tcp-scalable-test.cc:61
TcpScalableDecrementTest::TcpScalableDecrementTest
TcpScalableDecrementTest(uint32_t cWnd, uint32_t segmentSize, const std::string &name)
Constructor.
Definition:
tcp-scalable-test.cc:132
TcpScalableIncrementTest::TcpScalableIncrementTest
TcpScalableIncrementTest(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, const std::string &name)
Constructor.
Definition:
tcp-scalable-test.cc:67
TcpScalableTestSuite::TcpScalableTestSuite
TcpScalableTestSuite()
Definition:
tcp-scalable-test.cc:177
TcpScalableDecrementTest::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
tcp-scalable-test.cc:142
ns3::DoubleValue::Get
double Get(void) const
Definition:
double.cc:35
TcpScalableIncrementTest::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
tcp-scalable-test.cc:79
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1344
TcpScalableDecrementTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-scalable-test.cc:128
NS_TEST_ASSERT_MSG_EQ
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition:
test.h:166
TcpScalableDecrementTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition:
tcp-scalable-test.cc:129
TcpScalableIncrementTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition:
tcp-scalable-test.cc:64
ns3::TestSuite::UNIT
@ UNIT
This test suite implements a Unit Test.
Definition:
test.h:1353
segmentSize
uint32_t segmentSize
Definition:
tcp-linux-reno.cc:53
TcpScalableIncrementTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-scalable-test.cc:62
ns3::TcpSocketState::m_cWnd
TracedValue< uint32_t > m_cWnd
Congestion window.
Definition:
tcp-socket-state.h:165
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:44
ns3::UintegerValue::Get
uint64_t Get(void) const
Definition:
uinteger.cc:35
ns3::TcpNewReno::IncreaseWindow
virtual void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Try to increase the cWnd following the NewReno specification.
Definition:
tcp-congestion-ops.cc:214
src
internet
test
tcp-scalable-test.cc
Generated on Fri Oct 1 2021 17:03:12 for ns-3 by
1.8.20