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"
361 <<
static_cast<double>(newVal * 8) / (linkRate.
GetBitRate() / 1000) << std::endl;
369 Simulator::Schedule(dropsSamplingInterval,
372 dropsSamplingInterval);
380 Simulator::Schedule(marksSamplingInterval,
383 marksSamplingInterval);
392 Simulator::Schedule(throughputInterval, &
TraceN0Throughput, ofStream, throughputInterval);
401 Simulator::Schedule(throughputInterval, &
TraceN1Throughput, ofStream, throughputInterval);
459 else if (
address ==
"192.168.3.2")
467main(
int argc,
char* argv[])
480 std::string
dir =
"results/FqCoDel-L4S/";
481 std::string dirToSave =
"mkdir -p " +
dir;
482 if (system(dirToSave.c_str()) == -1)
487 std::string pingTraceFile =
dir +
"ping.dat";
488 std::string n0TcpRttTraceFile =
dir +
"n0-tcp-rtt.dat";
489 std::string n0TcpCwndTraceFile =
dir +
"n0-tcp-cwnd.dat";
490 std::string n0TcpThroughputTraceFile =
dir +
"n0-tcp-throughput.dat";
491 std::string n1TcpRttTraceFile =
dir +
"n1-tcp-rtt.dat";
492 std::string n1TcpCwndTraceFile =
dir +
"n1-tcp-cwnd.dat";
493 std::string n1TcpThroughputTraceFile =
dir +
"n1-tcp-throughput.dat";
494 std::string dropTraceFile =
dir +
"drops.dat";
495 std::string dropsFrequencyTraceFile =
dir +
"drops-frequency.dat";
496 std::string lengthTraceFile =
dir +
"length.dat";
497 std::string markTraceFile =
dir +
"mark.dat";
498 std::string marksFrequencyTraceFile =
dir +
"marks-frequency.dat";
499 std::string queueDelayN0TraceFile =
dir +
"queue-delay-n0.dat";
500 std::string queueDelayN1TraceFile =
dir +
"queue-delay-n1.dat";
505 bool enablePcap =
false;
506 bool useCeThreshold =
false;
508 std::string n0TcpType =
"bic";
509 std::string n1TcpType =
"";
510 bool enableN1Tcp =
false;
512 std::string queueType =
"fq";
513 std::string linkDataRate =
"1Gbps";
531 cmd.AddValue(
"n0TcpType",
"n0 TCP type (bic, dctcp, or reno)", n0TcpType);
532 cmd.AddValue(
"n1TcpType",
"n1 TCP type (bic, dctcp, or reno)", n1TcpType);
533 cmd.AddValue(
"scenarioNum",
534 "Scenario number from the scenarios avalaible in the file (1-9)",
536 cmd.AddValue(
"bottleneckQueueType",
"n2 queue type (fq or codel)", queueType);
537 cmd.AddValue(
"baseRtt",
"base RTT", baseRtt);
538 cmd.AddValue(
"useCeThreshold",
"use CE Threshold", useCeThreshold);
539 cmd.AddValue(
"useEcn",
"use ECN", useEcn);
540 cmd.AddValue(
"ceThreshold",
"CoDel CE threshold", ceThreshold);
541 cmd.AddValue(
"bottleneckRate",
"data rate of bottleneck", bottleneckRate);
542 cmd.AddValue(
"linkRate",
"data rate of edge link", linkDataRate);
543 cmd.AddValue(
"stopTime",
"simulation stop time",
stopTime);
544 cmd.AddValue(
"enablePcap",
"enable Pcap", enablePcap);
545 cmd.AddValue(
"pingTraceFile",
"filename for ping tracing", pingTraceFile);
546 cmd.AddValue(
"n0TcpRttTraceFile",
"filename for n0 rtt tracing", n0TcpRttTraceFile);
547 cmd.AddValue(
"n0TcpCwndTraceFile",
"filename for n0 cwnd tracing", n0TcpCwndTraceFile);
548 cmd.AddValue(
"n0TcpThroughputTraceFile",
549 "filename for n0 throughput tracing",
550 n0TcpThroughputTraceFile);
551 cmd.AddValue(
"n1TcpRttTraceFile",
"filename for n1 rtt tracing", n1TcpRttTraceFile);
552 cmd.AddValue(
"n1TcpCwndTraceFile",
"filename for n1 cwnd tracing", n1TcpCwndTraceFile);
553 cmd.AddValue(
"n1TcpThroughputTraceFile",
554 "filename for n1 throughput tracing",
555 n1TcpThroughputTraceFile);
556 cmd.AddValue(
"dropTraceFile",
"filename for n2 drops tracing", dropTraceFile);
557 cmd.AddValue(
"dropsFrequencyTraceFile",
558 "filename for n2 drop frequency tracing",
559 dropsFrequencyTraceFile);
560 cmd.AddValue(
"lengthTraceFile",
"filename for n2 queue length tracing", lengthTraceFile);
561 cmd.AddValue(
"markTraceFile",
"filename for n2 mark tracing", markTraceFile);
562 cmd.AddValue(
"marksFrequencyTraceFile",
563 "filename for n2 mark frequency tracing",
564 marksFrequencyTraceFile);
565 cmd.AddValue(
"queueDelayN0TraceFile",
566 "filename for n0 queue delay tracing",
567 queueDelayN0TraceFile);
568 cmd.AddValue(
"queueDelayN1TraceFile",
569 "filename for n1 queue delay tracing",
570 queueDelayN1TraceFile);
571 cmd.Parse(argc, argv);
572 Time oneWayDelay = baseRtt / 2;
583 if (n0TcpType ==
"reno")
585 n0TcpTypeId = TcpNewReno::GetTypeId();
587 else if (n0TcpType ==
"bic")
589 n0TcpTypeId = TcpBic::GetTypeId();
591 else if (n0TcpType ==
"dctcp")
593 n0TcpTypeId = TcpDctcp::GetTypeId();
600 if (n1TcpType ==
"reno")
603 n1TcpTypeId = TcpNewReno::GetTypeId();
605 else if (n1TcpType ==
"bic")
608 n1TcpTypeId = TcpBic::GetTypeId();
610 else if (n1TcpType ==
"dctcp")
613 n1TcpTypeId = TypeId::LookupByName(
"ns3::TcpDctcp");
615 else if (n1TcpType ==
"")
624 if (queueType ==
"fq")
626 queueTypeId = FqCoDelQueueDisc::GetTypeId();
628 else if (queueType ==
"codel")
630 queueTypeId = CoDelQueueDisc::GetTypeId();
641 else if (scenarioNum == 1 || scenarioNum == 2 || scenarioNum == 5 || scenarioNum == 6)
643 if (scenarioNum == 2 || scenarioNum == 6)
647 n0TcpTypeId = TcpBic::GetTypeId();
648 if (scenarioNum == 5 || scenarioNum == 6)
651 n1TcpTypeId = TcpBic::GetTypeId();
653 queueTypeId = FqCoDelQueueDisc::GetTypeId();
655 else if (scenarioNum == 3 || scenarioNum == 4 || scenarioNum == 7 || scenarioNum == 8 ||
659 n0TcpTypeId = TcpDctcp::GetTypeId();
660 queueTypeId = FqCoDelQueueDisc::GetTypeId();
663 if (scenarioNum == 9)
665 n0TcpTypeId = TcpBic::GetTypeId();
670 if (scenarioNum == 4 || scenarioNum == 8 || scenarioNum == 9)
675 if (scenarioNum == 7 || scenarioNum == 8 || scenarioNum == 9)
678 n1TcpTypeId = TcpDctcp::GetTypeId();
686 std::ofstream pingOfStream;
687 pingOfStream.open(pingTraceFile, std::ofstream::out);
688 std::ofstream n0TcpRttOfStream;
689 n0TcpRttOfStream.open(n0TcpRttTraceFile, std::ofstream::out);
690 std::ofstream n0TcpCwndOfStream;
691 n0TcpCwndOfStream.open(n0TcpCwndTraceFile, std::ofstream::out);
692 std::ofstream n0TcpThroughputOfStream;
693 n0TcpThroughputOfStream.open(n0TcpThroughputTraceFile, std::ofstream::out);
694 std::ofstream n1TcpRttOfStream;
695 n1TcpRttOfStream.open(n1TcpRttTraceFile, std::ofstream::out);
696 std::ofstream n1TcpCwndOfStream;
697 n1TcpCwndOfStream.open(n1TcpCwndTraceFile, std::ofstream::out);
698 std::ofstream n1TcpThroughputOfStream;
699 n1TcpThroughputOfStream.open(n1TcpThroughputTraceFile, std::ofstream::out);
702 std::ofstream dropOfStream;
703 dropOfStream.open(dropTraceFile, std::ofstream::out);
704 std::ofstream markOfStream;
705 markOfStream.open(markTraceFile, std::ofstream::out);
706 std::ofstream dropsFrequencyOfStream;
707 dropsFrequencyOfStream.open(dropsFrequencyTraceFile, std::ofstream::out);
708 std::ofstream marksFrequencyOfStream;
709 marksFrequencyOfStream.open(marksFrequencyTraceFile, std::ofstream::out);
710 std::ofstream lengthOfStream;
711 lengthOfStream.open(lengthTraceFile, std::ofstream::out);
712 std::ofstream queueDelayN0OfStream;
713 queueDelayN0OfStream.open(queueDelayN0TraceFile, std::ofstream::out);
714 std::ofstream queueDelayN1OfStream;
715 queueDelayN1OfStream.open(queueDelayN1TraceFile, std::ofstream::out);
720 Ptr<Node> pingServer = CreateObject<Node>();
721 Ptr<Node> n0Server = CreateObject<Node>();
722 Ptr<Node> n1Server = CreateObject<Node>();
725 Ptr<Node> pingClient = CreateObject<Node>();
726 Ptr<Node> n4Client = CreateObject<Node>();
727 Ptr<Node> n5Client = CreateObject<Node>();
743 pingServerDevices = p2p.
Install(n2, pingServer);
744 n0ServerDevices = p2p.
Install(n2, n0Server);
747 if (scenarioNum == 9)
751 n1ServerDevices = p2p.
Install(n2, n1Server);
753 n2n3Devices = p2p.
Install(n2, n3);
754 pingClientDevices = p2p.
Install(n3, pingClient);
755 n4ClientDevices = p2p.
Install(n3, n4Client);
756 n5ClientDevices = p2p.
Install(n3, n5Client);
766 proto->SetAttribute(
"SocketType",
TypeIdValue(n0TcpTypeId));
768 proto->SetAttribute(
"SocketType",
TypeIdValue(n0TcpTypeId));
772 proto->SetAttribute(
"SocketType",
TypeIdValue(n1TcpTypeId));
774 proto->SetAttribute(
"SocketType",
TypeIdValue(n1TcpTypeId));
785 tchFq.
Install(pingServerDevices);
786 tchFq.
Install(n0ServerDevices);
787 tchFq.
Install(n1ServerDevices);
789 tchFq.
Install(pingClientDevices);
790 tchFq.
Install(n4ClientDevices);
791 tchFq.
Install(n5ClientDevices);
798 ipv4.
SetBase(
"10.1.1.0",
"255.255.255.0");
800 ipv4.
SetBase(
"10.1.2.0",
"255.255.255.0");
802 ipv4.
SetBase(
"10.1.3.0",
"255.255.255.0");
804 ipv4.
SetBase(
"172.16.1.0",
"255.255.255.0");
806 ipv4.
SetBase(
"192.168.1.0",
"255.255.255.0");
808 ipv4.
SetBase(
"192.168.2.0",
"255.255.255.0");
810 ipv4.
SetBase(
"192.168.3.0",
"255.255.255.0");
813 Ipv4GlobalRoutingHelper::PopulateRoutingTables();
820 pingHelper.SetAttribute(
"Interval",
TimeValue(pingInterval));
832 uint16_t n4Port = 5000;
835 tcp.SetAttribute(
"Remote",
AddressValue(n0DestAddress));
836 n0App = tcp.Install(n0Server);
843 n4SinkApp = n4SinkHelper.Install(n4Client);
850 uint16_t n5Port = 5000;
853 tcp.SetAttribute(
"Remote",
AddressValue(n1DestAddress));
854 secondApp = tcp.Install(n1Server);
861 n5SinkApp = n5SinkHelper.Install(n5Client);
870 qd = tc->GetRootQueueDiscOnDevice(n2n3Devices.
Get(0));
888 Simulator::Schedule(throughputSamplingInterval,
890 &n0TcpThroughputOfStream,
891 throughputSamplingInterval);
903 Simulator::Schedule(throughputSamplingInterval,
905 &n1TcpThroughputOfStream,
906 throughputSamplingInterval);
907 Simulator::Schedule(marksSamplingInterval,
909 &marksFrequencyOfStream,
910 marksSamplingInterval);
911 Simulator::Schedule(marksSamplingInterval,
913 &dropsFrequencyOfStream,
914 marksSamplingInterval);
924 pingOfStream.close();
925 n0TcpCwndOfStream.close();
926 n0TcpRttOfStream.close();
927 n0TcpThroughputOfStream.close();
928 n1TcpCwndOfStream.close();
929 n1TcpRttOfStream.close();
930 n1TcpThroughputOfStream.close();
931 dropOfStream.close();
932 markOfStream.close();
933 dropsFrequencyOfStream.close();
934 marksFrequencyOfStream.close();
935 lengthOfStream.close();
936 queueDelayN0OfStream.close();
937 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.
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 ...
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.
Introspection did not find any typical Config paths.
a unique identifier for an interface.
std::string GetName() 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 TraceMark(std::ofstream *ofStream, Ptr< const QueueDiscItem > item, const char *reason)
void TracePingRtt(std::ofstream *ofStream, Time rtt)
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 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...