phi*_*ill 5 c c++ sockets boost-asio windows-10
简短版本:我正在尝试在我的应用程序正在发送的流量上设置IP_TOS字段,即使setsockopt成功返回并且getsockopt返回正确的IP_TOS值,离开Windows 10框时,流量也未加标签。
The longer version: I have an application that sends traffic that needs to have the IP_TOS field set and the IP_TOS value can be one in a range of values; it's an environment requirement so there is no way around it. The application also needs to be cross-platform (Windows 10 and Linux). Considering those requirements, we decided to just use boost asio and set the IP_TOS on the socket when it's created.
The Linux side works the way we want, socket is created, IP_TOS is set, data is sent, and tcpdump shows the data is correctly tagged on the send and receive sides.
The Windows side does everything except for actually tag the traffic. The socket is created, IP_TOS is set and read back to verify before sending, however wireshark/tcpdump shows that the traffic is not tagged at all (IP_TOS is 0). When we started to see issues with this, we created a simple test app using normal Windows TCP sockets, set and read IP_TOS using setsockopt and getsockopt and still had the same issues.
我的google-fu有时可能会很弱,但是有关Windows 10对IP_TOS的支持的信息似乎很少。我有一个MSDN Doc说两者都不使用它(而是使用QoS API),但是Windows 10支持它,我认为这意味着可以对其进行设置。我也有一个较旧的支持文档,其中说必须启用支持,但是我找不到与Windows 10相关的最新文档。我确实尝试了注册表调整,外加第二个(不要使用NLA),并且没有没有帮助。
我现在有点茫然,所以我希望有人以前处理过这个问题,并且有解决方案,可以在套接字上设置IP_TOS。真正尝试避免引入另一个API或在应用程序外部调用(netsh或组策略)来实现应该很简单的事情。
小智 1
操作系统中默认禁用 TOS(不完美)
要启用 TOS,请使用 regedit:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DisableUserTOSSetting
请参阅:设置服务类型 (TOS) 位