在Linux上提取TCP往返时间(RTT)估计 [英] Extract TCP round trip time (RTT) estimations on linux

查看:412
本文介绍了在Linux上提取TCP往返时间(RTT)估计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在Ubuntu上运行的apache服务器.客户端连接并下载图像.我需要提取基础TCP连接的RTT估算值.有没有办法做到这一点?也许像在调试模式下运行我的tcp堆栈以使其将此信息记录到某处?

I have apache server running on Ubuntu. Client connects and downloads an image. I need to extract RTT estimations for the underlying TCP connection. Is there a way to do this? Maybe something like running my tcp stack in debug mode to have it log this info somewhere?

请注意,我不想运行tcpdump并从记录的跟踪中提取RTT!我需要TCP堆栈的RTT估算值(显然,这是您可以通过TCP_INFO套接字选项获得的信息的一部分).基本上需要像tcpprob(kprobe)这样的东西来插入一个钩子,并记录每个传入数据包(或每次更改)上TCP连接的估计RTT.

Note that I don't want to run tcpdump and extract RTTs from the recorded trace! I need the TCP stack's RTT estimations (apparently this is part of the info you can get with TCP_INFO socket option). Basically need something like tcpprob (kprobe) to insert a hook and record the estimated RTT of the TCP connection on every incoming packet (or on every change).

更新:

我找到了解决方案.可以使用tcpprobe记录rtt,拥塞窗口等.我在下面发布了答案.

I found a solution. rtt, congestion window and more can be logged using tcpprobe. I posted an answer below.

推荐答案

这可以使用 tcpprobe ,这是一个使用 kprobe 将钩子插入tcp_recv处理路径的模块,用于记录TCP连接的状态响应传入的数据包.

This can be done using tcpprobe, which is a module that inserts a hook into the tcp_recv processing path using kprobe records the state of a TCP connection in response to incoming packets.

假设您要在端口443上探测tcp连接,则需要执行以下操作:

Let's say you want to probe tcp connection on port 443, you need to do the following:

sudo modprobe tcp_probe port=443 full=1
sudo chmod 444 /proc/net/tcpprobe
cat /proc/net/tcpprobe > /tmp/output.out &
pid=$!

完整= 1 :登录收到的每个ack数据包

full=1: log on every ack packet received

完全= 0 :仅登录公寓更改(如果使用此选项,则您的输出可能为空)

full=0: log on only condo changes (if you use this your output might be empty)

现在 pid 是记录探针的过程.要停止,只需终止此过程即可:

Now pid is the process which is logging the probe. To stop, simply kill this process:

kill $pid

output.out的格式(根据在198行):

The format of output.out (according to the source at line 198):

[time][src][dst][length][snd_nxt][snd_una][snd_cwnd][ssthresh][snd_wnd][srtt][rcv_wnd]

这篇关于在Linux上提取TCP往返时间(RTT)估计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆