A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-prr-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-prr-recovery.h"
27#include "ns3/tcp-recovery-ops.h"
28#include "ns3/tcp-socket-base.h"
29#include "ns3/test.h"
30
31using namespace ns3;
32
33NS_LOG_COMPONENT_DEFINE("TcpPrrRecoveryTestSuite");
34
35/**
36 * \brief PRR Recovery algorithm test
37 */
39{
40 public:
41 /**
42 * \brief Constructor.
43 * \param cWnd Congestion window.
44 * \param segmentSize Segment size.
45 * \param ssThresh Slow Start Threshold.
46 * \param unAckDataCount Unacknowledged data at the start of recovery.
47 * \param bytesInFlight Current bytes in flight.
48 * \param m_deliveredBytes Bytes SACKed on last acknowledgment.
49 * \param bytesSent Bytes sent while in recovery phase.
50 * \param reductionBound Type of reduction bound to be used.
51 * \param name Test description.
52 */
55 uint32_t ssThresh,
56 uint32_t unAckDataCount,
57 uint32_t bytesInFlight,
59 uint32_t bytesSent,
60 const std::string& reductionBound,
61 const std::string& name);
62
63 private:
64 void DoRun() override;
65
66 uint32_t m_cWnd; //!< Congestion window.
67 uint32_t m_segmentSize; //!< Segment size.
68 uint32_t m_ssThresh; //!< Slow Start Threshold.
69 uint32_t m_unAckDataCount; //!< Unacknowledged data at the start of recovery.
70 uint32_t m_bytesInFlight; //!< Current bytes in flight.
71 uint32_t m_deliveredBytes; //!< Bytes SACKed on last acknowledgment.
72 uint32_t m_bytesSent; //!< Bytes sent while in recovery phase.
73 const std::string m_reductionBound; //!< Type of reduction bound to be used.
74
75 Ptr<TcpSocketState> m_state; //!< TCP socket state.
76};
77
80 uint32_t ssThresh,
81 uint32_t unAckDataCount,
82 uint32_t bytesInFlight,
83 uint32_t deliveredBytes,
84 uint32_t bytesSent,
85 const std::string& reductionBound,
86 const std::string& name)
87 : TestCase(name),
88 m_cWnd(cWnd),
89 m_segmentSize(segmentSize),
90 m_ssThresh(ssThresh),
91 m_unAckDataCount(unAckDataCount),
92 m_bytesInFlight(bytesInFlight),
93 m_deliveredBytes(deliveredBytes),
94 m_bytesSent(bytesSent),
95 m_reductionBound(reductionBound)
96{
97}
98
99void
101{
102 m_state = CreateObject<TcpSocketState>();
103
109
110 Ptr<TcpPrrRecovery> recovery = CreateObject<TcpPrrRecovery>();
111 recovery->SetAttribute("ReductionBound", StringValue(m_reductionBound));
112
113 recovery->EnterRecovery(m_state, 3, m_unAckDataCount, 0);
114
117 "There should be at least one transmission on entering recovery");
118
119 for (uint32_t iterator = 0; iterator < m_bytesSent;)
120 {
121 recovery->UpdateBytesSent(m_segmentSize);
122 iterator += m_segmentSize;
123 }
124
128 recovery->DoRecovery(m_state, m_deliveredBytes);
129
131 {
133 m_state->m_cWnd.Get(),
134 m_cWnd,
135 "Updated cwnd should be less than or equal to the existing cwnd");
136 }
137 else
138 {
140 m_state->m_cWnd.Get(),
141 m_cWnd,
142 "Updated cwnd should be greater than or equal to the existing cwnd");
143 }
144}
145
146/**
147 * \ingroup internet-test
148 *
149 * \brief PRR Recovery TestSuite
150 */
152{
153 public:
155 : TestSuite("tcp-prr-recovery-test", Type::UNIT)
156 {
158 3000,
159 500,
160 2500,
161 3000,
162 3000,
163 500,
164 1000,
165 "SSRB",
166 "Prr test on cWnd when bytesInFlight is greater than ssThresh with SSRB"),
167 TestCase::Duration::QUICK);
169 1000,
170 500,
171 2500,
172 3000,
173 1000,
174 500,
175 1000,
176 "SSRB",
177 "Prr test on cWnd when bytesInFlight is lower than ssThresh with SSRB"),
178 TestCase::Duration::QUICK);
180 3000,
181 500,
182 2500,
183 3000,
184 3000,
185 500,
186 1000,
187 "CRB",
188 "Prr test on cWnd when bytesInFlight is greater than ssThresh with CRB"),
189 TestCase::Duration::QUICK);
191 1000,
192 500,
193 2500,
194 3000,
195 1000,
196 500,
197 1000,
198 "CRB",
199 "Prr test on cWnd when bytesInFlight is lower than ssThresh with CRB"),
200 TestCase::Duration::QUICK);
201 }
202};
203
204static PrrRecoveryTestSuite g_TcpPrrRecoveryTest; //!< Static variable for test initialization
PRR Recovery algorithm test.
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_bytesInFlight
Current bytes in flight.
uint32_t m_bytesSent
Bytes sent while in recovery phase.
PrrRecoveryTest(uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh, uint32_t unAckDataCount, uint32_t bytesInFlight, uint32_t m_deliveredBytes, uint32_t bytesSent, const std::string &reductionBound, const std::string &name)
Constructor.
uint32_t m_segmentSize
Segment size.
Ptr< TcpSocketState > m_state
TCP socket state.
uint32_t m_ssThresh
Slow Start Threshold.
uint32_t m_deliveredBytes
Bytes SACKed on last acknowledgment.
uint32_t m_cWnd
Congestion window.
const std::string m_reductionBound
Type of reduction bound to be used.
uint32_t m_unAckDataCount
Unacknowledged data at the start of recovery.
PRR Recovery TestSuite.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Hold variables of type string.
Definition: string.h:56
uint32_t m_segmentSize
Segment size.
TracedValue< uint32_t > m_cWnd
Congestion window.
TracedValue< uint32_t > m_bytesInFlight
Bytes in flight.
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
T Get() const
Get the underlying value.
Definition: traced-value.h:249
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_LT_OR_EQ(actual, limit, msg)
Test that an actual value is less than or equal to a limit and report and abort if not.
Definition: test.h:751
#define NS_TEST_ASSERT_MSG_GT_OR_EQ(actual, limit, msg)
Test that an actual value is greater than or equal to a limit and report and abort if not.
Definition: test.h:916
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static PrrRecoveryTestSuite g_TcpPrrRecoveryTest
Static variable for test initialization.