Ping is basically the command used in networking to check whether the two systems are
connected or not. it sends an ICMP (Internet control message protocol) echo request signal to an interface on the network and in the response it expects to receive an echo ICMP reply. So, by doing this it checks the connectivity .
ICMP is a protocol which is used for internet working layer of TCP/IP and it relies on IP for transport across the network.
Please check this link. It might be useful for you.