273#include "ns3/applications-module.h"
274#include "ns3/core-module.h"
275#include "ns3/flow-monitor-helper.h"
276#include "ns3/internet-apps-module.h"
277#include "ns3/internet-module.h"
278#include "ns3/network-module.h"
279#include "ns3/point-to-point-module.h"
280#include "ns3/traffic-control-module.h"
362 <<
static_cast<double>(newVal * 8) / (linkRate.
GetBitRate() / 1000) << std::endl;
370 Simulator::Schedule(dropsSamplingInterval,
373 dropsSamplingInterval);
381 Simulator::Schedule(marksSamplingInterval,
384 marksSamplingInterval);
393 Simulator::Schedule(throughputInterval, &
TraceN0Throughput, ofStream, throughputInterval);
402 Simulator::Schedule(throughputInterval, &
TraceN1Throughput, ofStream, throughputInterval);
460 else if (
address ==
"192.168.3.2")
468main(
int argc,
char* argv[])
481 std::string
dir =
"results/FqCoDel-L4S/";
482 std::string dirToSave =
"mkdir -p " +
dir;
483 if (system(dirToSave.c_str()) == -1)
488 std::string pingTraceFile =
dir +
"ping.dat";
489 std::string n0TcpRttTraceFile =
dir +
"n0-tcp-rtt.dat";
490 std::string n0TcpCwndTraceFile =
dir +
"n0-tcp-cwnd.dat";
491 std::string n0TcpThroughputTraceFile =
dir +
"n0-tcp-throughput.dat";
492 std::string n1TcpRttTraceFile =
dir +
"n1-tcp-rtt.dat";
493 std::string n1TcpCwndTraceFile =
dir +
"n1-tcp-cwnd.dat";
494 std::string n1TcpThroughputTraceFile =
dir +
"n1-tcp-throughput.dat";
495 std::string dropTraceFile =
dir +
"drops.dat";
496 std::string dropsFrequencyTraceFile =
dir +
"drops-frequency.dat";
497 std::string lengthTraceFile =
dir +
"length.dat";
498 std::string markTraceFile =
dir +
"mark.dat";
499 std::string marksFrequencyTraceFile =
dir +
"marks-frequency.dat";
500 std::string queueDelayN0TraceFile =
dir +
"queue-delay-n0.dat";
501 std::string queueDelayN1TraceFile =
dir +
"queue-delay-n1.dat";
506 bool enablePcap =
false;
507 bool useCeThreshold =
false;
509 std::string n0TcpType =
"bic";
510 std::string n1TcpType =
"";
511 bool enableN1Tcp =
false;
513 std::string queueType =
"fq";
514 std::string linkDataRate =
"1Gbps";
532 cmd.AddValue(
"n0TcpType",
"n0 TCP type (bic, dctcp, or reno)", n0TcpType);
533 cmd.AddValue(
"n1TcpType",
"n1 TCP type (bic, dctcp, or reno)", n1TcpType);
534 cmd.AddValue(
"scenarioNum",
535 "Scenario number from the scenarios available in the file (1-9)",
537 cmd.AddValue(
"bottleneckQueueType",
"n2 queue type (fq or codel)", queueType);
538 cmd.AddValue(
"baseRtt",
"base RTT", baseRtt);
539 cmd.AddValue(
"useCeThreshold",
"use CE Threshold", useCeThreshold);
540 cmd.AddValue(
"useEcn",
"use ECN", useEcn);
541 cmd.AddValue(
"ceThreshold",
"CoDel CE threshold", ceThreshold);
542 cmd.AddValue(
"bottleneckRate",
"data rate of bottleneck", bottleneckRate);
543 cmd.AddValue(
"linkRate",
"data rate of edge link", linkDataRate);
544 cmd.AddValue(
"stopTime",
"simulation stop time",
stopTime);
545 cmd.AddValue(
"enablePcap",
"enable Pcap", enablePcap);
546 cmd.AddValue(
"pingTraceFile",
"filename for ping tracing", pingTraceFile);
547 cmd.AddValue(
"n0TcpRttTraceFile",
"filename for n0 rtt tracing", n0TcpRttTraceFile);
548 cmd.AddValue(
"n0TcpCwndTraceFile",
"filename for n0 cwnd tracing", n0TcpCwndTraceFile);
549 cmd.AddValue(
"n0TcpThroughputTraceFile",
550 "filename for n0 throughput tracing",
551 n0TcpThroughputTraceFile);
552 cmd.AddValue(
"n1TcpRttTraceFile",
"filename for n1 rtt tracing", n1TcpRttTraceFile);
553 cmd.AddValue(
"n1TcpCwndTraceFile",
"filename for n1 cwnd tracing", n1TcpCwndTraceFile);
554 cmd.AddValue(
"n1TcpThroughputTraceFile",
555 "filename for n1 throughput tracing",
556 n1TcpThroughputTraceFile);
557 cmd.AddValue(
"dropTraceFile",
"filename for n2 drops tracing", dropTraceFile);
558 cmd.AddValue(
"dropsFrequencyTraceFile",
559 "filename for n2 drop frequency tracing",
560 dropsFrequencyTraceFile);
561 cmd.AddValue(
"lengthTraceFile",
"filename for n2 queue length tracing", lengthTraceFile);
562 cmd.AddValue(
"markTraceFile",
"filename for n2 mark tracing", markTraceFile);
563 cmd.AddValue(
"marksFrequencyTraceFile",
564 "filename for n2 mark frequency tracing",
565 marksFrequencyTraceFile);
566 cmd.AddValue(
"queueDelayN0TraceFile",
567 "filename for n0 queue delay tracing",
568 queueDelayN0TraceFile);
569 cmd.AddValue(
"queueDelayN1TraceFile",
570 "filename for n1 queue delay tracing",
571 queueDelayN1TraceFile);
572 cmd.Parse(argc, argv);
573 Time oneWayDelay = baseRtt / 2;
584 if (n0TcpType ==
"reno")
586 n0TcpTypeId = TcpNewReno::GetTypeId();
588 else if (n0TcpType ==
"bic")
590 n0TcpTypeId = TcpBic::GetTypeId();
592 else if (n0TcpType ==
"dctcp")
594 n0TcpTypeId = TcpDctcp::GetTypeId();
601 if (n1TcpType ==
"reno")
604 n1TcpTypeId = TcpNewReno::GetTypeId();
606 else if (n1TcpType ==
"bic")
609 n1TcpTypeId = TcpBic::GetTypeId();
611 else if (n1TcpType ==
"dctcp")
614 n1TcpTypeId = TypeId::LookupByName(
"ns3::TcpDctcp");
616 else if (n1TcpType.empty())
625 if (queueType ==
"fq")
627 queueTypeId = FqCoDelQueueDisc::GetTypeId();
629 else if (queueType ==
"codel")
631 queueTypeId = CoDelQueueDisc::GetTypeId();
642 else if (scenarioNum == 1 || scenarioNum == 2 || scenarioNum == 5 || scenarioNum == 6)
644 if (scenarioNum == 2 || scenarioNum == 6)
648 n0TcpTypeId = TcpBic::GetTypeId();
649 if (scenarioNum == 5 || scenarioNum == 6)
652 n1TcpTypeId = TcpBic::GetTypeId();
654 queueTypeId = FqCoDelQueueDisc::GetTypeId();
656 else if (scenarioNum == 3 || scenarioNum == 4 || scenarioNum == 7 || scenarioNum == 8 ||
660 n0TcpTypeId = TcpDctcp::GetTypeId();
661 queueTypeId = FqCoDelQueueDisc::GetTypeId();
664 if (scenarioNum == 9)
666 n0TcpTypeId = TcpBic::GetTypeId();
671 if (scenarioNum == 4 || scenarioNum == 8 || scenarioNum == 9)
676 if (scenarioNum == 7 || scenarioNum == 8 || scenarioNum == 9)
679 n1TcpTypeId = TcpDctcp::GetTypeId();
687 std::ofstream pingOfStream;
688 pingOfStream.open(pingTraceFile, std::ofstream::out);
689 std::ofstream n0TcpRttOfStream;
690 n0TcpRttOfStream.open(n0TcpRttTraceFile, std::ofstream::out);
691 std::ofstream n0TcpCwndOfStream;
692 n0TcpCwndOfStream.open(n0TcpCwndTraceFile, std::ofstream::out);
693 std::ofstream n0TcpThroughputOfStream;
694 n0TcpThroughputOfStream.open(n0TcpThroughputTraceFile, std::ofstream::out);
695 std::ofstream n1TcpRttOfStream;
696 n1TcpRttOfStream.open(n1TcpRttTraceFile, std::ofstream::out);
697 std::ofstream n1TcpCwndOfStream;
698 n1TcpCwndOfStream.open(n1TcpCwndTraceFile, std::ofstream::out);
699 std::ofstream n1TcpThroughputOfStream;
700 n1TcpThroughputOfStream.open(n1TcpThroughputTraceFile, std::ofstream::out);
703 std::ofstream dropOfStream;
704 dropOfStream.open(dropTraceFile, std::ofstream::out);
705 std::ofstream markOfStream;
706 markOfStream.open(markTraceFile, std::ofstream::out);
707 std::ofstream dropsFrequencyOfStream;
708 dropsFrequencyOfStream.open(dropsFrequencyTraceFile, std::ofstream::out);
709 std::ofstream marksFrequencyOfStream;
710 marksFrequencyOfStream.open(marksFrequencyTraceFile, std::ofstream::out);
711 std::ofstream lengthOfStream;
712 lengthOfStream.open(lengthTraceFile, std::ofstream::out);
713 std::ofstream queueDelayN0OfStream;
714 queueDelayN0OfStream.open(queueDelayN0TraceFile, std::ofstream::out);
715 std::ofstream queueDelayN1OfStream;
716 queueDelayN1OfStream.open(queueDelayN1TraceFile, std::ofstream::out);
721 Ptr<Node> pingServer = CreateObject<Node>();
722 Ptr<Node> n0Server = CreateObject<Node>();
723 Ptr<Node> n1Server = CreateObject<Node>();
726 Ptr<Node> pingClient = CreateObject<Node>();
727 Ptr<Node> n4Client = CreateObject<Node>();
728 Ptr<Node> n5Client = CreateObject<Node>();
744 pingServerDevices = p2p.
Install(n2, pingServer);
745 n0ServerDevices = p2p.
Install(n2, n0Server);
748 if (scenarioNum == 9)
752 n1ServerDevices = p2p.
Install(n2, n1Server);
754 n2n3Devices = p2p.
Install(n2, n3);
755 pingClientDevices = p2p.
Install(n3, pingClient);
756 n4ClientDevices = p2p.
Install(n3, n4Client);
757 n5ClientDevices = p2p.
Install(n3, n5Client);
767 proto->SetAttribute(
"SocketType",
TypeIdValue(n0TcpTypeId));
769 proto->SetAttribute(
"SocketType",
TypeIdValue(n0TcpTypeId));
773 proto->SetAttribute(
"SocketType",
TypeIdValue(n1TcpTypeId));
775 proto->SetAttribute(
"SocketType",
TypeIdValue(n1TcpTypeId));
786 tchFq.
Install(pingServerDevices);
787 tchFq.
Install(n0ServerDevices);
788 tchFq.
Install(n1ServerDevices);
790 tchFq.
Install(pingClientDevices);
791 tchFq.
Install(n4ClientDevices);
792 tchFq.
Install(n5ClientDevices);
799 ipv4.
SetBase(
"10.1.1.0",
"255.255.255.0");
801 ipv4.
SetBase(
"10.1.2.0",
"255.255.255.0");
803 ipv4.
SetBase(
"10.1.3.0",
"255.255.255.0");
805 ipv4.
SetBase(
"172.16.1.0",
"255.255.255.0");
807 ipv4.
SetBase(
"192.168.1.0",
"255.255.255.0");
809 ipv4.
SetBase(
"192.168.2.0",
"255.255.255.0");
811 ipv4.
SetBase(
"192.168.3.0",
"255.255.255.0");
814 Ipv4GlobalRoutingHelper::PopulateRoutingTables();
821 pingHelper.SetAttribute(
"Interval",
TimeValue(pingInterval));
833 uint16_t n4Port = 5000;
836 tcp.SetAttribute(
"Remote",
AddressValue(n0DestAddress));
837 n0App = tcp.Install(n0Server);
844 n4SinkApp = n4SinkHelper.Install(n4Client);
851 uint16_t n5Port = 5000;
854 tcp.SetAttribute(
"Remote",
AddressValue(n1DestAddress));
855 secondApp = tcp.Install(n1Server);
862 n5SinkApp = n5SinkHelper.Install(n5Client);
871 qd = tc->GetRootQueueDiscOnDevice(n2n3Devices.
Get(0));
889 Simulator::Schedule(throughputSamplingInterval,
891 &n0TcpThroughputOfStream,
892 throughputSamplingInterval);
904 Simulator::Schedule(throughputSamplingInterval,
906 &n1TcpThroughputOfStream,
907 throughputSamplingInterval);
908 Simulator::Schedule(marksSamplingInterval,
910 &marksFrequencyOfStream,
911 marksSamplingInterval);
912 Simulator::Schedule(marksSamplingInterval,
914 &dropsFrequencyOfStream,
915 marksSamplingInterval);
925 pingOfStream.close();
926 n0TcpCwndOfStream.close();
927 n0TcpRttOfStream.close();
928 n0TcpThroughputOfStream.close();
929 n1TcpCwndOfStream.close();
930 n1TcpRttOfStream.close();
931 n1TcpThroughputOfStream.close();
932 dropOfStream.close();
933 markOfStream.close();
934 dropsFrequencyOfStream.close();
935 marksFrequencyOfStream.close();
936 lengthOfStream.close();
937 queueDelayN0OfStream.close();
938 queueDelayN1OfStream.close();
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.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Stop(Time stop) const
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.
Parse command-line arguments.
Class for representing data rates.
uint64_t GetBitRate() const
Get the underlying bitrate.
AttributeValue implementation for DataRate.
aggregate IP/TCP/UDP functionality to existing Nodes.
void InstallAll() 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.
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.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
uint32_t GetSize() 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 ...
Create a ping application and associate it to a node.
This application behaves similarly to the Unix ping application, although with fewer options supporte...
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.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
Hold variables of type string.
TCP socket creation and multiplexing/demultiplexing.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetMicroSeconds() 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.
The Traffic Control layer aims at introducing an equivalent of the Linux Traffic Control infrastructu...
a unique identifier for an interface.
std::string GetName() const
Get the name.
AttributeValue implementation for TypeId.
Hold an unsigned integer type.
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 TraceMark(std::ofstream *ofStream, Ptr< const QueueDiscItem > item, const char *reason)
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 ScheduleN1PacketSinkConnection()
void ScheduleN1TcpCwndTraceConnection(std::ofstream *ofStream)
void ScheduleN0PacketSinkConnection()
void TraceN0Rtt(std::ofstream *ofStream, Time oldRtt, Time newRtt)
static void PacketDequeue(std::ofstream *n0OfStream, std::ofstream *n1OfStream, Ptr< const QueueDiscItem > item)
void TraceQueueLength(std::ofstream *ofStream, DataRate linkRate, uint32_t oldVal, uint32_t newVal)
void TraceN1Rx(Ptr< const Packet > packet, const Address &address)
void TracePingRtt(std::ofstream *ofStream, uint16_t seqNo, Time rtt)
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.
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.
Time Now()
create an ns3::Time instance which contains the current simulation time.
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.
U * PeekPointer(const Ptr< U > &p)
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...