A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
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
30
using namespace
ns3
;
31
32
NS_LOG_COMPONENT_DEFINE
(
"TcpClassicRecoveryTestSuite"
);
33
37
class
ClassicRecoveryTest
:
public
TestCase
38
{
39
public
:
48
ClassicRecoveryTest
(uint32_t cWnd,
49
uint32_t
segmentSize
,
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
;
58
uint32_t
m_segmentSize
;
59
uint32_t
m_ssThresh
;
60
uint32_t
m_dupAckCount
;
61
62
Ptr<TcpSocketState>
m_state
;
63
};
64
65
ClassicRecoveryTest::ClassicRecoveryTest
(uint32_t cWnd,
66
uint32_t
segmentSize
,
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
78
void
79
ClassicRecoveryTest::DoRun
()
80
{
81
m_state
= CreateObject<TcpSocketState>();
82
83
m_state
->
m_cWnd
=
m_cWnd
;
84
m_state
->
m_segmentSize
=
m_segmentSize
;
85
m_state
->
m_ssThresh
=
m_ssThresh
;
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);
94
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWnd
,
95
m_state
->
m_ssThresh
,
96
"cWnd should be set to ssThresh on entering recovery"
);
97
NS_TEST_ASSERT_MSG_EQ
(
98
m_state
->
m_cWndInfl
,
99
(
m_state
->
m_ssThresh
+ (
m_dupAckCount
*
m_state
->
m_segmentSize
)),
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);
105
NS_TEST_ASSERT_MSG_EQ
(
106
m_state
->
m_cWndInfl
,
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
);
112
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWndInfl
,
113
m_state
->
m_ssThresh
,
114
"cWndInfl should be set to ssThresh on exiting recovery"
);
115
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWnd
,
116
m_state
->
m_ssThresh
,
117
"cWnd should be set to ssThresh on exiting recovery"
);
118
}
119
125
class
ClassicRecoveryTestSuite
:
public
TestSuite
126
{
127
public
:
128
ClassicRecoveryTestSuite
()
129
:
TestSuite
(
"tcp-classic-recovery-test"
,
UNIT
)
130
{
131
AddTestCase
(
new
ClassicRecoveryTest
(3000,
132
500,
133
2500,
134
3,
135
"Classic recovery test with 500 bytes segmentSize"
),
136
TestCase::QUICK);
137
AddTestCase
(
new
ClassicRecoveryTest
(3000,
138
1000,
139
2500,
140
3,
141
"Classic recovery test with 1000 bytes segmentSize"
),
142
TestCase::QUICK);
143
AddTestCase
(
new
ClassicRecoveryTest
(3000,
144
500,
145
2500,
146
4,
147
"Classic recovery test with 4 DupAck threshold"
),
148
TestCase::QUICK);
149
AddTestCase
(
new
ClassicRecoveryTest
(3000,
150
500,
151
1000,
152
3,
153
"Classic recovery test with 1000 bytes ssThresh"
),
154
TestCase::QUICK);
155
AddTestCase
(
new
ClassicRecoveryTest
(2500,
156
500,
157
2500,
158
3,
159
"Classic recovery test with same cWnd and ssThresh"
),
160
TestCase::QUICK);
161
AddTestCase
(
new
ClassicRecoveryTest
(1000,
162
500,
163
2500,
164
3,
165
"Classic recovery test with cWnd lesser than ssThresh"
),
166
TestCase::QUICK);
167
}
168
};
169
170
static
ClassicRecoveryTestSuite
171
g_TcpClassicRecoveryTest
;
ClassicRecoveryTest
Classic Recovery algorithm test.
Definition:
tcp-classic-recovery-test.cc:38
ClassicRecoveryTest::ClassicRecoveryTest
ClassicRecoveryTest(uint32_t cWnd, uint32_t segmentSize, uint32_t ssThresh, uint32_t dupAckCount, const std::string &name)
Constructor.
Definition:
tcp-classic-recovery-test.cc:65
ClassicRecoveryTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition:
tcp-classic-recovery-test.cc:57
ClassicRecoveryTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition:
tcp-classic-recovery-test.cc:62
ClassicRecoveryTest::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
tcp-classic-recovery-test.cc:79
ClassicRecoveryTest::m_ssThresh
uint32_t m_ssThresh
Slow Start Threshold.
Definition:
tcp-classic-recovery-test.cc:59
ClassicRecoveryTest::m_dupAckCount
uint32_t m_dupAckCount
Duplicate acknowledgement Threshold.
Definition:
tcp-classic-recovery-test.cc:60
ClassicRecoveryTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-classic-recovery-test.cc:58
ClassicRecoveryTestSuite
Classic Recovery TestSuite.
Definition:
tcp-classic-recovery-test.cc:126
ClassicRecoveryTestSuite::ClassicRecoveryTestSuite
ClassicRecoveryTestSuite()
Definition:
tcp-classic-recovery-test.cc:128
ns3::Ptr< TcpSocketState >
ns3::TcpSocketState::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-socket-state.h:184
ns3::TcpSocketState::m_cWnd
TracedValue< uint32_t > m_cWnd
Congestion window.
Definition:
tcp-socket-state.h:170
ns3::TcpSocketState::m_cWndInfl
TracedValue< uint32_t > m_cWndInfl
Inflated congestion window trace (used only for backward compatibility purpose)
Definition:
tcp-socket-state.h:171
ns3::TcpSocketState::m_ssThresh
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
Definition:
tcp-socket-state.h:173
ns3::TestCase
encapsulates test code
Definition:
test.h:1060
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
ns3::TestSuite::UNIT
@ UNIT
This test suite implements a Unit Test.
Definition:
test.h:1265
segmentSize
uint32_t segmentSize
Definition:
tcp-linux-reno.cc:53
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_TEST_ASSERT_MSG_EQ
#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:144
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
g_TcpClassicRecoveryTest
static ClassicRecoveryTestSuite g_TcpClassicRecoveryTest
Static variable for test initialization.
Definition:
tcp-classic-recovery-test.cc:171
src
internet
test
tcp-classic-recovery-test.cc
Generated on Sun Mar 3 2024 17:11:00 for ns-3 by
1.9.1