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 * 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-prr-recovery.h"
16#include "ns3/tcp-recovery-ops.h"
17#include "ns3/tcp-socket-base.h"
18#include "ns3/test.h"
19
20using namespace ns3;
21
22NS_LOG_COMPONENT_DEFINE("TcpPrrRecoveryTestSuite");
23
24/**
25 * @brief PRR Recovery algorithm test
26 */
28{
29 public:
30 /**
31 * @brief Constructor.
32 * @param cWnd Congestion window.
33 * @param segmentSize Segment size.
34 * @param ssThresh Slow Start Threshold.
35 * @param unAckDataCount Unacknowledged data at the start of recovery.
36 * @param bytesInFlight Current bytes in flight.
37 * @param m_deliveredBytes Bytes SACKed on last acknowledgment.
38 * @param bytesSent Bytes sent while in recovery phase.
39 * @param name Test description.
40 */
43 uint32_t ssThresh,
44 uint32_t unAckDataCount,
45 uint32_t bytesInFlight,
47 uint32_t bytesSent,
48 const std::string& name);
49
50 private:
51 void DoRun() override;
52
53 uint32_t m_cWnd; //!< Congestion window.
54 uint32_t m_segmentSize; //!< Segment size.
55 uint32_t m_ssThresh; //!< Slow Start Threshold.
56 uint32_t m_unAckDataCount; //!< Unacknowledged data at the start of recovery.
57 uint32_t m_bytesInFlight; //!< Current bytes in flight.
58 uint32_t m_deliveredBytes; //!< Bytes SACKed on last acknowledgment.
59 uint32_t m_bytesSent; //!< Bytes sent while in recovery phase.
60
61 Ptr<TcpSocketState> m_state; //!< TCP socket state.
62};
63
66 uint32_t ssThresh,
67 uint32_t unAckDataCount,
68 uint32_t bytesInFlight,
69 uint32_t deliveredBytes,
70 uint32_t bytesSent,
71 const std::string& name)
72 : TestCase(name),
73 m_cWnd(cWnd),
74 m_segmentSize(segmentSize),
75 m_ssThresh(ssThresh),
76 m_unAckDataCount(unAckDataCount),
77 m_bytesInFlight(bytesInFlight),
78 m_deliveredBytes(deliveredBytes),
79 m_bytesSent(bytesSent)
80{
81}
82
83void
85{
87
88 m_state->m_cWnd = m_cWnd;
89 m_state->m_cWndInfl = m_cWnd;
90 m_state->m_segmentSize = m_segmentSize;
91 m_state->m_ssThresh = m_ssThresh;
92 m_state->m_bytesInFlight = m_bytesInFlight;
93
95
96 recovery->EnterRecovery(m_state, 3, m_unAckDataCount, 0);
97
100 "There should be at least one transmission on entering recovery");
101
102 for (uint32_t iterator = 0; iterator < m_bytesSent;)
103 {
104 recovery->UpdateBytesSent(m_segmentSize);
105 iterator += m_segmentSize;
106 }
107
108 m_bytesInFlight += m_state->m_cWnd.Get() - m_cWnd;
109 m_state->m_bytesInFlight = m_bytesInFlight;
110 m_cWnd = m_state->m_cWnd.Get();
111 recovery->DoRecovery(m_state, m_deliveredBytes, false);
112
113 if (m_bytesInFlight > m_state->m_ssThresh)
114 {
116 m_state->m_cWnd.Get(),
117 m_cWnd,
118 "Updated cwnd should be less than or equal to the existing cwnd");
119 }
120 else
121 {
123 m_state->m_cWnd.Get(),
124 m_cWnd,
125 "Updated cwnd should be greater than or equal to the existing cwnd");
126 }
127}
128
129/**
130 * @ingroup internet-test
131 *
132 * @brief PRR Recovery TestSuite
133 */
135{
136 public:
138 : TestSuite("tcp-prr-recovery-test", Type::UNIT)
139 {
141 3000,
142 500,
143 2500,
144 3000,
145 3000,
146 500,
147 1000,
148 "Prr test on cWnd when bytesInFlight is greater than ssThresh with SSRB"),
149 TestCase::Duration::QUICK);
151 1000,
152 500,
153 2500,
154 3000,
155 1000,
156 500,
157 1000,
158 "Prr test on cWnd when bytesInFlight is lower than ssThresh with SSRB"),
159 TestCase::Duration::QUICK);
161 3000,
162 500,
163 2500,
164 3000,
165 3000,
166 500,
167 1000,
168 "Prr test on cWnd when bytesInFlight is greater than ssThresh with CRB"),
169 TestCase::Duration::QUICK);
171 1000,
172 500,
173 2500,
174 3000,
175 1000,
176 500,
177 1000,
178 "Prr test on cWnd when bytesInFlight is lower than ssThresh with CRB"),
179 TestCase::Duration::QUICK);
180 }
181};
182
183static 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 &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.
uint32_t m_unAckDataCount
Unacknowledged data at the start of recovery.
PRR 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_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:740
#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:905
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static PrrRecoveryTestSuite g_TcpPrrRecoveryTest
Static variable for test initialization.