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"
91 std::map<Time, double>* timeSeries,
120 bool fastConvergence,
121 bool tcpFriendliness,
123 bool capacityIncrease);
127 void DoRun()
override;
166 bool fastConvergence,
167 bool tcpFriendliness,
169 bool capacityIncrease)
172 m_fastConvergence(fastConvergence),
173 m_tcpFriendliness(tcpFriendliness),
175 m_capacityIncrease(capacityIncrease)
186 device->SetDataRate(
DataRate(
"100Mbps"));
193 "/NodeList/" + std::to_string(nodeId) +
"/$ns3::TcpL4Protocol/SocketList/" +
194 std::to_string(socketId) +
"/CongestionWindow",
203 for (
auto it = itStart; it != itEnd; it++)
205 if (it->second < lowerBound || it->second > upperBound)
207 NS_LOG_DEBUG(
"Value " << it->second <<
" at time " << it->first.GetSeconds()
208 <<
" outside range (" << lowerBound <<
"," << upperBound <<
")");
269 internet.Install(sender);
270 internet.Install(receiver);
271 internet.Install(routers);
283 ipv4.SetBase(
"10.0.0.0",
"255.255.255.0");
295 uint16_t
port = 50001;
323 std::ostringstream oss;
337 std::ofstream outfile(oss.str() +
".plt");
339 std::string capacityIncreaseString;
342 capacityIncreaseString =
" capacity increase = 1";
347 " ms RTT, 1448 byte segs, 100 Mbps bottleneck)\\nFast convergence = " +
349 " friendliness = " + std::to_string(
m_tcpFriendliness) + capacityIncreaseString);
351 gnuplot.
SetLegend(
"Time (seconds)",
"Cwnd (segments)");
359 if (
m_prefix ==
"ns3-tcp-cubic-no-heuristic")
364 "cwnd outside range");
368 "cwnd outside range");
370 else if (
m_prefix ==
"ns3-tcp-cubic-fast-conv")
375 "cwnd outside range");
379 "cwnd outside range");
381 else if (
m_prefix ==
"ns3-tcp-cubic-no-friendly")
387 "cwnd outside range");
391 "cwnd outside range");
393 else if (
m_prefix ==
"ns3-tcp-cubic-friendly")
398 "cwnd outside range");
421 "ns3-tcp-cubic-no-heuristic",
426 TestCase::Duration::QUICK);
432 "ns3-tcp-cubic-fast-conv",
437 TestCase::Duration::QUICK);
443 "ns3-tcp-cubic-no-friendly",
448 TestCase::Duration::QUICK);
454 "ns3-tcp-cubic-friendly",
459 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.