A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-htcp-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 ResiliNets, ITTC, University of Kansas
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 * Authors: Amir Modarresi <amodarresi@ittc.ku.edu>
18
19 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
20 * ResiliNets Research Group https://resilinets.org/
21 * Information and Telecommunication Technology Center (ITTC)
22 * and Department of Electrical Engineering and Computer Science
23 * The University of Kansas Lawrence, KS USA.
24 *
25 */
26
27#include "ns3/log.h"
28#include "ns3/tcp-congestion-ops.h"
29#include "ns3/tcp-htcp.h"
30#include "ns3/tcp-socket-base.h"
31#include "ns3/test.h"
32
33using namespace ns3;
34
35NS_LOG_COMPONENT_DEFINE("TcpHtcpTestSuite");
36
43{
44 public:
58 uint32_t segmentsAcked,
59 Time lastCongestion,
60 Time firstAck,
61 Time secondAck,
62 uint32_t expectedCwnd,
63 const std::string& name);
64
65 private:
66 void DoRun() override;
67
76};
77
80 uint32_t segmentsAcked,
81 Time lastCongestion,
82 Time firstAck,
83 Time secondAck,
84 uint32_t expectedCwnd,
85 const std::string& name)
86 : TestCase(name),
87 m_cWnd(cWnd),
88 m_segmentSize(segmentSize),
89 m_segmentsAcked(segmentsAcked),
90 m_lastCongestion(lastCongestion),
91 m_firstAck(firstAck),
92 m_secondAck(secondAck),
93 m_expectedCwnd(expectedCwnd)
94{
95}
96
103void
105{
106 NS_LOG_FUNCTION(this);
107 m_state = CreateObject<TcpSocketState>();
108
111
112 Ptr<TcpHtcp> cong = CreateObject<TcpHtcp>();
113 Time lastCongestion;
114
115 NS_LOG_DEBUG("m_cWnd: " << m_cWnd << " m_segmentSize: " << m_segmentSize << " m_segmentsAcked: "
116 << m_segmentsAcked << " m_lastCongestion" << m_lastCongestion);
119 cong,
120 m_state,
121 m_state->m_cWnd);
122 lastCongestion = m_lastCongestion;
125 cong,
126 m_state,
131 cong,
132 m_state,
134 Time(ns3::MilliSeconds(100)));
135
137 NS_LOG_DEBUG("Simulation ran for the scheduled events");
138
139 cong->IncreaseWindow(m_state, m_segmentsAcked);
140 NS_LOG_DEBUG("m_cwnd from function: " << m_state->m_cWnd
141 << " expected cWnd calculated: " << m_expectedCwnd);
142
143 NS_TEST_ASSERT_MSG_EQ(m_state->m_cWnd.Get(), m_expectedCwnd, "CWnd has not updated correctly");
144
146}
147
165{
166 public:
168 : TestSuite("tcp-htcp-test", UNIT)
169 {
171 536,
172 38,
175 ns3::MilliSeconds(1000),
176 20383,
177 "TcpHtcp increment test on cWnd "),
180 1,
181 100,
184 ns3::MilliSeconds(1100),
185 40,
186 "TcpHtcp increment test on cWnd "),
188 AddTestCase(new TcpHtcpIncrementTest(53 * 1446,
189 1446,
190 50,
193 ns3::MilliSeconds(1500),
194 76671,
195 "TcpHtcp increment test on cWnd "),
197 }
198};
199
Testing the congestion avoidance increment on TcpHtcp.
void DoRun() override
Since the calculation depends on the throughput and its associated timing, we schedule a few exact ev...
Time m_secondAck
Second ACK time.
Time m_lastCongestion
Last congestion time.
uint32_t m_segmentsAcked
Segments already ACKed.
uint32_t m_cWnd
Congestion window.
uint32_t m_expectedCwnd
Expected cWnd.
Ptr< TcpSocketState > m_state
TCP socket state.
uint32_t m_segmentSize
Segment size.
TcpHtcpIncrementTest(uint32_t cWnd, uint32_t segmentSize, uint32_t segmentsAcked, Time lastCongestion, Time firstAck, Time secondAck, uint32_t expectedCwnd, const std::string &name)
Constructor.
Time m_firstAck
First ACK time.
TCP Htcp TestSuite.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:568
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition: simulator.cc:140
static void Run()
Run the simulation.
Definition: simulator.cc:176
uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight) override
Get the slow start threshold after a loss event.
Definition: tcp-htcp.cc:175
void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt) override
Timing information on received ACK.
Definition: tcp-htcp.cc:197
uint32_t m_segmentSize
Segment size.
TracedValue< uint32_t > m_cWnd
Congestion window.
encapsulates test code
Definition: test.h:1060
@ QUICK
Fast test.
Definition: test.h:1065
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:301
A suite of tests to run.
Definition: test.h:1256
@ UNIT
This test suite implements a Unit Test.
Definition: test.h:1265
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
T Get() const
Get the underlying value.
Definition: traced-value.h:249
uint32_t segmentSize
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#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
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1348
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TcpHtcpTestSuite g_TcpHtcpTest
Static variable for test initialization.