A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
40{
41 public:
53 uint32_t segmentsAcked,
54 uint32_t ssThresh,
55 Time rtt,
56 const std::string& name);
57
58 private:
59 void DoRun() override;
66};
67
70 uint32_t segmentsAcked,
71 uint32_t ssThresh,
72 Time rtt,
73 const std::string& name)
74 : TestCase(name),
75 m_cWnd(cWnd),
76 m_segmentSize(segmentSize),
77 m_ssThresh(ssThresh),
78 m_segmentsAcked(segmentsAcked),
79 m_rtt(rtt)
80{
81}
82
83void
85{
86 m_state = CreateObject<TcpSocketState>();
90
91 Ptr<TcpSocketState> state = CreateObject<TcpSocketState>();
92 state->m_cWnd = m_cWnd;
93 state->m_ssThresh = m_ssThresh;
94 state->m_segmentSize = m_segmentSize;
95
96 Ptr<TcpLp> cong = CreateObject<TcpLp>();
97
100
101 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
102 cong->IncreaseWindow(m_state, m_segmentsAcked);
103
104 Ptr<TcpNewReno> NewRenoCong = CreateObject<TcpNewReno>();
105 NewRenoCong->IncreaseWindow(state, m_segmentsAcked);
106
108 state->m_cWnd.Get(),
109 "cWnd has not updated correctly");
112}
113
120{
121 public:
132 uint32_t segmentsAcked,
133 Time rtt,
134 const std::string& name);
135
136 private:
137 void DoRun() override;
138
144};
145
148 uint32_t segmentsAcked,
149 Time rtt,
150 const std::string& name)
151 : TestCase(name),
152 m_cWnd(cWnd),
153 m_segmentSize(segmentSize),
154 m_segmentsAcked(segmentsAcked),
155 m_rtt(rtt)
156{
157}
158
159void
161{
162 m_state = CreateObject<TcpSocketState>();
165
166 Ptr<TcpLp> cong = CreateObject<TcpLp>();
167
170
171 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
172
175 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
176
177 m_cWnd = m_cWnd / 2;
178 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd.Get(), m_cWnd, "cWnd has not updated correctly");
181}
182
189{
190 public:
201 uint32_t segmentsAcked,
202 Time rtt,
203 const std::string& name);
204
205 private:
206 void DoRun() override;
207
213};
214
217 uint32_t segmentsAcked,
218 Time rtt,
219 const std::string& name)
220 : TestCase(name),
221 m_cWnd(cWnd),
222 m_segmentSize(segmentSize),
223 m_segmentsAcked(segmentsAcked),
224 m_rtt(rtt)
225{
226}
227
228void
230{
231 m_state = CreateObject<TcpSocketState>();
234
235 Ptr<TcpLp> cong = CreateObject<TcpLp>();
236
239 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
240
243 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
244
247 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
248
249 m_cWnd = 1U * m_segmentSize;
250
251 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd.Get(), m_cWnd, "cWnd has not updated correctly");
254}
255
262{
263 public:
265 : TestSuite("tcp-lp-test", UNIT)
266 {
267 AddTestCase(new TcpLpToNewReno(4 * 1446,
268 1446,
269 2,
270 2 * 1446,
271 MilliSeconds(100),
272 "LP falls to New Reno if the cwd is within threshold"),
274
276 2 * 1446,
277 1446,
278 2,
279 MilliSeconds(100),
280 "LP enters Inference phase when cwd exceeds threshold for the first time"),
282
284 2 * 1446,
285 1446,
286 2,
287 MilliSeconds(100),
288 "LP reduces cWnd to 1 if cwd exceeds threshold in inference phase"),
290 }
291};
292
294
295} // namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
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:120
void DoRun() override
Implementation to actually run this TestCase.
Definition: tcp-lp-test.cc:160
uint32_t m_cWnd
Congestion window size.
Definition: tcp-lp-test.cc:139
TcpLpInferenceTest1(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, Time rtt, const std::string &name)
Constructor.
Definition: tcp-lp-test.cc:146
uint32_t m_segmentsAcked
Segments acked.
Definition: tcp-lp-test.cc:141
Ptr< TcpSocketState > m_state
TCP socket state.
Definition: tcp-lp-test.cc:143
uint32_t m_segmentSize
Segment size.
Definition: tcp-lp-test.cc:140
Testing TcpLp when it is inference phase.
Definition: tcp-lp-test.cc:189
uint32_t m_segmentsAcked
Segments acked.
Definition: tcp-lp-test.cc:210
uint32_t m_cWnd
Congestion window size.
Definition: tcp-lp-test.cc:208
TcpLpInferenceTest2(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, Time rtt, const std::string &name)
Constructor.
Definition: tcp-lp-test.cc:215
uint32_t m_segmentSize
Segment size.
Definition: tcp-lp-test.cc:209
void DoRun() override
Implementation to actually run this TestCase.
Definition: tcp-lp-test.cc:229
Ptr< TcpSocketState > m_state
TCP socket state.
Definition: tcp-lp-test.cc:212
Test the behaviour common to New Reno.
Definition: tcp-lp-test.cc:262
Testing the behaviour common to New Reno.
Definition: tcp-lp-test.cc:40
uint32_t m_ssThresh
Slow start threshold.
Definition: tcp-lp-test.cc:62
uint32_t m_segmentsAcked
Segments acked.
Definition: tcp-lp-test.cc:63
void DoRun() override
Implementation to actually run this TestCase.
Definition: tcp-lp-test.cc:84
Ptr< TcpSocketState > m_state
TCP socket state.
Definition: tcp-lp-test.cc:65
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:68
uint32_t m_cWnd
Congestion window size.
Definition: tcp-lp-test.cc:60
uint32_t m_segmentSize
Segment size.
Definition: tcp-lp-test.cc:61
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:301
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:1348
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:293