Search code examples
androidpingbroadcastandroid-networkingicmp

Is there a way to make an android device answer to icmp pings addressed to the broadcast address?


I would like to programatically make my device answer to broadcast pings (i.e pinging 192.178.1.255) while connected to a wifi network.

Is there a way i can do that ? Maybe a listener that will ping back, or a flag to set somewhere?

Thanks.


Solution

  • Is there a way i can do that ?

    In short: Yes. But it will take some good effort to integrate the necessary components.

    The key problem is that you need to listen for ICMP network packets. Such functionality is not accessible from Java and would require either JNI code or an external program. (To my knowledge, it also requires a rooted device.)

    You will need a library or program that can process network traffic, such as Jpcap (which would require some modification to work on Android). You could also install and run an instance of tcpdump in the background and parse its output.