ping works by sending
ICMP packets to the target host and timing the host's response. It also measures connection quality by recording percentage packet loss. The time taken to establish the connection is not taken into account, only the time it takes for the packets themselves to be transferred.
On *nix machines,
ping can be run by simply executing
ping also has a partner-in-crime utility -
ping6 essentially works the exact same way as
ping, but it uses an IPv6 stack instead of an IPv4 stack. This means that it expects IPv6 addresses, IPv6 DNS records, and will use IPv6 to transfer the ICMP packets.
Both binaries are provided by the iputils package on most of GNU/Linux distributions. Pinging a host known to always respond correctly (such as
22.214.171.124 - one of Google's Public DNS servers) is a common first step in diagnosing network issues.