Linux性能检查(三)网络

Linux性能检查(三)网络

我们可以通过 ethtool 工具来查看网卡的配置和工作模式:
>/sbin/ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Half 1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                         100baseT/Half 100baseT/Full
                                         1000baseT/Half 1000baseT/Full
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: d
        Current message level: 0x000000ff (255)
        Link detected: yes
说明网卡有 10baseT,100baseT 和 1000baseT 三种选择,目前正自适应为 100baseT(Speed: 100Mb/s)。

iptraf
iptraf 就是一个很好的查看本机网络吞吐量的好工具
[root@cd5 ~]# iptraf -d eth
-bash: iptraf: command not found
安装该工具
>yum install iptraf

netperf
略过

iperf
略过

tcpdump 和 tcptrace
先用 tcpdump 按要求捕获数据包把结果输出到某一文件,然后再用 tcptrace 分析其文件格式。
>/usr/sbin/tcpdump -w network.dmp
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes

安装tcptrace工具
首页:http://www.tcptrace.org/download.html
解开压缩
>tar zxvf tcptrace-6.6.7.tar.gz
>mv tcptrace-6.6.7 /opt/
>cd /opt/tcptrace-6.6.7/
>./configure
>make
出错提示:
tcpdump.c:66:18: error: pcap.h: No such file or directory
tcpdump.c:72: error: expected declaration specifiers or ‘...’ before ‘pcap_handler’
tcpdump.c:75: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
tcpdump.c: In function ‘callback’:
tcpdump.c:100: error: dereferencing pointer to incomplete type
tcpdump.c:104: error: ‘pcap’ undeclared (first use in this function)
tcpdump.c:104: error: (Each undeclared identifier is reported only once
tcpdump.c:104: error: for each function it appears in.)
tcpdump.c: In function ‘pread_tcpdump’:
tcpdump.c:251: error: ‘pcap’ undeclared (first use in this function)
tcpdump.c:251: error: ‘pcap_handler’ undeclared (first use in this function)
tcpdump.c:251: error: expected ‘)’ before ‘callback’
解决方案,安装libpcap
下载文件:
http://www.tcpdump.org/release/
>tar zxvf libpcap-1.1.1.tar.gz
>mv libpcap-1.1.1 /opt/
>./configure
>make
>make install
问题解决。

继续make tcptrace的包
>cd /opt/tcptrace-6.6.7/
>make
>make install

安装成功后,直接执行命令
>tcptrace network.dmp
报错如下:
tcptrace: error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or directory
解决方法,在libpcap里面查找这个文件:
[root@localhost libpcap-1.1.1]# ls *.so.*
libpcap.so.1.1.1
拷贝该文件过去:
>cp libpcap.so.1.1.1 /usr/lib/libpcap.so.1
问题解决,执行命令
>tcptrace network.dmp
[root@localhost tmp]# tcptrace network.dmp
1 arg remaining, starting with 'network.dmp'
Ostermann's tcptrace -- version 6.6.7 -- Thu Nov  4, 2004

4 packets seen, 4 TCP packets traced
elapsed wallclock time: 0:00:05.403615, 0 pkts/sec analyzed
trace file elapsed time: 0:00:30.744403
TCP connection info:
  1: 192.168.56.104:pcanywherestat - 192.168.56.101:53290 (a2b)    2>    2<

参考:
http://www.blogjava.net/cssseek/archive/2010/10/29/335797.html

你可能感兴趣的:(C++,c,linux,C#,bash)