gpt4 book ai didi

sockets - 跟踪路由中的SO_DEBUG和SO_DONTROUTE

转载 作者:行者123 更新时间:2023-12-03 11:53:57 24 4
gpt4 key购买 nike

谁能解释SO_DEBUG和SO_DONTROUTE之间的区别。这是我的理解

SO_DONTROUTE

            Enable / disable routing bypass for outgoing message

Routing takes place only when it goes to out of subnet.

This tell that do not route, directly connect to the destination instead of routing

SO_DONTROUTE refers to the local routing

But default it is zero

Do not route send directly to the connected network

If the host is not on a directly-attached network
an error is returned. This option can be used to ping
a local host through an interface that has no route.

SO_DEBUG
            When enabled, the kernel keeps track of detailed
information about the packets sent and received by TCP for the socket

但是在traceroute中,如果我在命令行中提供-d选项,则还启用了SO_DONTROUTE选项。另外,当我启用-r选项时,-d也启用。我可以知道为什么吗?

最佳答案

我没有看到两个标志之间有任何明确的关系,因此(可能)这是一些特定于实现的行为,甚至可能是错误。

我已经在安装了默认traceroute的Ubuntu 14.04计算机上运行了traceroute -d 8.8.8.8-Modern traceroute for Linux, version 2.0.20, Aug 19 2014并设法达到8.8.8.8。使用-r标志,由于机器无法找到Network is unreachable,所以traceroute失败,并显示8.8.8.8错误消息。

查看stracetraceroute -rtraceroute -d,我还验证了一个调用 setsockopt(3, SOL_SOCKET, SO_DONTROUTE, [1], 4),而另一个调用 setsockopt(3, SOL_SOCKET, SO_DEBUG, [1], 4)

Van Jacobson的traceroute的official(?)来源应以相同的方式运行。这是(一部分)解析命令行开关的代码:

case 'r':
options |= SO_DONTROUTE;
break;

case 'd':
options |= SO_DEBUG;
break;

这是套接字选项:
if (options & SO_DEBUG)
(void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&on,
sizeof(on));
if (options & SO_DONTROUTE)
(void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&on,
sizeof(on));

但也许来源是不同的版本。

关于sockets - 跟踪路由中的SO_DEBUG和SO_DONTROUTE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37965705/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com