我需要在 socket(AF_INET
, SOCK_RAW
, IPPROTO_TCP
) 方式中设置或获取 RTT。
在socket编程中要控制这样的RTT,接下来需要做什么?也就是说,如何找到这样的RTT参数?
最佳答案
在 Linux 上,您可以通过使用 TCP_INFO
调用 getsockopt()
来获取 RTT:
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
/* ... */
tcp_info info;
socklen_t tcp_info_length = sizeof info;
ret = getsockopt(sock, SOL_TCP, TCP_INFO, &info, &tcp_info_length);
printf("rtt: %u microseconds\n", info.tcpi_rtt);
关于linux - 如何在 linux 套接字编程中设置/获取套接字 RTT?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30979301/