A Discrete-Event Network Simulator
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
22using namespace ns3;
23
24NS_LOG_COMPONENT_DEFINE("TcpScalableTestSuite");
25
26/**
27 * \ingroup internet-test
28 *
29 * \brief Testing the congestion avoidance increment on TcpScalable
30 */
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 */
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
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
66void
68{
70
71 m_state->m_cWnd = m_cWnd;
72 m_state->m_segmentSize = m_segmentSize;
73
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 */
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
121 const std::string& name)
122 : TestCase(name),
123 m_cWnd(cWnd),
124 m_segmentSize(segmentSize)
125{
126}
127
128void
130{
132
133 m_state->m_cWnd = m_cWnd;
134 m_state->m_segmentSize = m_segmentSize;
135
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 */
159{
160 public:
162 : TestSuite("tcp-scalable-test", Type::UNIT)
163 {
166 38 * 536,
167 536,
168 38,
169 "Scalable increment test on cWnd = 38 segments and segmentSize = 536 bytes"),
170 TestCase::Duration::QUICK);
172 38,
173 1,
174 100,
175 "Scalable increment test on cWnd = 38 segments and segmentSize = 1 byte"),
176 TestCase::Duration::QUICK);
179 53 * 1446,
180 1446,
181 50,
182 "Scalable increment test on cWnd = 53 segments and segmentSize = 1446 bytes"),
183 TestCase::Duration::QUICK);
184
186 38,
187 1,
188 "Scalable decrement test on cWnd = 38 segments and segmentSize = 1 byte"),
189 TestCase::Duration::QUICK);
192 100 * 536,
193 536,
194 "Scalable decrement test on cWnd = 100 segments and segmentSize = 536 bytes"),
195 TestCase::Duration::QUICK);
198 40 * 1446,
199 1446,
200 "Scalable decrement test on cWnd = 40 segments and segmentSize = 1446 bytes"),
201 TestCase::Duration::QUICK);
202 }
203};
204
205static TcpScalableTestSuite g_tcpScalableTest; //!< Static variable for test initialization
Testing the multiplicative decrease on TcpScalable.
uint32_t m_segmentSize
Segment size.
Ptr< TcpSocketState > m_state
TCP socket state.
TcpScalableDecrementTest(uint32_t cWnd, uint32_t segmentSize, const std::string &name)
Constructor.
uint32_t m_cWnd
Congestion window.
void DoRun() override
Implementation to actually run this TestCase.
Testing the congestion avoidance increment on TcpScalable.
TcpScalableIncrementTest(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, const std::string &name)
Constructor.
uint32_t m_segmentSize
Segment size.
Ptr< TcpSocketState > m_state
TCP socket state.
uint32_t m_segmentsAcked
Segments ACKed.
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_cWnd
Congestion window.
TcpScalable TestSuite.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
double Get() const
Definition double.cc:26
Smart pointer class similar to boost::intrusive_ptr.
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
static constexpr auto UNIT
Definition test.h:1291
Hold an unsigned integer type.
Definition uinteger.h:34
uint64_t Get() const
Definition uinteger.cc:26
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.
static TcpScalableTestSuite g_tcpScalableTest
Static variable for test initialization.