网络测试工具—— iperf2详细使用方法
簡介
很多公司都在將自己的無線網(wǎng)絡(luò)升級到802.11n,以實(shí)現(xiàn)更大的吞吐量、更廣的覆蓋范圍和更高的可靠性,然而保證無線LAN(WLAN)的性能對于確保足夠的網(wǎng)絡(luò)容量和覆蓋率尤為重要。下面,我們將探討如何通過iPerf來測定網(wǎng)絡(luò)性能,這是一個(gè)簡單易用測量TCP/UDP的吞吐量、損耗和延遲的工具。
軟件安裝
# ubuntu系統(tǒng) sudo apt install iperf說明:不同的系統(tǒng)安裝方式不同,這里只介紹ubuntu系統(tǒng)
使用介紹
案例一:工具檢驗(yàn)測試
啟動(dòng)一個(gè)串口,輸入指令
iperf -s # 開啟iperf服務(wù)端效果如下:
啟動(dòng)另一個(gè)窗口,輸入指令
iperf -c 127.0.0.1 # 作為客戶端運(yùn)行,測試10s回環(huán)通信數(shù)據(jù)測試結(jié)果如下:
??
上面的例子只是簡單測試了回環(huán)通信的吞吐量,如果顯示正常,說明iperf安裝和運(yùn)行均正常。
案例二:TCP通信測試
先關(guān)閉上面的測試窗口,或結(jié)束上面的服務(wù)程序,我們這里還是以127.0.0.1作回環(huán)測試,時(shí)間應(yīng)用場景中只需要把IP地址替換為對應(yīng)服務(wù)端的IP地址即可
啟動(dòng)服務(wù)端,輸入指令
iperf -s -b 7M -i 5 # 作為服務(wù)端運(yùn)行,帶寬7M,報(bào)告回顯間隔時(shí)間5s效果如下
打開新的terminal,啟動(dòng)客戶端,輸入指令
iperf -c 127.0.0.1 -b 7M -i 5 -t 30 #作為客戶端,連接服務(wù)端ip地址127.0.0.1,帶寬7M,與服務(wù)端保持一致,報(bào)告回顯間隔5s,測試時(shí)間30s測試效果如下:
我們這里測試吞吐量的結(jié)果為7.34M左右,是因?yàn)槲覀兿拗屏藴y試數(shù)據(jù)的帶寬就是7M,我們做的回環(huán)測試,實(shí)際回環(huán)的吞吐量應(yīng)該是G為單位,測試過程中,如果發(fā)現(xiàn)測試的帶寬與限制帶寬接近,說明限制設(shè)置的太小了,需要適當(dāng)調(diào)整-b參數(shù),或者參考硬件廠家給的指標(biāo)測試。
案例三:UDP測試
先關(guān)閉上面的測試窗口,或結(jié)束上面的服務(wù)程序,我們這里還是以127.0.0.1作回環(huán)測試,時(shí)間應(yīng)用場景中只需要把IP地址替換為對應(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)客戶端,輸入指令
iperf -u -c 127.0.0.1 -b 7M -i 5 -t 30測試效果如下:
我們這里測試吞吐量的結(jié)果為7.34M左右,是因?yàn)槲覀兿拗屏藴y試數(shù)據(jù)的帶寬就是7M,我們做的回環(huán)測試,實(shí)際回環(huán)的吞吐量應(yīng)該是G為單位,測試過程中,如果發(fā)現(xiàn)測試的帶寬與限制帶寬接近,說明限制設(shè)置的太小了,需要適當(dāng)調(diào)整-b參數(shù),或者參考硬件廠家給的指標(biāo)測試。
此時(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>我們抽取我在測試過程中用到的一些參數(shù)做一些翻譯和解讀
Client/Server: # 客戶端和服務(wù)端公有的參數(shù) 帶寬參數(shù),單位:字節(jié)每秒:kmg或者KMG,小寫為10的3次方,大寫為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 指定端口號,默認(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)無上限,可以不設(shè)此參數(shù),作為udp模式測試時(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 指定測試時(shí)間,服務(wù)端一般一直開著,不設(shè)此參數(shù) -t, --time # time in seconds to listen for new connections as well as to receive traffic (default not set) Client specific: #客戶端私有參數(shù) 指定以客戶端運(yùn)行,后面要帶服務(wù)端的IP地址 -c, --client <host> run in client mode, connecting to <host> 指定測試時(shí)間,不帶參數(shù)默認(rèn)測試10s -t, --time # time in seconds to transmit for (default 10 secs) 翻轉(zhuǎn)測試,iperf2并不支持此功能,無法使用,可以推薦使用iperf3 -R, --reverse reverse the test (client receives, server sends) Miscellaneous: #混合參數(shù),指既不是服務(wù)端也不是客戶端的時(shí)候使用 顯示幫助菜單 -h, --help print this message and quit 顯示版本-v, --version print version information and quit·
·
·
歡迎各位老鐵一鍵三連,本號后續(xù)會(huì)不斷更新樹莓派、人工智能、STM32、ROS小車相關(guān)文章和知識。
大家對感興趣的知識點(diǎn)可以在文章下面留言,我可以優(yōu)先幫大家講解哦
歡迎大家光臨我的淘寶小店【玩轉(zhuǎn)智能機(jī)器人】,會(huì)定期推出教程中使用的物美價(jià)優(yōu)的硬件,你的光臨就是對我的支持
原創(chuàng)不易,轉(zhuǎn)載請說明出處。
總結(jié)
以上是生活随笔為你收集整理的网络测试工具—— iperf2详细使用方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端学习(2664):vue3.0的to
- 下一篇: 工作207:修改表头按钮样式