34#include "ns3/bulk-send-helper.h"
35#include "ns3/config.h"
36#include "ns3/data-rate.h"
37#include "ns3/error-model.h"
38#include "ns3/gnuplot.h"
39#include "ns3/inet-socket-address.h"
40#include "ns3/internet-stack-helper.h"
41#include "ns3/ipv4-address-helper.h"
42#include "ns3/ipv4-global-routing-helper.h"
44#include "ns3/node-container.h"
45#include "ns3/output-stream-wrapper.h"
46#include "ns3/packet-sink-helper.h"
47#include "ns3/pcap-file.h"
48#include "ns3/point-to-point-helper.h"
49#include "ns3/point-to-point-net-device.h"
50#include "ns3/pointer.h"
51#include "ns3/simulator.h"
52#include "ns3/string.h"
53#include "ns3/tcp-header.h"
54#include "ns3/tcp-socket-factory.h"
56#include "ns3/trace-helper.h"
57#include "ns3/traffic-control-helper.h"
58#include "ns3/uinteger.h"
80 std::map<Time, double>* timeSeries,
109 bool fastConvergence,
110 bool tcpFriendliness,
112 bool capacityIncrease);
116 void DoRun()
override;
155 bool fastConvergence,
156 bool tcpFriendliness,
158 bool capacityIncrease)
161 m_fastConvergence(fastConvergence),
162 m_tcpFriendliness(tcpFriendliness),
164 m_capacityIncrease(capacityIncrease)
175 device->SetDataRate(
DataRate(
"100Mbps"));
182 "/NodeList/" + std::to_string(nodeId) +
"/$ns3::TcpL4Protocol/SocketList/" +
183 std::to_string(socketId) +
"/CongestionWindow",
192 for (
auto it = itStart; it != itEnd; it++)
194 if (it->second < lowerBound || it->second > upperBound)
196 NS_LOG_DEBUG(
"Value " << it->second <<
" at time " << it->first.GetSeconds()
197 <<
" outside range (" << lowerBound <<
"," << upperBound <<
")");
258 internet.Install(sender);
259 internet.Install(receiver);
260 internet.Install(routers);
272 ipv4.SetBase(
"10.0.0.0",
"255.255.255.0");
284 uint16_t
port = 50001;
312 std::ostringstream oss;
326 std::ofstream outfile(oss.str() +
".plt");
328 std::string capacityIncreaseString;
331 capacityIncreaseString =
" capacity increase = 1";
336 " ms RTT, 1448 byte segs, 100 Mbps bottleneck)\\nFast convergence = " +
338 " friendliness = " + std::to_string(
m_tcpFriendliness) + capacityIncreaseString);
340 gnuplot.
SetLegend(
"Time (seconds)",
"Cwnd (segments)");
348 if (
m_prefix ==
"ns3-tcp-cubic-no-heuristic")
353 "cwnd outside range");
357 "cwnd outside range");
359 else if (
m_prefix ==
"ns3-tcp-cubic-fast-conv")
364 "cwnd outside range");
368 "cwnd outside range");
370 else if (
m_prefix ==
"ns3-tcp-cubic-no-friendly")
376 "cwnd outside range");
380 "cwnd outside range");
382 else if (
m_prefix ==
"ns3-tcp-cubic-friendly")
387 "cwnd outside range");
410 "ns3-tcp-cubic-no-heuristic",
415 TestCase::Duration::QUICK);
421 "ns3-tcp-cubic-fast-conv",
426 TestCase::Duration::QUICK);
432 "ns3-tcp-cubic-no-friendly",
437 TestCase::Duration::QUICK);
443 "ns3-tcp-cubic-friendly",
448 TestCase::Duration::QUICK);
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.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
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.
Class for representing data rates.
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.
static Ipv4Address GetAny()
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
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 EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=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 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.
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.