I am new to ns-3. I am trying to understand from the very basic. I created a network simulation containing two switches, then I want to visualize it using NetAnim.
Followings are my code
#include "ns3/core-module.h" #include "ns3/point-to-point-module.h" #include "ns3/network-module.h" #include "ns3/applications-module.h" #include "ns3/mobility-module.h" #include "ns3/csma-module.h" #include "ns3/internet-module.h" #include "ns3/yans-wifi-helper.h" #include "ns3/ssid.h" #include "ns3/netanim-module.h" #include "stdio.h" using namespace ns3; NS_LOG_COMPONENT_DEFINE ("HMTMRSim"); int main (int argc, char *argv[]) { std::cout << "create switches" << std::endl; NodeContainer switches; switches.Create(2); // create two switches AnimationInterface anim("myanim.xml"); std::cout << "set position for switches" << std::endl; anim.SetConstantPosition(switches.Get(0), 48.0, 70.0, 0); anim.SetConstantPosition(switches.Get(1), 48.0, 90.0, 0); anim.UpdateNodeDescription(0, "Main"); anim.UpdateNodeDescription(1, "Rack0"); anim.UpdateNodeSize(0, 10, 10); anim.UpdateNodeColor(0, 0, 0, 255); Simulator::Run (); Simulator::Destroy (); return 0; }
When I run it, it works without problem, but I get this warning
Waf: Leaving directory `/Users/arwankhoiruddin/Downloads/ns-allinone-3.30.1/ns-3.30.1/build'Build commands will be stored in build/compile_commands.json'build' finished successfully (18.508s)create switchesAnimationInterface WARNING:Node:0 Does not have a mobility model. Use SetConstantPosition if it is stationaryAnimationInterface WARNING:Node:1 Does not have a mobility model. Use SetConstantPosition if it is stationaryAnimationInterface WARNING:Node:0 Does not have a mobility model. Use SetConstantPosition if it is stationary
AnimationInterface WARNING:Node:
When I open in NetAnim (shown in the picture below), it seems to ignore the position that I defined in my code. As you see in the following properties, the first node (node 0) has position of (x,y) = (81.00, 83.00), while in my code, I set the position as
anim.SetConstantPosition(switches.Get(0), 48.0, 70.0, 0);anim.SetConstantPosition(switches.Get(1), 48.0, 90.0, 0);
I am aware that I can change the position by changing the value in properties, but later using ns-3, I want to create quite a complex network, so it will be difficult to set them manually.
MobilityHelper mobility;Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();positionAlloc->Add(Vector(0.0, 0.0, 0.0));positionAlloc->Add(Vector(5.0, 0.0, 0.0));mobility.SetPositionAllocator(positionAlloc);mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");mobility.Install(switches);
Please let me know how to set the position from my code and get rid of the warning.

--
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 a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/5k2HNfKcM8c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/777164aa-579d-40db-a6e4-625b867cf76bo%40googlegroups.com.