I would like to find the TCP payload activity counter (total number of bytes) for either a given file descriptor or for a given interface. Preferably, this file descriptor, but for the interface would be sufficient. Ideally, I would really like to know about any bytes that were found, even those that I have not read in user space yet (yet?).
I saw the TCP_INFO getsockopt() function, but none of the fields store "Total bytes received" or "Total transmitted bytes (for example)", as far as I can tell.
I also saw the netlink fields IFLA_STATS + RTNL_TC_BYTES and SIOCETHTOOL + ETHTOOL_GSTATS ioctl() ( rx_bytes ) for interfaces, and they are great, but I don’t know that they can distinguish between service / headers of other levels and actual payload bytes.
procfs has /proc/net/tcp , but that doesn't seem to contain what I'm looking for.
Is there any way to get this data?
EDIT: Messy mode has an unbearable effect on throughput, so I can't use everything that uses it. Not to mention the fact that introducing large parts of the IP stack to determine which packets are suitable goes beyond my intended use for this solution.
The goal is to have a comprehensive / no-trust / second guess about what values ​​are stored in recvmsg ().
The Right Thing ™ is keeping track of these values ​​correctly, but it would be helpful to have a simple “Hey OS”. How many bytes did I really get on this socket? "
linux networking tcp
Brian cain
source share