282 #include "ns3/core-module.h" 283 #include "ns3/network-module.h" 284 #include "ns3/internet-module.h" 285 #include "ns3/flow-monitor-helper.h" 286 #include "ns3/point-to-point-module.h" 287 #include "ns3/applications-module.h" 288 #include "ns3/internet-apps-module.h" 289 #include "ns3/traffic-control-module.h" 304 TraceN0Cwnd (std::ofstream* ofStream, uint32_t oldCwnd, uint32_t newCwnd)
312 TraceN1Cwnd (std::ofstream* ofStream, uint32_t oldCwnd, uint32_t newCwnd)
449 else if (
address ==
"192.168.3.2")
456 main (
int argc,
char *argv[])
463 uint32_t pingSize = 100;
467 DataRate bottleneckRate (
"100Mbps");
469 std::string
dir =
"results/FqCoDel-L4S/";
470 std::string dirToSave =
"mkdir -p " +
dir;
471 if (system (dirToSave.c_str ()) == -1)
476 std::string pingTraceFile =
dir +
"ping.dat";
477 std::string n0TcpRttTraceFile =
dir +
"n0-tcp-rtt.dat";
478 std::string n0TcpCwndTraceFile =
dir +
"n0-tcp-cwnd.dat";
479 std::string n0TcpThroughputTraceFile =
dir +
"n0-tcp-throughput.dat";
480 std::string n1TcpRttTraceFile =
dir +
"n1-tcp-rtt.dat";
481 std::string n1TcpCwndTraceFile =
dir +
"n1-tcp-cwnd.dat";
482 std::string n1TcpThroughputTraceFile =
dir +
"n1-tcp-throughput.dat";
483 std::string dropTraceFile =
dir +
"drops.dat";
484 std::string dropsFrequencyTraceFile =
dir +
"drops-frequency.dat";
485 std::string lengthTraceFile =
dir +
"length.dat";
486 std::string markTraceFile =
dir +
"mark.dat";
487 std::string marksFrequencyTraceFile =
dir +
"marks-frequency.dat";
488 std::string queueDelayN0TraceFile =
dir +
"queue-delay-n0.dat";
489 std::string queueDelayN1TraceFile =
dir +
"queue-delay-n1.dat";
495 bool useCeThreshold =
false;
497 std::string n0TcpType =
"bic";
498 std::string n1TcpType =
"";
499 bool enableN1Tcp =
false;
501 std::string queueType =
"fq";
502 std::string linkDataRate =
"1Gbps";
503 uint32_t scenarioNum = 0;
519 cmd.AddValue (
"n0TcpType",
"n0 TCP type (bic, dctcp, or reno)", n0TcpType);
520 cmd.AddValue (
"n1TcpType",
"n1 TCP type (bic, dctcp, or reno)", n1TcpType);
521 cmd.AddValue (
"scenarioNum",
"Scenario number from the scenarios avalaible in the file (1-9)", scenarioNum);
522 cmd.AddValue (
"bottleneckQueueType",
"n2 queue type (fq or codel)", queueType);
523 cmd.AddValue (
"baseRtt",
"base RTT", baseRtt);
524 cmd.AddValue (
"useCeThreshold",
"use CE Threshold", useCeThreshold);
525 cmd.AddValue (
"useEcn",
"use ECN", useEcn);
526 cmd.AddValue (
"ceThreshold",
"CoDel CE threshold", ceThreshold);
527 cmd.AddValue (
"bottleneckRate",
"data rate of bottleneck", bottleneckRate);
528 cmd.AddValue (
"linkRate",
"data rate of edge link", linkDataRate);
529 cmd.AddValue (
"stopTime",
"simulation stop time",
stopTime);
531 cmd.AddValue (
"pingTraceFile",
"filename for ping tracing", pingTraceFile);
532 cmd.AddValue (
"n0TcpRttTraceFile",
"filename for n0 rtt tracing", n0TcpRttTraceFile);
533 cmd.AddValue (
"n0TcpCwndTraceFile",
"filename for n0 cwnd tracing", n0TcpCwndTraceFile);
534 cmd.AddValue (
"n0TcpThroughputTraceFile",
"filename for n0 throughput tracing", n0TcpThroughputTraceFile);
535 cmd.AddValue (
"n1TcpRttTraceFile",
"filename for n1 rtt tracing", n1TcpRttTraceFile);
536 cmd.AddValue (
"n1TcpCwndTraceFile",
"filename for n1 cwnd tracing", n1TcpCwndTraceFile);
537 cmd.AddValue (
"n1TcpThroughputTraceFile",
"filename for n1 throughput tracing", n1TcpThroughputTraceFile);
538 cmd.AddValue (
"dropTraceFile",
"filename for n2 drops tracing", dropTraceFile);
539 cmd.AddValue (
"dropsFrequencyTraceFile",
"filename for n2 drop frequency tracing", dropsFrequencyTraceFile);
540 cmd.AddValue (
"lengthTraceFile",
"filename for n2 queue length tracing", lengthTraceFile);
541 cmd.AddValue (
"markTraceFile",
"filename for n2 mark tracing", markTraceFile);
542 cmd.AddValue (
"marksFrequencyTraceFile",
"filename for n2 mark frequency tracing", marksFrequencyTraceFile);
543 cmd.AddValue (
"queueDelayN0TraceFile",
"filename for n0 queue delay tracing", queueDelayN0TraceFile);
544 cmd.AddValue (
"queueDelayN1TraceFile",
"filename for n1 queue delay tracing", queueDelayN1TraceFile);
545 cmd.Parse (argc, argv);
546 Time oneWayDelay = baseRtt / 2;
557 if (n0TcpType ==
"reno")
561 else if (n0TcpType ==
"bic")
565 else if (n0TcpType ==
"dctcp")
574 if (n1TcpType ==
"reno")
579 else if (n1TcpType ==
"bic")
584 else if (n1TcpType ==
"dctcp")
589 else if (n1TcpType ==
"")
598 if (queueType ==
"fq")
602 else if (queueType ==
"codel")
615 else if (scenarioNum == 1 || scenarioNum == 2 || scenarioNum == 5 || scenarioNum == 6)
617 if (scenarioNum == 2 || scenarioNum == 6)
622 if (scenarioNum == 5 || scenarioNum == 6)
629 else if (scenarioNum == 3 || scenarioNum == 4 || scenarioNum == 7 || scenarioNum == 8 || scenarioNum == 9)
636 if (scenarioNum == 9)
642 if (scenarioNum == 4 || scenarioNum == 8 || scenarioNum == 9)
647 if (scenarioNum == 7 || scenarioNum == 8 || scenarioNum == 9)
658 std::ofstream pingOfStream;
659 pingOfStream.open (pingTraceFile.c_str (), std::ofstream::out);
660 std::ofstream n0TcpRttOfStream;
661 n0TcpRttOfStream.open (n0TcpRttTraceFile.c_str (), std::ofstream::out);
662 std::ofstream n0TcpCwndOfStream;
663 n0TcpCwndOfStream.open (n0TcpCwndTraceFile.c_str (), std::ofstream::out);
664 std::ofstream n0TcpThroughputOfStream;
665 n0TcpThroughputOfStream.open (n0TcpThroughputTraceFile.c_str (), std::ofstream::out);
666 std::ofstream n1TcpRttOfStream;
667 n1TcpRttOfStream.open (n1TcpRttTraceFile.c_str (), std::ofstream::out);
668 std::ofstream n1TcpCwndOfStream;
669 n1TcpCwndOfStream.open (n1TcpCwndTraceFile.c_str (), std::ofstream::out);
670 std::ofstream n1TcpThroughputOfStream;
671 n1TcpThroughputOfStream.open (n1TcpThroughputTraceFile.c_str (), std::ofstream::out);
674 std::ofstream dropOfStream;
675 dropOfStream.open (dropTraceFile.c_str (), std::ofstream::out);
676 std::ofstream markOfStream;
677 markOfStream.open (markTraceFile.c_str (), std::ofstream::out);
678 std::ofstream dropsFrequencyOfStream;
679 dropsFrequencyOfStream.open (dropsFrequencyTraceFile.c_str (), std::ofstream::out);
680 std::ofstream marksFrequencyOfStream;
681 marksFrequencyOfStream.open (marksFrequencyTraceFile.c_str (), std::ofstream::out);
682 std::ofstream lengthOfStream;
683 lengthOfStream.open (lengthTraceFile.c_str (), std::ofstream::out);
684 std::ofstream queueDelayN0OfStream;
685 queueDelayN0OfStream.open (queueDelayN0TraceFile.c_str (), std::ofstream::out);
686 std::ofstream queueDelayN1OfStream;
687 queueDelayN1OfStream.open (queueDelayN1TraceFile.c_str (), std::ofstream::out);
692 Ptr<Node> pingServer = CreateObject<Node> ();
693 Ptr<Node> n0Server = CreateObject<Node> ();
694 Ptr<Node> n1Server = CreateObject<Node> ();
697 Ptr<Node> pingClient = CreateObject<Node> ();
698 Ptr<Node> n4Client = CreateObject<Node> ();
699 Ptr<Node> n5Client = CreateObject<Node> ();
715 pingServerDevices = p2p.
Install (n2, pingServer);
716 n0ServerDevices = p2p.
Install (n2, n0Server);
719 if (scenarioNum == 9)
723 n1ServerDevices = p2p.
Install (n2, n1Server);
725 n2n3Devices = p2p.
Install (n2, n3);
726 pingClientDevices = p2p.
Install (n3, pingClient);
727 n4ClientDevices = p2p.
Install (n3, n4Client);
728 n5ClientDevices = p2p.
Install (n3, n5Client);
757 tchFq.
Install (pingServerDevices);
758 tchFq.
Install (n0ServerDevices);
759 tchFq.
Install (n1ServerDevices);
761 tchFq.
Install (pingClientDevices);
762 tchFq.
Install (n4ClientDevices);
763 tchFq.
Install (n5ClientDevices);
770 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
772 ipv4.
SetBase (
"10.1.2.0",
"255.255.255.0");
774 ipv4.
SetBase (
"10.1.3.0",
"255.255.255.0");
776 ipv4.
SetBase (
"172.16.1.0",
"255.255.255.0");
778 ipv4.
SetBase (
"192.168.1.0",
"255.255.255.0");
780 ipv4.
SetBase (
"192.168.2.0",
"255.255.255.0");
782 ipv4.
SetBase (
"192.168.3.0",
"255.255.255.0");
792 pingHelper.SetAttribute (
"Interval",
TimeValue (pingInterval));
804 uint16_t n4Port = 5000;
807 tcp.SetAttribute (
"Remote",
AddressValue (n0DestAddress));
808 n0App = tcp.Install (n0Server);
815 n4SinkApp = n4SinkHelper.Install (n4Client);
822 uint16_t n5Port = 5000;
825 tcp.SetAttribute (
"Remote",
AddressValue (n1DestAddress));
826 secondApp = tcp.Install (n1Server);
833 n5SinkApp = n5SinkHelper.Install (n5Client);
869 pingOfStream.close ();
870 n0TcpCwndOfStream.close ();
871 n0TcpRttOfStream.close ();
872 n0TcpThroughputOfStream.close ();
873 n1TcpCwndOfStream.close ();
874 n1TcpRttOfStream.close ();
875 n1TcpThroughputOfStream.close ();
876 dropOfStream.close ();
877 markOfStream.close ();
878 dropsFrequencyOfStream.close ();
879 marksFrequencyOfStream.close ();
880 lengthOfStream.close ();
881 queueDelayN0OfStream.close ();
882 queueDelayN1OfStream.close ();
void InstallAll(void) const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
holds a vector of ns3::Application pointers.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
std::string GetName(void) const
Get the name.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Simulation virtual time values and global simulation resolution.
static Ipv4Address GetAny(void)
AttributeValue implementation for Boolean.
QueueDiscContainer Install(NetDeviceContainer c)
Class for representing queue sizes.
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes...
holds a vector of std::pair of Ptr<Ipv4> and interface index.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
Hold variables of type string.
Introspection did not find any typical Config paths.
NetDeviceContainer Install(NodeContainer c)
void TraceN0Rtt(std::ofstream *ofStream, Time oldRtt, Time newRtt)
void TraceDrop(std::ofstream *ofStream, Ptr< const QueueDiscItem > item)
void TraceMarksFrequency(std::ofstream *ofStream, Time marksSamplingInterval)
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
void SetQueueLimits(std::string type, Args &&... args)
Helper function used to add a queue limits object to the transmission queues of the devices...
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.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
static void Run(void)
Run the simulation.
U * PeekPointer(const Ptr< U > &p)
static void PacketDequeue(std::ofstream *n0OfStream, std::ofstream *n1OfStream, Ptr< QueueDiscItem const > item)
static TypeId GetTypeId(void)
Get the type ID.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
Build a set of PointToPointNetDevice objects.
Ptr< Packet > GetPacket(void) const
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
uint64_t GetBitRate() const
Get the underlying bitrate.
static TypeId GetTypeId(void)
Get the type ID.
a polymophic address class
TCP socket creation and multiplexing/demultiplexing.
Class for representing data rates.
void TraceN1Rx(Ptr< const Packet > packet, const Address &address)
static TypeId GetTypeId(void)
Get the type ID.
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 ...
uint32_t g_n0BytesReceived
AttributeValue implementation for Time.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
const Ipv4Header & GetHeader(void) const
Hold an unsigned integer type.
void TraceN1Cwnd(std::ofstream *ofStream, uint32_t oldCwnd, uint32_t newCwnd)
holds a vector of ns3::NetDevice pointers
AttributeValue implementation for TypeId.
uint32_t g_n1BytesReceived
static TypeId GetTypeId(void)
Get the type ID.
A Device for a Point to Point Network Link.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Build a set of QueueDisc objects.
virtual uint32_t Hash(uint32_t perturbation=0) const
Computes the hash of various fields of the packet header.
static TypeId GetTypeId(void)
Get the type ID.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
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 ScheduleN0TcpCwndTraceConnection(std::ofstream *ofStream)
void ScheduleN1PacketSinkConnection(void)
void ScheduleN0TcpRttTraceConnection(std::ofstream *ofStream)
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void TraceMark(std::ofstream *ofStream, Ptr< const QueueDiscItem > item, const char *reason)
void TraceN1Rtt(std::ofstream *ofStream, Time oldRtt, Time newRtt)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ipv4QueueDiscItem is a subclass of QueueDiscItem which stores IPv4 packets.
static Time Now(void)
Return the current simulation virtual time.
void TraceDropsFrequency(std::ofstream *ofStream, Time dropsSamplingInterval)
void TraceN0Cwnd(std::ofstream *ofStream, uint32_t oldCwnd, uint32_t newCwnd)
Time GetTimeStamp(void) const
Get the timestamp included in this item.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
void TraceN1Throughput(std::ofstream *ofStream, Time throughputInterval)
void TraceQueueLength(std::ofstream *ofStream, DataRate linkRate, uint32_t oldVal, uint32_t newVal)
static TypeId GetTypeId(void)
Get the type ID.
Ipv4 addresses are stored in host order in this class.
AttributeValue implementation for Address.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
void ScheduleN1TcpCwndTraceConnection(std::ofstream *ofStream)
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
AttributeValue implementation for DataRate.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
an application which sends one ICMP ECHO request, waits for a REPLYs and reports the calculated RTT...
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
void TraceN0Throughput(std::ofstream *ofStream, Time throughputInterval)
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
void TraceN0Rx(Ptr< const Packet > packet, const Address &address)
void TracePingRtt(std::ofstream *ofStream, Time rtt)
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void ScheduleN1TcpRttTraceConnection(std::ofstream *ofStream)
void ScheduleN0PacketSinkConnection(void)
a unique identifier for an interface.
virtual Ptr< QueueDisc > GetRootQueueDiscOnDevice(Ptr< NetDevice > device) const
This method can be used to get the root queue disc installed on a device.
Create a IPv4 ping application and associate it to a node.
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...
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
static TypeId LookupByName(std::string name)
Get a TypeId by name.