I'm using Linux kernel 2.6.32 (x86_64) and can get TCP statistics by passing TCP_INFO to getsockopt and receiving a tcp_info struct, which is defined in /usr/include/netinet/tcp.h.

Can I get similar statistics for UDP? (possibly fewer because there's no built-in congestion control and retransmission etc. but I'm satisfied with any statistics that I can get)

有帮助吗?

解决方案

TCP_INFO literally means info for TCP. The reason there aren't info for UDP is because it's stateless. There's no guaranteed transfer, not rtf, no window size, no much info to provide about.

If you really wanna grab some extra info, take a look at man 2 recvmsg, especially this

Ancillary data should only be accessed by the macros defined in cmsg

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top