I'm interesting in obtaining, in userspace, the number of unacked sequence numbers (and ideally the last/last acked sequence numbers themselves) for a given (TCP) socket.
With Linux I can do this, partially at least (only the unacked count), using getsockopt TCP_INFO and getting back a struct tcp_info from /usr/include/linux/net.h.
Couple questions:
1) is there another way on Linux that might give me more info, short of libpcap'ing my own connection? Ideally I'd like the sequence numbers themselves, not just the unacked count.
2) is there a library to do this portable on different operating systems?
3) if not 2, how do I do this on $YOUR_OS so I can write a library.
Thanks!
P.S. In Perl, it looks like:
sub unacked { my ($sock) = @_; my $IPPROTO_TCP = 6; my $TCP_INFO = 11; my $data = getsockopt($sock, $IPPROTO_TCP, $TCP_INFO); die "no data" unless defined $data; # tcpi_unacked (u32) from struct tcp_info return unpack("L", substr($data, 24, 4)); }