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/netanim-module.h"
26 #include "ns3/applications-module.h"
27 #include "ns3/point-to-point-layout-module.h"
53 std::ostringstream oss;
68 std::ostringstream node0Oss;
71 static double size = 2;
85 static uint32_t index = 0;
89 struct rgb color = colors[index];
90 for (uint32_t nodeId = 4; nodeId < 12; ++nodeId)
108 int main (
int argc,
char *argv[])
113 uint32_t nLeftLeaf = 5;
114 uint32_t nRightLeaf = 5;
116 std::string animFile =
"resources_demo.xml" ;
119 cmd.
AddValue (
"nLeftLeaf",
"Number of left side leaf nodes", nLeftLeaf);
120 cmd.
AddValue (
"nRightLeaf",
"Number of right side leaf nodes", nRightLeaf);
121 cmd.
AddValue (
"nLeaf",
"Number of left and right side leaf nodes", nLeaf);
122 cmd.
AddValue (
"animFile",
"File Name for Animation Output", animFile);
124 cmd.
Parse (argc,argv);
140 nRightLeaf, pointToPointLeaf,
145 d.InstallStack (stack);
152 d.BoundingBox (1, 1, 100, 100);
155 clientHelper.SetAttribute
156 (
"OnTime",
StringValue (
"ns3::UniformRandomVariable[Min=0.,Max=1.]"));
157 clientHelper.SetAttribute
158 (
"OffTime",
StringValue (
"ns3::UniformRandomVariable[Min=0.,Max=1.]"));
161 for (uint32_t i = 0; i < d.RightCount (); ++i)
165 clientHelper.SetAttribute (
"Remote", remoteAddress);
166 clientApps.
Add (clientHelper.Install (d.GetRight (i)));
180 pAnim->
SetBackgroundImage (
"/Users/john/ns3/netanim-3.105/ns-3-background.png", 0, 0, 0.2, 0.2, 0.1);
194 std::cout <<
"Animation Trace file created:" << animFile.c_str ()<< std::endl;
holds a vector of ns3::Application pointers.
void UpdateNodeImage(uint32_t nodeId, uint32_t resourceId)
Helper function to update the image of a node.
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.
AnimationInterface * pAnim
Build a set of PointToPointNetDevice objects.
void UpdateNodeSize(uint32_t nodeId, double width, double height)
Helper function to update the size of a node.
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.
void UpdateNodeColor(Ptr< Node > n, uint8_t r, uint8_t g, uint8_t b)
Helper function to update the node color.
a polymophic address class
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void SetBackgroundImage(std::string fileName, double x, double y, double scaleX, double scaleY, double opacity)
Helper function to set the background image.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
void UpdateNodeCounter(uint32_t nodeCounterId, uint32_t nodeId, double counter)
Helper function to update a node's counter referenced by the nodeCounterId.
uint32_t AddNodeCounter(std::string counterName, CounterType counterType)
Setup a node counter.
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)
Execute the events scheduled with ScheduleDestroy().
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void UpdateLinkDescription(uint32_t fromNode, uint32_t toNode, std::string linkDescription)
Helper function to update the description for a link.
uint32_t AddResource(std::string resourcePath)
Add a resource such as the path to an image file.
uint32_t nodeCounterIdUint32
uint32_t nodeCounterIdDouble1
static Time Now(void)
Return the current simulation virtual time.
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...
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
Interface to network animator.
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.
uint32_t nodeCounterIdDouble2
void UpdateNodeDescription(Ptr< Node > n, std::string descr)
Helper function to update the description for a given node.