Node ID

876 views
Skip to first unread message

Fab

unread,
Nov 12, 2012, 3:04:36 PM11/12/12
to ns-3-...@googlegroups.com
Is there any existing method to get the node ID of an IP address? For example if I am sending a packet to IP address x.y.z.t I would like to display the node ID that hosts that IP address.
Thanks.

              Fab

Xuelei Tan

unread,
Nov 12, 2012, 8:03:36 PM11/12/12
to ns-3-...@googlegroups.com
Hi Fab,

I think it depends on in which layer you want to get the nodeID. Also  in some files like ipv4-l3-protocol.h there's already has Attribute like m_node, you can use it directly!  While if you can get the device which deal with your packet, you can try"m_node = device->GetNode".

Then nodeID = m_node->GetID();

Best regards,
Xuelei


2012/11/13 Fab <F...@hawk.iit.edu>
Is there any existing method to get the node ID of an IP address? For example if I am sending a packet to IP address x.y.z.t I would like to display the node ID that hosts that IP address.
Thanks.


              Fab

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/W_1fnmBK7LsJ.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.

Fab

unread,
Nov 13, 2012, 11:28:01 AM11/13/12
to ns-3-...@googlegroups.com
Xuelei,
thanks much for your response. It worked for the node where the request is made. I wonder if we can go a step further and do that also for the destination (remote) node: I am at node A (L3) and I get a packet for a remote destination (let us call it node B). From the IP header I can get the IP address of that remote destination and I want the node ID of that. Can I, at node A (m_node = A) , find both the node ID where I am (yes, I can do that, thanks to your response) and also the node ID of the remote destination (of which I have the IP address, but that is not  m_node)?

                          Fab

Xuelei Tan

unread,
Nov 14, 2012, 8:16:05 PM11/14/12
to ns-3-...@googlegroups.com
sorry, as I didn't have this request, I didn't study this part!

If you got new ideas, please share with us!

Thank you!


             Xuelei


2012/11/14 Fab <F...@hawk.iit.edu>
To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/SxmnGoMoEbMJ.

Konstantinos

unread,
Nov 15, 2012, 6:10:49 AM11/15/12
to ns-3-...@googlegroups.com
NS-3 provides you a public variable Nodes which holds ALL nodes of the simulation.
You can create a method at the initialization that will build a local std::map in each node holding the ID and the IP address of the node.
You can iterate on each node from Nodes, get the net-device, the interface and from that the IP which will be stored in the local std::map.

Then, whenever you want you can search the local map with key the IP address to get the ID.

Xuelei Tan

unread,
Nov 15, 2012, 6:43:48 AM11/15/12
to ns-3-...@googlegroups.com
thank you very much!


2012/11/15 Konstantinos <dinos.k...@gmail.com>
To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/ONXRCIPKPNoJ.

Fab

unread,
Nov 20, 2012, 10:31:10 AM11/20/12
to ns-3-...@googlegroups.com
Konstantinos,
You explained clearly how to do it. Thank you for your response.

                   Fab
Reply all
Reply to author
Forward
0 new messages