A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
tcp-highspeed-test.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2015 Natale Patriciello, <natale.patriciello@gmail.com>
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
*/
19
20
#include "ns3/test.h"
21
#include "ns3/log.h"
22
#include "ns3/tcp-congestion-ops.h"
23
#include "ns3/tcp-socket-base.h"
24
#include "ns3/tcp-highspeed.h"
25
26
using namespace
ns3
;
27
28
NS_LOG_COMPONENT_DEFINE
(
"TcpHighSpeedTestSuite"
);
29
36
class
TcpHighSpeedIncrementTest
:
public
TestCase
37
{
38
public
:
45
TcpHighSpeedIncrementTest
(uint32_t cWnd, uint32_t
segmentSize
,
46
const
std::string &name);
47
48
private
:
49
virtual
void
DoRun (
void
);
50
51
uint32_t
m_cWnd
;
52
uint32_t
m_segmentSize
;
53
Ptr<TcpSocketState>
m_state
;
54
};
55
56
TcpHighSpeedIncrementTest::TcpHighSpeedIncrementTest
(uint32_t cWnd,
57
uint32_t
segmentSize
,
58
const
std::string &name)
59
:
TestCase
(name),
60
m_cWnd (cWnd),
61
m_segmentSize (
segmentSize
)
62
{
63
}
64
65
void
66
TcpHighSpeedIncrementTest::DoRun
()
67
{
68
m_state
= CreateObject<TcpSocketState> ();
69
70
m_state
->
m_cWnd
=
m_cWnd
;
71
m_state
->
m_segmentSize
=
m_segmentSize
;
72
73
Ptr<TcpHighSpeed>
cong = CreateObject <TcpHighSpeed> ();
74
75
uint32_t segCwnd =
m_cWnd
/
m_segmentSize
;
76
uint32_t coeffA = TcpHighSpeed::TableLookupA (segCwnd);
77
78
// Each received ACK weight is "coeffA". To see an increase of 1 MSS, we need
79
// to ACK at least segCwnd/coeffA ACK.
80
81
cong->
IncreaseWindow
(
m_state
, (segCwnd / coeffA) + 1);
82
83
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWnd
.
Get
(),
m_cWnd
+
m_segmentSize
,
84
"CWnd has not increased"
);
85
}
86
93
class
TcpHighSpeedDecrementTest
:
public
TestCase
94
{
95
public
:
102
TcpHighSpeedDecrementTest
(uint32_t cWnd, uint32_t
segmentSize
,
103
const
std::string &name);
104
105
private
:
106
virtual
void
DoRun
(
void
);
107
108
uint32_t
m_cWnd
;
109
uint32_t
m_segmentSize
;
110
Ptr<TcpSocketState>
m_state
;
111
};
112
113
TcpHighSpeedDecrementTest::TcpHighSpeedDecrementTest
(uint32_t cWnd,
114
uint32_t
segmentSize
,
115
const
std::string &name)
116
:
TestCase
(name),
117
m_cWnd (cWnd),
118
m_segmentSize (
segmentSize
)
119
{
120
}
121
122
void
123
TcpHighSpeedDecrementTest::DoRun
()
124
{
125
m_state
= CreateObject<TcpSocketState> ();
126
127
m_state
->
m_cWnd
=
m_cWnd
;
128
m_state
->
m_segmentSize
=
m_segmentSize
;
129
130
Ptr<TcpHighSpeed>
cong = CreateObject <TcpHighSpeed> ();
131
132
uint32_t segCwnd =
m_cWnd
/
m_segmentSize
;
133
double
coeffB = 1.0 - TcpHighSpeed::TableLookupB (segCwnd);
134
135
uint32_t ret = cong->
GetSsThresh
(
m_state
,
m_state
->
m_cWnd
);
136
137
uint32_t ssThHS =
std::max
(2.0, segCwnd * coeffB);
138
139
NS_TEST_ASSERT_MSG_EQ
(ret /
m_segmentSize
, ssThHS,
140
"HighSpeed decrement fn not used"
);
141
}
142
143
150
static
const
struct
HighSpeedImportantValues
151
{
152
unsigned
int
cwnd
;
153
unsigned
int
md
;
154
}
highSpeedImportantValues
[] = {
155
{ 38, 128,
/* 0.50 */
},
156
{ 118, 112,
/* 0.44 */
},
157
{ 221, 104,
/* 0.41 */
},
158
{ 347, 98,
/* 0.38 */
},
159
{ 495, 93,
/* 0.37 */
},
160
{ 663, 89,
/* 0.35 */
},
161
{ 851, 86,
/* 0.34 */
},
162
{ 1058, 83,
/* 0.33 */
},
163
{ 1284, 81,
/* 0.32 */
},
164
{ 1529, 78,
/* 0.31 */
},
165
{ 1793, 76,
/* 0.30 */
},
166
{ 2076, 74,
/* 0.29 */
},
167
{ 2378, 72,
/* 0.28 */
},
168
{ 2699, 71,
/* 0.28 */
},
169
{ 3039, 69,
/* 0.27 */
},
170
{ 3399, 68,
/* 0.27 */
},
171
{ 3778, 66,
/* 0.26 */
},
172
{ 4177, 65,
/* 0.26 */
},
173
{ 4596, 64,
/* 0.25 */
},
174
{ 5036, 62,
/* 0.25 */
},
175
{ 5497, 61,
/* 0.24 */
},
176
{ 5979, 60,
/* 0.24 */
},
177
{ 6483, 59,
/* 0.23 */
},
178
{ 7009, 58,
/* 0.23 */
},
179
{ 7558, 57,
/* 0.22 */
},
180
{ 8130, 56,
/* 0.22 */
},
181
{ 8726, 55,
/* 0.22 */
},
182
{ 9346, 54,
/* 0.21 */
},
183
{ 9991, 53,
/* 0.21 */
},
184
{ 10661, 52,
/* 0.21 */
},
185
{ 11358, 52,
/* 0.20 */
},
186
{ 12082, 51,
/* 0.20 */
},
187
{ 12834, 50,
/* 0.20 */
},
188
{ 13614, 49,
/* 0.19 */
},
189
{ 14424, 48,
/* 0.19 */
},
190
{ 15265, 48,
/* 0.19 */
},
191
{ 16137, 47,
/* 0.19 */
},
192
{ 17042, 46,
/* 0.18 */
},
193
{ 17981, 45,
/* 0.18 */
},
194
{ 18955, 45,
/* 0.18 */
},
195
{ 19965, 44,
/* 0.17 */
},
196
{ 21013, 43,
/* 0.17 */
},
197
{ 22101, 43,
/* 0.17 */
},
198
{ 23230, 42,
/* 0.17 */
},
199
{ 24402, 41,
/* 0.16 */
},
200
{ 25618, 41,
/* 0.16 */
},
201
{ 26881, 40,
/* 0.16 */
},
202
{ 28193, 39,
/* 0.16 */
},
203
{ 29557, 39,
/* 0.15 */
},
204
{ 30975, 38,
/* 0.15 */
},
205
{ 32450, 38,
/* 0.15 */
},
206
{ 33986, 37,
/* 0.15 */
},
207
{ 35586, 36,
/* 0.14 */
},
208
{ 37253, 36,
/* 0.14 */
},
209
{ 38992, 35,
/* 0.14 */
},
210
{ 40808, 35,
/* 0.14 */
},
211
{ 42707, 34,
/* 0.13 */
},
212
{ 44694, 33,
/* 0.13 */
},
213
{ 46776, 33,
/* 0.13 */
},
214
{ 48961, 32,
/* 0.13 */
},
215
{ 51258, 32,
/* 0.13 */
},
216
{ 53677, 31,
/* 0.12 */
},
217
{ 56230, 30,
/* 0.12 */
},
218
{ 58932, 30,
/* 0.12 */
},
219
{ 61799, 29,
/* 0.12 */
},
220
{ 64851, 28,
/* 0.11 */
},
221
{ 68113, 28,
/* 0.11 */
},
222
{ 71617, 27,
/* 0.11 */
},
223
{ 75401, 26,
/* 0.10 */
},
224
{ 79517, 26,
/* 0.10 */
},
225
{ 84035, 25,
/* 0.10 */
},
226
{ 89053, 24,
/* 0.10 */
},
227
};
228
229
#define HIGHSPEED_VALUES_N 71
230
237
class
TcpHighSpeedTestSuite
:
public
TestSuite
238
{
239
public
:
240
TcpHighSpeedTestSuite
() :
TestSuite
(
"tcp-highspeed-test"
,
UNIT
)
241
{
242
std::stringstream ss;
243
244
for
(uint32_t i = 0; i <
HIGHSPEED_VALUES_N
; ++i)
245
{
246
ss <<
highSpeedImportantValues
[i].
cwnd
;
247
AddTestCase
(
new
TcpHighSpeedIncrementTest
(
highSpeedImportantValues
[i].cwnd, 1,
248
"Highspeed increment test on cWnd "
+ ss.str ()),
249
TestCase::QUICK);
250
AddTestCase
(
new
TcpHighSpeedIncrementTest
(
highSpeedImportantValues
[i].cwnd * 536, 536,
251
"Highspeed increment test on cWnd "
+ ss.str ()),
252
TestCase::QUICK);
253
AddTestCase
(
new
TcpHighSpeedIncrementTest
(
highSpeedImportantValues
[i].cwnd * 1446, 1446,
254
"Highspeed increment test on cWnd "
+ ss.str ()),
255
TestCase::QUICK);
256
AddTestCase
(
new
TcpHighSpeedDecrementTest
(
highSpeedImportantValues
[i].cwnd, 1,
257
"Highspeed Decrement test on cWnd "
+ ss.str ()),
258
TestCase::QUICK);
259
AddTestCase
(
new
TcpHighSpeedDecrementTest
(
highSpeedImportantValues
[i].cwnd * 536, 536,
260
"Highspeed Decrement test on cWnd "
+ ss.str ()),
261
TestCase::QUICK);
262
AddTestCase
(
new
TcpHighSpeedDecrementTest
(
highSpeedImportantValues
[i].cwnd * 1446, 1446,
263
"Highspeed Decrement test on cWnd "
+ ss.str ()),
264
TestCase::QUICK);
265
ss.flush ();
266
}
267
}
268
};
269
270
static
TcpHighSpeedTestSuite
g_tcpHighSpeedTest
;
271
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
TcpHighSpeedTestSuite
TCP HighSpeed TestSuite.
Definition:
tcp-highspeed-test.cc:238
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
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TcpHighSpeedIncrementTest::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
tcp-highspeed-test.cc:66
ns3::TcpSocketState::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-socket-state.h:177
TcpHighSpeedIncrementTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition:
tcp-highspeed-test.cc:53
ns3::TestCase
encapsulates test code
Definition:
test.h:1154
ns3::Ptr< TcpSocketState >
TcpHighSpeedDecrementTest::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
tcp-highspeed-test.cc:123
HIGHSPEED_VALUES_N
#define HIGHSPEED_VALUES_N
Definition:
tcp-highspeed-test.cc:229
max
#define max(a, b)
Definition:
80211b.c:43
g_tcpHighSpeedTest
static TcpHighSpeedTestSuite g_tcpHighSpeedTest
Static variable for test initialization.
Definition:
tcp-highspeed-test.cc:270
TcpHighSpeedIncrementTest
Testing the congestion avoidance increment on TcpHighSpeed.
Definition:
tcp-highspeed-test.cc:37
TcpHighSpeedIncrementTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-highspeed-test.cc:52
TcpHighSpeedDecrementTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition:
tcp-highspeed-test.cc:108
TcpHighSpeedDecrementTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition:
tcp-highspeed-test.cc:110
TcpHighSpeedIncrementTest::TcpHighSpeedIncrementTest
TcpHighSpeedIncrementTest(uint32_t cWnd, uint32_t segmentSize, const std::string &name)
Constructor.
Definition:
tcp-highspeed-test.cc:56
TcpHighSpeedDecrementTest::TcpHighSpeedDecrementTest
TcpHighSpeedDecrementTest(uint32_t cWnd, uint32_t segmentSize, const std::string &name)
Constructor.
Definition:
tcp-highspeed-test.cc:113
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1344
TcpHighSpeedIncrementTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition:
tcp-highspeed-test.cc:51
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
ns3::TestSuite::UNIT
@ UNIT
This test suite implements a Unit Test.
Definition:
test.h:1353
HighSpeedImportantValues
TcpHighSpeed Congestion window values to test.
Definition:
tcp-highspeed-test.cc:151
segmentSize
uint32_t segmentSize
Definition:
tcp-linux-reno.cc:53
ns3::TcpSocketState::m_cWnd
TracedValue< uint32_t > m_cWnd
Congestion window.
Definition:
tcp-socket-state.h:165
TcpHighSpeedTestSuite::TcpHighSpeedTestSuite
TcpHighSpeedTestSuite()
Definition:
tcp-highspeed-test.cc:240
highSpeedImportantValues
static const struct HighSpeedImportantValues highSpeedImportantValues[]
List of data to be tested.
TcpHighSpeedDecrementTest
Testing the congestion avoidance decrement on TcpHighSpeed.
Definition:
tcp-highspeed-test.cc:94
HighSpeedImportantValues::md
unsigned int md
Currently unused.
Definition:
tcp-highspeed-test.cc:153
TcpHighSpeedDecrementTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-highspeed-test.cc:109
HighSpeedImportantValues::cwnd
unsigned int cwnd
Congestion window.
Definition:
tcp-highspeed-test.cc:152
ns3::TcpHighSpeed::GetSsThresh
virtual uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight)
Get slow start threshold following HighSpeed principles.
Definition:
tcp-highspeed.cc:141
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-highspeed-test.cc
Generated on Fri Oct 1 2021 17:03:12 for ns-3 by
1.8.20