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"
37 int main (
int argc,
char *argv[])
40 uint32_t maxPackets = 100;
41 uint32_t modeBytes = 0;
42 uint32_t queueDiscLimitPackets = 1000;
46 std::string appDataRate =
"10Mbps";
47 std::string queueDiscType =
"PfifoFast";
49 std::string bottleNeckLinkBw =
"1Mbps";
50 std::string bottleNeckLinkDelay =
"50ms";
53 cmd.AddValue (
"nLeaf",
"Number of left and right side leaf nodes", nLeaf);
54 cmd.AddValue (
"maxPackets",
"Max Packets allowed in the device queue", maxPackets);
55 cmd.AddValue (
"queueDiscLimitPackets",
"Max Packets allowed in the queue disc", queueDiscLimitPackets);
56 cmd.AddValue (
"queueDiscType",
"Set QueueDisc type to PfifoFast or RED", queueDiscType);
57 cmd.AddValue (
"appPktSize",
"Set OnOff App Packet Size",
pktSize);
58 cmd.AddValue (
"appDataRate",
"Set OnOff App DataRate", appDataRate);
59 cmd.AddValue (
"modeBytes",
"Set QueueDisc mode to Packets <0> or bytes <1>", modeBytes);
61 cmd.AddValue (
"redMinTh",
"RED queue minimum threshold", minTh);
62 cmd.AddValue (
"redMaxTh",
"RED queue maximum threshold", maxTh);
63 cmd.Parse (argc,argv);
65 if ((queueDiscType !=
"RED") && (queueDiscType !=
"PfifoFast"))
67 NS_ABORT_MSG (
"Invalid queue disc type: Use --queueDiscType=RED or --queueDiscType=PfifoFast");
106 nLeaf, pointToPointLeaf,
111 for (uint32_t i = 0; i < d.LeftCount (); ++i)
113 stack.Install (d.GetLeft (i));
115 for (uint32_t i = 0; i < d.RightCount (); ++i)
117 stack.Install (d.GetRight (i));
120 if (queueDiscType ==
"PfifoFast")
122 stack.Install (d.GetLeft ());
123 stack.Install (d.GetRight ());
125 else if (queueDiscType ==
"RED")
127 stack.Install (d.GetLeft ());
128 stack.Install (d.GetRight ());
131 tchBottleneck.
Install (d.GetLeft ()->GetDevice (0));
132 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;
170 uint64_t totalRxBytesCounter = 0;
171 for (uint32_t i = 0; i < sinkApps.
GetN (); i++)
175 totalRxBytesCounter += pktSink->
GetTotalRx ();
177 NS_LOG_UNCOND (
"----------------------------\nQueueDisc Type:"
179 <<
"\nGoodput Bytes/sec:"
184 std::cout <<
"Destroying the simulation" << std::endl;
a polymophic address class
AttributeValue implementation for Address.
holds a vector of ns3::Application pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
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.
uint32_t GetN(void) const
Get the number of Ptr<Application> stored in this container.
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.
static Ipv4Address GetAny(void)
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
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.
uint64_t GetTotalRx() const
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.
Class for representing queue sizes.
AttributeValue implementation for QueueSize.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
static void Run(void)
Run the simulation.
static Time Now(void)
Return the current simulation virtual time.
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)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
@ 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.
uint32_t pktSize
packet size used for the simulation (in bytes)