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 
29 using namespace ns3;
30 
31 NS_LOG_COMPONENT_DEFINE ("TcpLedbatTestSuite");
32 
40 {
41 public:
54  TcpLedbatToNewReno (uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh,
55  uint32_t segmentsAcked, SequenceNumber32 highTxMark,
56  SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name);
57 
58 private:
59  virtual void DoRun (void);
62  void ExecuteTest (void);
63 
64  uint32_t m_cWnd;
65  uint32_t m_segmentSize;
66  uint32_t m_segmentsAcked;
67  uint32_t m_ssThresh;
72 };
73 
74 TcpLedbatToNewReno::TcpLedbatToNewReno (uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh,
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 
88 void
90 {
91  Simulator::Schedule (Seconds (0.0), &TcpLedbatToNewReno::ExecuteTest, this);
92  Simulator::Run ();
93  Simulator::Destroy ();
94 }
95 
96 void
98 {
99  m_state = CreateObject <TcpSocketState> ();
100  m_state->m_cWnd = m_cWnd;
105 
106  Ptr<TcpSocketState> state = CreateObject <TcpSocketState> ();
107  state->m_cWnd = m_cWnd;
108  state->m_ssThresh = m_ssThresh;
109  state->m_segmentSize = m_segmentSize;
110  state->m_highTxMark = m_highTxMark;
112 
113  Ptr<TcpLedbat> cong = CreateObject <TcpLedbat> ();
115 
116  Ptr<TcpNewReno> NewRenoCong = CreateObject <TcpNewReno> ();
117  NewRenoCong->IncreaseWindow (state, m_segmentsAcked);
118 
120  "cWnd has not updated correctly");
121 }
129 {
130 public:
143  TcpLedbatIncrementTest (uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh,
144  uint32_t segmentsAcked, SequenceNumber32 highTxMark,
145  SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name);
146 
147 private:
148  virtual void DoRun (void);
151  void ExecuteTest (void);
152 
153  uint32_t m_cWnd;
154  uint32_t m_segmentSize;
155  uint32_t m_segmentsAcked;
156  uint32_t m_ssThresh;
161 };
162 
163 TcpLedbatIncrementTest::TcpLedbatIncrementTest (uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh,
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 
177 void
179 {
180  Simulator::Schedule (Seconds (0.0), &TcpLedbatIncrementTest::ExecuteTest, this);
181  Simulator::Run ();
182  Simulator::Destroy ();
183 }
184 
185 void
187 {
188  m_state = CreateObject <TcpSocketState> ();
189  m_state->m_cWnd = m_cWnd;
194 
195  Ptr<TcpLedbat> cong = CreateObject <TcpLedbat> ();
196  cong->SetAttribute ("SSParam", StringValue ("no"));
197  cong->SetAttribute ("NoiseFilterLen", UintegerValue (1));
198 
202 
206 
208 
210 
212  "cWnd has not updated correctly");
213 }
214 
222 {
223 public:
236  TcpLedbatDecrementTest (uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh,
237  uint32_t segmentsAcked, SequenceNumber32 highTxMark,
238  SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name);
239 
240 private:
241  virtual void DoRun (void);
244  void ExecuteTest (void);
245 
246  uint32_t m_cWnd;
247  uint32_t m_segmentSize;
248  uint32_t m_segmentsAcked;
249  uint32_t m_ssThresh;
254 };
255 
256 TcpLedbatDecrementTest::TcpLedbatDecrementTest (uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh,
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 
270 void
272 {
273  Simulator::Schedule (Seconds (0.0), &TcpLedbatDecrementTest::ExecuteTest, this);
274  Simulator::Run ();
275  Simulator::Destroy ();
276 }
277 
278 void
280 {
281  UintegerValue minCwnd;
282  m_state = CreateObject <TcpSocketState> ();
283  m_state->m_cWnd = m_cWnd;
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 
297 
301 
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 {
319 public:
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 
uint32_t m_rcvTimestampValue
Receiver Timestamp value.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
SequenceNumber32 m_lastAckedSeq
last acked seq
uint32_t m_segmentSize
segment size
static TcpLedbatTestSuite g_tcpledbatTest
static var for test initialization
Hold variables of type string.
Definition: string.h:41
Ptr< TcpSocketState > m_state
state
virtual void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt)
Get information from the acked packet.
Definition: tcp-ledbat.cc:289
A suite of tests to run.
Definition: test.h:1342
uint32_t m_rcvTimestampEchoReply
Sender Timestamp echoed by the receiver.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t m_segmentsAcked
segments acked
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
virtual void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Adjust cwnd following LEDBAT algorithm.
Definition: tcp-ledbat.cc:170
virtual void DoRun(void)
Implementation to actually run this TestCase.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1022
Test to validate cWnd increment in LEDBAT.
SequenceNumber32 m_lastAckedSeq
last acked seq
uint32_t m_segmentSize
Segment size.
SequenceNumber32 m_highTxMark
high tx mark
virtual void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Try to increase the cWnd following the NewReno specification.
encapsulates test code
Definition: test.h:1155
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t m_ssThresh
ss thresh
uint32_t m_segmentsAcked
segments acked
uint32_t m_cWnd
cWnd
#define max(a, b)
Definition: 80211b.c:43
Ptr< TcpSocketState > m_state
state
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Hold an unsigned integer type.
Definition: uinteger.h:44
#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:168
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.
LEDBAT should be same as NewReno during slow start, and when timestamps are disabled.
SequenceNumber32 m_lastAckedSeq
Last sequence ACKed.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
uint64_t Get(void) const
Definition: uinteger.cc:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void ExecuteTest(void)
Execute the test.
Generic "sequence number" class.
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.
TracedValue< uint32_t > m_cWnd
Congestion window.
uint32_t m_segmentsAcked
segments acked
SequenceNumber32 m_highTxMark
high tx mark
void ExecuteTest(void)
Execute the test.
Ptr< TcpSocketState > m_state
state
T Get(void) const
Get the underlying value.
Definition: traced-value.h:218
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
TracedValue< SequenceNumber32 > m_highTxMark
Highest seqno ever sent, regardless of ReTx.
SequenceNumber32 m_highTxMark
high tx mark
TcpLedbatToNewReno(uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh, uint32_t segmentsAcked, SequenceNumber32 highTxMark, SequenceNumber32 lastAckedSeq, Time rtt, const std::string &name)
Constructor.
This test suite implements a Unit Test.
Definition: test.h:1352
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:223
uint32_t m_ssThresh
ss thresh
SequenceNumber32 m_lastAckedSeq
last acked seq
uint32_t m_segmentSize
segment size
uint32_t m_segmentSize
segment size
TCP Ledbat TestSuite.
uint32_t m_ssThresh
ss thresh