Getting TOS value in TCP socket

I have a scenario where a client opens a TCP connection to a server after setting some IP TOS value ( setsockopt(.., IP_TOS, ..) ). On the server, I want to get the received TOS value and set it on the socket so that the received TOS is reflected back to the server-client packages.

Server-side issue, how can I get the TOS value received from the client? I can assume that the client will not change the TOS value during the whole session, therefore it is enough to get and set the default TOS value.

Configure IP_RECVTOS and use supporting data for UDP, but not for TCP sockets. How can one achieve something like this in TCP sockets? getsockopt(2) with SO_PRIORITY or IP_TOS returns the configured values ​​on the local socket. Therefore, if I did locally setsockopt() , then getsockopt() reflects this value. It does not reflect what is received on the network.

+7
source share
1 answer

The TOS value may change for each received TCP datagram.

Thus, this is not a permanent option for the receiving TCP socket.

From the latter it can be concluded that the receiver cannot derive the value for TOS from the TCP receive socket in terms of a parameter whose value can be read using getsockopt() .

Since there is no such function as β€œhelper messages” available for TCP, the only way to see what the sender has installed is like TOS to directly view the received TCP datagram headers.

+2
source

All Articles