A Discrete-Event Network Simulator
API
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
39{
40 public:
55 uint32_t ssThresh,
56 uint32_t segmentsAcked,
57 SequenceNumber32 highTxMark,
58 SequenceNumber32 lastAckedSeq,
59 Time rtt,
60 const std::string& name);
61
62 private:
63 void DoRun() override;
66 void ExecuteTest();
67
76};
77
80 uint32_t ssThresh,
81 uint32_t segmentsAcked,
82 SequenceNumber32 highTxMark,
83 SequenceNumber32 lastAckedSeq,
84 Time rtt,
85 const std::string& name)
86 : TestCase(name),
87 m_cWnd(cWnd),
88 m_segmentSize(segmentSize),
89 m_segmentsAcked(segmentsAcked),
90 m_ssThresh(ssThresh),
91 m_rtt(rtt),
92 m_highTxMark(highTxMark),
93 m_lastAckedSeq(lastAckedSeq)
94{
95}
96
97void
99{
100 Simulator::Schedule(Seconds(0.0), &TcpLedbatToNewReno::ExecuteTest, this);
101 Simulator::Run();
102 Simulator::Destroy();
103}
104
105void
107{
108 m_state = CreateObject<TcpSocketState>();
114
115 Ptr<TcpSocketState> state = CreateObject<TcpSocketState>();
116 state->m_cWnd = m_cWnd;
117 state->m_ssThresh = m_ssThresh;
119 state->m_highTxMark = m_highTxMark;
121
122 Ptr<TcpLedbat> cong = CreateObject<TcpLedbat>();
123 cong->IncreaseWindow(m_state, m_segmentsAcked);
124
125 Ptr<TcpNewReno> NewRenoCong = CreateObject<TcpNewReno>();
126 NewRenoCong->IncreaseWindow(state, m_segmentsAcked);
127
129 state->m_cWnd.Get(),
130 "cWnd has not updated correctly");
131}
132
140{
141 public:
156 uint32_t ssThresh,
157 uint32_t segmentsAcked,
158 SequenceNumber32 highTxMark,
159 SequenceNumber32 lastAckedSeq,
160 Time rtt,
161 const std::string& name);
162
163 private:
164 void DoRun() override;
167 void ExecuteTest();
168
177};
178
181 uint32_t ssThresh,
182 uint32_t segmentsAcked,
183 SequenceNumber32 highTxMark,
184 SequenceNumber32 lastAckedSeq,
185 Time rtt,
186 const std::string& name)
187 : TestCase(name),
188 m_cWnd(cWnd),
189 m_segmentSize(segmentSize),
190 m_segmentsAcked(segmentsAcked),
191 m_ssThresh(ssThresh),
192 m_rtt(rtt),
193 m_highTxMark(highTxMark),
194 m_lastAckedSeq(lastAckedSeq)
195{
196}
197
198void
200{
201 Simulator::Schedule(Seconds(0.0), &TcpLedbatIncrementTest::ExecuteTest, this);
202 Simulator::Run();
203 Simulator::Destroy();
204}
205
206void
208{
209 m_state = CreateObject<TcpSocketState>();
215
216 Ptr<TcpLedbat> cong = CreateObject<TcpLedbat>();
217 cong->SetAttribute("SSParam", StringValue("no"));
218 cong->SetAttribute("NoiseFilterLen", UintegerValue(1));
219
222 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
223
226 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
227
228 cong->IncreaseWindow(m_state, m_segmentsAcked);
229
231
232 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd.Get(), m_cWnd, "cWnd has not updated correctly");
233}
234
242{
243 public:
258 uint32_t ssThresh,
259 uint32_t segmentsAcked,
260 SequenceNumber32 highTxMark,
261 SequenceNumber32 lastAckedSeq,
262 Time rtt,
263 const std::string& name);
264
265 private:
266 void DoRun() override;
269 void ExecuteTest();
270
279};
280
283 uint32_t ssThresh,
284 uint32_t segmentsAcked,
285 SequenceNumber32 highTxMark,
286 SequenceNumber32 lastAckedSeq,
287 Time rtt,
288 const std::string& name)
289 : TestCase(name),
290 m_cWnd(cWnd),
291 m_segmentSize(segmentSize),
292 m_segmentsAcked(segmentsAcked),
293 m_ssThresh(ssThresh),
294 m_rtt(rtt),
295 m_highTxMark(highTxMark),
296 m_lastAckedSeq(lastAckedSeq)
297{
298}
299
300void
302{
303 Simulator::Schedule(Seconds(0.0), &TcpLedbatDecrementTest::ExecuteTest, this);
304 Simulator::Run();
305 Simulator::Destroy();
306}
307
308void
310{
311 UintegerValue minCwnd;
312 m_state = CreateObject<TcpSocketState>();
318
319 Ptr<TcpLedbat> cong = CreateObject<TcpLedbat>();
320 cong->SetAttribute("SSParam", StringValue("no"));
321 cong->SetAttribute("NoiseFilterLen", UintegerValue(1));
322 cong->GetAttribute("MinCwnd", minCwnd);
323
326 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
327
330 cong->PktsAcked(m_state, m_segmentsAcked, m_rtt);
331
332 cong->IncreaseWindow(m_state, m_segmentsAcked);
333
335 m_cWnd = std::max(m_cWnd, static_cast<uint32_t>(m_segmentSize * minCwnd.Get()));
336
337 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd.Get(), m_cWnd, "cWnd has not updated correctly");
338}
339
347{
348 public:
350 : TestSuite("tcp-ledbat-test", UNIT)
351 {
352 AddTestCase(new TcpLedbatToNewReno(2 * 1446,
353 1446,
354 4 * 1446,
355 2,
356 SequenceNumber32(4753),
357 SequenceNumber32(3216),
358 MilliSeconds(100),
359 "LEDBAT falls to New Reno for slowstart"),
360 TestCase::QUICK);
361 AddTestCase(new TcpLedbatToNewReno(4 * 1446,
362 1446,
363 2 * 1446,
364 2,
365 SequenceNumber32(4753),
366 SequenceNumber32(3216),
367 MilliSeconds(100),
368 "LEDBAT falls to New Reno if timestamps are not found"),
369 TestCase::QUICK);
371 1446,
372 4 * 1446,
373 2,
374 SequenceNumber32(4753),
375 SequenceNumber32(3216),
376 MilliSeconds(100),
377 "LEDBAT increment test"),
378 TestCase::QUICK);
380 1446,
381 4 * 1446,
382 2,
383 SequenceNumber32(4753),
384 SequenceNumber32(3216),
385 MilliSeconds(100),
386 "LEDBAT decrement test"),
387 TestCase::QUICK);
388 }
389};
390
#define max(a, b)
Definition: 80211b.c:43
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
Hold variables of type string.
Definition: string.h:42
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
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
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:1338
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 TcpLedbatTestSuite g_tcpledbatTest
static var for test initialization