A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
tcp-scalable-test.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
19
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
20
* ResiliNets Research Group https://resilinets.org/
21
* Information and Telecommunication Technology Center (ITTC)
22
* and Department of Electrical Engineering and Computer Science
23
* The University of Kansas Lawrence, KS USA.
24
*
25
*/
26
27
#include "ns3/log.h"
28
#include "ns3/tcp-congestion-ops.h"
29
#include "ns3/tcp-scalable.h"
30
#include "ns3/tcp-socket-base.h"
31
#include "ns3/test.h"
32
33
using namespace
ns3
;
34
35
NS_LOG_COMPONENT_DEFINE
(
"TcpScalableTestSuite"
);
36
42
class
TcpScalableIncrementTest
:
public
TestCase
43
{
44
public
:
52
TcpScalableIncrementTest
(
uint32_t
cWnd,
53
uint32_t
segmentSize
,
54
uint32_t
segmentsAcked,
55
const
std::string& name);
56
57
private
:
58
void
DoRun
()
override
;
59
60
uint32_t
m_cWnd
;
61
uint32_t
m_segmentSize
;
62
uint32_t
m_segmentsAcked
;
63
Ptr<TcpSocketState>
m_state
;
64
};
65
66
TcpScalableIncrementTest::TcpScalableIncrementTest
(
uint32_t
cWnd,
67
uint32_t
segmentSize
,
68
uint32_t
segmentsAcked,
69
const
std::string& name)
70
:
TestCase
(name),
71
m_cWnd(cWnd),
72
m_segmentSize(
segmentSize
),
73
m_segmentsAcked(segmentsAcked)
74
{
75
}
76
77
void
78
TcpScalableIncrementTest::DoRun
()
79
{
80
m_state
= CreateObject<TcpSocketState>();
81
82
m_state
->
m_cWnd
=
m_cWnd
;
83
m_state
->
m_segmentSize
=
m_segmentSize
;
84
85
Ptr<TcpScalable>
cong = CreateObject<TcpScalable>();
86
87
uint32_t
segCwnd =
m_cWnd
/
m_segmentSize
;
88
89
// Get default value of additive increase factor
90
UintegerValue
aiFactor;
91
cong->GetAttribute(
"AIFactor"
, aiFactor);
92
93
// To see an increase of 1 MSS, the number of segments ACKed has to be at least
94
// min (segCwnd, aiFactor).
95
96
uint32_t
w = std::min(segCwnd, (
uint32_t
)aiFactor.
Get
());
97
uint32_t
delta =
m_segmentsAcked
/ w;
98
99
cong->IncreaseWindow(
m_state
,
m_segmentsAcked
);
100
101
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWnd
.
Get
(),
102
m_cWnd
+ delta *
m_segmentSize
,
103
"CWnd has not increased"
);
104
}
105
111
class
TcpScalableDecrementTest
:
public
TestCase
112
{
113
public
:
120
TcpScalableDecrementTest
(
uint32_t
cWnd,
uint32_t
segmentSize
,
const
std::string& name);
121
122
private
:
123
void
DoRun
()
override
;
124
125
uint32_t
m_cWnd
;
126
uint32_t
m_segmentSize
;
127
Ptr<TcpSocketState>
m_state
;
128
};
129
130
TcpScalableDecrementTest::TcpScalableDecrementTest
(
uint32_t
cWnd,
131
uint32_t
segmentSize
,
132
const
std::string& name)
133
:
TestCase
(name),
134
m_cWnd(cWnd),
135
m_segmentSize(
segmentSize
)
136
{
137
}
138
139
void
140
TcpScalableDecrementTest::DoRun
()
141
{
142
m_state
= CreateObject<TcpSocketState>();
143
144
m_state
->
m_cWnd
=
m_cWnd
;
145
m_state
->
m_segmentSize
=
m_segmentSize
;
146
147
Ptr<TcpScalable>
cong = CreateObject<TcpScalable>();
148
149
uint32_t
segCwnd =
m_cWnd
/
m_segmentSize
;
150
151
// Get default value of multiplicative decrease factor
152
DoubleValue
mdFactor;
153
cong->GetAttribute(
"MDFactor"
, mdFactor);
154
155
double
b = 1.0 - mdFactor.
Get
();
156
157
uint32_t
ssThresh = std::max(2.0, segCwnd * b);
158
159
uint32_t
ssThreshInSegments = cong->GetSsThresh(
m_state
,
m_state
->
m_cWnd
) /
m_segmentSize
;
160
161
NS_TEST_ASSERT_MSG_EQ
(ssThreshInSegments, ssThresh,
"Scalable decrement fn not used"
);
162
}
163
169
class
TcpScalableTestSuite
:
public
TestSuite
170
{
171
public
:
172
TcpScalableTestSuite
()
173
:
TestSuite
(
"tcp-scalable-test"
,
UNIT
)
174
{
175
AddTestCase
(
176
new
TcpScalableIncrementTest
(
177
38 * 536,
178
536,
179
38,
180
"Scalable increment test on cWnd = 38 segments and segmentSize = 536 bytes"
),
181
TestCase::QUICK
);
182
AddTestCase
(
new
TcpScalableIncrementTest
(
183
38,
184
1,
185
100,
186
"Scalable increment test on cWnd = 38 segments and segmentSize = 1 byte"
),
187
TestCase::QUICK
);
188
AddTestCase
(
189
new
TcpScalableIncrementTest
(
190
53 * 1446,
191
1446,
192
50,
193
"Scalable increment test on cWnd = 53 segments and segmentSize = 1446 bytes"
),
194
TestCase::QUICK
);
195
196
AddTestCase
(
new
TcpScalableDecrementTest
(
197
38,
198
1,
199
"Scalable decrement test on cWnd = 38 segments and segmentSize = 1 byte"
),
200
TestCase::QUICK
);
201
AddTestCase
(
202
new
TcpScalableDecrementTest
(
203
100 * 536,
204
536,
205
"Scalable decrement test on cWnd = 100 segments and segmentSize = 536 bytes"
),
206
TestCase::QUICK
);
207
AddTestCase
(
208
new
TcpScalableDecrementTest
(
209
40 * 1446,
210
1446,
211
"Scalable decrement test on cWnd = 40 segments and segmentSize = 1446 bytes"
),
212
TestCase::QUICK
);
213
}
214
};
215
216
static
TcpScalableTestSuite
g_tcpScalableTest
;
TcpScalableDecrementTest
Testing the multiplicative decrease on TcpScalable.
Definition:
tcp-scalable-test.cc:112
TcpScalableDecrementTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-scalable-test.cc:126
TcpScalableDecrementTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition:
tcp-scalable-test.cc:127
TcpScalableDecrementTest::TcpScalableDecrementTest
TcpScalableDecrementTest(uint32_t cWnd, uint32_t segmentSize, const std::string &name)
Constructor.
Definition:
tcp-scalable-test.cc:130
TcpScalableDecrementTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition:
tcp-scalable-test.cc:125
TcpScalableDecrementTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
tcp-scalable-test.cc:140
TcpScalableIncrementTest
Testing the congestion avoidance increment on TcpScalable.
Definition:
tcp-scalable-test.cc:43
TcpScalableIncrementTest::TcpScalableIncrementTest
TcpScalableIncrementTest(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, const std::string &name)
Constructor.
Definition:
tcp-scalable-test.cc:66
TcpScalableIncrementTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-scalable-test.cc:61
TcpScalableIncrementTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition:
tcp-scalable-test.cc:63
TcpScalableIncrementTest::m_segmentsAcked
uint32_t m_segmentsAcked
Segments ACKed.
Definition:
tcp-scalable-test.cc:62
TcpScalableIncrementTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
tcp-scalable-test.cc:78
TcpScalableIncrementTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition:
tcp-scalable-test.cc:60
TcpScalableTestSuite
TcpScalable TestSuite.
Definition:
tcp-scalable-test.cc:170
TcpScalableTestSuite::TcpScalableTestSuite
TcpScalableTestSuite()
Definition:
tcp-scalable-test.cc:172
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition:
double.h:42
ns3::DoubleValue::Get
double Get() const
Definition:
double.cc:37
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:78
ns3::TcpSocketState::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-socket-state.h:184
ns3::TcpSocketState::m_cWnd
TracedValue< uint32_t > m_cWnd
Congestion window.
Definition:
tcp-socket-state.h:170
ns3::TestCase
encapsulates test code
Definition:
test.h:1060
ns3::TestCase::QUICK
@ QUICK
Fast test.
Definition:
test.h:1065
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
ns3::TestSuite::UNIT
@ UNIT
This test suite implements a Unit Test.
Definition:
test.h:1265
ns3::TracedValue::Get
T Get() const
Get the underlying value.
Definition:
traced-value.h:249
ns3::UintegerValue
Hold an unsigned integer type.
Definition:
uinteger.h:45
ns3::UintegerValue::Get
uint64_t Get() const
Definition:
uinteger.cc:37
uint32_t
segmentSize
uint32_t segmentSize
Definition:
tcp-linux-reno.cc:53
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
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:144
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
g_tcpScalableTest
static TcpScalableTestSuite g_tcpScalableTest
Static variable for test initialization.
Definition:
tcp-scalable-test.cc:216
src
internet
test
tcp-scalable-test.cc
Generated on Sun Jul 2 2023 18:21:44 for ns-3 by
1.9.6