44 #include "ns3/abort.h"
45 #include "ns3/bulk-send-helper.h"
46 #include "ns3/config.h"
47 #include "ns3/data-rate.h"
48 #include "ns3/error-model.h"
49 #include "ns3/gnuplot.h"
50 #include "ns3/inet-socket-address.h"
51 #include "ns3/internet-stack-helper.h"
52 #include "ns3/ipv4-address-helper.h"
53 #include "ns3/ipv4-global-routing-helper.h"
55 #include "ns3/node-container.h"
56 #include "ns3/output-stream-wrapper.h"
57 #include "ns3/packet-sink-helper.h"
58 #include "ns3/pcap-file.h"
59 #include "ns3/point-to-point-helper.h"
60 #include "ns3/point-to-point-net-device.h"
61 #include "ns3/pointer.h"
62 #include "ns3/simulator.h"
63 #include "ns3/string.h"
64 #include "ns3/tcp-header.h"
65 #include "ns3/tcp-socket-factory.h"
67 #include "ns3/trace-helper.h"
68 #include "ns3/traffic-control-helper.h"
69 #include "ns3/uinteger.h"
93 std::map<Time, double>* timeSeries,
121 bool fastConvergence,
122 bool tcpFriendliness,
124 bool capacityIncrease);
128 void DoRun()
override;
136 void ConnectCwndTrace(uint32_t nodeId, uint32_t socketId);
152 bool CheckValues(
Time start,
Time end,
double lowerBound,
double upperBound);
167 bool fastConvergence,
168 bool tcpFriendliness,
170 bool capacityIncrease)
173 m_fastConvergence(fastConvergence),
174 m_tcpFriendliness(tcpFriendliness),
176 m_capacityIncrease(capacityIncrease)
187 device->SetDataRate(
DataRate(
"100Mbps"));
194 "/NodeList/" +
std::to_string(nodeId) +
"/$ns3::TcpL4Protocol/SocketList/" +
204 for (
auto it = itStart; it != itEnd; it++)
206 if (it->second < lowerBound || it->second > upperBound)
208 NS_LOG_DEBUG(
"Value " << it->second <<
" at time " << it->first.GetSeconds()
209 <<
" outside range (" << lowerBound <<
"," << upperBound <<
")");
284 ipv4.SetBase(
"10.0.0.0",
"255.255.255.0");
293 Ipv4GlobalRoutingHelper::PopulateRoutingTables();
296 uint16_t
port = 50001;
324 std::ostringstream oss;
338 std::ofstream outfile(oss.str() +
".plt");
340 std::string capacityIncreaseString;
343 capacityIncreaseString =
" capacity increase = 1";
348 " ms RTT, 1448 byte segs, 100 Mbps bottleneck)\\nFast convergence = " +
352 gnuplot.
SetLegend(
"Time (seconds)",
"Cwnd (segments)");
360 if (
m_prefix ==
"ns3-tcp-cubic-no-heuristic")
365 "cwnd outside range");
369 "cwnd outside range");
371 else if (
m_prefix ==
"ns3-tcp-cubic-fast-conv")
376 "cwnd outside range");
380 "cwnd outside range");
382 else if (
m_prefix ==
"ns3-tcp-cubic-no-friendly")
388 "cwnd outside range");
392 "cwnd outside range");
394 else if (
m_prefix ==
"ns3-tcp-cubic-friendly")
399 "cwnd outside range");
402 Simulator::Destroy();
422 "ns3-tcp-cubic-no-heuristic",
433 "ns3-tcp-cubic-fast-conv",
444 "ns3-tcp-cubic-no-friendly",
455 "ns3-tcp-cubic-friendly",
Ipv4InterfaceContainer i1i2
IPv4 interface container i1 + i2.
Gnuplot2dDataset m_cwndTimeSeries
cwnd time series
bool m_tcpFriendliness
whether to enable TCP friendliness
void DoRun() override
Implementation to actually run this TestCase.
Time m_baseRtt
the base RTT to use
void ConnectCwndTrace(uint32_t nodeId, uint32_t socketId)
Connect TCP cwnd trace after socket is instantiated.
std::string m_prefix
filename prefix if writing files
Ns3TcpCubicTestCase(std::string testCase, std::string prefix, bool fastConvergence, bool tcpFriendliness, Time baseRtt, bool capacityIncrease)
Constructor.
bool m_writeGnuplot
Whether to write gnuplot files.
~Ns3TcpCubicTestCase() override
bool m_capacityIncrease
whether to trigger a capacity increase
bool m_fastConvergence
whether to enable fast convergence
bool m_writeResults
Whether to write pcaps.
std::map< Time, double > m_timeSeries
time series to check
void IncreaseBandwidth(Ptr< PointToPointNetDevice > device)
Increases the device bandwidth to 100 Mbps.
bool CheckValues(Time start, Time end, double lowerBound, double upperBound)
Check that time series values within a time range are within a value range.
TestSuite for module tcp-cubic.
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
void EnableAscii(std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
Enable ascii trace output on the indicated net device.
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes, not the socket attributes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::BulkSendApplication on each node of the input container configured with all the attri...
Class to represent a 2D points plot.
void Add(double x, double y)
void SetTitle(const std::string &title)
Change line title.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
void AddDataset(const GnuplotDataset &dataset)
void SetLegend(const std::string &xLegend, const std::string &yLegend)
void SetTerminal(const std::string &terminal)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
Build a set of PointToPointNetDevice objects.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
void SetQueue(std::string type, Ts &&... args)
Each point to point net device must have a queue to pass packets through.
NetDeviceContainer Install(NodeContainer c)
A Device for a Point to Point Network Link.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Build a set of QueueDisc objects.
QueueDiscContainer Install(NetDeviceContainer c)
uint16_t SetRootQueueDisc(const std::string &type, Args &&... args)
Helper function used to set a root queue disc of the given type and with the given attributes.
void SetQueueLimits(std::string type, Args &&... args)
Helper function used to add a queue limits object to the transmission queues of the devices.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
void CubicCwndTracer(Gnuplot2dDataset *gnuplotTimeSeries, std::map< Time, double > *timeSeries, uint32_t oldval, uint32_t newval)
Add sample trace values to data structures.
#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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static constexpr bool WRITE_PCAP
Set to true to write out pcap.
static Ns3TcpCubicTestSuite ns3TcpCubicTestSuite
Static variable for test initialization.
static constexpr bool WRITE_GNUPLOT
Set to true to write out gnuplot.
Ptr< PacketSink > sink
Pointer to the packet sink application.