icrosoft使用ICMP,所以win95上發(fā)出的traceRT應(yīng)使用的是ICMP,但我沒有用 sniffer查過;其它包括unix和cisco router都使用UDP.
ICMP traceroute :
===========
使用ICMP Echo Request , Echo Reply and TTL-expired .
源發(fā)出 ICMP
Equest,第一個(gè)request的TTL為1,第二個(gè)request的TTL為2,以后依此遞增直至第30個(gè);中間的router送回ICMP TTL-expired ( ICMP type 11)通知source,(packet同時(shí)因TTL超時(shí)而被drop),由此source知曉一路上經(jīng)過的每一個(gè)router;最后的 destination送回ICMP Echo Reply 。
所以中間任何一個(gè)router上如果封了ICMP Echo Request , traceroute就不能工作 ;如果封了type 11 (TTL-expired), 中間的router全看不到 ,但能看到packet 到達(dá)了最后的destination;如果封了ICMP Echo Reply,中間的全能看到,最后的destination看不到 。
UDP traceroute:
==========
使用ICMP TTL-expired (type 11), ICMP port unreachable (type 3, code 3), UDP
port >32768 .
source發(fā)出UDP packet, source port使用隨機(jī)的任何大于32768的高段port, destination port從33434開始每送個(gè)probe依此遞增,直至33434+29,(cisco router上使用extended-traceroute命令可以修改這個(gè)起始的33434 port #),
同時(shí)TTL從1開始依此遞增,直至1+29=30(最多送30個(gè)probe)。中間的router送回 ICMP TTL-expired,使得source得知了中間的每一個(gè)router,最后的destination送回TTL-expired 和ICMP port unreachable (因?yàn)槿魏沃鳈C(jī)上都沒有應(yīng)用使用UDP port# >32768這樣的高段port )。
所以中間某處封掉UDP port>32768回導(dǎo)致traceroute不工作 ;封掉TTL超時(shí)會使source看不到中間的router(有的router根本不支持回送TTL超時(shí));封掉type3 code3可能看不到destination .
另外需要知道的是,由于回送TTL-expired的信息需要CPU生成一個(gè)packet,必須打斷 CPU,為保證其它工作的正常進(jìn)行,cisco router每隔一秒才處理traceroute ,所以在source 上你可能看到中間一路 * * *,但卻看得到最后的destination. 這時(shí)你應(yīng)知道這是中間的router CPU太忙或者中間路由器不回送TTL-expired包的原因 ,不必大驚小怪的。:-)
[at_Neal:root:~:]# traceroute -I www.baidu.com
traceroute to www.baidu.com (103.235.46.39), 30 hops max, 60 byte packets
1 192.168.10.254 (192.168.10.254) 0.472 ms 0.464 ms 0.461 ms
2 101.231.115.1 (101.231.115.1) 0.668 ms * *
3 * * *
4 * * *
5 * * *
6 * 59.43.77.145 (59.43.77.145) 3.597 ms 3.580 ms
7 59.43.116.230 (59.43.116.230) 3.559 ms 3.139 ms 3.347 ms
8 59.43.246.198 (59.43.246.198) 4.073 ms 4.076 ms 2.912 ms
9 59.43.246.254 (59.43.246.254) 2.202 ms 2.938 ms 2.937 ms
10 59.43.248.110 (59.43.248.110) 30.695 ms 30.245 ms 31.916 ms
11 203.131.250.85 (203.131.250.85) 32.146 ms 35.859 ms 35.847 ms
12 ae-3.r01.tkokhk01.hk.bb.gin.ntt.net (129.250.6.131) 33.435 ms 33.426 ms 32.407 ms
13 203.131.250.22 (203.131.250.22) 31.383 ms 32.681 ms 32.453 ms
14 103.235.45.6 (103.235.45.6) 33.665 ms 32.717 ms 33.674 ms
15 * * *
16 * * *
17 103.235.46.39 (103.235.46.39) 31.811 ms 31.846 ms 31.846 ms