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

Xuelei Fan xuelei.fan at oracle.com
Wed Dec 9 01:31:17 UTC 2015


Is it nice to say in the spec that it is not reliable if the timeout is
too small?  At least 1000ms timeout by default may be not acceptable in
some circumstances.

Xuelei

On 12/9/2015 12:31 AM, Rob McKenna wrote:
> 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