liunx下載地址:ftp://ftp.netperf.org/netperf/數據庫
windows版下載地址:ftp://ftp.netperf.org/netperf/misc/windows
這裏我下載版本:netperf-2.6.0.tar.gzbash
[root@localhost home]# tar -zxvf netperf-2.6.0.tar.gz [root@localhost home]# cd netperf-2.6.0/ [root@localhost netperf-2.6.0]# ./configure [root@localhost netperf-2.6.0]# make&& make install [root@localhost ~]# netperf -V Netperf version 2.6.0
Netperf是一種網絡性能的測量工具,能夠測試基於TCP或UDP吞吐、響應速率。Netperf包括Clien和Server端。Server端主要用來實現監聽工做,Client端進行測試。根據流量傳輸方式可分爲如下三種:服務器
1)單方向最大吞吐傳輸大量數據。網絡
2)雙方向交互傳輸數據,對於tcp爲單鏈接。socket
3)針對tcp,每一個鏈接交互傳輸數據。tcp
Netperf服務端使用命令爲netserver。netserver默認監聽端口爲12865。netserver可選項較少,經常使用-p指定監聽端口。-h能夠查看可選項。ide
[root@localhost ~]# netserver Starting netserver with host'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC
[root@localhost tmp]# netserver -p 1180 Starting netserver with host'IN(6)ADDR_ANY' port '1180' and family AF_UNSPEC
Netperf客戶端使用命令就是netperf。netperf使用語法:svn
netperf <全局選項> -- <特指選項>工具
這裏舉例介紹幾種常見使用場景來演示netperf使用:
[root@localhost ~]# netperf -t TCP_STREAM -H 192.168.0.221 -l 10 -P 1180 MIGRATED TCP STREAM TEST from 0.0.0.0(0.0.0.0) port 0 AF_INET to 192.168.0.221 () port 0 AF_INET Recv Send Send Socket Socket Message Elapsed Size Size Size Time Throughput bytes bytes bytes secs. 10^6bits/sec 87380 16384 16384 10.00 4586.58
測試結果:吞吐爲4.5G/s。
-t: 指定進行的測試類型,包括TCP_STREAM,UDP_STREAM,TCP_RR,TCP_CRR,UDP_RR。能夠省略,省略即爲TCP_STEAM。
-H:指定遠程主機,即netserver服務器地址。
-l: 指定時間。
-p:指定netserver監聽端口,能夠省略,省略即爲默認端口12865。
[root@localhost ~]# netperf -t UDP_STREAM -H 192.168.0.221 -l 10 MIGRATED UDP STREAM TEST from 0.0.0.0(0.0.0.0) port 0 AF_INET to 192.168.0.221 () port 0 AF_INET Socket Message Elapsed Messages Size Size Time Okay Errors Throughput bytes bytes secs # # 10^6bits/sec 212992 65507 10.00 78233 0 4099.59 212992 10.00 74263 3891.55
測試結果:
第一行表示本地吞吐4.0G/s,第二行表示接收端吞吐只有3.8G/s。
[root@localhost ~]# netperf -t TCP_RR -H 192.168.0.221 -l 10 -- -r 256,2048 MIGRATED TCP REQUEST/RESPONSE TEST from0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.0.221 () port 0 AF_INET : firstburst 0 Local /Remote Socket Size Request Resp. Elapsed Trans. Send Recv Size Size Time Rate bytes Bytes bytes bytes secs. per sec 16384 87380 256 2048 10.00 6020.25 16384 87380
測試結果:第一行顯示:每秒達6k響應。第二行只是顯示服務器端信息。
-r:指定客戶端發送數據大小和服務器端響應數據大小。例子中客戶端每次發送tcp數據256字節,服務器每次回覆2048字節。
[root@localhost ~]# netperf -t UDP_RR -H 192.168.0.221 -l 10 -- -r 256,2048 MIGRATED UDP REQUEST/RESPONSE TEST from0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.0.221 () port 0 AF_INET : firstburst 0 Local /Remote Socket Size Request Resp. Elapsed Trans. Send Recv Size Size Time Rate bytes Bytes bytes bytes secs. per sec 212992 212992 256 2048 10.00 5385.92 212992 212992
[root@localhost ~]# netperf -t TCP_CRR -H 192.168.0.221 -l 10 -- -r 128,1024 MIGRATED TCP Connect/Request/Response TESTfrom 0.0.0.0 (0.0.0.0) port 0 AF_INET to 192.168.0.221 () port 0 AF_INET Local /Remote Socket Size Request Resp. Elapsed Trans. Send Recv Size Size Time Rate bytes Bytes bytes bytes secs. per sec 16384 87380 128 1024 10.00 2623.44 16384 87380
測試結果:比沒有每次建鏈接響應速率少一半。
參數 |
說明 |
-s size |
設置本地系統的socket發送與接收緩衝大小 |
-S size |
設置遠端系統的socket發送與接收緩衝大小 |
-m size |
設置本地系統發送測試分組的大小 |
-M size |
設置遠端系統接收測試分組的大小 |
-D |
設置TCP_NODELAY選項 |
-r req,resp |
設置request和reponse分組的大小 |
官方用戶手冊:http://www.netperf.org/svn/netperf2/trunk/doc/netperf.pdf