如今Linux平臺下各類管理工具很是多,有的功能強大塊頭也不小,有的功能能夠知足通常需求且塊頭很小,我本身通常比較喜歡後者。在這個系列文章中將給你們介紹一些我知道的Linux中的一些小工具,也歡迎你們來補充。php
這篇先介紹幾個網絡測試的小工具:網絡
1、ethtool:查看網卡工做模式
testsrv:~# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
#說明eth0有10baseT、100baseT和1000baseT 三種選擇。
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
#目前正工做在1000baseT 模式。
Speed: 1000Mb/s
#全雙功。
Duplex: Full
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000033 (51)
Link detected: yes
2、iptraf:查看本機網絡吞吐量
testsrv:~# iptraf -d eth0
3、iperf:詳細查看本機網絡吞吐量。
iperf是一個C/S模式的小工具,也就是說要使用該功能時,必須2臺被測試計算機,其中1臺運行iperf的服務,在另1臺上使用iperf查看網絡吞吐量。在選擇iperf服務的計算機使用iperf -D -s啓動iperf所需服務後,在另1臺計算機上使用以下命令便可查看網絡吞吐量。
#每10秒進行一次測試,共測試60秒時間。
testsrv:~# iperf -c 192.168.1.254 -t 60 -i 10
------------------------------------------------------------
Client connecting to 192.168.1.254, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.1.253 port 41960 connected with 192.168.1.254 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 1.08 GBytes 926 Mbits/sec
[ 3] 10.0-20.0 sec 1.08 GBytes 926 Mbits/sec
[ 3] 0.0-28.9 sec 3.11 GBytes 925 Mbits/sec
固然還有tcpdump 和 tcptrace 這樣提供更細緻的分析方法,通常能夠用 tcpdump 按要求捕獲數據包並把結果保存到一個文件中,而後使用用tcptrace分析其文件格式。這個工具組合能夠提供一些難以用其餘工具發現的信息