|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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 ();
holds a vector of ns3::NetDevice pointers
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
AttributeValue implementation for DataRate.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
Parse command-line arguments.
AttributeValue implementation for Boolean.
static TypeId GetTypeId(void)
Get the type ID.
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 ScheduleN1TcpRttTraceConnection(std::ofstream *ofStream)
void TraceDropsFrequency(std::ofstream *ofStream, Time dropsSamplingInterval)
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
static TypeId GetTypeId(void)
Get the type ID.
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.
void TraceMark(std::ofstream *ofStream, Ptr< const QueueDiscItem > item, const char *reason)
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void ScheduleN0PacketSinkConnection(void)
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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
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 ...
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
AttributeValue implementation for Address.
NetDeviceContainer Install(NodeContainer c)
Ipv4 addresses are stored in host order in this class.
A helper to make it easier to instantiate an ns3::BulkSendApplication on a set of nodes.
const Ipv4Header & GetHeader(void) const
void TraceN0Cwnd(std::ofstream *ofStream, uint32_t oldCwnd, uint32_t newCwnd)
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
an application which sends one ICMP ECHO request, waits for a REPLYs and reports the calculated RTT.
void InstallAll(void) const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
void ScheduleN1TcpCwndTraceConnection(std::ofstream *ofStream)
U * PeekPointer(const Ptr< U > &p)
void TraceN0Rtt(std::ofstream *ofStream, Time oldRtt, Time newRtt)
void TraceN0Throughput(std::ofstream *ofStream, Time throughputInterval)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
static TypeId GetTypeId(void)
Get the type ID.
static void PacketDequeue(std::ofstream *n0OfStream, std::ofstream *n1OfStream, Ptr< QueueDiscItem const > item)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Class for representing data rates.
static TypeId GetTypeId(void)
Get the type ID.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
AttributeValue implementation for TypeId.
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
void SetQueueLimits(std::string type, Args &&... args)
Helper function used to add a queue limits object to the transmission queues of the devices.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
QueueDiscContainer Install(NetDeviceContainer c)
a polymophic address class
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Ipv4QueueDiscItem is a subclass of QueueDiscItem which stores IPv4 packets.
Create a IPv4 ping application and associate it to a node.
static TypeId GetTypeId(void)
Get the type ID.
void TracePingRtt(std::ofstream *ofStream, Time rtt)
virtual Ptr< Node > GetNode(void) const =0
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Simulation virtual time values and global simulation resolution.
void TraceN1Rx(Ptr< const Packet > packet, const Address &address)
uint64_t GetBitRate() const
Get the underlying bitrate.
void TraceMarksFrequency(std::ofstream *ofStream, Time marksSamplingInterval)
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...
static void Run(void)
Run the simulation.
Hold variables of type string.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
void ScheduleN0TcpCwndTraceConnection(std::ofstream *ofStream)
std::string GetName(void) const
Get the name.
void ScheduleN0TcpRttTraceConnection(std::ofstream *ofStream)
static Ipv4Address GetAny(void)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< Packet > GetPacket(void) const
Introspection did not find any typical Config paths.
void TraceN1Rtt(std::ofstream *ofStream, Time oldRtt, Time newRtt)
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
Time Seconds(double value)
Construct a Time in the indicated unit.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Build a set of QueueDisc objects.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
holds a vector of ns3::Application pointers.
virtual Ptr< QueueDisc > GetRootQueueDiscOnDevice(Ptr< NetDevice > device) const
This method can be used to get the root queue disc installed on a device.
void TraceN0Rx(Ptr< const Packet > packet, const Address &address)
AttributeValue implementation for Time.
A Device for a Point to Point Network Link.
Build a set of PointToPointNetDevice objects.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
TCP socket creation and multiplexing/demultiplexing.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
void TraceQueueLength(std::ofstream *ofStream, DataRate linkRate, uint32_t oldVal, uint32_t newVal)
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
uint32_t g_n0BytesReceived
void TraceN1Throughput(std::ofstream *ofStream, Time throughputInterval)
virtual uint32_t Hash(uint32_t perturbation=0) const
Computes the hash of various fields of the packet header.
Class for representing queue sizes.
aggregate IP/TCP/UDP functionality to existing Nodes.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Time GetTimeStamp(void) const
Get the timestamp included in this item.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
uint32_t g_n1BytesReceived
void ScheduleN1PacketSinkConnection(void)
void TraceDrop(std::ofstream *ofStream, Ptr< const QueueDiscItem > item)
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void TraceN1Cwnd(std::ofstream *ofStream, uint32_t oldCwnd, uint32_t newCwnd)