8143397: It looks like InetAddress.isReachable(timeout) works incorrectly

Rob McKenna rob.mckenna at oracle.com
Tue Dec 8 16:31:00 UTC 2015


Testing has shown that when a timeout < 1000ms is specified the 
IcmpSendEcho calls fail (apparently) randomly. Once the timeout is 
1000ms or greater it works as expected. Therefore I've updated the fix 
to use 1000ms as a minimum. The existing logic ensures that the ttl is 
less than the specified timeout in any case:

http://cr.openjdk.java.net/~robm/8143397/webrev.02/

	-Rob

On 01/12/15 14:59, Rob McKenna wrote:
> It appears that there is an undocumented minimum timeout in the
> IcmpSendEcho* functions. If the timeout parameter is set to a number
> below this minimum timeout it is effectively ignored. Thus if you wanted
> to ensure that you could ping a particular host within a certain timeout
> less than the undocumented minimum, you could potentially receive a
> false positive. (i.e. if you set the timeout to 20ms but the ping takes
> 30ms, IcmpSendEcho will still succeed)
>
> The following fix checks the icmp reply packet and compares the round
> trip time to the requested timeout parameter before deciding whether the
> call was successful or not:
>
> http://cr.openjdk.java.net/~robm/8143397/webrev.01/
>
>      -Rob


More information about the net-dev mailing list