簡(jiǎn)介
很多公司都在將自己的無(wú)線網(wǎng)絡(luò)升級(jí)到802.11n,以實(shí)現(xiàn)更大的吞吐量、更廣的覆蓋范圍和更高的可靠性,然而保證無(wú)線LAN(WLAN)的性能對(duì)于確保足夠的網(wǎng)絡(luò)容量和覆蓋率尤為重要。下面,我們將探討如何通過(guò)iPerf來(lái)測(cè)定網(wǎng)絡(luò)性能,這是一個(gè)簡(jiǎn)單易用測(cè)量TCP/UDP的吞吐量、損耗和延遲的工具。
軟件安裝
# ubuntu系統(tǒng)
sudo apt install iperf
說(shuō)明:不同的系統(tǒng)安裝方式不同,這里只介紹ubuntu系統(tǒng)
使用介紹
案例一:工具檢驗(yàn)測(cè)試
啟動(dòng)一個(gè)串口,輸入指令
iperf -s
# 開(kāi)啟iperf服務(wù)端
效果如下:
啟動(dòng)另一個(gè)窗口,輸入指令
iperf -c 127.0.0.1
# 作為客戶(hù)端運(yùn)行,測(cè)試10s回環(huán)通信數(shù)據(jù)
測(cè)試結(jié)果如下:
??
上面的例子只是簡(jiǎn)單測(cè)試了回環(huán)通信的吞吐量,如果顯示正常,說(shuō)明iperf安裝和運(yùn)行均正常。
案例二:TCP通信測(cè)試
先關(guān)閉上面的測(cè)試窗口,或結(jié)束上面的服務(wù)程序,我們這里還是以127.0.0.1作回環(huán)測(cè)試,時(shí)間應(yīng)用場(chǎng)景中只需要把IP地址替換為對(duì)應(yīng)服務(wù)端的IP地址即可
啟動(dòng)服務(wù)端,輸入指令
iperf -s -b 7M -i 5
# 作為服務(wù)端運(yùn)行,帶寬7M,報(bào)告回顯間隔時(shí)間5s
效果如下
打開(kāi)新的terminal,啟動(dòng)客戶(hù)端,輸入指令
iperf -c 127.0.0.1 -b 7M -i 5 -t 30
#作為客戶(hù)端,連接服務(wù)端ip地址127.0.0.1,帶寬7M,與服務(wù)端保持一致,報(bào)告回顯間隔5s,測(cè)試時(shí)間30s
測(cè)試效果如下:
我們這里測(cè)試吞吐量的結(jié)果為7.34M左右,是因?yàn)槲覀兿拗屏藴y(cè)試數(shù)據(jù)的帶寬就是7M,我們做的回環(huán)測(cè)試,實(shí)際回環(huán)的吞吐量應(yīng)該是G為單位,測(cè)試過(guò)程中,如果發(fā)現(xiàn)測(cè)試的帶寬與限制帶寬接近,說(shuō)明限制設(shè)置的太小了,需要適當(dāng)調(diào)整-b參數(shù),或者參考硬件廠家給的指標(biāo)測(cè)試。
案例三:UDP測(cè)試
先關(guān)閉上面的測(cè)試窗口,或結(jié)束上面的服務(wù)程序,我們這里還是以127.0.0.1作回環(huán)測(cè)試,時(shí)間應(yīng)用場(chǎng)景中只需要把IP地址替換為對(duì)應(yīng)服務(wù)端的IP地址即可
啟動(dòng)服務(wù)端,輸入指令
iperf -s -u -b 7M -i 5
# 作為UDP服務(wù)端啟動(dòng)iperf,限制帶寬7M,報(bào)告回顯時(shí)間間隔5s
效果如下:
啟動(dòng)客戶(hù)端,輸入指令
iperf -u -c 127.0.0.1 -b 7M -i 5 -t 30
測(cè)試效果如下:
我們這里測(cè)試吞吐量的結(jié)果為7.34M左右,是因?yàn)槲覀兿拗屏藴y(cè)試數(shù)據(jù)的帶寬就是7M,我們做的回環(huán)測(cè)試,實(shí)際回環(huán)的吞吐量應(yīng)該是G為單位,測(cè)試過(guò)程中,如果發(fā)現(xiàn)測(cè)試的帶寬與限制帶寬接近,說(shuō)明限制設(shè)置的太小了,需要適當(dāng)調(diào)整-b參數(shù),或者參考硬件廠家給的指標(biāo)測(cè)試。
此時(shí)服務(wù)端顯示內(nèi)容如下:
我們可以看到服務(wù)端還可以顯示通信延時(shí)Jitter(在連續(xù)傳輸中的平滑平均值差)和丟包率:Lost/Total Data
詳細(xì)解讀
我們可以直接參考系統(tǒng)自帶的幫助文檔,如下:
iperf -h
Usage: iperf [-s|-c host] [options]
iperf [-h|--help] [-v|--version]
Client/Server:
-b, --bandwidth #[kmgKMG | pps] bandwidth to send at in bits/sec or packets per second
-e, --enhancedreports use enhanced reporting giving more tcp/udp and traffic information
-f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes
-i, --interval # seconds between periodic bandwidth reports
-l, --len #[kmKM] length of buffer in bytes to read or write (Defaults: TCP=128K, v4 UDP=1470, v6 UDP=1450)
-m, --print_mss print TCP maximum segment size (MTU - TCP/IP header)
-o, --output <filename> output the report or error message to this specified file
-p, --port # server port to listen on/connect to
-u, --udp use UDP rather than TCP
--udp-counters-64bit use 64 bit sequence numbers with UDP
-w, --window #[KM] TCP window size (socket buffer size)
-z, --realtime request realtime scheduler
-B, --bind <host>[:<port>][%<dev>] bind to <host>, ip addr (including multicast address) and optional port and device
-C, --compatibility for use with older versions does not sent extra msgs
-M, --mss # set TCP maximum segment size (MTU - 40 bytes)
-N, --nodelay set TCP no delay, disabling Nagle's Algorithm
-S, --tos # set the socket's IP_TOS (byte) field
Server specific:
-s, --server run in server mode
-t, --time # time in seconds to listen for new connections as well as to receive traffic (default not set)
--udp-histogram #,# enable UDP latency histogram(s) with bin width and count, e.g. 1,1000=1(ms),1000(bins)
-B, --bind <ip>[%<dev>] bind to multicast address and optional device
-H, --ssm-host <ip> set the SSM source, use with -B for (S,G)
-U, --single_udp run in single threaded UDP mode
-D, --daemon run the server as a daemon
-V, --ipv6_domain Enable IPv6 reception by setting the domain and socket to AF_INET6 (Can receive on both IPv4 and IPv6)
Client specific:
-c, --client <host> run in client mode, connecting to <host>
-d, --dualtest Do a bidirectional test simultaneously
--ipg set the the interpacket gap (milliseconds) for packets within an isochronous frame
--isochronous <frames-per-second>:<mean>,<stddev> send traffic in bursts (frames - emulate video traffic)
-n, --num #[kmgKMG] number of bytes to transmit (instead of -t)
-r, --tradeoff Do a bidirectional test individually
-t, --time # time in seconds to transmit for (default 10 secs)
-B, --bind [<ip> | <ip:port>] bind ip (and optional port) from which to source traffic
-F, --fileinput <name> input the data to be transmitted from a file
-I, --stdin input the data to be transmitted from stdin
-L, --listenport # port to receive bidirectional tests back on
-P, --parallel # number of parallel client threads to run
-R, --reverse reverse the test (client receives, server sends)
-T, --ttl # time-to-live, for multicast (default 1)
-V, --ipv6_domain Set the domain to IPv6 (send packets over IPv6)
-X, --peer-detect perform server version detection and version exchange
-Z, --linux-congestion <algo> set TCP congestion control algorithm (Linux only)
Miscellaneous:
-x, --reportexclude [CDMSV] exclude C(connection) D(data) M(multicast) S(settings) V(server) reports
-y, --reportstyle C report as a Comma-Separated Values
-h, --help print this message and quit
-v, --version print version information and quit
[kmgKMG] Indicates options that support a k,m,g,K,M or G suffix
Lowercase format characters are 10^3 based and uppercase are 2^n based
(e.g. 1k = 1000, 1K = 1024, 1m = 1,000,000 and 1M = 1,048,576)
The TCP window size option can be set by the environment variable
TCP_WINDOW_SIZE. Most other options can be set by an environment variable
IPERF_<long option name>, such as IPERF_BANDWIDTH.
Source at <http://sourceforge.net/projects/iperf2/>
Report bugs to <iperf-users@lists.sourceforge.net>
我們抽取我在測(cè)試過(guò)程中用到的一些參數(shù)做一些翻譯和解讀
Client/Server: # 客戶(hù)端和服務(wù)端公有的參數(shù)
帶寬參數(shù),單位:字節(jié)每秒:kmg或者KMG,小寫(xiě)為10的3次方,大寫(xiě)為2的n次方,比如1k=1000,1K=1024,;單位包數(shù)量每秒:pps(packets per second)
-b, --bandwidth #[kmgKMG | pps] bandwidth to send at in bits/sec or packets per second
回顯報(bào)告的間隔時(shí)間
-i, --interval # seconds between periodic bandwidth reports
指定端口號(hào),默認(rèn)為5001
-p, --port # server port to listen on/connect to
udp模式,不帶-u默認(rèn)為tcp模式
-u, --udp use UDP rather than TCP
tcp窗口大小,默認(rèn)無(wú)上限,可以不設(shè)此參數(shù),作為udp模式測(cè)試時(shí)也不需要此參數(shù) ,單位:KM,1K=1024
-w, --window #[KM] TCP window size (socket buffer size)
Server specific: #服務(wù)端私有參數(shù)
指定以服務(wù)端運(yùn)行
-s, --server run in server mode
指定測(cè)試時(shí)間,服務(wù)端一般一直開(kāi)著,不設(shè)此參數(shù)
-t, --time # time in seconds to listen for new connections as well as to receive traffic (default not set)
Client specific: #客戶(hù)端私有參數(shù)
指定以客戶(hù)端運(yùn)行,后面要帶服務(wù)端的IP地址
-c, --client <host> run in client mode, connecting to <host>
指定測(cè)試時(shí)間,不帶參數(shù)默認(rèn)測(cè)試10s
-t, --time # time in seconds to transmit for (default 10 secs)
翻轉(zhuǎn)測(cè)試,iperf2并不支持此功能,無(wú)法使用,可以推薦使用iperf3
-R, --reverse reverse the test (client receives, server sends)
Miscellaneous: #混合參數(shù),指既不是服務(wù)端也不是客戶(hù)端的時(shí)候使用
顯示幫助菜單
-h, --help print this message and quit
顯示版本
-v, --version print version information and quit
·
·
·
歡迎各位老鐵一鍵三連,本號(hào)后續(xù)會(huì)不斷更新樹(shù)莓派、人工智能、STM32、ROS小車(chē)相關(guān)文章和知識(shí)。
大家對(duì)感興趣的知識(shí)點(diǎn)可以在文章下面留言,我可以?xún)?yōu)先幫大家講解哦
歡迎大家光臨我的淘寶小店【玩轉(zhuǎn)智能機(jī)器人】,會(huì)定期推出教程中使用的物美價(jià)優(yōu)的硬件,你的光臨就是對(duì)我的支持文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-460148.html
原創(chuàng)不易,轉(zhuǎn)載請(qǐng)說(shuō)明出處。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-460148.html
到了這里,關(guān)于網(wǎng)絡(luò)測(cè)試工具—— iperf2詳細(xì)使用方法的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!