I’m writing a C/C++ client-server program under Linux. Assume a message m is to be sent from the client to the server.
Is it possible for the client to read the TCP sequence number of the packet which will carry m, before sending m?
In fact, I’d like to append this sequence number to m, and send the resulting packet. (Well, things are more complicated, but let’s keep it that simple. In fact, I’d like to apply authentication info to this sequence number, and then append it to m.)
Moreover,
is it possible for the server to read the TCP sequence number of the packet carrying m?
no, you can’t do that — at least not with expected result
This is because:
These means you might send a “packet” with the sequence number at the end of “packet”. It turns out, the underlying magics re-segment your packet.
What you want:
What you might get: