24 #include "ns3/core-module.h" 25 #include "ns3/network-module.h" 26 #include "ns3/internet-module.h" 27 #include "ns3/point-to-point-module.h" 28 #include "ns3/applications-module.h" 29 #include "ns3/point-to-point-layout-module.h" 30 #include "ns3/traffic-control-module.h" 38 int main (
int argc,
char *argv[])
41 uint32_t maxPackets = 100;
42 bool modeBytes =
false;
43 uint32_t queueDiscLimitPackets = 1000;
46 uint32_t pktSize = 512;
47 std::string appDataRate =
"10Mbps";
48 std::string queueDiscType =
"RED";
50 std::string bottleNeckLinkBw =
"1Mbps";
51 std::string bottleNeckLinkDelay =
"50ms";
54 cmd.AddValue (
"nLeaf",
"Number of left and right side leaf nodes", nLeaf);
55 cmd.AddValue (
"maxPackets",
"Max Packets allowed in the device queue", maxPackets);
56 cmd.AddValue (
"queueDiscLimitPackets",
"Max Packets allowed in the queue disc", queueDiscLimitPackets);
57 cmd.AddValue (
"queueDiscType",
"Set Queue disc type to RED or NLRED", 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 !=
"NLRED"))
68 std::cout <<
"Invalid queue disc type: Use --queueDiscType=RED or --queueDiscType=NLRED" << std::endl;
97 if (queueDiscType ==
"NLRED")
113 nLeaf, pointToPointLeaf,
118 for (uint32_t i = 0; i < d.LeftCount (); ++i)
120 stack.Install (d.GetLeft (i));
122 for (uint32_t i = 0; i < d.RightCount (); ++i)
124 stack.Install (d.GetRight (i));
127 stack.Install (d.GetLeft ());
128 stack.Install (d.GetRight ());
132 tchBottleneck.
Install (d.GetLeft ()->GetDevice (0));
133 queueDiscs = tchBottleneck.
Install (d.GetRight ()->GetDevice (0));
142 clientHelper.SetAttribute (
"OnTime",
StringValue (
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
143 clientHelper.SetAttribute (
"OffTime",
StringValue (
"ns3::UniformRandomVariable[Min=0.|Max=1.]"));
145 PacketSinkHelper packetSinkHelper (
"ns3::TcpSocketFactory", sinkLocalAddress);
147 for (uint32_t i = 0; i < d.LeftCount (); ++i)
149 sinkApps.
Add (packetSinkHelper.Install (d.GetLeft (i)));
155 for (uint32_t i = 0; i < d.RightCount (); ++i)
159 clientHelper.SetAttribute (
"Remote", remoteAddress);
160 clientApps.Add (clientHelper.Install (d.GetRight (i)));
167 std::cout <<
"Running the simulation" << std::endl;
174 std::cout <<
"There should be some unforced drops" << std::endl;
180 std::cout <<
"There should be zero drops due to queue full" << std::endl;
184 std::cout <<
"*** Stats from the bottleneck queue disc ***" << std::endl;
185 std::cout << st << std::endl;
186 std::cout <<
"Destroying the simulation" << std::endl;
Structure that keeps the queue disc statistics.
holds a vector of ns3::Application pointers.
static Ipv4Address GetAny(void)
AttributeValue implementation for Boolean.
QueueDiscContainer Install(NetDeviceContainer c)
Class for representing queue sizes.
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
Hold variables of type string.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
static void Run(void)
Run the simulation.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
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.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
static constexpr const char * UNFORCED_DROP
Early probability drops.
a polymophic address class
Holds a vector of ns3::QueueDisc pointers.
Hold an unsigned integer type.
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Use number of packets for queue size.
Build a set of QueueDisc objects.
const Stats & GetStats(void)
Retrieve all the collected statistics.
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.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< QueueDisc > Get(std::size_t i) const
Get the Ptr<QueueDisc> stored in this container at a given index.
uint16_t SetRootQueueDisc(std::string type, std::string n01="", const AttributeValue &v01=EmptyAttributeValue(), std::string n02="", const AttributeValue &v02=EmptyAttributeValue(), std::string n03="", const AttributeValue &v03=EmptyAttributeValue(), std::string n04="", const AttributeValue &v04=EmptyAttributeValue(), std::string n05="", const AttributeValue &v05=EmptyAttributeValue(), std::string n06="", const AttributeValue &v06=EmptyAttributeValue(), std::string n07="", const AttributeValue &v07=EmptyAttributeValue(), std::string n08="", const AttributeValue &v08=EmptyAttributeValue(), std::string n09="", const AttributeValue &v09=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue(), std::string n11="", const AttributeValue &v11=EmptyAttributeValue(), std::string n12="", const AttributeValue &v12=EmptyAttributeValue(), std::string n13="", const AttributeValue &v13=EmptyAttributeValue(), std::string n14="", const AttributeValue &v14=EmptyAttributeValue(), std::string n15="", const AttributeValue &v15=EmptyAttributeValue())
Helper function used to set a root queue disc of the given type and with the given attributes...
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.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
A helper to make it easier to create a dumbbell topology with p2p links.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Use number of bytes for queue size.
static constexpr const char * INTERNAL_QUEUE_DROP
Packet dropped by an internal queue.