|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/core-module.h"
23 #include "ns3/network-module.h"
24 #include "ns3/internet-module.h"
25 #include "ns3/point-to-point-module.h"
26 #include "ns3/applications-module.h"
27 #include "ns3/point-to-point-layout-module.h"
28 #include "ns3/traffic-control-module.h"
36 int main (
int argc,
char *argv[])
39 uint32_t maxPackets = 100;
40 bool modeBytes =
false;
41 uint32_t queueDiscLimitPackets = 1000;
45 std::string appDataRate =
"10Mbps";
46 std::string queueDiscType =
"RED";
48 std::string bottleNeckLinkBw =
"1Mbps";
49 std::string bottleNeckLinkDelay =
"50ms";
52 cmd.AddValue (
"nLeaf",
"Number of left and right side leaf nodes", nLeaf);
53 cmd.AddValue (
"maxPackets",
"Max Packets allowed in the device queue", maxPackets);
54 cmd.AddValue (
"queueDiscLimitPackets",
"Max Packets allowed in the queue disc", queueDiscLimitPackets);
55 cmd.AddValue (
"queueDiscType",
"Set Queue disc type to RED or FengAdaptive", queueDiscType);
56 cmd.AddValue (
"appPktSize",
"Set OnOff App Packet Size",
pktSize);
57 cmd.AddValue (
"appDataRate",
"Set OnOff App DataRate", appDataRate);
58 cmd.AddValue (
"modeBytes",
"Set Queue disc mode to Packets (false) or bytes (true)", modeBytes);
60 cmd.AddValue (
"redMinTh",
"RED queue minimum threshold", minTh);
61 cmd.AddValue (
"redMaxTh",
"RED queue maximum threshold", maxTh);
62 cmd.Parse (argc,argv);
64 if ((queueDiscType !=
"RED") && (queueDiscType !=
"FengAdaptive"))
66 std::cout <<
"Invalid queue disc type: Use --queueDiscType=RED or --queueDiscType=FengAdaptive" << std::endl;
95 if (queueDiscType ==
"FengAdaptive")
111 nLeaf, pointToPointLeaf,
116 for (uint32_t i = 0; i < d.LeftCount (); ++i)
118 stack.Install (d.GetLeft (i));
120 for (uint32_t i = 0; i < d.RightCount (); ++i)
122 stack.Install (d.GetRight (i));
125 stack.Install (d.GetLeft ());
126 stack.Install (d.GetRight ());
130 tchBottleneck.
Install (d.GetLeft ()->GetDevice (0));
131 queueDiscs = tchBottleneck.
Install (d.GetRight ()->GetDevice (0));
140 clientHelper.SetAttribute (
"OnTime",
StringValue (
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
141 clientHelper.SetAttribute (
"OffTime",
StringValue (
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
143 PacketSinkHelper packetSinkHelper (
"ns3::TcpSocketFactory", sinkLocalAddress);
145 for (uint32_t i = 0; i < d.LeftCount (); ++i)
147 sinkApps.
Add (packetSinkHelper.Install (d.GetLeft (i)));
153 for (uint32_t i = 0; i < d.RightCount (); ++i)
157 clientHelper.SetAttribute (
"Remote", remoteAddress);
158 clientApps.Add (clientHelper.Install (d.GetRight (i)));
165 std::cout <<
"Running the simulation" << std::endl;
172 std::cout <<
"There should be some unforced drops" << std::endl;
178 std::cout <<
"There should be zero drops due to queue full" << std::endl;
182 std::cout <<
"*** Stats from the bottleneck queue disc ***" << std::endl;
183 std::cout << st << std::endl;
184 std::cout <<
"Destroying the simulation" << std::endl;
Parse command-line arguments.
AttributeValue implementation for Boolean.
Structure that keeps the queue disc statistics.
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.
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.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
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.
AttributeValue implementation for Address.
@ PACKETS
Use number of packets for queue size.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
QueueDiscContainer Install(NetDeviceContainer c)
a polymophic address class
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Holds a vector of ns3::QueueDisc pointers.
A helper to make it easier to create a dumbbell topology with p2p links.
static constexpr const char * INTERNAL_QUEUE_DROP
Packet dropped by an internal queue.
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.
static constexpr const char * UNFORCED_DROP
Early probability drops.
static Ipv4Address GetAny(void)
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.
Build a set of QueueDisc objects.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
holds a vector of ns3::Application pointers.
uint32_t pktSize
packet size used for the simulation (in bytes)
@ BYTES
Use number of bytes for queue size.
Build a set of PointToPointNetDevice objects.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
const Stats & GetStats(void)
Retrieve all the collected statistics.
Class for representing queue sizes.
aggregate IP/TCP/UDP functionality to existing Nodes.
Ptr< QueueDisc > Get(std::size_t i) const
Get the Ptr<QueueDisc> stored in this container at a given index.