A Discrete-Event Network Simulator
API
tcp-ledbat-test.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2016 NITK Surathkal
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Ankit Deepak <adadeepak8@gmail.com>
19 *
20 */
21
22#include "ns3/test.h"
23#include "ns3/log.h"
24#include "ns3/tcp-congestion-ops.h"
25#include "ns3/tcp-socket-base.h"
26#include "ns3/tcp-ledbat.h"
27#include "ns3/string.h"
28
29using namespace ns3;
30
31NS_LOG_COMPONENT_DEFINE ("TcpLedbatTestSuite");
32
40{
41public:
55 uint32_t segmentsAcked, SequenceNumber32 highTxMark,
56 SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name);
57
58private:
59 virtual void DoRun (void);
62 void ExecuteTest (void);
63
72};
73
75 uint32_t segmentsAcked, SequenceNumber32 highTxMark,
76 SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
77 : TestCase (name),
78 m_cWnd (cWnd),
79 m_segmentSize (segmentSize),
80 m_segmentsAcked (segmentsAcked),
81 m_ssThresh (ssThresh),
82 m_rtt (rtt),
83 m_highTxMark (highTxMark),
84 m_lastAckedSeq (lastAckedSeq)
85{
86}
87
88void
90{
91 Simulator::Schedule (Seconds (0.0), &TcpLedbatToNewReno::ExecuteTest, this);
92 Simulator::Run ();
93 Simulator::Destroy ();
94}
95
96void
98{
99 m_state = CreateObject <TcpSocketState> ();
105
106 Ptr<TcpSocketState> state = CreateObject <TcpSocketState> ();
107 state->m_cWnd = m_cWnd;
108 state->m_ssThresh = m_ssThresh;
110 state->m_highTxMark = m_highTxMark;
112
113 Ptr<TcpLedbat> cong = CreateObject <TcpLedbat> ();
114 cong->IncreaseWindow (m_state, m_segmentsAcked);
115
116 Ptr<TcpNewReno> NewRenoCong = CreateObject <TcpNewReno> ();
117 NewRenoCong->IncreaseWindow (state, m_segmentsAcked);
118
120 "cWnd has not updated correctly");
121}
129{
130public:
144 uint32_t segmentsAcked, SequenceNumber32 highTxMark,
145 SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name);
146
147private:
148 virtual void DoRun (void);
151 void ExecuteTest (void);
152
161};
162
164 uint32_t segmentsAcked, SequenceNumber32 highTxMark,
165 SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
166 : TestCase (name),
167 m_cWnd (cWnd),
168 m_segmentSize (segmentSize),
169 m_segmentsAcked (segmentsAcked),
170 m_ssThresh (ssThresh),
171 m_rtt (rtt),
172 m_highTxMark (highTxMark),
173 m_lastAckedSeq (lastAckedSeq)
174{
175}
176
177void
179{
180 Simulator::Schedule (Seconds (0.0), &TcpLedbatIncrementTest::ExecuteTest, this);
181 Simulator::Run ();
182 Simulator::Destroy ();
183}
184
185void
187{
188 m_state = CreateObject <TcpSocketState> ();
194
195 Ptr<TcpLedbat> cong = CreateObject <TcpLedbat> ();
196 cong->SetAttribute ("SSParam", StringValue ("no"));
197 cong->SetAttribute ("NoiseFilterLen", UintegerValue (1));
198
201 cong->PktsAcked (m_state, m_segmentsAcked, m_rtt);
202
205 cong->PktsAcked (m_state, m_segmentsAcked, m_rtt);
206
207 cong->IncreaseWindow (m_state, m_segmentsAcked);
208
210
212 "cWnd has not updated correctly");
213}
214
222{
223public:
237 uint32_t segmentsAcked, SequenceNumber32 highTxMark,
238 SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name);
239
240private:
241 virtual void DoRun (void);
244 void ExecuteTest (void);
245
254};
255
257 uint32_t segmentsAcked, SequenceNumber32 highTxMark,
258 SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
259 : TestCase (name),
260 m_cWnd (cWnd),
261 m_segmentSize (segmentSize),
262 m_segmentsAcked (segmentsAcked),
263 m_ssThresh (ssThresh),
264 m_rtt (rtt),
265 m_highTxMark (highTxMark),
266 m_lastAckedSeq (lastAckedSeq)
267{
268}
269
270void
272{
273 Simulator::Schedule (Seconds (0.0), &TcpLedbatDecrementTest::ExecuteTest, this);
274 Simulator::Run ();
275 Simulator::Destroy ();
276}
277
278void
280{
281 UintegerValue minCwnd;
282 m_state = CreateObject <TcpSocketState> ();
288
289 Ptr<TcpLedbat> cong = CreateObject <TcpLedbat> ();
290 cong->SetAttribute ("SSParam", StringValue ("no"));
291 cong->SetAttribute ("NoiseFilterLen", UintegerValue (1));
292 cong->GetAttribute ("MinCwnd", minCwnd);
293
296 cong->PktsAcked (m_state, m_segmentsAcked, m_rtt);
297
300 cong->PktsAcked (m_state, m_segmentsAcked, m_rtt);
301
302 cong->IncreaseWindow (m_state, m_segmentsAcked);
303
305 m_cWnd = std::max (m_cWnd, static_cast<uint32_t> (m_segmentSize * minCwnd.Get ()));
306
308 "cWnd has not updated correctly");
309}
310
318{
319public:
320 TcpLedbatTestSuite () : TestSuite ("tcp-ledbat-test", UNIT)
321 {
322 AddTestCase (new TcpLedbatToNewReno (2 * 1446, 1446, 4 * 1446, 2, SequenceNumber32 (4753), SequenceNumber32 (3216), MilliSeconds (100), "LEDBAT falls to New Reno for slowstart"), TestCase::QUICK);
323 AddTestCase (new TcpLedbatToNewReno (4 * 1446, 1446, 2 * 1446, 2, SequenceNumber32 (4753), SequenceNumber32 (3216), MilliSeconds (100), "LEDBAT falls to New Reno if timestamps are not found"), TestCase::QUICK);
324 AddTestCase (new TcpLedbatIncrementTest (2 * 1446, 1446, 4 * 1446, 2, SequenceNumber32 (4753), SequenceNumber32 (3216), MilliSeconds (100), "LEDBAT increment test"), TestCase::QUICK);
325 AddTestCase (new TcpLedbatDecrementTest (2 * 1446, 1446, 4 * 1446, 2, SequenceNumber32 (4753), SequenceNumber32 (3216), MilliSeconds (100), "LEDBAT decrement test"), TestCase::QUICK);
326 }
327};
328
#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
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t m_segmentSize
segment size
uint32_t m_ssThresh
ss thresh
void ExecuteTest(void)
Execute the test.
uint32_t m_segmentsAcked
segments acked
SequenceNumber32 m_lastAckedSeq
last acked seq
Ptr< TcpSocketState > m_state
state
Test to validate cWnd increment in LEDBAT.
SequenceNumber32 m_highTxMark
high tx mark
uint32_t m_segmentsAcked
segments acked
uint32_t m_segmentSize
segment size
virtual void DoRun(void)
Implementation to actually run this TestCase.
void ExecuteTest(void)
Execute the test.
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
void ExecuteTest(void)
Execute the test.
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
virtual void DoRun(void)
Implementation to actually run this TestCase.
SequenceNumber32 m_lastAckedSeq
last acked seq
uint32_t m_segmentSize
segment size
uint32_t m_ssThresh
ss thresh
Hold variables of type string.
Definition: string.h:41
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:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
@ UNIT
This test suite implements a Unit Test.
Definition: test.h:1197
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
T Get(void) const
Get the underlying value.
Definition: traced-value.h:232
Hold an unsigned integer type.
Definition: uinteger.h:44
uint64_t Get(void) const
Definition: uinteger.cc:35
uint32_t segmentSize
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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:141
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1244
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1252
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TcpLedbatTestSuite g_tcpledbatTest
static var for test initialization