How many hops are there between baidu.com and baidu.com?
I. background
Recently, after reading Netease game interview experience (3)-cotyb-blog Park, I tried to tracert baidu.com on windows. The result is as shown in the following figure, it seems that baidu.com (220.181.57.217) has not been reached until the last 30 hops ). However, if you ping baidu.com, You can ping it. It seems a little far away that you cannot jump to baidu.com after 30, so you can try the following.
Try 1: Set ttl to 29, ping, and ping
Test 2: Compare the packet capture results of ping and tracert.
Ping Package content
Tracert Package content
Ii. Preliminary conclusion
Compared with the ping and tracert packets, the ping packet contains abcdef... and other characters, while the tracert icmp packet is all 0. It is assumed that baidu.com has identified the content of the icmp packet. To verify this, the following uses scapy to construct different icmp packets for verification.
Iii. Verification
1) scapy sends 64 bytes of all zero packets. wireshark packet capture shows that no response is received:
A = 64 * "\ x00"
Send (IP (dst = "220.181.57.217")/ICMP ()/)
2) All messages sent with the content "abcdefghjklmnopq" and "abcdefghjklmnopqr" receive a response.
Send (IP (dst = "220.181.57.217")/ICMP ()/"abcdefghjklmnopq ")
4. A small script that can output several hops from baidu.com
In some complex scenarios, for example, different ping baidu.com addresses are not considered. Modify this applet to read the ping output and get the IP address of each hop.
import osn=30i=1while i<n: a=os.popen('ping -n 2 -i '+str(i)+' baidu.com').read() if "TTL=" in a: print "success" break i=i+1 #print aif i<n: print "distance is %d hops"%i