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"
295 TraceN0Cwnd(std::ofstream* ofStream, uint32_t oldCwnd, uint32_t newCwnd)
304 TraceN1Cwnd(std::ofstream* ofStream, uint32_t oldCwnd, uint32_t newCwnd)
362 <<
static_cast<double>(newVal * 8) / (linkRate.
GetBitRate() / 1000) << std::endl;
373 dropsSamplingInterval);
384 marksSamplingInterval);
460 else if (
address ==
"192.168.3.2")
468 main(
int argc,
char* argv[])
475 uint32_t pingSize = 100;
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";
515 uint32_t scenarioNum = 0;
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")
588 else if (n0TcpType ==
"bic")
592 else if (n0TcpType ==
"dctcp")
601 if (n1TcpType ==
"reno")
606 else if (n1TcpType ==
"bic")
611 else if (n1TcpType ==
"dctcp")
616 else if (n1TcpType.empty())
625 if (queueType ==
"fq")
629 else if (queueType ==
"codel")
642 else if (scenarioNum == 1 || scenarioNum == 2 || scenarioNum == 5 || scenarioNum == 6)
644 if (scenarioNum == 2 || scenarioNum == 6)
649 if (scenarioNum == 5 || scenarioNum == 6)
656 else if (scenarioNum == 3 || scenarioNum == 4 || scenarioNum == 7 || scenarioNum == 8 ||
664 if (scenarioNum == 9)
671 if (scenarioNum == 4 || scenarioNum == 8 || scenarioNum == 9)
676 if (scenarioNum == 7 || scenarioNum == 8 || scenarioNum == 9)
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>();
740 p2p.SetQueue(
"ns3::DropTailQueue",
"MaxSize", QueueSizeValue(
QueueSize(
"3p")));
741 p2p.SetDeviceAttribute(
"DataRate", DataRateValue(
DataRate(linkDataRate)));
743 p2p.SetChannelAttribute(
"Delay",
TimeValue(oneWayDelay));
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);
759 p->SetAttribute(
"DataRate", DataRateValue(bottleneckRate));
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");
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));
891 &n0TcpThroughputOfStream,
892 throughputSamplingInterval);
906 &n1TcpThroughputOfStream,
907 throughputSamplingInterval);
910 &marksFrequencyOfStream,
911 marksSamplingInterval);
914 &dropsFrequencyOfStream,
915 marksSamplingInterval);
919 p2p.EnablePcapAll(
"FqCoDel-L4S-example",
false);
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
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.
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
static TypeId GetTypeId()
Get the type ID.
Parse command-line arguments.
Class for representing data rates.
uint64_t GetBitRate() const
Get the underlying bitrate.
static TypeId GetTypeId()
Get the type ID.
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.
Ipv4 addresses are stored in host order in this class.
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
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.
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.
A Device for a Point to Point Network Link.
Class for representing queue sizes.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
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.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Get the type ID.
TCP socket creation and multiplexing/demultiplexing.
static TypeId GetTypeId()
Get the type ID.
static TypeId GetTypeId()
Get the type ID.
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.
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.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
std::string GetName() const
Get the name.
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 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, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
U * PeekPointer(const Ptr< U > &p)