Android的ARP结算时间时间、Android、ARP

2023-09-06 11:11:45 作者:戈登心里咯噔了一下

我写的WiFi直接的应用程序,它使用MAC地址通过我的另一种方法(即作品)转移那里的客户将使用ARP表中查找主机的IP,因为groupownerintent不工作所有Android上。不过,我不断发现我的ARP表中仅持有我的WiFi接入点(互联网接入),以及附加的P2P界面不到5分钟就会消失。

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.

什么是ARP超时Android和有没有办法把它扩大?也许在我的应用程序是不是一个问题,但调试是一个真正的痛苦时,接口down,然后未能通过WiFi直接连接(因为它似乎,如果你做到这一点通过code pretty打破)。

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是基于Linux内核,并使用相同类型的 ARP超时策略。参赛作品中的缓存超时某处base_reachable_time之间/ 2和3 * base_reachable_time / 2,用base_reachable_time默认为30秒左右。您可以通过在的/ proc / SYS /网/的IPv4 /嘶/ eth0的/通过 PROC 接口更改内核参数更改此设置base_reachable_time ,但手机将需要扎根。你也可以只ping通你想要的检查表,以保持在缓存更新进入前的MAC地址的IP地址。

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.

 
精彩推荐
图片推荐