A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-classic-recovery-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 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: Viyom Mittal <viyommittal@gmail.com>
18 * Vivek Jain <jain.vivek.anand@gmail.com>
19 * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
20 *
21 */
22
23#include "ns3/log.h"
24#include "ns3/string.h"
25#include "ns3/tcp-congestion-ops.h"
26#include "ns3/tcp-recovery-ops.h"
27#include "ns3/tcp-socket-base.h"
28#include "ns3/test.h"
29
30using namespace ns3;
31
32NS_LOG_COMPONENT_DEFINE("TcpClassicRecoveryTestSuite");
33
34/**
35 * \brief Classic Recovery algorithm test
36 */
38{
39 public:
40 /**
41 * \brief Constructor.
42 * \param cWnd Congestion window.
43 * \param segmentSize Segment size.
44 * \param ssThresh Slow Start Threshold.
45 * \param dupAckCount Duplicate acknowledgement Threshold.
46 * \param name Test description.
47 */
50 uint32_t ssThresh,
51 uint32_t dupAckCount,
52 const std::string& name);
53
54 private:
55 void DoRun() override;
56
57 uint32_t m_cWnd; //!< Congestion window.
58 uint32_t m_segmentSize; //!< Segment size.
59 uint32_t m_ssThresh; //!< Slow Start Threshold.
60 uint32_t m_dupAckCount; //!< Duplicate acknowledgement Threshold.
61
62 Ptr<TcpSocketState> m_state; //!< TCP socket state.
63};
64
67 uint32_t ssThresh,
68 uint32_t dupAckCount,
69 const std::string& name)
70 : TestCase(name),
71 m_cWnd(cWnd),
72 m_segmentSize(segmentSize),
73 m_ssThresh(ssThresh),
74 m_dupAckCount(dupAckCount)
75{
76}
77
78void
80{
81 m_state = CreateObject<TcpSocketState>();
82
86
87 Ptr<TcpClassicRecovery> recovery = CreateObject<TcpClassicRecovery>();
88
89 NS_TEST_ASSERT_MSG_EQ(recovery->GetName(),
90 "TcpClassicRecovery",
91 "The name of recovery used should be TcpClassicRecovery");
92
93 recovery->EnterRecovery(m_state, m_dupAckCount, 1000, 0);
96 "cWnd should be set to ssThresh on entering recovery");
100 "cWndInfl should be set to (ssThresh + dupAckCount * segmentSize) on entering recovery");
101
102 uint32_t cWndInflPrevious = m_state->m_cWndInfl;
103 uint32_t cWndPrevious = m_state->m_cWnd;
104 recovery->DoRecovery(m_state, 500);
107 (cWndInflPrevious + m_state->m_segmentSize),
108 "m_cWndInfl should be increased by one segmentSize on calling DoRecovery");
109 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd, cWndPrevious, "cWnd should not change in recovery");
110
111 recovery->ExitRecovery(m_state);
114 "cWndInfl should be set to ssThresh on exiting recovery");
117 "cWnd should be set to ssThresh on exiting recovery");
118}
119
120/**
121 * \ingroup internet-test
122 *
123 * \brief Classic Recovery TestSuite
124 */
126{
127 public:
129 : TestSuite("tcp-classic-recovery-test", Type::UNIT)
130 {
132 500,
133 2500,
134 3,
135 "Classic recovery test with 500 bytes segmentSize"),
136 TestCase::Duration::QUICK);
138 1000,
139 2500,
140 3,
141 "Classic recovery test with 1000 bytes segmentSize"),
142 TestCase::Duration::QUICK);
144 500,
145 2500,
146 4,
147 "Classic recovery test with 4 DupAck threshold"),
148 TestCase::Duration::QUICK);
150 500,
151 1000,
152 3,
153 "Classic recovery test with 1000 bytes ssThresh"),
154 TestCase::Duration::QUICK);
156 500,
157 2500,
158 3,
159 "Classic recovery test with same cWnd and ssThresh"),
160 TestCase::Duration::QUICK);
162 500,
163 2500,
164 3,
165 "Classic recovery test with cWnd lesser than ssThresh"),
166 TestCase::Duration::QUICK);
167 }
168};
169
171 g_TcpClassicRecoveryTest; //!< Static variable for test initialization
Classic Recovery algorithm test.
ClassicRecoveryTest(uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh, uint32_t dupAckCount, const std::string &name)
Constructor.
uint32_t m_cWnd
Congestion window.
Ptr< TcpSocketState > m_state
TCP socket state.
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_ssThresh
Slow Start Threshold.
uint32_t m_dupAckCount
Duplicate acknowledgement Threshold.
uint32_t m_segmentSize
Segment size.
Classic Recovery TestSuite.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
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:1061
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1268
Type
Type of test.
Definition: test.h:1275
static constexpr auto UNIT
Definition: test.h:1286
uint32_t segmentSize
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:145
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static ClassicRecoveryTestSuite g_TcpClassicRecoveryTest
Static variable for test initialization.