Pinging an IP address in Java | Set 1

PING stands for Packet InterNet Groper in computer networking field. It’s a computer network administration software used to test the reachability of a host on an Internet Protocol (IP) network. It measures the round-trip time for messages sent from the originating host to a destination computer that are echoed back to the source.

Ping operates by sending Internet Control Message Protocol (ICMP/ICMP6 ) Echo Request packets to the target host and waiting for an ICMP Echo Reply. The program reports errors, packet loss, and a statistical summary of the results.

Internet Control Message Protocol (ICMP) : The Internet Control Message Protocol (ICMP) supports protocol in the Internet Protocol suite. It is used by network devices like routers, to send error messages and operational information indicating whether a request to service is available or not or that a host or router could not be reached.
ICMP differs from transport protocols such as TCP and UDP in that it is not typically used to exchange data between systems.
ICMP is not supported in Java and ping in Java as it relies on ICMP
We can’t simply ping in Java as it relies on ICMP, which is sadly not supported in Java

This Java Program pings an IP address in Java using InetAddress class. It is successful in case of Local Host but for other hosts this program shows that the host is unreachable.