Getting Node Id

331 views
Skip to first unread message

neeraj garg

unread,
May 10, 2012, 4:12:15 PM5/10/12
to ns-3-users
I want to Get Node id From Given Node Address suppose my node Address
is that 10.0.0.20 . What is the Node Id from This Address of the node.
so plz tell me ........

Konstantinos

unread,
May 10, 2012, 5:47:20 PM5/10/12
to ns-3-...@googlegroups.com
There is no such function to do that.

You have to get the NodeList that contains ALL the nodes, iterate on them and get ALL NetDevices of each node, and on ALL interfaces of them and get the IP address of each interface. Then if the interface address matches your address, you have your node.

If you want to do this search more than once, then I would recommend to build a std::map with key the IP address and field the Node. This will be done again with the same approach as above. But instead of "matching" the address with something, you will add it to the std::map. And when you want to search an IP address, you will search this map.
Reply all
Reply to author
Forward
0 new messages