2011-08-05 122 views
6

我有一个小办公室网络,并且遇到巨大的互联网链接延迟。我们有一个简单的网络拓扑结构:配置为运行Ubuntu 10.10服务器的路由器,2个网卡(一个连接到互联网,另一个连接到办公网络)和一台连接20台计算机的交换机。我在路由器上收集了一个巨大的tcpdump日志,我想绘制一个直方图,其RTT时间为,全部为 TCP流,以尝试找出此延迟问题的最佳解决方案。那么,有人可以告诉我如何使用wireshark或其他工具来做到这一点吗?使用wireshark或其他工具绘制RTT直方图

回答

11

Wireshark的或tshark的可以给你TCP RTT为每个接收到使用tcp.analysis.ack_rtt其测量捕获一个TCP包和用于该数据包的ACK之间的时间增量ACK分组。

你必须要小心,这是大部分的ACK包会您的办公用机员在确认从互联网上接收的数据包,这样你就可以测量RTT路由器之间看到来自互联网的数据包,看到来自你的办公机器的确认。

要测量您的互联网RTT,您需要查找来自互联网的ACK(确认从您的网络发送的数据)。假设你的办公用机有一个像192.168.1.x的IP地址,你已经登录你的路由器的LAN端口上的所有数据,你可以使用显示过滤器,像这样:

tcp.analysis.ack_rtt and ip.dst==192.168.1.255/24 

要转储的RTT成。用于分析的csv,你可以像这样使用tshark命令;

tshark -r router.pcap -Y "tcp.analysis.ack_rtt and ip.dst==192.168.1.255/24" -e tcp.analysis.ack_rtt -T fields -E separator=, -E quote=d > rtt.csv

  • -r选项告诉tshark的从.pcap文件读取
  • -Y选项指定显示过滤器使用(-R而不-2已被弃用)
  • 的-e选项指定输出
  • 了-t选项字段中指定的输出格式

你ç在运行此命令之前,使用mergecap实用程序将所有pcap文件合并到一个文件中。将此输出转换为直方图应该很简单!

-1
 
You can use tshark statistics to create a table of all tcp conversations: 
$ tshark -r test.pcap -q -z conv,tcp 
================================================================================ 
TCP Conversations 
Filter: 
               |    | |  Total  | 
               | Frames Bytes | | Frames Bytes | | Frames Bytes | 
192.168.108.2:2720  147.234.1.253:21   28  2306  18  1047  46  3353 
147.234.1.253:58999  192.168.108.2:2721   3  170  2  122  5  292 
192.168.108.2:2718  147.137.21.94:139   0   0  3  186  3  186 
192.168.108.2:2717  147.137.21.94:445   0   0  3  186  3  186 
================================================================================ 

Or use this little script: 

for file in `ls -1 *.pcap` 
do 
    tshark -r $file -q -z conv,tcp > $file.txt 
done 
+0

我没有看到这个问题的相关性。 – MaxVT

1

这里的5分钟perlscript通过rupello的回答启发:

#!/usr/bin/perl 

# For a live histogram of rtt latencies, save this file as /tmp/x.pl and chmod +x /tmp/x.pl, then run: 
# tshark -i br1 -R "tcp.analysis.ack_rtt and ip.dst==192.168.1.0/24" -e tcp.analysis.ack_rtt -T fields -E separator=, -E quote=d | /tmp/x.pl 
# Don't forget to update the interface "br1" and "and ip.dst==..." bits as appropriate. 

@t[$m=0]=20; 
@t[++$m]=10; 
@t[++$m]=5; 
@t[++$m]=2; 
@t[++$m]=1; 
@t[++$m]=0.9; 
@t[++$m]=0.8; 
@t[++$m]=0.7; 
@t[++$m]=0.6; 
@t[++$m]=0.5; 
@t[++$m]=0.4; 
@t[++$m]=0.3; 
@t[++$m]=0.2; 
@t[++$m]=0.1; 
@t[++$m]=0.05; 
@t[++$m]=0.04; 
@t[++$m]=0.03; 
@t[++$m]=0.02; 
@t[++$m]=0.01; 
@t[++$m]=0.005; 
@t[++$m]=0.001; 
@t[++$m]=0; 

@h[0]=0; 

while (<>) { 
s/\"//g; $n=$_; chomp($n); 
for ($i=$m;$i>=0;$i--) { if ($n<=$t[$i]) { $h[$i]++; $i=-1; }; }; 
if ($i==-1) { $h[0]++; }; 
print "\033c"; 
for (0..$m) { printf "%6s %6s %8s\n",$t[$_],sprintf("%3.2f",$h[$_]/$o*100),$h[$_]; }; 
} 

假如把它放在你的smokeping图和...实用的“的统计瑞士军刀”这一直激励着待机...

tshark的新版本似乎更好地使用“tshark”前面的“stdbuf -i0 -o0 -e0”。

PS有谁知道wireshark是否内置了DNS和ICMP rtt stats或者如何轻松获取这些内容?