I am writing an app for WiFi direct and it uses the mac address I transfer via another method (that works) where the client will use the ARP table to find the IP of the host, since the groupownerintent doesn't work at all on android. However I keep finding my arp table only holds my WiFi access point (for internet access), and the additional p2p interface disappears in less than 5 minutes.
What is the ARP timeout for Android, and is there a way to extend it? Perhaps in my app it is not an issue but debugging is a real pain when the interface goes down, and then fails to connect via WiFi direct (since it seems pretty broken if you do it through code).
Android is based on the Linux kernel and uses the same sort of ARP timeout policy. Entries in the cache timeout somewhere between base_reachable_time/2 and 3*base_reachable_time/2, with base_reachable_time defaulting to 30 seconds or so. You may be able to change this setting by changing the kernel parameters via the proc
interface at /proc/sys/net/ipv4/neigh/eth0/base_reachable_time
, but the phone will need to be rooted. You could also just ping the IP you want the MAC of before checking the table to keep the entry in the cache updated.