例如, google.com至less有这些IP:
74.125.225.49 74.125.225.51 74.125.225.81
ping只是随便挑一个呢?
答案取决于您的DNSparsing器是如何设置的,以及如何设置相关域的DNS服务器。
ping源主机上的DNSparsing器将查询操作系统和networkingconfiguration,以查找要ping的主机。 如果这是一个新的主机,以前没有进行查询的主机,则DNS查询顺序将从头到尾。
Alogging的数量和logging的内容以及它们返回的顺序取决于目标ping目标域的名称服务器。 这个过程是一个完整的讨论。
您的DNS客户端将selectAlogging中返回的IP之一,您的ping将开始发送IMCP回应请求消息到该目标IP。
您的本地操作系统可能会在一段时间内caching一个或多个响应,但通常并不总是在Alogging中指定的TTL。 再次,您的DNSparsing器也有另一个caching机会,通常但不总是遵循TTL。
最后的一个问题就是一些DNS客户端所做的所谓的sorting。 看到:
它只是select其中之一。 这并不是随机的 – 例如,如果其中一个在同一个本地networking上,通常会select一个。
平过程
The source host generates an ICMP protocol data unit. The ICMP PDU is encapsulated in an IP datagram, with the source and destination IP addresses in the IP header. At this point the datagram is most properly referred to as an ICMP ECHO datagram, but we will call it an IP datagram from here on since that's what it looks like to the networks it is sent over. The source host notes the local time on it's clock as it transmits the IP datagram towards the destination. Each host that receives the IP datagram checks the destination address to see if it matches their own address or is the all hosts address (all 1's in the host field of the IP address). If the destination IP address in the IP datagram does not match the local host's address, the IP datagram is forwarded to the network where the IP address resides. The destination host receives the IP datagram, finds a match between itself and the destination address in the IP datagram. The destination host notes the ICMP ECHO information in the IP datagram, performs any necessary work then destroys the original IP/ICMP ECHO datagram. The destination host creates an ICMP ECHO REPLY, encapsulates it in an IP datagram placing it's own IP address in the source IP address field, and the original sender's IP address in the destination field of the IP datagram. The new IP datagram is routed back to the originator of the PING. The host receives it, notes the time on the clock and finally prints PING output information, including the elapsed time.
重复上述过程,直到发送了所有请求的ICMP ECHO数据包并且收到了它们的响应,或者默认的2秒超时过期。 默认的2秒钟timout是发起PING的主机本地的,而不是数据报中的Time-To-Live值。
更多: http : //www.inetdaemon.com/tools/ping/how_ping_works.shtml