A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
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
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2018 NITK Surathkal
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Viyom Mittal <viyommittal@gmail.com>
19
* Vivek Jain <jain.vivek.anand@gmail.com>
20
* Mohit P. Tahiliani <tahiliani@nitk.edu.in>
21
*
22
*/
23
24
#include "ns3/test.h"
25
#include "ns3/log.h"
26
#include "ns3/tcp-congestion-ops.h"
27
#include "ns3/tcp-recovery-ops.h"
28
#include "ns3/tcp-socket-base.h"
29
#include "ns3/string.h"
30
31
using namespace
ns3
;
32
33
NS_LOG_COMPONENT_DEFINE
(
"TcpClassicRecoveryTestSuite"
);
34
38
class
ClassicRecoveryTest
:
public
TestCase
39
{
40
public
:
49
ClassicRecoveryTest
(uint32_t cWnd,
50
uint32_t
segmentSize
,
51
uint32_t ssThresh,
52
uint32_t dupAckCount,
53
const
std::string &name);
54
55
private
:
56
virtual
void
DoRun (
void
);
57
58
uint32_t
m_cWnd
;
59
uint32_t
m_segmentSize
;
60
uint32_t
m_ssThresh
;
61
uint32_t
m_dupAckCount
;
62
63
Ptr<TcpSocketState>
m_state
;
64
};
65
66
ClassicRecoveryTest::ClassicRecoveryTest
(uint32_t cWnd,
67
uint32_t
segmentSize
,
68
uint32_t ssThresh,
69
uint32_t dupAckCount,
70
const
std::string &name)
71
:
TestCase
(name),
72
m_cWnd (cWnd),
73
m_segmentSize (
segmentSize
),
74
m_ssThresh (ssThresh),
75
m_dupAckCount (dupAckCount)
76
{
77
}
78
79
void
80
ClassicRecoveryTest::DoRun
()
81
{
82
m_state
= CreateObject<TcpSocketState> ();
83
84
m_state
->
m_cWnd
=
m_cWnd
;
85
m_state
->
m_segmentSize
=
m_segmentSize
;
86
m_state
->
m_ssThresh
=
m_ssThresh
;
87
88
Ptr<TcpClassicRecovery>
recovery = CreateObject <TcpClassicRecovery> ();
89
90
NS_TEST_ASSERT_MSG_EQ
(recovery->GetName (),
"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
,
m_state
->
m_ssThresh
,
95
"cWnd should be set to ssThresh on entering recovery"
);
96
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWndInfl
, (
m_state
->
m_ssThresh
+ (
m_dupAckCount
*
m_state
->
m_segmentSize
)),
97
"cWndInfl should be set to (ssThresh + dupAckCount * segmentSize) on entering recovery"
);
98
99
uint32_t cWndInflPrevious =
m_state
->
m_cWndInfl
;
100
uint32_t cWndPrevious =
m_state
->
m_cWnd
;
101
recovery->DoRecovery (
m_state
, 500);
102
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWndInfl
, (cWndInflPrevious +
m_state
->
m_segmentSize
),
103
"m_cWndInfl should be incresed by one segmentSize on calling DoRecovery"
);
104
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWnd
, cWndPrevious,
105
"cWnd should not change in recovery"
);
106
107
recovery->ExitRecovery (
m_state
);
108
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWndInfl
,
m_state
->
m_ssThresh
,
109
"cWndInfl should be set to ssThresh on exiting recovery"
);
110
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWnd
,
m_state
->
m_ssThresh
,
111
"cWnd should be set to ssThresh on exiting recovery"
);
112
}
113
120
class
ClassicRecoveryTestSuite
:
public
TestSuite
121
{
122
public
:
123
ClassicRecoveryTestSuite
() :
TestSuite
(
"tcp-classic-recovery-test"
,
UNIT
)
124
{
125
AddTestCase
(
new
ClassicRecoveryTest
(3000, 500, 2500, 3,
"Classic recovery test with 500 bytes segmentSize"
),
126
TestCase::QUICK);
127
AddTestCase
(
new
ClassicRecoveryTest
(3000, 1000, 2500, 3,
"Classic recovery test with 1000 bytes segmentSize"
),
128
TestCase::QUICK);
129
AddTestCase
(
new
ClassicRecoveryTest
(3000, 500, 2500, 4,
"Classic recovery test with 4 DupAck threshold"
),
130
TestCase::QUICK);
131
AddTestCase
(
new
ClassicRecoveryTest
(3000, 500, 1000, 3,
"Classic recovery test with 1000 bytes ssThresh"
),
132
TestCase::QUICK);
133
AddTestCase
(
new
ClassicRecoveryTest
(2500, 500, 2500, 3,
"Classic recovery test with same cWnd and ssThresh"
),
134
TestCase::QUICK);
135
AddTestCase
(
new
ClassicRecoveryTest
(1000, 500, 2500, 3,
"Classic recovery test with cWnd lesser than ssThresh"
),
136
TestCase::QUICK);
137
}
138
};
139
140
static
ClassicRecoveryTestSuite
g_TcpClassicRecoveryTest
;
ClassicRecoveryTest
Classic Recovery algorithm test.
Definition:
tcp-classic-recovery-test.cc:39
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:66
ClassicRecoveryTest::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
tcp-classic-recovery-test.cc:80
ClassicRecoveryTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition:
tcp-classic-recovery-test.cc:58
ClassicRecoveryTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition:
tcp-classic-recovery-test.cc:63
ClassicRecoveryTest::m_ssThresh
uint32_t m_ssThresh
Slow Start Threshold.
Definition:
tcp-classic-recovery-test.cc:60
ClassicRecoveryTest::m_dupAckCount
uint32_t m_dupAckCount
Duplicate acknowledgement Threshold.
Definition:
tcp-classic-recovery-test.cc:61
ClassicRecoveryTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-classic-recovery-test.cc:59
ClassicRecoveryTestSuite
Classic Recovery TestSuite.
Definition:
tcp-classic-recovery-test.cc:121
ClassicRecoveryTestSuite::ClassicRecoveryTestSuite
ClassicRecoveryTestSuite()
Definition:
tcp-classic-recovery-test.cc:123
ns3::Ptr< TcpSocketState >
ns3::TcpSocketState::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-socket-state.h:177
ns3::TcpSocketState::m_cWnd
TracedValue< uint32_t > m_cWnd
Congestion window.
Definition:
tcp-socket-state.h:165
ns3::TcpSocketState::m_cWndInfl
TracedValue< uint32_t > m_cWndInfl
Inflated congestion window trace (used only for backward compatibility purpose)
Definition:
tcp-socket-state.h:166
ns3::TcpSocketState::m_ssThresh
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
Definition:
tcp-socket-state.h:167
ns3::TestCase
encapsulates test code
Definition:
test.h:994
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:299
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1188
ns3::TestSuite::UNIT
@ UNIT
This test suite implements a Unit Test.
Definition:
test.h:1197
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:205
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:141
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:140
src
internet
test
tcp-classic-recovery-test.cc
Generated on Tue Feb 6 2024 19:21:20 for ns-3 by
1.9.1