A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-highspeed-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Natale Patriciello, <natale.patriciello@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8#include "ns3/log.h"
9#include "ns3/tcp-congestion-ops.h"
10#include "ns3/tcp-highspeed.h"
11#include "ns3/tcp-socket-base.h"
12#include "ns3/test.h"
13
14using namespace ns3;
15
16NS_LOG_COMPONENT_DEFINE("TcpHighSpeedTestSuite");
17
18/**
19 * @ingroup internet-test
20 *
21 * @brief Testing the congestion avoidance increment on TcpHighSpeed
22 */
24{
25 public:
26 /**
27 * @brief Constructor.
28 * @param cWnd Congestion window.
29 * @param segmentSize Segment size.
30 * @param name Test description.
31 */
32 TcpHighSpeedIncrementTest(uint32_t cWnd, uint32_t segmentSize, const std::string& name);
33
34 private:
35 void DoRun() override;
36
37 uint32_t m_cWnd; //!< Congestion window.
38 uint32_t m_segmentSize; //!< Segment size.
39 Ptr<TcpSocketState> m_state; //!< TCP socket state.
40};
41
44 const std::string& name)
45 : TestCase(name),
46 m_cWnd(cWnd),
48{
49}
50
51void
53{
55
56 m_state->m_cWnd = m_cWnd;
57 m_state->m_segmentSize = m_segmentSize;
58
60
61 uint32_t segCwnd = m_cWnd / m_segmentSize;
62 uint32_t coeffA = TcpHighSpeed::TableLookupA(segCwnd);
63
64 // Each received ACK weight is "coeffA". To see an increase of 1 MSS, we need
65 // to ACK at least segCwnd/coeffA ACK.
66
67 cong->IncreaseWindow(m_state, (segCwnd / coeffA) + 1);
68
69 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd.Get(), m_cWnd + m_segmentSize, "CWnd has not increased");
70}
71
72/**
73 * @ingroup internet-test
74 *
75 * @brief Testing the congestion avoidance decrement on TcpHighSpeed
76 */
78{
79 public:
80 /**
81 * @brief Constructor.
82 * @param cWnd Congestion window.
83 * @param segmentSize Segment size.
84 * @param name Test description.
85 */
86 TcpHighSpeedDecrementTest(uint32_t cWnd, uint32_t segmentSize, const std::string& name);
87
88 private:
89 void DoRun() override;
90
91 uint32_t m_cWnd; //!< Congestion window.
92 uint32_t m_segmentSize; //!< Segment size.
93 Ptr<TcpSocketState> m_state; //!< TCP socket state.
94};
95
98 const std::string& name)
99 : TestCase(name),
100 m_cWnd(cWnd),
102{
103}
104
105void
107{
109
110 m_state->m_cWnd = m_cWnd;
111 m_state->m_segmentSize = m_segmentSize;
112
114
115 uint32_t segCwnd = m_cWnd / m_segmentSize;
116 double coeffB = 1.0 - TcpHighSpeed::TableLookupB(segCwnd);
117
118 uint32_t ret = cong->GetSsThresh(m_state, m_state->m_cWnd);
119
120 uint32_t ssThHS = std::max(2.0, segCwnd * coeffB);
121
122 NS_TEST_ASSERT_MSG_EQ(ret / m_segmentSize, ssThHS, "HighSpeed decrement fn not used");
123}
124
125/**
126 * @ingroup internet-test
127 *
128 * @brief TcpHighSpeed Congestion window values to test.
129 */
131{
132 unsigned int cwnd; //!< Congestion window.
133 unsigned int md; //!< Currently unused.
134};
135
136/// List of data to be tested
138 {38, 128, /* 0.50 */}, {118, 112, /* 0.44 */}, {221, 104, /* 0.41 */},
139 {347, 98, /* 0.38 */}, {495, 93, /* 0.37 */}, {663, 89, /* 0.35 */},
140 {851, 86, /* 0.34 */}, {1058, 83, /* 0.33 */}, {1284, 81, /* 0.32 */},
141 {1529, 78, /* 0.31 */}, {1793, 76, /* 0.30 */}, {2076, 74, /* 0.29 */},
142 {2378, 72, /* 0.28 */}, {2699, 71, /* 0.28 */}, {3039, 69, /* 0.27 */},
143 {3399, 68, /* 0.27 */}, {3778, 66, /* 0.26 */}, {4177, 65, /* 0.26 */},
144 {4596, 64, /* 0.25 */}, {5036, 62, /* 0.25 */}, {5497, 61, /* 0.24 */},
145 {5979, 60, /* 0.24 */}, {6483, 59, /* 0.23 */}, {7009, 58, /* 0.23 */},
146 {7558, 57, /* 0.22 */}, {8130, 56, /* 0.22 */}, {8726, 55, /* 0.22 */},
147 {9346, 54, /* 0.21 */}, {9991, 53, /* 0.21 */}, {10661, 52, /* 0.21 */},
148 {11358, 52, /* 0.20 */}, {12082, 51, /* 0.20 */}, {12834, 50, /* 0.20 */},
149 {13614, 49, /* 0.19 */}, {14424, 48, /* 0.19 */}, {15265, 48, /* 0.19 */},
150 {16137, 47, /* 0.19 */}, {17042, 46, /* 0.18 */}, {17981, 45, /* 0.18 */},
151 {18955, 45, /* 0.18 */}, {19965, 44, /* 0.17 */}, {21013, 43, /* 0.17 */},
152 {22101, 43, /* 0.17 */}, {23230, 42, /* 0.17 */}, {24402, 41, /* 0.16 */},
153 {25618, 41, /* 0.16 */}, {26881, 40, /* 0.16 */}, {28193, 39, /* 0.16 */},
154 {29557, 39, /* 0.15 */}, {30975, 38, /* 0.15 */}, {32450, 38, /* 0.15 */},
155 {33986, 37, /* 0.15 */}, {35586, 36, /* 0.14 */}, {37253, 36, /* 0.14 */},
156 {38992, 35, /* 0.14 */}, {40808, 35, /* 0.14 */}, {42707, 34, /* 0.13 */},
157 {44694, 33, /* 0.13 */}, {46776, 33, /* 0.13 */}, {48961, 32, /* 0.13 */},
158 {51258, 32, /* 0.13 */}, {53677, 31, /* 0.12 */}, {56230, 30, /* 0.12 */},
159 {58932, 30, /* 0.12 */}, {61799, 29, /* 0.12 */}, {64851, 28, /* 0.11 */},
160 {68113, 28, /* 0.11 */}, {71617, 27, /* 0.11 */}, {75401, 26, /* 0.10 */},
161 {79517, 26, /* 0.10 */}, {84035, 25, /* 0.10 */}, {89053, 24, /* 0.10 */},
162};
163
164#define HIGHSPEED_VALUES_N 71
165
166/**
167 * @ingroup internet-test
168 *
169 * @brief TCP HighSpeed TestSuite
170 */
172{
173 public:
175 : TestSuite("tcp-highspeed-test", Type::UNIT)
176 {
177 std::stringstream ss;
178
179 for (uint32_t i = 0; i < HIGHSPEED_VALUES_N; ++i)
180 {
181 ss << highSpeedImportantValues[i].cwnd;
184 1,
185 "Highspeed increment test on cWnd " + ss.str()),
189 536,
190 "Highspeed increment test on cWnd " + ss.str()),
194 1446,
195 "Highspeed increment test on cWnd " + ss.str()),
199 1,
200 "Highspeed Decrement test on cWnd " + ss.str()),
204 536,
205 "Highspeed Decrement test on cWnd " + ss.str()),
209 1446,
210 "Highspeed Decrement test on cWnd " + ss.str()),
212 ss.flush();
213 }
214 }
215};
216
217static TcpHighSpeedTestSuite g_tcpHighSpeedTest; //!< Static variable for test initialization
Testing the congestion avoidance decrement on TcpHighSpeed.
uint32_t m_segmentSize
Segment size.
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_cWnd
Congestion window.
Ptr< TcpSocketState > m_state
TCP socket state.
TcpHighSpeedDecrementTest(uint32_t cWnd, uint32_t segmentSize, const std::string &name)
Constructor.
Testing the congestion avoidance increment on TcpHighSpeed.
Ptr< TcpSocketState > m_state
TCP socket state.
uint32_t m_segmentSize
Segment size.
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_cWnd
Congestion window.
TcpHighSpeedIncrementTest(uint32_t cWnd, uint32_t segmentSize, const std::string &name)
Constructor.
TCP HighSpeed TestSuite.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
static double TableLookupB(uint32_t w)
Lookup table for the coefficient b (from RFC 3649)
static uint32_t TableLookupA(uint32_t w)
Lookup table for the coefficient a (from RFC 3649)
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
@ QUICK
Fast test.
Definition test.h:1055
TestCase(const TestCase &)=delete
Type
Type of test.
Definition test.h:1274
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:490
static constexpr auto UNIT
Definition test.h:1291
uint32_t segmentSize
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TcpHighSpeed Congestion window values to test.
unsigned int cwnd
Congestion window.
unsigned int md
Currently unused.
static TcpHighSpeedTestSuite g_tcpHighSpeedTest
Static variable for test initialization.
static const HighSpeedImportantValues highSpeedImportantValues[]
List of data to be tested.
#define HIGHSPEED_VALUES_N