55#include "ns3/applications-module.h"
56#include "ns3/core-module.h"
57#include "ns3/flow-monitor-helper.h"
58#include "ns3/internet-module.h"
59#include "ns3/network-module.h"
60#include "ns3/point-to-point-module.h"
61#include "ns3/traffic-control-module.h"
101 uint32_t qSize = queue->GetCurrentSize().GetValue();
109 std::ofstream fPlotQueueDisc(
filePlotQueueDisc.str(), std::ios::out | std::ios::app);
111 fPlotQueueDisc.close();
116 fPlotQueueDiscAvg.close();
128 uint16_t
port = 50000;
178main(
int argc,
char* argv[])
183 std::string aredLinkDataRate =
"1.5Mbps";
184 std::string aredLinkDelay =
"20ms";
187 bool writeForPlot =
false;
188 bool writePcap =
false;
189 bool flowMonitor =
false;
191 bool printAredStats =
true;
205 cmd.AddValue(
"testNumber",
206 "Run test 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14 or 15",
208 cmd.AddValue(
"pathOut",
209 "Path to save results from --writeForPlot/--writePcap/--writeFlowMonitor",
211 cmd.AddValue(
"writeForPlot",
"Write results for plot (gnuplot)", writeForPlot);
212 cmd.AddValue(
"writePcap",
"Write results in pcapfile", writePcap);
213 cmd.AddValue(
"writeFlowMonitor",
"Enable Flow Monitor and write their results", flowMonitor);
215 cmd.Parse(argc, argv);
216 if ((aredTest < 1) || (aredTest == 5) || (aredTest > 15))
218 std::cout <<
"Invalid test number. Supported tests are 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, "
261 else if (aredTest == 2)
267 else if (aredTest == 3)
273 else if (aredTest == 4)
281 else if (aredTest == 7)
285 else if (aredTest == 8)
290 else if (aredTest == 9)
295 else if (aredTest == 10)
300 else if (aredTest == 11)
308 else if (aredTest == 12)
314 else if (aredTest == 13)
318 else if (aredTest == 14)
324 else if (aredTest == 15)
334 NS_LOG_INFO(
"Install internet stack on all nodes.");
360 if (aredTest == 1 || aredTest == 2 || aredTest == 3 || aredTest == 4)
362 p2p.SetQueue(
"ns3::DropTailQueue");
368 p2p.SetQueue(
"ns3::DropTailQueue");
374 p2p.SetQueue(
"ns3::DropTailQueue");
375 p2p.SetDeviceAttribute(
"DataRate",
StringValue(aredLinkDataRate));
379 queueDiscs = tchRed.
Install(devn2n3);
381 p2p.SetQueue(
"ns3::DropTailQueue");
387 p2p.SetQueue(
"ns3::DropTailQueue");
393 else if (aredTest == 13 || aredTest == 14 || aredTest == 15)
395 p2p.SetQueue(
"ns3::DropTailQueue");
401 p2p.SetQueue(
"ns3::DropTailQueue");
407 p2p.SetQueue(
"ns3::DropTailQueue");
408 p2p.SetDeviceAttribute(
"DataRate",
StringValue(aredLinkDataRate));
412 queueDiscs = tchRed.
Install(devn2n3);
414 p2p.SetQueue(
"ns3::DropTailQueue");
420 p2p.SetQueue(
"ns3::DropTailQueue");
426 else if (aredTest == 6 || aredTest == 7 || aredTest == 8 || aredTest == 9 || aredTest == 10 ||
427 aredTest == 11 || aredTest == 12)
429 p2p.SetQueue(
"ns3::DropTailQueue");
435 p2p.SetQueue(
"ns3::DropTailQueue");
441 p2p.SetQueue(
"ns3::DropTailQueue");
446 queueDiscs = tchRed.
Install(devn2n3);
448 p2p.SetQueue(
"ns3::DropTailQueue");
454 p2p.SetQueue(
"ns3::DropTailQueue");
464 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
467 ipv4.SetBase(
"10.1.2.0",
"255.255.255.0");
470 ipv4.SetBase(
"10.1.3.0",
"255.255.255.0");
473 ipv4.SetBase(
"10.1.4.0",
"255.255.255.0");
476 ipv4.SetBase(
"10.1.5.0",
"255.255.255.0");
487 std::stringstream stmp;
488 stmp << pathOut <<
"/ared";
502 <<
"ared-queue-disc.plotme";
504 <<
"ared-queue-disc_avg.plotme";
520 std::cout <<
"There should be some unforced drops or marks" << std::endl;
524 if (aredTest == 1 || aredTest == 2 || aredTest == 3 || aredTest == 4 || aredTest == 13)
528 std::cout <<
"There should be some drops due to queue full" << std::endl;
536 std::cout <<
"There should be zero drops due to queue full" << std::endl;
543 std::stringstream stmp;
544 stmp << pathOut <<
"/ared.flowmon";
546 flowmon->SerializeToXmlFile(stmp.str(),
false,
false);
551 std::cout <<
"*** ARED stats from Node 2 queue ***" << std::endl;
552 std::cout << st << std::endl;
Ipv4InterfaceContainer i0i2
IPv4 interface container i0 + i2.
std::stringstream filePlotQueueDisc
Output file name for queue disc size.
double client_start_time
Client start time.
double sink_stop_time
Sink stop time.
double sink_start_time
Sink start time.
double global_stop_time
Global stop time.
std::stringstream filePlotQueueDiscAvg
Output file name for queue disc average.
NodeContainer n2n3
Nodecontainer n2 + n3.
void CheckQueueDiscSize(Ptr< QueueDisc > queue)
Check the queue disc size and write its stats to the output files.
NodeContainer n1n2
Nodecontainer n1 + n2.
double avgQueueDiscSize
Average QueueDisc size.
NodeContainer n3n4
Nodecontainer n3 + n4.
double global_start_time
Global start time.
Ipv4InterfaceContainer i1i2
IPv4 interface container i1 + i2.
Ipv4InterfaceContainer i3i4
IPv4 interface container i3 + i4.
NodeContainer n0n2
Nodecontainer n0 + n2.
double client_stop_time
Client stop time.
uint32_t checkTimes
Number of times the queues have been checked.
NodeContainer n3n5
Nodecontainer n3 + n5.
Ipv4InterfaceContainer i3i5
IPv4 interface container i3 + i5.
Ipv4InterfaceContainer i2i3
IPv4 interface container i2 + i3.
a polymophic address class
AttributeValue implementation for Address.
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 Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
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.
AttributeValue implementation for Boolean.
Parse command-line arguments.
Class for representing data rates.
AttributeValue implementation for DataRate.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Helper to enable IP flow monitoring on a set of Nodes.
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
static void Bind(std::string name, const AttributeValue &value)
Iterate over the set of GlobalValues until a matching name is found and then set its value with Globa...
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
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
holds a vector of ns3::NetDevice pointers
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::OnOffApplication on a set of nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
Build a set of PointToPointNetDevice objects.
Smart pointer class similar to boost::intrusive_ptr.
Holds a vector of ns3::QueueDisc pointers.
Ptr< QueueDisc > Get(std::size_t i) const
Get the Ptr<QueueDisc> stored in this container at a given index.
static constexpr const char * INTERNAL_QUEUE_DROP
Packet dropped by an internal queue.
const Stats & GetStats()
Retrieve all the collected statistics.
static constexpr const char * UNFORCED_DROP
Early probability drops.
static constexpr const char * UNFORCED_MARK
Early probability marks.
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 EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Hold variables of type string.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
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 AddInternalQueues(uint16_t handle, uint16_t count, std::string type, Args &&... args)
Helper function used to add the given number of internal queues (of the given type and with the given...
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
@ LOG_LEVEL_INFO
LOG_INFO and above.
-ns3 Test suite for the ns3 wrapper script
Structure that keeps the queue disc statistics.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.