A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-ledbat-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 * Author: Ankit Deepak <adadeepak8@gmail.com>
18 *
19 */
20
21#include "ns3/log.h"
22#include "ns3/string.h"
23#include "ns3/tcp-congestion-ops.h"
24#include "ns3/tcp-ledbat.h"
25#include "ns3/tcp-socket-base.h"
26#include "ns3/test.h"
27
28using namespace ns3;
29
30NS_LOG_COMPONENT_DEFINE("TcpLedbatTestSuite");
31
38{
39 public:
54 uint32_t ssThresh,
55 uint32_t segmentsAcked,
56 SequenceNumber32 highTxMark,
57 SequenceNumber32 lastAckedSeq,
58 Time rtt,
59 const std::string& name);
60
61 private:
62 void DoRun() override;
65 void ExecuteTest();
66
75};
76
79 uint32_t ssThresh,
80 uint32_t segmentsAcked,
81 SequenceNumber32 highTxMark,
82 SequenceNumber32 lastAckedSeq,
83 Time rtt,
84 const std::string& name)
85 : TestCase(name),
86 m_cWnd(cWnd),
87 m_segmentSize(segmentSize),
88 m_segmentsAcked(segmentsAcked),
89 m_ssThresh(ssThresh),
90 m_rtt(rtt),
91 m_highTxMark(highTxMark),
92 m_lastAckedSeq(lastAckedSeq)
93{
94}
95
96void
98{
102}
103
104void
106{
107 m_state = CreateObject<TcpSocketState>();
113
114 Ptr<TcpSocketState> state = CreateObject<TcpSocketState>();
115 state->m_cWnd = m_cWnd;
116 state->m_ssThresh = m_ssThresh;
117 state->m_segmentSize = m_segmentSize;
118 state->m_highTxMark = m_highTxMark;
119 state->m_lastAckedSeq = m_lastAckedSeq;
120
121 Ptr<TcpLedbat> cong = CreateObject<TcpLedbat>();
122 cong->IncreaseWindow(m_state, m_segmentsAcked);
123
124 Ptr<TcpNewReno> NewRenoCong = CreateObject<TcpNewReno>();
125 NewRenoCong->IncreaseWindow(state, m_segmentsAcked);
126
128 state->m_cWnd.Get(),
129 "cWnd has not updated correctly");
130}
131
138{
139 public:
154 uint32_t ssThresh,
155 uint32_t segmentsAcked,
156 SequenceNumber32 highTxMark,
157 SequenceNumber32 lastAckedSeq,
158 Time rtt,
159 const std::string& name);
160
161 private:
162 void DoRun() override;
165 void ExecuteTest();
166
175};
176
179 uint32_t ssThresh,
180 uint32_t segmentsAcked,
181 SequenceNumber32 highTxMark,
182 SequenceNumber32 lastAckedSeq,
183 Time rtt,
184 const std::string& name)
185 : TestCase(name),
186 m_cWnd(cWnd),
187 m_segmentSize(segmentSize),
188 m_segmentsAcked(segmentsAcked),
189 m_ssThresh(ssThresh),
190 m_rtt(rtt),
191 m_highTxMark(highTxMark),
192 m_lastAckedSeq(lastAckedSeq)
193{
194}
195
196void
198{
202}
203
204void
206{
207 m_state = CreateObject<TcpSocketState>();
213
214 Ptr<TcpLedbat> cong = CreateObject<TcpLedbat>();
215 cong->SetAttribute("SSParam", StringValue("no"));
216 cong->SetAttribute("NoiseFilterLen", UintegerValue(1));
217
220 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
221
224 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
225
226 cong->IncreaseWindow(m_state, m_segmentsAcked);
227
229
230 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd.Get(), m_cWnd, "cWnd has not updated correctly");
231}
232
239{
240 public:
255 uint32_t ssThresh,
256 uint32_t segmentsAcked,
257 SequenceNumber32 highTxMark,
258 SequenceNumber32 lastAckedSeq,
259 Time rtt,
260 const std::string& name);
261
262 private:
263 void DoRun() override;
266 void ExecuteTest();
267
276};
277
280 uint32_t ssThresh,
281 uint32_t segmentsAcked,
282 SequenceNumber32 highTxMark,
283 SequenceNumber32 lastAckedSeq,
284 Time rtt,
285 const std::string& name)
286 : TestCase(name),
287 m_cWnd(cWnd),
288 m_segmentSize(segmentSize),
289 m_segmentsAcked(segmentsAcked),
290 m_ssThresh(ssThresh),
291 m_rtt(rtt),
292 m_highTxMark(highTxMark),
293 m_lastAckedSeq(lastAckedSeq)
294{
295}
296
297void
299{
303}
304
305void
307{
308 UintegerValue minCwnd;
309 m_state = CreateObject<TcpSocketState>();
315
316 Ptr<TcpLedbat> cong = CreateObject<TcpLedbat>();
317 cong->SetAttribute("SSParam", StringValue("no"));
318 cong->SetAttribute("NoiseFilterLen", UintegerValue(1));
319 cong->GetAttribute("MinCwnd", minCwnd);
320
323 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
324
327 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
328
329 cong->IncreaseWindow(m_state, m_segmentsAcked);
330
332 m_cWnd = std::max(m_cWnd, static_cast<uint32_t>(m_segmentSize * minCwnd.Get()));
333
334 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd.Get(), m_cWnd, "cWnd has not updated correctly");
335}
336
343{
344 public:
346 : TestSuite("tcp-ledbat-test", UNIT)
347 {
348 AddTestCase(new TcpLedbatToNewReno(2 * 1446,
349 1446,
350 4 * 1446,
351 2,
352 SequenceNumber32(4753),
353 SequenceNumber32(3216),
354 MilliSeconds(100),
355 "LEDBAT falls to New Reno for slowstart"),
357 AddTestCase(new TcpLedbatToNewReno(4 * 1446,
358 1446,
359 2 * 1446,
360 2,
361 SequenceNumber32(4753),
362 SequenceNumber32(3216),
363 MilliSeconds(100),
364 "LEDBAT falls to New Reno if timestamps are not found"),
367 1446,
368 4 * 1446,
369 2,
370 SequenceNumber32(4753),
371 SequenceNumber32(3216),
372 MilliSeconds(100),
373 "LEDBAT increment test"),
376 1446,
377 4 * 1446,
378 2,
379 SequenceNumber32(4753),
380 SequenceNumber32(3216),
381 MilliSeconds(100),
382 "LEDBAT decrement test"),
384 }
385};
386
Test to validate cWnd decrement in LEDBAT.
TcpLedbatDecrementTest(uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh, uint32_t segmentsAcked, SequenceNumber32 highTxMark, SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
Constructor.
SequenceNumber32 m_highTxMark
high tx mark
uint32_t m_segmentSize
segment size
uint32_t m_ssThresh
ss thresh
void ExecuteTest()
Execute the test.
uint32_t m_segmentsAcked
segments acked
SequenceNumber32 m_lastAckedSeq
last acked seq
void DoRun() override
Implementation to actually run this TestCase.
Ptr< TcpSocketState > m_state
state
Test to validate cWnd increment in LEDBAT.
SequenceNumber32 m_highTxMark
high tx mark
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_segmentsAcked
segments acked
void ExecuteTest()
Execute the test.
uint32_t m_segmentSize
segment size
TcpLedbatIncrementTest(uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh, uint32_t segmentsAcked, SequenceNumber32 highTxMark, SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
Constructor.
uint32_t m_ssThresh
ss thresh
SequenceNumber32 m_lastAckedSeq
last acked seq
Ptr< TcpSocketState > m_state
state
TCP Ledbat TestSuite.
LEDBAT should be same as NewReno during slow start, and when timestamps are disabled.
uint32_t m_segmentsAcked
segments acked
TcpLedbatToNewReno(uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh, uint32_t segmentsAcked, SequenceNumber32 highTxMark, SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
Constructor.
SequenceNumber32 m_highTxMark
high tx mark
Ptr< TcpSocketState > m_state
state
SequenceNumber32 m_lastAckedSeq
last acked seq
void DoRun() override
Implementation to actually run this TestCase.
void ExecuteTest()
Execute the test.
uint32_t m_segmentSize
segment size
uint32_t m_ssThresh
ss thresh
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:568
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:140
static void Run()
Run the simulation.
Definition: simulator.cc:176
Hold variables of type string.
Definition: string.h:56
uint32_t m_segmentSize
Segment size.
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
SequenceNumber32 m_lastAckedSeq
Last sequence ACKed.
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
Hold an unsigned integer type.
Definition: uinteger.h:45
uint64_t Get() const
Definition: uinteger.cc:37
uint32_t segmentSize
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
SequenceNumber< uint32_t, int32_t > SequenceNumber32
32 bit Sequence number.
#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 Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
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 TcpLedbatTestSuite g_tcpledbatTest
static var for test initialization