289 #include "ns3/core-module.h"
290 #include "ns3/network-module.h"
291 #include "ns3/internet-module.h"
292 #include "ns3/flow-monitor-helper.h"
293 #include "ns3/point-to-point-module.h"
294 #include "ns3/applications-module.h"
295 #include "ns3/internet-apps-module.h"
296 #include "ns3/traffic-control-module.h"
311 TraceN0Cwnd (std::ofstream* ofStream, uint32_t oldCwnd, uint32_t newCwnd)
319 TraceN1Cwnd (std::ofstream* ofStream, uint32_t oldCwnd, uint32_t newCwnd)
456 else if (
address ==
"192.168.3.2")
463 main (
int argc,
char *argv[])
470 uint32_t pingSize = 100;
474 DataRate bottleneckRate (
"100Mbps");
476 std::string
dir =
"results/FqCoDel-L4S/";
477 std::string dirToSave =
"mkdir -p " +
dir;
478 if (system (dirToSave.c_str ()) == -1)
483 std::string pingTraceFile =
dir +
"ping.dat";
484 std::string n0TcpRttTraceFile =
dir +
"n0-tcp-rtt.dat";
485 std::string n0TcpCwndTraceFile =
dir +
"n0-tcp-cwnd.dat";
486 std::string n0TcpThroughputTraceFile =
dir +
"n0-tcp-throughput.dat";
487 std::string n1TcpRttTraceFile =
dir +
"n1-tcp-rtt.dat";
488 std::string n1TcpCwndTraceFile =
dir +
"n1-tcp-cwnd.dat";
489 std::string n1TcpThroughputTraceFile =
dir +
"n1-tcp-throughput.dat";
490 std::string dropTraceFile =
dir +
"drops.dat";
491 std::string dropsFrequencyTraceFile =
dir +
"drops-frequency.dat";
492 std::string lengthTraceFile =
dir +
"length.dat";
493 std::string markTraceFile =
dir +
"mark.dat";
494 std::string marksFrequencyTraceFile =
dir +
"marks-frequency.dat";
495 std::string queueDelayN0TraceFile =
dir +
"queue-delay-n0.dat";
496 std::string queueDelayN1TraceFile =
dir +
"queue-delay-n1.dat";
502 bool useCeThreshold =
false;
504 std::string n0TcpType =
"bic";
505 std::string n1TcpType =
"";
506 bool enableN1Tcp =
false;
508 std::string queueType =
"fq";
509 std::string linkDataRate =
"1Gbps";
510 uint32_t scenarioNum = 0;
526 cmd.AddValue (
"n0TcpType",
"n0 TCP type (bic, dctcp, or reno)", n0TcpType);
527 cmd.AddValue (
"n1TcpType",
"n1 TCP type (bic, dctcp, or reno)", n1TcpType);
528 cmd.AddValue (
"scenarioNum",
"Scenario number from the scenarios avalaible in the file (1-9)", scenarioNum);
529 cmd.AddValue (
"bottleneckQueueType",
"n2 queue type (fq or codel)", queueType);
530 cmd.AddValue (
"baseRtt",
"base RTT", baseRtt);
531 cmd.AddValue (
"useCeThreshold",
"use CE Threshold", useCeThreshold);
532 cmd.AddValue (
"useEcn",
"use ECN", useEcn);
533 cmd.AddValue (
"ceThreshold",
"CoDel CE threshold", ceThreshold);
534 cmd.AddValue (
"bottleneckRate",
"data rate of bottleneck", bottleneckRate);
535 cmd.AddValue (
"linkRate",
"data rate of edge link", linkDataRate);
536 cmd.AddValue (
"stopTime",
"simulation stop time",
stopTime);
538 cmd.AddValue (
"pingTraceFile",
"filename for ping tracing", pingTraceFile);
539 cmd.AddValue (
"n0TcpRttTraceFile",
"filename for n0 rtt tracing", n0TcpRttTraceFile);
540 cmd.AddValue (
"n0TcpCwndTraceFile",
"filename for n0 cwnd tracing", n0TcpCwndTraceFile);
541 cmd.AddValue (
"n0TcpThroughputTraceFile",
"filename for n0 throughput tracing", n0TcpThroughputTraceFile);
542 cmd.AddValue (
"n1TcpRttTraceFile",
"filename for n1 rtt tracing", n1TcpRttTraceFile);
543 cmd.AddValue (
"n1TcpCwndTraceFile",
"filename for n1 cwnd tracing", n1TcpCwndTraceFile);
544 cmd.AddValue (
"n1TcpThroughputTraceFile",
"filename for n1 throughput tracing", n1TcpThroughputTraceFile);
545 cmd.AddValue (
"dropTraceFile",
"filename for n2 drops tracing", dropTraceFile);
546 cmd.AddValue (
"dropsFrequencyTraceFile",
"filename for n2 drop frequency tracing", dropsFrequencyTraceFile);
547 cmd.AddValue (
"lengthTraceFile",
"filename for n2 queue length tracing", lengthTraceFile);
548 cmd.AddValue (
"markTraceFile",
"filename for n2 mark tracing", markTraceFile);
549 cmd.AddValue (
"marksFrequencyTraceFile",
"filename for n2 mark frequency tracing", marksFrequencyTraceFile);
550 cmd.AddValue (
"queueDelayN0TraceFile",
"filename for n0 queue delay tracing", queueDelayN0TraceFile);
551 cmd.AddValue (
"queueDelayN1TraceFile",
"filename for n1 queue delay tracing", queueDelayN1TraceFile);
552 cmd.Parse (argc, argv);
553 Time oneWayDelay = baseRtt / 2;
564 if (n0TcpType ==
"reno")
568 else if (n0TcpType ==
"bic")
572 else if (n0TcpType ==
"dctcp")
581 if (n1TcpType ==
"reno")
586 else if (n1TcpType ==
"bic")
591 else if (n1TcpType ==
"dctcp")
596 else if (n1TcpType ==
"")
605 if (queueType ==
"fq")
609 else if (queueType ==
"codel")
622 else if (scenarioNum == 1 || scenarioNum == 2 || scenarioNum == 5 || scenarioNum == 6)
624 if (scenarioNum == 2 || scenarioNum == 6)
629 if (scenarioNum == 5 || scenarioNum == 6)
636 else if (scenarioNum == 3 || scenarioNum == 4 || scenarioNum == 7 || scenarioNum == 8 || scenarioNum == 9)
643 if (scenarioNum == 9)
649 if (scenarioNum == 4 || scenarioNum == 8 || scenarioNum == 9)
654 if (scenarioNum == 7 || scenarioNum == 8 || scenarioNum == 9)
665 std::ofstream pingOfStream;
666 pingOfStream.open (pingTraceFile.c_str (), std::ofstream::out);
667 std::ofstream n0TcpRttOfStream;
668 n0TcpRttOfStream.open (n0TcpRttTraceFile.c_str (), std::ofstream::out);
669 std::ofstream n0TcpCwndOfStream;
670 n0TcpCwndOfStream.open (n0TcpCwndTraceFile.c_str (), std::ofstream::out);
671 std::ofstream n0TcpThroughputOfStream;
672 n0TcpThroughputOfStream.open (n0TcpThroughputTraceFile.c_str (), std::ofstream::out);
673 std::ofstream n1TcpRttOfStream;
674 n1TcpRttOfStream.open (n1TcpRttTraceFile.c_str (), std::ofstream::out);
675 std::ofstream n1TcpCwndOfStream;
676 n1TcpCwndOfStream.open (n1TcpCwndTraceFile.c_str (), std::ofstream::out);
677 std::ofstream n1TcpThroughputOfStream;
678 n1TcpThroughputOfStream.open (n1TcpThroughputTraceFile.c_str (), std::ofstream::out);
681 std::ofstream dropOfStream;
682 dropOfStream.open (dropTraceFile.c_str (), std::ofstream::out);
683 std::ofstream markOfStream;
684 markOfStream.open (markTraceFile.c_str (), std::ofstream::out);
685 std::ofstream dropsFrequencyOfStream;
686 dropsFrequencyOfStream.open (dropsFrequencyTraceFile.c_str (), std::ofstream::out);
687 std::ofstream marksFrequencyOfStream;
688 marksFrequencyOfStream.open (marksFrequencyTraceFile.c_str (), std::ofstream::out);
689 std::ofstream lengthOfStream;
690 lengthOfStream.open (lengthTraceFile.c_str (), std::ofstream::out);
691 std::ofstream queueDelayN0OfStream;
692 queueDelayN0OfStream.open (queueDelayN0TraceFile.c_str (), std::ofstream::out);
693 std::ofstream queueDelayN1OfStream;
694 queueDelayN1OfStream.open (queueDelayN1TraceFile.c_str (), std::ofstream::out);
699 Ptr<Node> pingServer = CreateObject<Node> ();
700 Ptr<Node> n0Server = CreateObject<Node> ();
701 Ptr<Node> n1Server = CreateObject<Node> ();
704 Ptr<Node> pingClient = CreateObject<Node> ();
705 Ptr<Node> n4Client = CreateObject<Node> ();
706 Ptr<Node> n5Client = CreateObject<Node> ();
722 pingServerDevices = p2p.
Install (n2, pingServer);
723 n0ServerDevices = p2p.
Install (n2, n0Server);
726 if (scenarioNum == 9)
730 n1ServerDevices = p2p.
Install (n2, n1Server);
732 n2n3Devices = p2p.
Install (n2, n3);
733 pingClientDevices = p2p.
Install (n3, pingClient);
734 n4ClientDevices = p2p.
Install (n3, n4Client);
735 n5ClientDevices = p2p.
Install (n3, n5Client);
737 p->SetAttribute (
"DataRate",
DataRateValue (bottleneckRate));
745 proto->SetAttribute (
"SocketType",
TypeIdValue (n0TcpTypeId));
747 proto->SetAttribute (
"SocketType",
TypeIdValue (n0TcpTypeId));
751 proto->SetAttribute (
"SocketType",
TypeIdValue (n1TcpTypeId));
753 proto->SetAttribute (
"SocketType",
TypeIdValue (n1TcpTypeId));
764 tchFq.
Install (pingServerDevices);
765 tchFq.
Install (n0ServerDevices);
766 tchFq.
Install (n1ServerDevices);
768 tchFq.
Install (pingClientDevices);
769 tchFq.
Install (n4ClientDevices);
770 tchFq.
Install (n5ClientDevices);
777 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
779 ipv4.
SetBase (
"10.1.2.0",
"255.255.255.0");
781 ipv4.
SetBase (
"10.1.3.0",
"255.255.255.0");
783 ipv4.
SetBase (
"172.16.1.0",
"255.255.255.0");
785 ipv4.
SetBase (
"192.168.1.0",
"255.255.255.0");
787 ipv4.
SetBase (
"192.168.2.0",
"255.255.255.0");
789 ipv4.
SetBase (
"192.168.3.0",
"255.255.255.0");
799 pingHelper.SetAttribute (
"Interval",
TimeValue (pingInterval));
811 uint16_t n4Port = 5000;
814 tcp.SetAttribute (
"Remote",
AddressValue (n0DestAddress));
815 n0App = tcp.Install (n0Server);
822 n4SinkApp = n4SinkHelper.Install (n4Client);
829 uint16_t n5Port = 5000;
832 tcp.SetAttribute (
"Remote",
AddressValue (n1DestAddress));
833 secondApp = tcp.Install (n1Server);
840 n5SinkApp = n5SinkHelper.Install (n5Client);
849 qd = tc->GetRootQueueDiscOnDevice (n2n3Devices.
Get (0));
879 pingOfStream.close ();
880 n0TcpCwndOfStream.close ();
881 n0TcpRttOfStream.close ();
882 n0TcpThroughputOfStream.close ();
883 n1TcpCwndOfStream.close ();
884 n1TcpRttOfStream.close ();
885 n1TcpThroughputOfStream.close ();
886 dropOfStream.close ();
887 markOfStream.close ();
888 dropsFrequencyOfStream.close ();
889 marksFrequencyOfStream.close ();
890 lengthOfStream.close ();
891 queueDelayN0OfStream.close ();
892 queueDelayN1OfStream.close ();
a polymophic address class
AttributeValue implementation for Address.
holds a vector of ns3::Application pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
AttributeValue implementation for Boolean.
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
static TypeId GetTypeId(void)
Get the type ID.
Parse command-line arguments.
Class for representing data rates.
uint64_t GetBitRate() const
Get the underlying bitrate.
AttributeValue implementation for DataRate.
static TypeId GetTypeId(void)
Get the type ID.
aggregate IP/TCP/UDP functionality to existing Nodes.
void InstallAll(void) const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny(void)
static void PopulateRoutingTables(void)
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
Ipv4QueueDiscItem is a subclass of QueueDiscItem which stores IPv4 packets.
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.
virtual Ptr< Node > GetNode(void) const =0
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
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.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetQueue(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue())
Each point to point net device must have a queue to pass packets through.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
NetDeviceContainer Install(NodeContainer c)
A Device for a Point to Point Network Link.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Run(void)
Run the simulation.
static Time Now(void)
Return the current simulation virtual time.
Hold variables of type string.
static TypeId GetTypeId(void)
Get the type ID.
static TypeId GetTypeId(void)
Get the type ID.
TCP socket creation and multiplexing/demultiplexing.
static TypeId GetTypeId(void)
Get the type ID.
static TypeId GetTypeId(void)
Get the type ID.
Simulation virtual time values and global simulation resolution.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
double GetSeconds(void) 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 SetQueueLimits(std::string type, Args &&... args)
Helper function used to add a queue limits object to the transmission queues of the devices.
Introspection did not find any typical Config paths.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
std::string GetName(void) const
Get the name.
AttributeValue implementation for TypeId.
Hold an unsigned integer type.
Create a IPv4 ping application and associate it to a node.
an application which sends one ICMP ECHO request, waits for a REPLYs and reports the calculated RTT.
void TraceDropsFrequency(std::ofstream *ofStream, Time dropsSamplingInterval)
void TraceN0Rx(Ptr< const Packet > packet, const Address &address)
void ScheduleN0TcpCwndTraceConnection(std::ofstream *ofStream)
void TraceMarksFrequency(std::ofstream *ofStream, Time marksSamplingInterval)
void ScheduleN1TcpRttTraceConnection(std::ofstream *ofStream)
void TraceN0Cwnd(std::ofstream *ofStream, uint32_t oldCwnd, uint32_t newCwnd)
void TraceN1Throughput(std::ofstream *ofStream, Time throughputInterval)
void ScheduleN1PacketSinkConnection(void)
void TraceMark(std::ofstream *ofStream, Ptr< const QueueDiscItem > item, const char *reason)
void TracePingRtt(std::ofstream *ofStream, Time rtt)
void ScheduleN0PacketSinkConnection(void)
void TraceN1Cwnd(std::ofstream *ofStream, uint32_t oldCwnd, uint32_t newCwnd)
uint32_t g_n1BytesReceived
void TraceDrop(std::ofstream *ofStream, Ptr< const QueueDiscItem > item)
uint32_t g_n0BytesReceived
void TraceN0Throughput(std::ofstream *ofStream, Time throughputInterval)
void TraceN1Rtt(std::ofstream *ofStream, Time oldRtt, Time newRtt)
void ScheduleN1TcpCwndTraceConnection(std::ofstream *ofStream)
void TraceN0Rtt(std::ofstream *ofStream, Time oldRtt, Time newRtt)
void TraceQueueLength(std::ofstream *ofStream, DataRate linkRate, uint32_t oldVal, uint32_t newVal)
void TraceN1Rx(Ptr< const Packet > packet, const Address &address)
static void PacketDequeue(std::ofstream *n0OfStream, std::ofstream *n1OfStream, Ptr< QueueDiscItem const > item)
void ScheduleN0TcpRttTraceConnection(std::ofstream *ofStream)
void SetDefault(std::string name, const AttributeValue &value)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#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.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
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.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
U * PeekPointer(const Ptr< U > &p)