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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Viyom Mittal <viyommittal@gmail.com>
7 * Vivek Jain <jain.vivek.anand@gmail.com>
8 * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
9 *
10 */
11
12#include "ns3/log.h"
13#include "ns3/string.h"
14#include "ns3/tcp-congestion-ops.h"
15#include "ns3/tcp-recovery-ops.h"
16#include "ns3/tcp-socket-base.h"
17#include "ns3/test.h"
18
19using namespace ns3;
20
21NS_LOG_COMPONENT_DEFINE("TcpClassicRecoveryTestSuite");
22
23/**
24 * \brief Classic Recovery algorithm test
25 */
27{
28 public:
29 /**
30 * \brief Constructor.
31 * \param cWnd Congestion window.
32 * \param segmentSize Segment size.
33 * \param ssThresh Slow Start Threshold.
34 * \param dupAckCount Duplicate acknowledgement Threshold.
35 * \param name Test description.
36 */
39 uint32_t ssThresh,
40 uint32_t dupAckCount,
41 const std::string& name);
42
43 private:
44 void DoRun() override;
45
46 uint32_t m_cWnd; //!< Congestion window.
47 uint32_t m_segmentSize; //!< Segment size.
48 uint32_t m_ssThresh; //!< Slow Start Threshold.
49 uint32_t m_dupAckCount; //!< Duplicate acknowledgement Threshold.
50
51 Ptr<TcpSocketState> m_state; //!< TCP socket state.
52};
53
56 uint32_t ssThresh,
57 uint32_t dupAckCount,
58 const std::string& name)
59 : TestCase(name),
60 m_cWnd(cWnd),
61 m_segmentSize(segmentSize),
62 m_ssThresh(ssThresh),
63 m_dupAckCount(dupAckCount)
64{
65}
66
67void
69{
71
72 m_state->m_cWnd = m_cWnd;
73 m_state->m_segmentSize = m_segmentSize;
74 m_state->m_ssThresh = m_ssThresh;
75
77
78 NS_TEST_ASSERT_MSG_EQ(recovery->GetName(),
79 "TcpClassicRecovery",
80 "The name of recovery used should be TcpClassicRecovery");
81
82 recovery->EnterRecovery(m_state, m_dupAckCount, 1000, 0);
84 m_state->m_ssThresh,
85 "cWnd should be set to ssThresh on entering recovery");
87 m_state->m_cWndInfl,
88 (m_state->m_ssThresh + (m_dupAckCount * m_state->m_segmentSize)),
89 "cWndInfl should be set to (ssThresh + dupAckCount * segmentSize) on entering recovery");
90
91 uint32_t cWndInflPrevious = m_state->m_cWndInfl;
92 uint32_t cWndPrevious = m_state->m_cWnd;
93 recovery->DoRecovery(m_state, 500, false);
95 m_state->m_cWndInfl,
96 (cWndInflPrevious + m_state->m_segmentSize),
97 "m_cWndInfl should be increased by one segmentSize on calling DoRecovery");
98 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd, cWndPrevious, "cWnd should not change in recovery");
99
100 recovery->ExitRecovery(m_state);
101 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWndInfl,
102 m_state->m_ssThresh,
103 "cWndInfl should be set to ssThresh on exiting recovery");
105 m_state->m_ssThresh,
106 "cWnd should be set to ssThresh on exiting recovery");
107}
108
109/**
110 * \ingroup internet-test
111 *
112 * \brief Classic Recovery TestSuite
113 */
115{
116 public:
118 : TestSuite("tcp-classic-recovery-test", Type::UNIT)
119 {
121 500,
122 2500,
123 3,
124 "Classic recovery test with 500 bytes segmentSize"),
125 TestCase::Duration::QUICK);
127 1000,
128 2500,
129 3,
130 "Classic recovery test with 1000 bytes segmentSize"),
131 TestCase::Duration::QUICK);
133 500,
134 2500,
135 4,
136 "Classic recovery test with 4 DupAck threshold"),
137 TestCase::Duration::QUICK);
139 500,
140 1000,
141 3,
142 "Classic recovery test with 1000 bytes ssThresh"),
143 TestCase::Duration::QUICK);
145 500,
146 2500,
147 3,
148 "Classic recovery test with same cWnd and ssThresh"),
149 TestCase::Duration::QUICK);
151 500,
152 2500,
153 3,
154 "Classic recovery test with cWnd lesser than ssThresh"),
155 TestCase::Duration::QUICK);
156 }
157};
158
160 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.
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
static constexpr auto UNIT
Definition test.h:1291
uint32_t segmentSize
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#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:134
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static ClassicRecoveryTestSuite g_TcpClassicRecoveryTest
Static variable for test initialization.