21 #include "ns3/core-module.h"
22 #include "ns3/network-module.h"
23 #include "ns3/internet-module.h"
24 #include "ns3/point-to-point-module.h"
25 #include "ns3/applications-module.h"
26 #include "ns3/point-to-point-layout-module.h"
35 int main (
int argc,
char *argv[])
38 uint32_t maxPackets = 100;
39 uint32_t modeBytes = 0;
42 uint32_t pktSize = 512;
43 std::string appDataRate =
"10Mbps";
44 std::string queueType =
"DropTail";
46 std::string bottleNeckLinkBw =
"1Mbps";
47 std::string bottleNeckLinkDelay =
"50ms";
50 cmd.
AddValue (
"nLeaf",
"Number of left and right side leaf nodes", nLeaf);
51 cmd.
AddValue (
"maxPackets",
"Max Packets allowed in the queue", maxPackets);
52 cmd.
AddValue (
"queueType",
"Set Queue type to DropTail or RED", queueType);
53 cmd.
AddValue (
"appPktSize",
"Set OnOff App Packet Size", pktSize);
54 cmd.
AddValue (
"appDataRate",
"Set OnOff App DataRate", appDataRate);
55 cmd.
AddValue (
"modeBytes",
"Set Queue mode to Packets <0> or bytes <1>", modeBytes);
57 cmd.
AddValue (
"redMinTh",
"RED queue minimum threshold", minTh);
58 cmd.
AddValue (
"redMaxTh",
"RED queue maximum threshold", maxTh);
59 cmd.
Parse (argc,argv);
61 if ((queueType !=
"RED") && (queueType !=
"DropTail"))
63 NS_ABORT_MSG (
"Invalid queue type: Use --queueType=RED or --queueType=DropTail");
91 if (queueType ==
"RED")
93 bottleNeckLink.
SetQueue (
"ns3::RedQueue",
104 nLeaf, pointToPointLeaf,
121 PacketSinkHelper packetSinkHelper (
"ns3::TcpSocketFactory", sinkLocalAddress);
123 for (uint32_t i = 0; i < d.
LeftCount (); ++i)
127 sinkApps.
Start (Seconds (0.0));
128 sinkApps.
Stop (Seconds (30.0));
131 for (uint32_t i = 0; i < d.
RightCount (); ++i)
138 clientApps.
Start (Seconds (1.0));
139 clientApps.
Stop (Seconds (15.0));
143 std::cout <<
"Running the simulation" << std::endl;
146 uint32_t totalRxBytesCounter = 0;
147 for (uint32_t i = 0; i < sinkApps.
GetN (); i++)
151 totalRxBytesCounter += pktSink->
GetTotalRx ();
155 <<
"\nGoodput Bytes/sec:"
160 std::cout <<
"Destroying the simulation" << std::endl;
holds a vector of ns3::Application pointers.
static Ipv4Address GetAny(void)
smart pointer class similar to boost::intrusive_ptr
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. ...
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.
int main(int argc, char *argv[])
static void Run(void)
Run the simulation until one of:
aggregate IP/TCP/UDP functionality to existing Nodes.
uint32_t GetN(void) const
Get the number of Ptr
stored in this container.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
Ptr< Node > GetRight() const
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.
Ptr< Node > GetLeft() const
a polymophic address class
Hold an unsigned integer type.
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)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
uint32_t LeftCount() const
void SetDefault(std::string name, const AttributeValue &value)
Ptr< Application > Get(uint32_t i) const
Get the Ptr
stored in this container at a given index.
#define NS_LOG_UNCOND(msg)
void AssignIpv4Addresses(Ipv4AddressHelper leftIp, Ipv4AddressHelper rightIp, Ipv4AddressHelper routerIp)
static Time Now(void)
Return the "current simulation time".
uint32_t GetTotalRx() const
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
#define NS_ABORT_MSG(msg)
Abnormal program termination.
uint32_t RightCount() const
hold objects of type ns3::Address
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
void InstallStack(InternetStackHelper stack)
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
A helper to make it easier to create a dumbbell topology with p2p links.
void Parse(int argc, char *argv[])
Parse the program arguments.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Hold a floating point type.
Ipv4Address GetLeftIpv4Address(uint32_t i) const
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.