A Discrete-Event Network Simulator
API
tcp-classic-recovery-test.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2018 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: Viyom Mittal <viyommittal@gmail.com>
19 * Vivek Jain <jain.vivek.anand@gmail.com>
20 * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
21 *
22 */
23
24#include "ns3/test.h"
25#include "ns3/log.h"
26#include "ns3/tcp-congestion-ops.h"
27#include "ns3/tcp-recovery-ops.h"
28#include "ns3/tcp-socket-base.h"
29#include "ns3/string.h"
30
31using namespace ns3;
32
33NS_LOG_COMPONENT_DEFINE ("TcpClassicRecoveryTestSuite");
34
39{
40public:
51 uint32_t ssThresh,
52 uint32_t dupAckCount,
53 const std::string &name);
54
55private:
56 virtual void DoRun (void);
57
62
64};
65
68 uint32_t ssThresh,
69 uint32_t dupAckCount,
70 const std::string &name)
71 : TestCase (name),
72 m_cWnd (cWnd),
73 m_segmentSize (segmentSize),
74 m_ssThresh (ssThresh),
75 m_dupAckCount (dupAckCount)
76{
77}
78
79void
81{
82 m_state = CreateObject<TcpSocketState> ();
83
87
88 Ptr<TcpClassicRecovery> recovery = CreateObject <TcpClassicRecovery> ();
89
90 NS_TEST_ASSERT_MSG_EQ (recovery->GetName (), "TcpClassicRecovery",
91 "The name of recovery used should be TcpClassicRecovery");
92
93 recovery->EnterRecovery (m_state, m_dupAckCount, 1000, 0);
95 "cWnd should be set to ssThresh on entering recovery");
97 "cWndInfl should be set to (ssThresh + dupAckCount * segmentSize) on entering recovery");
98
99 uint32_t cWndInflPrevious = m_state->m_cWndInfl;
100 uint32_t cWndPrevious = m_state->m_cWnd;
101 recovery->DoRecovery (m_state, 500);
103 "m_cWndInfl should be incresed by one segmentSize on calling DoRecovery");
104 NS_TEST_ASSERT_MSG_EQ (m_state->m_cWnd, cWndPrevious,
105 "cWnd should not change in recovery");
106
107 recovery->ExitRecovery (m_state);
109 "cWndInfl should be set to ssThresh on exiting recovery");
111 "cWnd should be set to ssThresh on exiting recovery");
112}
113
121{
122public:
123 ClassicRecoveryTestSuite () : TestSuite ("tcp-classic-recovery-test", UNIT)
124 {
125 AddTestCase (new ClassicRecoveryTest (3000, 500, 2500, 3, "Classic recovery test with 500 bytes segmentSize"),
126 TestCase::QUICK);
127 AddTestCase (new ClassicRecoveryTest (3000, 1000, 2500, 3, "Classic recovery test with 1000 bytes segmentSize"),
128 TestCase::QUICK);
129 AddTestCase (new ClassicRecoveryTest (3000, 500, 2500, 4, "Classic recovery test with 4 DupAck threshold"),
130 TestCase::QUICK);
131 AddTestCase (new ClassicRecoveryTest (3000, 500, 1000, 3, "Classic recovery test with 1000 bytes ssThresh"),
132 TestCase::QUICK);
133 AddTestCase (new ClassicRecoveryTest (2500, 500, 2500, 3, "Classic recovery test with same cWnd and ssThresh"),
134 TestCase::QUICK);
135 AddTestCase (new ClassicRecoveryTest (1000, 500, 2500, 3, "Classic recovery test with cWnd lesser than ssThresh"),
136 TestCase::QUICK);
137 }
138};
139
Classic Recovery algorithm test.
ClassicRecoveryTest(uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh, uint32_t dupAckCount, const std::string &name)
Constructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t m_cWnd
Congestion window.
Ptr< TcpSocketState > m_state
TCP socket state.
uint32_t m_ssThresh
Slow Start Threshold.
uint32_t m_dupAckCount
Duplicate acknowledgement Threshold.
uint32_t m_segmentSize
Segment size.
Classic Recovery TestSuite.
uint32_t m_segmentSize
Segment size.
TracedValue< uint32_t > m_cWnd
Congestion window.
TracedValue< uint32_t > m_cWndInfl
Inflated congestion window trace (used only for backward compatibility purpose)
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
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
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static ClassicRecoveryTestSuite g_TcpClassicRecoveryTest
Static variable for test initialization.