I cant run NetAnim for first.cc

795 views
Skip to first unread message

Miguel Alves

unread,
Apr 11, 2018, 1:13:13 PM4/11/18
to ns-3-users
Hello guys, i am having a problem here.

I did this, and everything was ok:

1. make clean 2. qmake NetAnim.pro 3. make Now your NetAnim is ready to use For adding ns3 to your program, do the following 1. include "ns3/netanim-module.h" 2. Add the following statement before Simulation::Run() AnimationInterface anim ("animation.xml"); 3. Set give positions to your nodes. anim.SetConstantPosition (node, double x, double y);

but, when i open NetAnim i couldnt find my xml file. Do you know why?

Vitor Lamela

unread,
Apr 12, 2018, 9:11:36 AM4/12/18
to ns-3-users
You should provide the code you are using on the simulation. Assuming you placedĀ  AnimationInterface anim ("animation.xml"); before Simulation::Run and that you have configured node, their mobility and made a simulation with a duration > 0. You should find a file called "animation.xml" on your ns-3 main directory (ex. ns-3-allinone/ns-3.27)
Then you have to open NetAnim, go to load XML file (little folder icon on top left corner) and choose that file "animation.xml".

Can't help you any further without code.

Miguel Alves

unread,
Apr 12, 2018, 9:31:56 AM4/12/18
to ns-3-...@googlegroups.com

sry, the code is this one (first.cc) :


#include "ns3/netanim-module.h"

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");

int
main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);

Time::SetResolution (Time::NS);
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);

NS_LOG_INFO ("Creating Topology");

NodeContainer nodes;
nodes.Create (2);

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));

NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);

InternetStackHelper stack;
stack.Install (nodes);

Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");

Ipv4InterfaceContainer interfaces = address.Assign (devices);

UdpEchoServerHelper echoServer (9);

ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));

UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));

ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));


AnimationInterface anim ("animation.xml");
anim.SetConstantPosition(nodes.Get(0), 1.0, 2.0);
anim.SetConstantPosition(nodes.Get(1), 2.0, 3.0);

Simulator::Run ();
Simulator::Destroy ();
return 0;
}

The xml file doesnt appear in NetAnim, something wrong here?

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Miguel Alves

unread,
Apr 12, 2018, 9:33:45 AM4/12/18
to ns-3-...@googlegroups.com
i didnt configured mobility nodes, but in youtube videos they say it is not impotant for the xml file be created.

Vitor Lamela

unread,
Apr 12, 2018, 11:11:40 AM4/12/18
to ns-3-users
just ran the code you gave on ns-3 (ns-3-dev) and correctly produced the animation.xml file.


Build commands will be stored in build/compile_commands.json

'build' finished successfully (1m54.702s)

AnimationInterface WARNING:Node:0 Does not have a mobility model. Use SetConstantPosition if it is stationary

AnimationInterface WARNING:Node:1 Does not have a mobility model. Use SetConstantPosition if it is stationary

AnimationInterface WARNING:Node:0 Does not have a mobility model. Use SetConstantPosition if it is stationary

AnimationInterface WARNING:Node:1 Does not have a mobility model. Use SetConstantPosition if it is stationary

At time 2s client sent 1024 bytes to 10.1.1.2 port 9

At time 2.00369s server received 1024 bytes from 10.1.1.1 port 49153

At time 2.00369s server sent 1024 bytes to 10.1.1.1 port 49153

At time 2.00737s client received 1024 bytes from 10.1.1.2 port 9


There are warnings because of the mobility model as you can see. But anyways you manually set it on the "anim" variable.
Here I attach the file.

animation.xml

Miguel Alves

unread,
Apr 12, 2018, 11:22:47 AM4/12/18
to ns-3-...@googlegroups.com
Appart of mobility model the xml file should be created. And i still cant make it appear. Anyway, thanks for the file.

Reply all
Reply to author
Forward
0 new messages