JDK-5061571 : InetAddress#isReachable does not send PINGs but only TCP echos
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2004-06-10
  • Updated: 2005-01-24
  • Resolved: 2004-06-11
Description

Name: rmT116609			Date: 06/10/2004


FULL PRODUCT VERSION :
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
I want to test reachability of a host using the new ping mechanism.

However, instead of pings, TCP ECHOS are sent (I see it in firewall logs).
These are blocked by the destination host and therefore the program thinks it's dead.

It worked just fine in Beta1

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
package test;

import java.net.*;
import java.net.Inet4Address;
import java.net.InetAddress;

public class Pinger {

    public static void main(String[] args) throws UnknownHostException {
        InetAddress addr = Inet4Address.getByName("www");
        try {
            addr.isReachable(100);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Details: 1.5.0-beta2. Host "www" resolves just fine. Instead of sending 
an ICMP message, it sends TCP echo (port 7) which is blocked by the 
firewall.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
ICMP PING being sent
ACTUAL -
TCP ECHO BEING SENT

REPRODUCIBILITY :
This bug can be reproduced always.
(Incident Review ID: 275552) 
======================================================================

Comments
EVALUATION The javadoc states: * Test whether that address is reachable. Best effort is made by the * implementation to try to reach the host, but firewalls and server * configuration may block requests resulting in a unreachable status * while some specific ports may be accessible. * A typical implementation will use ICMP ECHO REQUESTs if the * privilege can be obtained, otherwise it will try to establish * a TCP connection on port 7 (Echo) of the destination host. Which clearly says ICMP usage is not guaranteed and that firewalls may hinder the functionality. So it's not a bug. Because RAW sockets (and therefore ICMP) support is too inconsistent and unreliable across Windows versions, ICMP is never tried on Windows although it was briefly enabled in beta 1. However this is consistent with the specifications, therefore closing as "not a bug". ###@###.### 2004-06-11
11-06-2004