The well-known ping application checks to see if another computer is alive and reachable, whether it is on the same LAN or is a distant machine connected via the Internet. Of course, ping may not work if a machine is hidden behind a corporate firewall. Ping sends an ICMP echo request message to the desired computer. If that computer receives the echo request, it responds with an ICMP echo reply message. Ping is useful when trying to figure out why some other application involving the distant computer is not working. Perhaps email to that machine is not getting through, perhaps you cannot telnet to the machine (but normally you are allowed to do this). Ping will tell you if the very basics are in place: the machine is running and can be reached over the network.
The traceroute application is used to report the route taken by packets sent to another host over the network (or Intenet). Traceroute begins by sending a datagram to the desired destination host, but with a value of 1 in the TimeToLive field. This means that when the datagram reaches the first router, the datagram expires and is discarded. However, the router does send an ICMP message to the sender. This message naturally contains the router's own IP address. The sender then sends a datagram with 2 in the TimeToLive field. This datagram expires at the second router, which sends an ICMP message to the sender. The IP address of the second router thus gets sent to the sender. This process continues until the sender learns the complete route being taken by datagrams to the desired destination. Of course, it is always possible that some datagrams might follow different routes and thus confuse traceroute. However, if the above process happens very quickly, this problem is unlikely to occur.