A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
tcp-htcp-test.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2015 ResiliNets, ITTC, University of Kansas
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
* Authors: Amir Modarresi <amodarresi@ittc.ku.edu>
19
20
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21
* ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22
* Information and Telecommunication Technology Center (ITTC)
23
* and Department of Electrical Engineering and Computer Science
24
* The University of Kansas Lawrence, KS USA.
25
*
26
*/
27
28
#include "ns3/test.h"
29
#include "ns3/log.h"
30
#include "ns3/tcp-congestion-ops.h"
31
#include "ns3/tcp-socket-base.h"
32
#include "ns3/tcp-htcp.h"
33
34
using namespace
ns3
;
35
36
NS_LOG_COMPONENT_DEFINE
(
"TcpHtcpTestSuite"
);
37
44
class
TcpHtcpIncrementTest
:
public
TestCase
45
{
46
public
:
58
TcpHtcpIncrementTest
(uint32_t cWnd, uint32_t
segmentSize
,
59
uint32_t segmentsAcked,
Time
lastCongestion,
Time
firstAck,
60
Time
secondAck, uint32_t expectedCwnd,
const
std::string &name);
61
62
private
:
63
virtual
void
DoRun (
void
);
64
65
uint32_t
m_cWnd
;
66
uint32_t
m_segmentSize
;
67
uint32_t
m_segmentsAcked
;
68
Time
m_lastCongestion
;
69
Time
m_firstAck
;
70
Time
m_secondAck
;
71
uint32_t
m_expectedCwnd
;
72
Ptr<TcpSocketState>
m_state
;
73
};
74
75
TcpHtcpIncrementTest::TcpHtcpIncrementTest
(uint32_t cWnd, uint32_t
segmentSize
,
76
uint32_t segmentsAcked,
Time
lastCongestion,
Time
firstAck,
77
Time
secondAck, uint32_t expectedCwnd,
const
std::string &name)
78
:
TestCase
(name),
79
m_cWnd (cWnd),
80
m_segmentSize (
segmentSize
),
81
m_segmentsAcked (segmentsAcked),
82
m_lastCongestion (lastCongestion),
83
m_firstAck (firstAck),
84
m_secondAck (secondAck),
85
m_expectedCwnd (expectedCwnd)
86
{
87
}
88
95
void
96
TcpHtcpIncrementTest::DoRun
()
97
{
98
NS_LOG_FUNCTION
(
this
);
99
m_state
= CreateObject<TcpSocketState> ();
100
101
m_state
->
m_cWnd
=
m_cWnd
;
102
m_state
->
m_segmentSize
=
m_segmentSize
;
103
104
Ptr<TcpHtcp>
cong = CreateObject<TcpHtcp> ();
105
Time
lastCongestion;
106
107
NS_LOG_DEBUG
(
"m_cWnd: "
<<
m_cWnd
<<
" m_segmentSize: "
<<
m_segmentSize
<<
108
" m_segmentsAcked: "
<<
m_segmentsAcked
<<
" m_lastCongestion"
<<
m_lastCongestion
);
109
Simulator::Schedule (
Time
(
m_lastCongestion
), &TcpHtcp::GetSsThresh, cong,
110
m_state
,
m_state
->
m_cWnd
);
111
lastCongestion =
m_lastCongestion
;
112
Simulator::Schedule (
Time
(
m_firstAck
), &TcpHtcp::PktsAcked, cong,
m_state
,
113
m_segmentsAcked
,
Time
(
ns3::MilliSeconds
(80)));
114
Simulator::Schedule (
Time
(
m_secondAck
), &TcpHtcp::PktsAcked, cong,
m_state
,
115
m_segmentsAcked
,
Time
(
ns3::MilliSeconds
(100)));
116
117
Simulator::Run ();
118
NS_LOG_DEBUG
(
"Simulation ran for the scheduled events"
);
119
120
cong->
IncreaseWindow
(
m_state
,
m_segmentsAcked
);
121
NS_LOG_DEBUG
(
"m_cwnd from function: "
<<
m_state
->
m_cWnd
<<
" expected cWnd calculated: "
<<
m_expectedCwnd
);
122
123
NS_TEST_ASSERT_MSG_EQ
(
m_state
->
m_cWnd
.
Get
(),
m_expectedCwnd
,
124
"CWnd has not updated correctly"
);
125
126
Simulator::Destroy ();
127
}
128
146
class
TcpHtcpTestSuite
:
public
TestSuite
147
{
148
public
:
149
TcpHtcpTestSuite
()
150
:
TestSuite
(
"tcp-htcp-test"
,
UNIT
)
151
{
152
153
AddTestCase
(
154
new
TcpHtcpIncrementTest
(38 * 536, 536, 38,
ns3::MilliSeconds
(1),
155
ns3::MilliSeconds
(900),
ns3::MilliSeconds
(1000),
156
20383,
"TcpHtcp increment test on cWnd "
), TestCase::QUICK);
157
AddTestCase
(
158
new
TcpHtcpIncrementTest
(38, 1, 100,
ns3::MilliSeconds
(1),
159
ns3::MilliSeconds
(900),
ns3::MilliSeconds
(1100),
160
40,
"TcpHtcp increment test on cWnd "
), TestCase::QUICK);
161
AddTestCase
(
162
new
TcpHtcpIncrementTest
(53 * 1446, 1446, 50,
ns3::MilliSeconds
(1),
163
ns3::MilliSeconds
(900),
ns3::MilliSeconds
(1500),
164
76671,
"TcpHtcp increment test on cWnd "
), TestCase::QUICK);
165
166
}
167
};
168
169
static
TcpHtcpTestSuite
g_TcpHtcpTest
;
170
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:299
ns3::TracedValue::Get
T Get(void) const
Get the underlying value.
Definition:
traced-value.h:229
TcpHtcpIncrementTest::m_segmentsAcked
uint32_t m_segmentsAcked
Segments already ACKed.
Definition:
tcp-htcp-test.cc:67
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TcpHtcpIncrementTest::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-htcp-test.cc:66
g_TcpHtcpTest
static TcpHtcpTestSuite g_TcpHtcpTest
Static variable for test initialization.
Definition:
tcp-htcp-test.cc:169
ns3::TcpSocketState::m_segmentSize
uint32_t m_segmentSize
Segment size.
Definition:
tcp-socket-state.h:177
TcpHtcpIncrementTest::m_secondAck
Time m_secondAck
Second ACK time.
Definition:
tcp-htcp-test.cc:70
TcpHtcpIncrementTest::m_expectedCwnd
uint32_t m_expectedCwnd
Expected cWnd.
Definition:
tcp-htcp-test.cc:71
TcpHtcpTestSuite::TcpHtcpTestSuite
TcpHtcpTestSuite()
Definition:
tcp-htcp-test.cc:149
ns3::TestCase
encapsulates test code
Definition:
test.h:1154
TcpHtcpIncrementTest::m_cWnd
uint32_t m_cWnd
Congestion window.
Definition:
tcp-htcp-test.cc:65
ns3::Ptr< TcpSocketState >
TcpHtcpIncrementTest::DoRun
virtual void DoRun(void)
Since the calculation depends on the throughput and its associated timing, we schedule a few exact ev...
Definition:
tcp-htcp-test.cc:96
TcpHtcpTestSuite
TCP Htcp TestSuite.
Definition:
tcp-htcp-test.cc:147
ns3::MilliSeconds
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1297
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:104
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1344
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:166
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition:
log.h:273
ns3::TestSuite::UNIT
@ UNIT
This test suite implements a Unit Test.
Definition:
test.h:1353
segmentSize
uint32_t segmentSize
Definition:
tcp-linux-reno.cc:53
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:244
ns3::TcpSocketState::m_cWnd
TracedValue< uint32_t > m_cWnd
Congestion window.
Definition:
tcp-socket-state.h:165
TcpHtcpIncrementTest
Testing the congestion avoidance increment on TcpHtcp.
Definition:
tcp-htcp-test.cc:45
TcpHtcpIncrementTest::TcpHtcpIncrementTest
TcpHtcpIncrementTest(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, Time lastCongestion, Time firstAck, Time secondAck, uint32_t expectedCwnd, const std::string &name)
Constructor.
Definition:
tcp-htcp-test.cc:75
TcpHtcpIncrementTest::m_state
Ptr< TcpSocketState > m_state
TCP socket state.
Definition:
tcp-htcp-test.cc:72
TcpHtcpIncrementTest::m_lastCongestion
Time m_lastCongestion
Last congestion time.
Definition:
tcp-htcp-test.cc:68
TcpHtcpIncrementTest::m_firstAck
Time m_firstAck
First ACK time.
Definition:
tcp-htcp-test.cc:69
ns3::TcpNewReno::IncreaseWindow
virtual void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Try to increase the cWnd following the NewReno specification.
Definition:
tcp-congestion-ops.cc:214
src
internet
test
tcp-htcp-test.cc
Generated on Fri Oct 1 2021 17:03:12 for ns-3 by
1.8.20