How many hops are there between baidu.com and baidu.com?

Source: Internet
Author: User

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        

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.