ProjectSPAN / android-manet-manager

SPAN - Android Manet Manager
72 stars 37 forks source link

Detect other device IP #26

Open wooof21 opened 10 years ago

wooof21 commented 10 years ago

Hi, please help, how the project find the other device IP address when join the network? I ma trying to do broadcast some packet in the ad hoc, but seems every time it only send the packet to itself. I did some research, but all their broadcast packet are doing under Wifi network, and also their detect other device IP method are not appear in this project, I don't know its the reason that this project turn off wifi so that method won't work anymore or you find another way to do it. Can you give me some hint, thank you!

jrobble commented 10 years ago

SPAN uses the OLSR routing protocol to form the network. Essentially Device A will broadcast a HELLO messages that Device B will here if it's in range. The same thing happens in the opposite direction and they form a link.

We turn off the Wi-Fi in the Settings app because we work below the Android OS and turn on ad-hoc mode in the kernel. Android doesn't natively support ad-hoc mode. You should still be able to send data in your apps even if the WifiManager (http://developer.android.com/reference/android/net/wifi/WifiManager.html) tells you that there is no network.

Try and form a network with two devices and click on the "Routing Info" option in the MANET Manager app. Please include the output in your next reply.

wooof21 commented 10 years ago

Thank you for your replying, sir! I got the broadcast worked, but now the problem is, if want to send a unicast message to a device in the network, how I get that device IP? In your project, when a device join the network, in the visualizer it will automatic show the device IP, I don't know how you detect the other device IP address, can you also give a hint please?

jrobble commented 10 years ago

The SPAN code pulls the IP address from the OLSR txtinfo plugin. You can use the SPAN API to get information about peers in the network. You need to use ManetHelper.sendPeersQuery(), which will invoke the callback ManetObserver.onPeersUpdated(). Refer to how the android-manet-ptt and android-manet-visualizer projects use those calls.

superdav815 commented 10 years ago

Hi I am new to android programming doing networking project application to run on nexus7 tablet, can you give beginner step by step details on how to get the IP addresses and nexthop address from OLSR routing table. I unable to understand how android-manet-ptt is doing it.

jrobble commented 10 years ago

The Manet PTT app is using the Manet Manager Service. The Manet Manager Service pulls a text dump from the running olsrd process using the OLSR txtinfo plugin. Refer to this code:

https://github.com/ProjectSPAN/android-manet-manager/blob/master/AndroidManetManager/src/org/span/service/routing/OlsrProtocol.java

Specifically, look at the InfoThread and getPeers() method.