A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
20
using namespace
ns3
;
21
22
NS_LOG_COMPONENT_DEFINE
(
"TcpPrrRecoveryTestSuite"
);
23
24
/**
25
* \brief PRR Recovery algorithm test
26
*/
27
class
PrrRecoveryTest
:
public
TestCase
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
*/
41
PrrRecoveryTest
(
uint32_t
cWnd,
42
uint32_t
segmentSize
,
43
uint32_t
ssThresh,
44
uint32_t
unAckDataCount,
45
uint32_t
bytesInFlight,
46
uint32_t
m_deliveredBytes
,
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
64
PrrRecoveryTest::PrrRecoveryTest
(
uint32_t
cWnd,
65
uint32_t
segmentSize
,
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
83
void
84
PrrRecoveryTest::DoRun
()
85
{
86
m_state
=
CreateObject<TcpSocketState>
();
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
94
Ptr<TcpPrrRecovery>
recovery =
CreateObject<TcpPrrRecovery>
();
95
96
recovery->EnterRecovery(
m_state
, 3,
m_unAckDataCount
, 0);
97
98
NS_TEST_ASSERT_MSG_GT_OR_EQ
(
m_state
->m_cWnd.Get(),
99
m_cWnd
+
m_segmentSize
,
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
{
115
NS_TEST_ASSERT_MSG_LT_OR_EQ
(
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
{
122
NS_TEST_ASSERT_MSG_GT_OR_EQ
(
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
*/
134
class
PrrRecoveryTestSuite
:
public
TestSuite
135
{
136
public
:
137
PrrRecoveryTestSuite
()
138
:
TestSuite
(
"tcp-prr-recovery-test"
,
Type
::
UNIT
)
139
{
140
AddTestCase
(
new
PrrRecoveryTest
(
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);
150
AddTestCase
(
new
PrrRecoveryTest
(
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);
160
AddTestCase
(
new
PrrRecoveryTest
(
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);
170
AddTestCase
(
new
PrrRecoveryTest
(
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
183
static
PrrRecoveryTestSuite
g_TcpPrrRecoveryTest
;
//!< Static variable for test initialization
PrrRecoveryTest
PRR Recovery algorithm test.
Definition
tcp-prr-recovery-test.cc:28
PrrRecoveryTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition
tcp-prr-recovery-test.cc:84
PrrRecoveryTest::m_bytesInFlight
uint32_t m_bytesInFlight
Current bytes in flight.
Definition
tcp-prr-recovery-test.cc:57
PrrRecoveryTest::m_bytesSent
uint32_t m_bytesSent
Bytes sent while in recovery phase.
Definition
tcp-prr-recovery-test.cc:59
PrrRecoveryTest::PrrRecoveryTest
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.
Definition
tcp-prr-recovery-test.cc:64
PrrRecoveryTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition
tcp-prr-recovery-test.cc:54
PrrRecoveryTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition
tcp-prr-recovery-test.cc:61
PrrRecoveryTest::m_ssThresh
uint32_t m_ssThresh
Slow Start Threshold.
Definition
tcp-prr-recovery-test.cc:55
PrrRecoveryTest::m_deliveredBytes
uint32_t m_deliveredBytes
Bytes SACKed on last acknowledgment.
Definition
tcp-prr-recovery-test.cc:58
PrrRecoveryTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition
tcp-prr-recovery-test.cc:53
PrrRecoveryTest::m_unAckDataCount
uint32_t m_unAckDataCount
Unacknowledged data at the start of recovery.
Definition
tcp-prr-recovery-test.cc:56
PrrRecoveryTestSuite
PRR Recovery TestSuite.
Definition
tcp-prr-recovery-test.cc:135
PrrRecoveryTestSuite::PrrRecoveryTestSuite
PrrRecoveryTestSuite()
Definition
tcp-prr-recovery-test.cc:137
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TestCase
encapsulates test code
Definition
test.h:1050
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition
test.cc:292
ns3::TestSuite
A suite of tests to run.
Definition
test.h:1267
ns3::TestSuite::Type
Type
Type of test.
Definition
test.h:1274
ns3::TestSuite::UNIT
static constexpr auto UNIT
Definition
test.h:1291
uint32_t
segmentSize
uint32_t segmentSize
Definition
tcp-linux-reno.cc:42
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
ns3::CreateObject
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition
object.h:619
NS_TEST_ASSERT_MSG_LT_OR_EQ
#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
NS_TEST_ASSERT_MSG_GT_OR_EQ
#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
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
g_TcpPrrRecoveryTest
static PrrRecoveryTestSuite g_TcpPrrRecoveryTest
Static variable for test initialization.
Definition
tcp-prr-recovery-test.cc:183
src
internet
test
tcp-prr-recovery-test.cc
Generated on Fri Nov 8 2024 13:59:02 for ns-3 by
1.11.0