Using Netanim in NS-3 : how to positionate a node

259 views
Skip to first unread message

Arij Souai

unread,
Jun 8, 2021, 8:19:15 AM6/8/21
to ns-3-users
Hi everyone,

I need you help please !
Im a biginner  in using NS-3 

So i want to know how can i set a constant position for a node,
In fact when i run ./NetAnim , it shows nodes in disorder , so i want them to be clear whith a convinient size too. 
can you help me if you know please ? 
thank you.


Capture d’écran de 2021-06-07 13-07-09.png

Gabriel Ferreira

unread,
Jun 8, 2021, 1:59:16 PM6/8/21
to ns-3-users
You need to put something like this in your simulation.

Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
    for (uint16_t i = 0; i < numberOfNodes; i++)
    {
        positionAlloc->Add (Vector(X, Y, Z));
    }
    MobilityHelper mobility;
    mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
    mobility.SetPositionAllocator(positionAlloc);
    mobility.Install(your_node_container);

shreya mishra

unread,
Jun 8, 2021, 2:29:56 PM6/8/21
to ns-3-...@googlegroups.com
Hello,

What if I have the x and y coordinates of nodes in a file for around 11k nodes. How can I do then?

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/0a0bf19f-6aaf-4882-a9a5-445080822c72n%40googlegroups.com.

Gabriel Ferreira

unread,
Jun 8, 2021, 2:42:04 PM6/8/21
to ns-3-users
I would read the coordinates into an array of arrays
e.g. double xyz[][] = [[x0,y0,y0],[x1,y1,z1];
then
e.g. positionAlloc->Add(Vector(xyz[i][0], xyz[i][1], xyz[i][2]));

shreya mishra

unread,
Jun 8, 2021, 3:46:26 PM6/8/21
to ns-3-...@googlegroups.com
Thanks a lot for your response . I'm still a little confused about reading the file that contains the coords... I'll try doing as you suggested.

Arij Souai

unread,
Jun 9, 2021, 6:29:13 AM6/9/21
to ns-3-...@googlegroups.com
Thanks a lot for your help !  It works .



--
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/BbwIu5Cx6iA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

Juan Antonio Arízaga Silva

unread,
Jun 10, 2021, 6:25:12 PM6/10/21
to ns-3-...@googlegroups.com
This fie has the information you need


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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/CAFK2aFB2RQJwmF8aiWsyO_%2Bu-kmZj6N-t4qXJfB919eHGg1MYg%40mail.gmail.com.


--
MHMD Inc.
M.C. Juan Antonio Arízaga Silva
Celular: 044 22 25 54 20 45

shreya mishra

unread,
Jun 14, 2021, 1:12:47 PM6/14/21
to ns-3-...@googlegroups.com
Hello,

I can place the nodes as per my pre-defined coordinates. However, I cannot map the node IDs predefined by me corresponding to the coordinates. Is there a way to do so? Because in Vector function I can only give the coordinates. 

Please let me know

Thanks in advance

Gabriel Ferreira

unread,
Jun 14, 2021, 7:11:58 PM6/14/21
to ns-3-users
I'm not sure if there is a "correct" way to do this.
I would create all the nodes in the correct order, matching the coordinate file, and then assign their positions as shown before. 
You could also install the mobility model + coordinate individually (e.g. by replacing the coordinate vector with a map using the NodeId as a key).

shreya mishra

unread,
Jun 15, 2021, 6:58:50 AM6/15/21
to ns-3-...@googlegroups.com
Okay... I'll try doing the same...

Thanks for your help.

shreya mishra

unread,
Jun 17, 2021, 3:00:48 AM6/17/21
to ns-3-...@googlegroups.com
Hello,

Do you think I can simulate elevations in NS3? By that I mean movement of drones 

Thanks in advance
Shreya
Reply all
Reply to author
Forward
0 new messages