262#include "ns3/applications-module.h"
263#include "ns3/core-module.h"
264#include "ns3/flow-monitor-helper.h"
265#include "ns3/internet-apps-module.h"
266#include "ns3/internet-module.h"
267#include "ns3/network-module.h"
268#include "ns3/point-to-point-module.h"
269#include "ns3/traffic-control-module.h"
351 <<
static_cast<double>(newVal * 8) / (linkRate.
GetBitRate() / 1000) << std::endl;
362 dropsSamplingInterval);
373 marksSamplingInterval);
442 Ipv4Address address = iqdi->GetHeader().GetDestination();
444 if (address ==
"192.168.2.2")
449 else if (address ==
"192.168.3.2")
457main(
int argc,
char* argv[])
470 std::string
dir =
"results/FqCoDel-L4S/";
471 std::string dirToSave =
"mkdir -p " +
dir;
472 if (system(dirToSave.c_str()) == -1)
477 std::string pingTraceFile =
dir +
"ping.dat";
478 std::string n0TcpRttTraceFile =
dir +
"n0-tcp-rtt.dat";
479 std::string n0TcpCwndTraceFile =
dir +
"n0-tcp-cwnd.dat";
480 std::string n0TcpThroughputTraceFile =
dir +
"n0-tcp-throughput.dat";
481 std::string n1TcpRttTraceFile =
dir +
"n1-tcp-rtt.dat";
482 std::string n1TcpCwndTraceFile =
dir +
"n1-tcp-cwnd.dat";
483 std::string n1TcpThroughputTraceFile =
dir +
"n1-tcp-throughput.dat";
484 std::string dropTraceFile =
dir +
"drops.dat";
485 std::string dropsFrequencyTraceFile =
dir +
"drops-frequency.dat";
486 std::string lengthTraceFile =
dir +
"length.dat";
487 std::string markTraceFile =
dir +
"mark.dat";
488 std::string marksFrequencyTraceFile =
dir +
"marks-frequency.dat";
489 std::string queueDelayN0TraceFile =
dir +
"queue-delay-n0.dat";
490 std::string queueDelayN1TraceFile =
dir +
"queue-delay-n1.dat";
495 bool enablePcap =
false;
496 bool useCeThreshold =
false;
498 std::string n0TcpType =
"bic";
499 std::string n1TcpType =
"";
500 bool enableN1Tcp =
false;
502 std::string queueType =
"fq";
503 std::string linkDataRate =
"1Gbps";
521 cmd.AddValue(
"n0TcpType",
"n0 TCP type (bic, dctcp, or reno)", n0TcpType);
522 cmd.AddValue(
"n1TcpType",
"n1 TCP type (bic, dctcp, or reno)", n1TcpType);
523 cmd.AddValue(
"scenarioNum",
524 "Scenario number from the scenarios available in the file (1-9)",
526 cmd.AddValue(
"bottleneckQueueType",
"n2 queue type (fq or codel)", queueType);
527 cmd.AddValue(
"baseRtt",
"base RTT", baseRtt);
528 cmd.AddValue(
"useCeThreshold",
"use CE Threshold", useCeThreshold);
529 cmd.AddValue(
"useEcn",
"use ECN", useEcn);
530 cmd.AddValue(
"ceThreshold",
"CoDel CE threshold", ceThreshold);
531 cmd.AddValue(
"bottleneckRate",
"data rate of bottleneck", bottleneckRate);
532 cmd.AddValue(
"linkRate",
"data rate of edge link", linkDataRate);
533 cmd.AddValue(
"stopTime",
"simulation stop time",
stopTime);
534 cmd.AddValue(
"enablePcap",
"enable Pcap", enablePcap);
535 cmd.AddValue(
"pingTraceFile",
"filename for ping tracing", pingTraceFile);
536 cmd.AddValue(
"n0TcpRttTraceFile",
"filename for n0 rtt tracing", n0TcpRttTraceFile);
537 cmd.AddValue(
"n0TcpCwndTraceFile",
"filename for n0 cwnd tracing", n0TcpCwndTraceFile);
538 cmd.AddValue(
"n0TcpThroughputTraceFile",
539 "filename for n0 throughput tracing",
540 n0TcpThroughputTraceFile);
541 cmd.AddValue(
"n1TcpRttTraceFile",
"filename for n1 rtt tracing", n1TcpRttTraceFile);
542 cmd.AddValue(
"n1TcpCwndTraceFile",
"filename for n1 cwnd tracing", n1TcpCwndTraceFile);
543 cmd.AddValue(
"n1TcpThroughputTraceFile",
544 "filename for n1 throughput tracing",
545 n1TcpThroughputTraceFile);
546 cmd.AddValue(
"dropTraceFile",
"filename for n2 drops tracing", dropTraceFile);
547 cmd.AddValue(
"dropsFrequencyTraceFile",
548 "filename for n2 drop frequency tracing",
549 dropsFrequencyTraceFile);
550 cmd.AddValue(
"lengthTraceFile",
"filename for n2 queue length tracing", lengthTraceFile);
551 cmd.AddValue(
"markTraceFile",
"filename for n2 mark tracing", markTraceFile);
552 cmd.AddValue(
"marksFrequencyTraceFile",
553 "filename for n2 mark frequency tracing",
554 marksFrequencyTraceFile);
555 cmd.AddValue(
"queueDelayN0TraceFile",
556 "filename for n0 queue delay tracing",
557 queueDelayN0TraceFile);
558 cmd.AddValue(
"queueDelayN1TraceFile",
559 "filename for n1 queue delay tracing",
560 queueDelayN1TraceFile);
561 cmd.Parse(argc, argv);
562 Time oneWayDelay = baseRtt / 2;
573 if (n0TcpType ==
"reno")
577 else if (n0TcpType ==
"bic")
581 else if (n0TcpType ==
"dctcp")
590 if (n1TcpType ==
"reno")
595 else if (n1TcpType ==
"bic")
600 else if (n1TcpType ==
"dctcp")
605 else if (n1TcpType.empty())
614 if (queueType ==
"fq")
618 else if (queueType ==
"codel")
631 else if (scenarioNum == 1 || scenarioNum == 2 || scenarioNum == 5 || scenarioNum == 6)
633 if (scenarioNum == 2 || scenarioNum == 6)
638 if (scenarioNum == 5 || scenarioNum == 6)
645 else if (scenarioNum == 3 || scenarioNum == 4 || scenarioNum == 7 || scenarioNum == 8 ||
653 if (scenarioNum == 9)
660 if (scenarioNum == 4 || scenarioNum == 8 || scenarioNum == 9)
665 if (scenarioNum == 7 || scenarioNum == 8 || scenarioNum == 9)
676 std::ofstream pingOfStream;
677 pingOfStream.open(pingTraceFile, std::ofstream::out);
678 std::ofstream n0TcpRttOfStream;
679 n0TcpRttOfStream.open(n0TcpRttTraceFile, std::ofstream::out);
680 std::ofstream n0TcpCwndOfStream;
681 n0TcpCwndOfStream.open(n0TcpCwndTraceFile, std::ofstream::out);
682 std::ofstream n0TcpThroughputOfStream;
683 n0TcpThroughputOfStream.open(n0TcpThroughputTraceFile, std::ofstream::out);
684 std::ofstream n1TcpRttOfStream;
685 n1TcpRttOfStream.open(n1TcpRttTraceFile, std::ofstream::out);
686 std::ofstream n1TcpCwndOfStream;
687 n1TcpCwndOfStream.open(n1TcpCwndTraceFile, std::ofstream::out);
688 std::ofstream n1TcpThroughputOfStream;
689 n1TcpThroughputOfStream.open(n1TcpThroughputTraceFile, std::ofstream::out);
692 std::ofstream dropOfStream;
693 dropOfStream.open(dropTraceFile, std::ofstream::out);
694 std::ofstream markOfStream;
695 markOfStream.open(markTraceFile, std::ofstream::out);
696 std::ofstream dropsFrequencyOfStream;
697 dropsFrequencyOfStream.open(dropsFrequencyTraceFile, std::ofstream::out);
698 std::ofstream marksFrequencyOfStream;
699 marksFrequencyOfStream.open(marksFrequencyTraceFile, std::ofstream::out);
700 std::ofstream lengthOfStream;
701 lengthOfStream.open(lengthTraceFile, std::ofstream::out);
702 std::ofstream queueDelayN0OfStream;
703 queueDelayN0OfStream.open(queueDelayN0TraceFile, std::ofstream::out);
704 std::ofstream queueDelayN1OfStream;
705 queueDelayN1OfStream.open(queueDelayN1TraceFile, std::ofstream::out);
732 p2p.SetChannelAttribute(
"Delay",
TimeValue(oneWayDelay));
733 pingServerDevices =
p2p.Install(n2, pingServer);
734 n0ServerDevices =
p2p.Install(n2, n0Server);
737 if (scenarioNum == 9)
741 n1ServerDevices =
p2p.Install(n2, n1Server);
743 n2n3Devices =
p2p.Install(n2, n3);
744 pingClientDevices =
p2p.Install(n3, pingClient);
745 n4ClientDevices =
p2p.Install(n3, n4Client);
746 n5ClientDevices =
p2p.Install(n3, n5Client);
756 proto->SetAttribute(
"SocketType",
TypeIdValue(n0TcpTypeId));
758 proto->SetAttribute(
"SocketType",
TypeIdValue(n0TcpTypeId));
762 proto->SetAttribute(
"SocketType",
TypeIdValue(n1TcpTypeId));
764 proto->SetAttribute(
"SocketType",
TypeIdValue(n1TcpTypeId));
775 tchFq.
Install(pingServerDevices);
776 tchFq.
Install(n0ServerDevices);
777 tchFq.
Install(n1ServerDevices);
779 tchFq.
Install(pingClientDevices);
780 tchFq.
Install(n4ClientDevices);
781 tchFq.
Install(n5ClientDevices);
788 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
790 ipv4.SetBase(
"10.1.2.0",
"255.255.255.0");
792 ipv4.SetBase(
"10.1.3.0",
"255.255.255.0");
794 ipv4.SetBase(
"172.16.1.0",
"255.255.255.0");
796 ipv4.SetBase(
"192.168.1.0",
"255.255.255.0");
798 ipv4.SetBase(
"192.168.2.0",
"255.255.255.0");
800 ipv4.SetBase(
"192.168.3.0",
"255.255.255.0");
810 pingHelper.SetAttribute(
"Interval",
TimeValue(pingInterval));
822 uint16_t n4Port = 5000;
825 tcp.SetAttribute(
"Remote",
AddressValue(n0DestAddress));
826 n0App = tcp.Install(n0Server);
833 n4SinkApp = n4SinkHelper.Install(n4Client);
840 uint16_t n5Port = 5000;
843 tcp.SetAttribute(
"Remote",
AddressValue(n1DestAddress));
844 secondApp = tcp.Install(n1Server);
851 n5SinkApp = n5SinkHelper.Install(n5Client);
860 qd = tc->GetRootQueueDiscOnDevice(n2n3Devices.
Get(0));
880 &n0TcpThroughputOfStream,
881 throughputSamplingInterval);
895 &n1TcpThroughputOfStream,
896 throughputSamplingInterval);
899 &marksFrequencyOfStream,
900 marksSamplingInterval);
903 &dropsFrequencyOfStream,
904 marksSamplingInterval);
908 p2p.EnablePcapAll(
"FqCoDel-L4S-example",
false);
914 pingOfStream.close();
915 n0TcpCwndOfStream.close();
916 n0TcpRttOfStream.close();
917 n0TcpThroughputOfStream.close();
918 n1TcpCwndOfStream.close();
919 n1TcpRttOfStream.close();
920 n1TcpThroughputOfStream.close();
921 dropOfStream.close();
922 markOfStream.close();
923 dropsFrequencyOfStream.close();
924 marksFrequencyOfStream.close();
925 lengthOfStream.close();
926 queueDelayN0OfStream.close();
927 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.
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.
Smart pointer class similar to boost::intrusive_ptr.
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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
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...