How do I get the original TCP sequence number from user space in Linux?
In order to keep track of a TCP session as it traverses the network, I would like to know the starting sequence number of the session. I wrote some code to just copy the ISN into the tcp_sock structure when creating a TCP session, and then add code to copy that value into the tcp_info structure returned by getsockopt (). This seems to work, but I was wondering if there is a better way. I can see that snt_isn and rcv_isn are stored in the tcp_request_sock structure. Is there a way to access the tcp_request_sock structure from the tp structure in getsockopt ()?
thanks in advance bws
No, there is no way for user space to get (or set) sequence numbers via the socket API (e.g. via setsockopt or tcp_info, ...).
The only way to read this is by capturing the trace with tcpdump.