assign positions to mesh nodes

615 views
Skip to first unread message

Luis Mendes

unread,
Mar 4, 2013, 6:04:01 PM3/4/13
to ns-3-...@googlegroups.com
Hi,

I'm making a project for the university using ns3, I'm using the example that is provided in src folder called mesh.cc. I want to edit the code, and instead of having a grid position allocator I want to specify a x and y coordinates to wish mesh node. Can anyone help me with that? I know that should be extremely obvious but since I'm new using the ns3 I'm having some difficulties. 


thnks  

Konstantinos

unread,
Mar 5, 2013, 5:34:03 AM3/5/13
to ns-3-...@googlegroups.com
In order to do that, you have to use a different Position Allocation class instead of the Grid.

Here is an example:
http://www.nsnam.org/doxygen/classns3_1_1_list_position_allocator.html

  MobilityHelper mobility;
  Ptr<ListPositionAllocator> positionAlloc = CreateObject <ListPositionAllocator>();
  positionAlloc ->Add(Vector(0, 0, 0)); // node0
  positionAlloc ->Add(Vector(1000, 0, 0)); // node1
  positionAlloc ->Add(Vector(450, 0, 0)); // node2
  mobility.SetPositionAllocator(positionAlloc);
  mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
  mobility.Install(nodes);

However you can use more than one Allocators in the same script. For example you can use the Grid to place some nodes and the List with exact positions for other nodes.

Luis Mendes

unread,
Mar 5, 2013, 6:47:41 PM3/5/13
to ns-3-...@googlegroups.com
thnks!! that was very, very helpful

Shahrokh Vahabi

unread,
Sep 29, 2017, 8:36:45 AM9/29/17
to ns-3-users
Hi. How can I change position of a node in grid? for instance I want to put sink node in special position in grid.
Reply all
Reply to author
Forward
0 new messages