A Discrete-Event Network Simulator
API
tcp-lp-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 NITK Surathkal
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: Charitha Sangaraju <charitha29193@gmail.com>
18 * Nandita G <gm.nandita@gmail.com>
19 * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
20 *
21 */
22
23#include "ns3/log.h"
24#include "ns3/tcp-congestion-ops.h"
25#include "ns3/tcp-lp.h"
26#include "ns3/tcp-socket-base.h"
27#include "ns3/test.h"
28
29namespace ns3
30{
31
32NS_LOG_COMPONENT_DEFINE("TcpLpTestSuite");
33
41{
42 public:
54 uint32_t segmentsAcked,
55 uint32_t ssThresh,
56 Time rtt,
57 const std::string& name);
58
59 private:
60 void DoRun() override;
67};
68
71 uint32_t segmentsAcked,
72 uint32_t ssThresh,
73 Time rtt,
74 const std::string& name)
75 : TestCase(name),
76 m_cWnd(cWnd),
77 m_segmentSize(segmentSize),
78 m_ssThresh(ssThresh),
79 m_segmentsAcked(segmentsAcked),
80 m_rtt(rtt)
81{
82}
83
84void
86{
87 m_state = CreateObject<TcpSocketState>();
91
92 Ptr<TcpSocketState> state = CreateObject<TcpSocketState>();
93 state->m_cWnd = m_cWnd;
94 state->m_ssThresh = m_ssThresh;
96
97 Ptr<TcpLp> cong = CreateObject<TcpLp>();
98
101
102 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
103 cong->IncreaseWindow(m_state, m_segmentsAcked);
104
105 Ptr<TcpNewReno> NewRenoCong = CreateObject<TcpNewReno>();
106 NewRenoCong->IncreaseWindow(state, m_segmentsAcked);
107
109 state->m_cWnd.Get(),
110 "cWnd has not updated correctly");
113}
114
122{
123 public:
134 uint32_t segmentsAcked,
135 Time rtt,
136 const std::string& name);
137
138 private:
139 void DoRun() override;
140
146};
147
150 uint32_t segmentsAcked,
151 Time rtt,
152 const std::string& name)
153 : TestCase(name),
154 m_cWnd(cWnd),
155 m_segmentSize(segmentSize),
156 m_segmentsAcked(segmentsAcked),
157 m_rtt(rtt)
158{
159}
160
161void
163{
164 m_state = CreateObject<TcpSocketState>();
167
168 Ptr<TcpLp> cong = CreateObject<TcpLp>();
169
172
173 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
174
177 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
178
179 m_cWnd = m_cWnd / 2;
180 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd.Get(), m_cWnd, "cWnd has not updated correctly");
183}
184
192{
193 public:
204 uint32_t segmentsAcked,
205 Time rtt,
206 const std::string& name);
207
208 private:
209 void DoRun() override;
210
216};
217
220 uint32_t segmentsAcked,
221 Time rtt,
222 const std::string& name)
223 : TestCase(name),
224 m_cWnd(cWnd),
225 m_segmentSize(segmentSize),
226 m_segmentsAcked(segmentsAcked),
227 m_rtt(rtt)
228{
229}
230
231void
233{
234 m_state = CreateObject<TcpSocketState>();
237
238 Ptr<TcpLp> cong = CreateObject<TcpLp>();
239
242 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
243
246 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
247
250 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
251
252 m_cWnd = 1U * m_segmentSize;
253
254 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd.Get(), m_cWnd, "cWnd has not updated correctly");
257}
258
266{
267 public:
269 : TestSuite("tcp-lp-test", UNIT)
270 {
271 AddTestCase(new TcpLpToNewReno(4 * 1446,
272 1446,
273 2,
274 2 * 1446,
275 MilliSeconds(100),
276 "LP falls to New Reno if the cwd is within threshold"),
278
280 2 * 1446,
281 1446,
282 2,
283 MilliSeconds(100),
284 "LP enters Inference phase when cwd exceeds threshold for the first time"),
286
288 2 * 1446,
289 1446,
290 2,
291 MilliSeconds(100),
292 "LP reduces cWnd to 1 if cwd exceeds threshold in inference phase"),
294 }
295};
296
298
299} // namespace ns3
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:140
static void Run()
Run the simulation.
Definition: simulator.cc:176
Testing TcpLp when cwd exceeds threshold.
Definition: tcp-lp-test.cc:122
void DoRun() override
Implementation to actually run this TestCase.
Definition: tcp-lp-test.cc:162
uint32_t m_cWnd
Congestion window size.
Definition: tcp-lp-test.cc:141
TcpLpInferenceTest1(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, Time rtt, const std::string &name)
Constructor.
Definition: tcp-lp-test.cc:148
uint32_t m_segmentsAcked
Segments acked.
Definition: tcp-lp-test.cc:143
Ptr< TcpSocketState > m_state
TCP socket state.
Definition: tcp-lp-test.cc:145
uint32_t m_segmentSize
Segment size.
Definition: tcp-lp-test.cc:142
Testing TcpLp when it is inference phase.
Definition: tcp-lp-test.cc:192
uint32_t m_segmentsAcked
Segments acked.
Definition: tcp-lp-test.cc:213
uint32_t m_cWnd
Congestion window size.
Definition: tcp-lp-test.cc:211
TcpLpInferenceTest2(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, Time rtt, const std::string &name)
Constructor.
Definition: tcp-lp-test.cc:218
uint32_t m_segmentSize
Segment size.
Definition: tcp-lp-test.cc:212
void DoRun() override
Implementation to actually run this TestCase.
Definition: tcp-lp-test.cc:232
Ptr< TcpSocketState > m_state
TCP socket state.
Definition: tcp-lp-test.cc:215
Test the behaviour common to New Reno.
Definition: tcp-lp-test.cc:266
Testing the behaviour common to New Reno.
Definition: tcp-lp-test.cc:41
uint32_t m_ssThresh
Slow start threshold.
Definition: tcp-lp-test.cc:63
uint32_t m_segmentsAcked
Segments acked.
Definition: tcp-lp-test.cc:64
void DoRun() override
Implementation to actually run this TestCase.
Definition: tcp-lp-test.cc:85
Ptr< TcpSocketState > m_state
TCP socket state.
Definition: tcp-lp-test.cc:66
TcpLpToNewReno(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, uint32_t ssThresh, Time rtt, const std::string &name)
Constructor.
Definition: tcp-lp-test.cc:69
uint32_t m_cWnd
Congestion window size.
Definition: tcp-lp-test.cc:61
uint32_t m_segmentSize
Segment size.
Definition: tcp-lp-test.cc:62
uint32_t m_segmentSize
Segment size.
TracedValue< uint32_t > m_cWnd
Congestion window.
uint32_t m_rcvTimestampEchoReply
Sender Timestamp echoed by the receiver.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
uint32_t m_rcvTimestampValue
Receiver Timestamp value.
encapsulates test code
Definition: test.h:1060
@ QUICK
Fast test.
Definition: test.h:1065
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:305
A suite of tests to run.
Definition: test.h:1256
@ UNIT
This test suite implements a Unit Test.
Definition: test.h:1265
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
T Get() const
Get the underlying value.
Definition: traced-value.h:249
uint32_t segmentSize
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1350
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TcpLpTestSuite g_tcplpTest
static var for test initialization
Definition: tcp-lp-test.cc:297