Reputation: 369
I am writing a program that needs to create an ad-hoc network. Once it's created and other nodes connect, i need a way to determine the ip of every node on the network (or some other way of forming a connection. I would prefer to use tcp and/or udp, but I don't have to). Once I have a way to connect to other nodes, I need to determine the number of hops between this machine and the node I'm wishing to connect to.
I have looked around a lot for this information, but to no avail.... Does anyone know if there is an already in place API for this? And if not, how I would be able to create my own....
Upvotes: 3
Views: 969
Reputation: 2497
I know this question is pretty old, but I have extensive experience in this field.
What you need is an ad hoc routing protocol, often called MANET (Mobile Adhoc NETwork) protocol. I would suggest that you take a look at OLSR, which is standardized by the IETF as RFC 7181 and RFC 3636. You can obtain source code and binaries for OLSR at http://www.olsr.org/?q=download.
By using this, OLSR will create routes between all nodes in the network, and by looking at the routing table you will be able to determine the IP address of every node in the network, and can then easily open a socket connection (UDP/TCP) to any of them. You will also get information about the quality of each link, if needed.
Upvotes: 1