-1

我正在尝试在 Windows 上使用 tcp 实现 tracert。我正在使用 Winsock。我使用的套接字是 SOCK_STREAM。

问题是如何获取具有下一个 TTL 的主机地址。据我所知,在这种情况下我不能使用 recvfrom 函数,因为 TCP 是基于连接的协议,所以在这种情况下 recv 等于 recvfrom 。我尝试使用 getpeername 但我仍然只获得目标节点的 IP 地址。

而且。即使将 TTL = 0 设置为 IP 数据包,仍然会找到到达目标机器的方式,并且我得到了响应。

4

1 回答 1

1

tracert (or traceroute) doesn't work with TCP but with ICMP (like ping). The TTL should be started by 1 and then incremented by 1 until the destination was reached.

More can be found on http://en.wikipedia.org/wiki/Traceroute#Implementation

于 2013-10-30T14:27:35.087 回答