This documentation is not the Latest Release.
A Discrete-Event Network Simulator
API
tcp-cong-avoid-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 Natale Patriciello <natale.patriciello@gmail.com>
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  */
19 #include "ns3/log.h"
20 #include "ns3/simple-channel.h"
21 #include "ns3/internet-module.h"
22 #include "ns3/config.h"
23 #include "tcp-cong-avoid-test.h"
24 
25 namespace ns3 {
26 
27 NS_LOG_COMPONENT_DEFINE ("TcpNewRenoCongAvoidTest");
28 
30  uint32_t packetSize,
31  uint32_t packets,
32  TypeId &typeId,
33  const std::string &desc)
34  : TcpGeneralTest (desc, packetSize, packets, Seconds (0.01), Seconds (0.5),
35  Seconds (10), 0, 1, segmentSize, typeId, 1500),
36  m_increment (0),
37  m_initial (true)
38 {
39 }
40 
48 void
49 TcpNewRenoCongAvoidNormalTest::CWndTrace (uint32_t oldValue, uint32_t newValue)
50 {
51  if (m_initial)
52  {
53  m_initial = false;
54  return;
55  }
56 
57  if (!m_event.IsRunning ())
58  {
61  }
62 
63  m_increment += newValue - oldValue;
64 }
65 
66 void
68 {
69  NS_FATAL_ERROR ("Drop on the queue; cannot validate congestion avoidance");
70 }
71 
72 void
74 {
75  NS_FATAL_ERROR ("Drop on the phy: cannot validate congestion avoidance");
76 }
77 
82 void
84 {
85  uint32_t segSize = GetSegSize (TcpGeneralTest::SENDER);
86 
87  if (m_increment != 0)
88  {
90  "Increment exceeded segment size in one RTT");
91  }
92 
93  m_increment = 0;
94 
97 
98 }
99 
100 void
102 {
103  if (who == SENDER)
104  {
105  m_event.Cancel ();
106  }
107 }
108 
109 //-----------------------------------------------------------------------------
110 
112 {
113 public:
114  TcpRenoCongAvoidTestSuite () : TestSuite ("tcp-cong-avoid-test", UNIT)
115  {
116  std::list<TypeId> types;
117  types.insert (types.begin (), TcpWestwood::GetTypeId ());
118  types.insert (types.begin (), TcpNewReno::GetTypeId ());
119 
120  for (std::list<TypeId>::iterator it = types.begin (); it != types.end (); ++it)
121  {
122  for (uint32_t i = 10; i <= 50; i += 10)
123  {
124  AddTestCase (new TcpNewRenoCongAvoidNormalTest (500, 500, i, (*it),
125  "cong avoid MSS=500, pkt_size=500," + (*it).GetName ()),
127  AddTestCase (new TcpNewRenoCongAvoidNormalTest (500, 1000, i, (*it),
128  "cong avoid MSS=500, pkt_size=1000," + (*it).GetName ()),
130  }
131  }
132  }
134 
135 } // namespace ns3
uint32_t GetSegSize(SocketWho who)
Get the segment size of the node specified.
Fast test.
Definition: test.h:1152
A suite of tests to run.
Definition: test.h:1333
void PhyDrop(SocketWho who)
Link drop.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
void QueueDrop(SocketWho who)
Drop on the queue.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:145
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
void NormalClose(SocketWho who)
Socket closed normally.
This test suite implements a Unit Test.
Definition: test.h:1343
static TypeId GetTypeId(void)
Get the type ID.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1216
virtual void CWndTrace(uint32_t oldValue, uint32_t newValue)
Check the increment of the congestion window in the congestion avoidance.
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:297
TcpNewRenoCongAvoidNormalTest(uint32_t segmentSize, uint32_t packetSize, uint32_t packets, TypeId &congControl, const std::string &msg)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-westwood.cc:47
SocketWho
Used as parameter of methods, specifies on what node the caller is interested (e.g.
General infrastructure for TCP testing.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:895
ns3::TcpRenoCongAvoidTestSuite g_tcpCongAvoidNormalTest
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
void Check()
Called each RTT (1.0 sec in the testing environment) and check that the overall increment in this RTT...
Test the behavior of RFC congestion avoidance.
#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:825
static const uint32_t packetSize
a unique identifier for an interface.
Definition: type-id.h:58