> For the complete documentation index, see [llms.txt](https://valineliu.gitbook.io/deuterium-wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://valineliu.gitbook.io/deuterium-wiki/reading/cs-jing-dian-shu-ji/tcpv1/ch08-traceroute-program.md).

# ch08: Traceroute Program

ICMP and UDP

## MindMap

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggbq3d0uo4j316l0u07d9.jpg)

## Traceroute Program Operation

主要有以下几点：

* 使用TTL字段；
* 一个路由器不可能收到TTL等于0的IP数据报，TTL等于1的时候就抛弃；
* 如果没到目标，就会收到一个timeout的ICMP；
* 使用一个不可能的UDP端口，这样到达目标后就会收到一个端口不可达的ICMP。

## ICMP Time Exceeded

格式：

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggbskp73xcj31160f6gnf.jpg)

有两种超时，type都是11，这里超时的code是0。

另一个是组装报文超时。

需要注意的三点：

* 现在的路由将来不一定也用这个；
* ICMP报文的路由不一定和traceroute发送的UDP数据报的路由一样；
* 返回ICMP报文的源IP地址是traceroute发送的UDP数据报到达路由器接口的IP地址。

## IP Source Routing Option

简单来说就是制定具体的路由。

* **Strict**：严格按照制定的路由发包，不成功的话发送一个“source route failed”的ICMP；
* **Loose**：制定了必须经过的路由，也可以经过其他的路由。

格式如下（Source and Record Route）：

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggceat6v2qj313008wjs9.jpg)

code=0x83是宽松的（LSRR），code=0x89是严格的（SSRR）。

一个例子：

![](https://tva1.sinaimg.cn/large/007S8ZIlly1ggcef702c0j313008amxr.jpg)
