21#include "ns3/applications-module.h"
22#include "ns3/core-module.h"
23#include "ns3/internet-module.h"
24#include "ns3/network-module.h"
25#include "ns3/point-to-point-layout-module.h"
26#include "ns3/point-to-point-module.h"
27#include "ns3/traffic-control-module.h"
36main(
int argc,
char* argv[])
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",
55 "Max Packets allowed in the queue disc",
56 queueDiscLimitPackets);
57 cmd.AddValue(
"queueDiscType",
"Set Queue disc type to RED or FengAdaptive", queueDiscType);
58 cmd.AddValue(
"appPktSize",
"Set OnOff App Packet Size",
pktSize);
59 cmd.AddValue(
"appDataRate",
"Set OnOff App DataRate", appDataRate);
60 cmd.AddValue(
"modeBytes",
"Set Queue disc mode to Packets (false) or bytes (true)", modeBytes);
62 cmd.AddValue(
"redMinTh",
"RED queue minimum threshold", minTh);
63 cmd.AddValue(
"redMaxTh",
"RED queue maximum threshold", maxTh);
64 cmd.Parse(argc, argv);
66 if ((queueDiscType !=
"RED") && (queueDiscType !=
"FengAdaptive"))
69 <<
"Invalid queue disc type: Use --queueDiscType=RED or --queueDiscType=FengAdaptive"
83 "ns3::RedQueueDisc::MaxSize",
89 "ns3::RedQueueDisc::MaxSize",
101 if (queueDiscType ==
"FengAdaptive")
120 for (
uint32_t i = 0; i < d.LeftCount(); ++i)
122 stack.Install(d.GetLeft(i));
124 for (
uint32_t i = 0; i < d.RightCount(); ++i)
126 stack.Install(d.GetRight(i));
129 stack.Install(d.GetLeft());
130 stack.Install(d.GetRight());
134 tchBottleneck.
Install(d.GetLeft()->GetDevice(0));
135 queueDiscs = tchBottleneck.
Install(d.GetRight()->GetDevice(0));
144 clientHelper.SetAttribute(
"OnTime",
StringValue(
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
145 clientHelper.SetAttribute(
"OffTime",
StringValue(
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
147 PacketSinkHelper packetSinkHelper(
"ns3::TcpSocketFactory", sinkLocalAddress);
149 for (
uint32_t i = 0; i < d.LeftCount(); ++i)
151 sinkApps.
Add(packetSinkHelper.Install(d.GetLeft(i)));
157 for (
uint32_t i = 0; i < d.RightCount(); ++i)
161 clientHelper.SetAttribute(
"Remote", remoteAddress);
162 clientApps.Add(clientHelper.Install(d.GetRight(i)));
167 Ipv4GlobalRoutingHelper::PopulateRoutingTables();
169 std::cout <<
"Running the simulation" << std::endl;
176 std::cout <<
"There should be some unforced drops" << std::endl;
182 std::cout <<
"There should be zero drops due to queue full" << std::endl;
186 std::cout <<
"*** Stats from the bottleneck queue disc ***" << std::endl;
187 std::cout << st << std::endl;
188 std::cout <<
"Destroying the simulation" << std::endl;
190 Simulator::Destroy();
a polymophic address class
AttributeValue implementation for Address.
holds a vector of ns3::Application pointers.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
AttributeValue implementation for Boolean.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
A helper to make it easier to create a dumbbell topology with p2p links.
Build a set of PointToPointNetDevice objects.
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.
Holds a vector of ns3::QueueDisc pointers.
Ptr< QueueDisc > Get(std::size_t i) const
Get the Ptr<QueueDisc> stored in this container at a given index.
const Stats & GetStats()
Retrieve all the collected statistics.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
Hold variables of type string.
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.
Hold an unsigned integer type.
void SetDefault(std::string name, const AttributeValue &value)
@ BYTES
Use number of bytes for queue size.
@ PACKETS
Use number of packets for queue size.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure that keeps the queue disc statistics.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
uint32_t pktSize
packet size used for the simulation (in bytes)