Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find node id in NS2?

Tags:

c++

ns2

i would like to know how to get the node id where the packet is being processed.

I tried name(), but it doesn't give the id of the node, like the one which is shown in trace file, where the source and destination of the packet hop are shown. In trace file from format() the source and destination are available, but how to access to them , that might also help to know on which node is the current processing is going on.

This is about NS2. Could someone provide some help.

like image 337
user1221876 Avatar asked Jun 27 '12 07:06

user1221876


2 Answers

MobileNode *thisnode = (MobileNode *) ((Node::get_node_by_address(id)));
printf("%d\n",thisnode->address());

You can get the id of this node! Try it.

like image 183
GodQ Avatar answered Oct 25 '22 16:10

GodQ


try this:

Node *thisnode = Node::get_node_by_address(id);
printf("%d\n",thisnode->nodeid());

where id is just a number of your node: ex for node(1):

Node *thisnode = Node::get_node_by_address(1)
printf("%d\n",thisnode->nodeid());
like image 37
user1582256 Avatar answered Oct 25 '22 18:10

user1582256