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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Authors: Truc Anh N. Nguyen <annguyen@ittc.ku.edu>
7
8
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
9
* ResiliNets Research Group https://resilinets.org/
10
* Information and Telecommunication Technology Center (ITTC)
11
* and Department of Electrical Engineering and Computer Science
12
* The University of Kansas Lawrence, KS USA.
13
*
14
*/
15
16
#include "ns3/log.h"
17
#include "ns3/tcp-congestion-ops.h"
18
#include "ns3/tcp-scalable.h"
19
#include "ns3/tcp-socket-base.h"
20
#include "ns3/test.h"
21
22
using namespace
ns3
;
23
24
NS_LOG_COMPONENT_DEFINE
(
"TcpScalableTestSuite"
);
25
26
/**
27
* @ingroup internet-test
28
*
29
* @brief Testing the congestion avoidance increment on TcpScalable
30
*/
31
class
TcpScalableIncrementTest
:
public
TestCase
32
{
33
public
:
34
/**
35
* @brief Constructor.
36
* @param cWnd Congestion window.
37
* @param segmentSize Segment size.
38
* @param segmentsAcked Segments ACKed.
39
* @param name Test description.
40
*/
41
TcpScalableIncrementTest
(
uint32_t
cWnd,
42
uint32_t
segmentSize
,
43
uint32_t
segmentsAcked,
44
const
std::string& name);
45
46
private
:
47
void
DoRun
()
override
;
48
49
uint32_t
m_cWnd
;
//!< Congestion window.
50
uint32_t
m_segmentSize
;
//!< Segment size.
51
uint32_t
m_segmentsAcked
;
//!< Segments ACKed.
52
Ptr<TcpSocketState>
m_state
;
//!< TCP socket state.
53
};
54
55
TcpScalableIncrementTest::TcpScalableIncrementTest
(
uint32_t
cWnd,
56
uint32_t
segmentSize
,
57
uint32_t
segmentsAcked,
58
const
std::string& name)
59
:
TestCase
(name),
60
m_cWnd(cWnd),
61
m_segmentSize(
segmentSize
),
62
m_segmentsAcked(segmentsAcked)
63
{
64
}
65
66
void
67
TcpScalableIncrementTest::DoRun
()
68
{
69
m_state
=
CreateObject<TcpSocketState>
();
70
71
m_state
->m_cWnd =
m_cWnd
;
72
m_state
->m_segmentSize =
m_segmentSize
;
73
74
Ptr<TcpScalable>
cong =
CreateObject<TcpScalable>
();
75
76
uint32_t
segCwnd =
m_cWnd
/
m_segmentSize
;
77
78
// Get default value of additive increase factor
79
UintegerValue
aiFactor;
80
cong->GetAttribute(
"AIFactor"
, aiFactor);
81
82
// To see an increase of 1 MSS, the number of segments ACKed has to be at least
83
// min (segCwnd, aiFactor).
84
85
uint32_t
w = std::min(segCwnd, (
uint32_t
)aiFactor.
Get
());
86
uint32_t
delta =
m_segmentsAcked
/ w;
87
88
cong->IncreaseWindow(
m_state
,
m_segmentsAcked
);
89
90
NS_TEST_ASSERT_MSG_EQ
(
m_state
->m_cWnd.Get(),
91
m_cWnd
+ delta *
m_segmentSize
,
92
"CWnd has not increased"
);
93
}
94
95
/**
96
* @ingroup internet-test
97
*
98
* @brief Testing the multiplicative decrease on TcpScalable
99
*/
100
class
TcpScalableDecrementTest
:
public
TestCase
101
{
102
public
:
103
/**
104
* @brief Constructor.
105
* @param cWnd Congestion window.
106
* @param segmentSize Segment size.
107
* @param name Test description.
108
*/
109
TcpScalableDecrementTest
(
uint32_t
cWnd,
uint32_t
segmentSize
,
const
std::string& name);
110
111
private
:
112
void
DoRun
()
override
;
113
114
uint32_t
m_cWnd
;
//!< Congestion window.
115
uint32_t
m_segmentSize
;
//!< Segment size.
116
Ptr<TcpSocketState>
m_state
;
//!< TCP socket state.
117
};
118
119
TcpScalableDecrementTest::TcpScalableDecrementTest
(
uint32_t
cWnd,
120
uint32_t
segmentSize
,
121
const
std::string& name)
122
:
TestCase
(name),
123
m_cWnd(cWnd),
124
m_segmentSize(
segmentSize
)
125
{
126
}
127
128
void
129
TcpScalableDecrementTest::DoRun
()
130
{
131
m_state
=
CreateObject<TcpSocketState>
();
132
133
m_state
->m_cWnd =
m_cWnd
;
134
m_state
->m_segmentSize =
m_segmentSize
;
135
136
Ptr<TcpScalable>
cong =
CreateObject<TcpScalable>
();
137
138
uint32_t
segCwnd =
m_cWnd
/
m_segmentSize
;
139
140
// Get default value of multiplicative decrease factor
141
DoubleValue
mdFactor;
142
cong->GetAttribute(
"MDFactor"
, mdFactor);
143
144
double
b = 1.0 - mdFactor.
Get
();
145
146
uint32_t
ssThresh = std::max(2.0, segCwnd * b);
147
148
uint32_t
ssThreshInSegments = cong->GetSsThresh(
m_state
,
m_state
->m_cWnd) /
m_segmentSize
;
149
150
NS_TEST_ASSERT_MSG_EQ
(ssThreshInSegments, ssThresh,
"Scalable decrement fn not used"
);
151
}
152
153
/**
154
* @ingroup internet-test
155
*
156
* @brief TcpScalable TestSuite.
157
*/
158
class
TcpScalableTestSuite
:
public
TestSuite
159
{
160
public
:
161
TcpScalableTestSuite
()
162
:
TestSuite
(
"tcp-scalable-test"
,
Type
::
UNIT
)
163
{
164
AddTestCase
(
165
new
TcpScalableIncrementTest
(
166
38 * 536,
167
536,
168
38,
169
"Scalable increment test on cWnd = 38 segments and segmentSize = 536 bytes"
),
170
TestCase::Duration::QUICK);
171
AddTestCase
(
new
TcpScalableIncrementTest
(
172
38,
173
1,
174
100,
175
"Scalable increment test on cWnd = 38 segments and segmentSize = 1 byte"
),
176
TestCase::Duration::QUICK);
177
AddTestCase
(
178
new
TcpScalableIncrementTest
(
179
53 * 1446,
180
1446,
181
50,
182
"Scalable increment test on cWnd = 53 segments and segmentSize = 1446 bytes"
),
183
TestCase::Duration::QUICK);
184
185
AddTestCase
(
new
TcpScalableDecrementTest
(
186
38,
187
1,
188
"Scalable decrement test on cWnd = 38 segments and segmentSize = 1 byte"
),
189
TestCase::Duration::QUICK);
190
AddTestCase
(
191
new
TcpScalableDecrementTest
(
192
100 * 536,
193
536,
194
"Scalable decrement test on cWnd = 100 segments and segmentSize = 536 bytes"
),
195
TestCase::Duration::QUICK);
196
AddTestCase
(
197
new
TcpScalableDecrementTest
(
198
40 * 1446,
199
1446,
200
"Scalable decrement test on cWnd = 40 segments and segmentSize = 1446 bytes"
),
201
TestCase::Duration::QUICK);
202
}
203
};
204
205
static
TcpScalableTestSuite
g_tcpScalableTest
;
//!< Static variable for test initialization
TcpScalableDecrementTest
Testing the multiplicative decrease on TcpScalable.
Definition
tcp-scalable-test.cc:101
TcpScalableDecrementTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition
tcp-scalable-test.cc:115
TcpScalableDecrementTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition
tcp-scalable-test.cc:116
TcpScalableDecrementTest::TcpScalableDecrementTest
TcpScalableDecrementTest(uint32_t cWnd, uint32_t segmentSize, const std::string &name)
Constructor.
Definition
tcp-scalable-test.cc:119
TcpScalableDecrementTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition
tcp-scalable-test.cc:114
TcpScalableDecrementTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
tcp-scalable-test.cc:129
TcpScalableIncrementTest
Testing the congestion avoidance increment on TcpScalable.
Definition
tcp-scalable-test.cc:32
TcpScalableIncrementTest::TcpScalableIncrementTest
TcpScalableIncrementTest(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, const std::string &name)
Constructor.
Definition
tcp-scalable-test.cc:55
TcpScalableIncrementTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition
tcp-scalable-test.cc:50
TcpScalableIncrementTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition
tcp-scalable-test.cc:52
TcpScalableIncrementTest::m_segmentsAcked
uint32_t m_segmentsAcked
Segments ACKed.
Definition
tcp-scalable-test.cc:51
TcpScalableIncrementTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
tcp-scalable-test.cc:67
TcpScalableIncrementTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition
tcp-scalable-test.cc:49
TcpScalableTestSuite
TcpScalable TestSuite.
Definition
tcp-scalable-test.cc:159
TcpScalableTestSuite::TcpScalableTestSuite
TcpScalableTestSuite()
Definition
tcp-scalable-test.cc:161
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition
double.h:31
ns3::DoubleValue::Get
double Get() const
Definition
double.cc:26
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TestCase
encapsulates test code
Definition
test.h:1050
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:292
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
ns3::TestSuite::UNIT
static constexpr auto UNIT
Definition
test.h:1291
ns3::UintegerValue
Hold an unsigned integer type.
Definition
uinteger.h:34
ns3::UintegerValue::Get
uint64_t Get() const
Definition
uinteger.cc:26
uint32_t
segmentSize
uint32_t segmentSize
Definition
tcp-linux-reno.cc:42
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
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:134
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:205
src
internet
test
tcp-scalable-test.cc
Generated on Tue Nov 12 2024 18:20:42 for ns-3 by
1.11.0