iperf は、TCP/UDPのネットワーク最大帯域幅パフォーマンスを測定できるベンチマークツールです。今回、iperf3 を使ってみたので記録しておきます。
バージョンについて
iperf は現在、iperf2 と iperf3 があります。以下に示しますが、iperf 2 は古く、現在 iperf3 にて開発が進められているようです。ですが、iperf3 も頻繁に更新されている訳ではなさそうです。(ベンチマークツールですので、そもそも頻繁な更新が必要なものではないとも考えられますが。)
ツール | 現在のバージョン | 最新更新日 | URL |
iperf2 | iperf 2.0.5 | 2010/07/09 | http://sourceforge.net/projects/iperf/ |
iperf3 | iperf 3.0 b5 (まだベータ版です) | 2013/03/28 | http://code.google.com/p/iperf/ |
iperf3 はスクラッチから新しくコーディングされたようで、iperf2 との後方互換はないようです。
今回は、iperf3 を使いました。
テスト環境
今回のテストでは、以下のようなテスト環境になります。
サーバー、クライアント共に、CentOSを使いました。
iperf3 は、Linux環境での実行プログラムとなりますので、Windows環境で使う場合は、別のプログラムを使う必要がありそうです。iperf3を使ったプログラムもいくつかあるようですが、現時点では試していません。
インストール
iperf3 のインストールは、ソースから導入しました。インストール手順の抜粋は以下になります。
# cd /usr/local/src # wget https://iperf.googlecode.com/files/iperf-3.0b5.tar.gz # sha1sum iperf-3.0b5.tar.gz cad3c9390814a53ab718710e9454513f8215113a iperf-3.0b5.tar.gz # # tar zxvf iperf-3.0b5.tar.gz # cd iperf-3.0b5 # ./configure # make # make check # make install # which iperf3 /usr/local/bin/iperf3 #
ちなみに「make check」では、以下のエラーが出ましたが、今回はそのままにしておきました。
# make check Making check in src make[1]: Entering directory `/usr/local/src/iperf-3.0b5/src' make check-TESTS make[2]: Entering directory `/usr/local/src/iperf-3.0b5/src' PASS: t_timer t_units: t_units.c:30: main: Assertion `1000.0 * 0.5 == unit_atof("0.5k")' failed. /bin/sh: line 4: 15515 Aborted ${dir}$tst FAIL: t_units cookie: '(省略)' PASS: t_uuid ================================================== 1 of 3 tests failed Please report to iperf-users@lists.sourceforge.net ================================================== make[2]: *** [check-TESTS] Error 1 make[2]: Leaving directory `/usr/local/src/iperf-3.0b5/src' make[1]: *** [check-am] Error 2 make[1]: Leaving directory `/usr/local/src/iperf-3.0b5/src' make: *** [check-recursive] Error 1 #
iperf3 は、「/usr/local/bin/iperf3」にインストールされます。
iperf3 の実行
まず、サーバ側で iperf3 を Server Mode で起動します。オプション「-s」を付けると Server Mode になります。
[サーバー側]# iperf3 -s ----------------------------------------------------------- Server listening on 5201
デフォルトでは、5201 ポートで起動します。
次に、クライアント側で iperf3 を Client Mode で起動します。オプション「-c」を付けて、サーバを指定して起動します。
もし、クライアント側から、サーバ側へ接続できない場合は、以下のようなエラーが出ます。
[クライアント側]# iperf3 -c (サーバーアドレス) iperf3: error - unable to connect to server: No route to host #
今回の環境では、都合上、サーバを8080ポートで起動しました。
[サーバー側]# iperf3 -s -p 8080 ----------------------------------------------------------- Server listening on 8080 -----------------------------------------------------------
次に、クライアント側で以下のオプションで iperf3 を起動すると、10秒でベンチマークが行われました。
[クライアント側]# iperf3 -c (サーバーアドレス) -p 8080 Connecting to host (サーバーアドレス), port 8080 [ 4] local (クライアントアドレス) port 58395 connected to (サーバーアドレス) port 8080 [ ID] Interval Transfer Bandwidth Retransmits [ 4] 0.00-10.00 sec 120 MBytes 101 Mbits/sec 2107 [ ID] Interval Transfer Bandwidth Retransmits Sent [ 4] 0.00-10.00 sec 120 MBytes 101 Mbits/sec 2107 Received [ 4] 0.00-10.00 sec 117 MBytes 97.9 Mbits/sec iperf Done. [クライアント側]#
上記のように、クライアント側で実行すると、サーバー側では以下のようにコンソール出力され、再度待ち受け状態になります。
[サーバー側]# iperf3 -s -p 8080 ----------------------------------------------------------- Server listening on 8080 ----------------------------------------------------------- Accepted connection from (クライアントアドレス), port 58394 [ 5] local (サーバーアドレス) port 8080 connected to (クライアントアドレス) port 58395 [ ID] Interval Transfer Bandwidth Retransmits [ 5] 0.00-10.05 sec 117 MBytes 97.4 Mbits/sec 0 [ ID] Interval Transfer Bandwidth Retransmits Sent [ 5] 0.00-10.05 sec 120 MBytes 100 Mbits/sec 0 Received [ 5] 0.00-10.05 sec 117 MBytes 97.4 Mbits/sec ----------------------------------------------------------- Server listening on 8080 -----------------------------------------------------------
今回の環境は、サーバー側とクライアント側は、それぞれインターネット上のVPSサービスを利用しており、インターネット経由での試験になります。(各サーバー間でどのくらいスピードが出るのかを見てみた、という感じです。)
iperf3 実行オプション
iperf3 の実行オプションは以下になります。
# iperf3 --help Usage: iperf [-s|-c host] [options] iperf [-h|--help] [-v|--version] Server or Client: -p, --port # server port to listen on/connect to -f, --format [kmgKMG] format to report: Kbits, Mbits, KBytes, MBytes -i, --interval # seconds between periodic bandwidth reports -V, --verbose more detailed output -J, --json output in JSON format -d, --debug debug mode -v, --version show version information and quit -h, --help show this message and quit Server specific: -s, --server run in server mode Client specific: -c, --client run in client mode, connecting to -u, --udp use UDP rather than TCP -b, --bandwidth #[KMG] for UDP, bandwidth to send at in bits/sec (default 1 Mbit/sec) -t, --time # time in seconds to transmit for (default 10 secs) -n, --num #[KMG] number of bytes to transmit (instead of -t) -l, --len #[KMG] length of buffer to read or write (default 128 KB for TCP, 8 KB for UDP) -P, --parallel # number of parallel client streams to run -R, --reverse run in reverse mode (server sends, client receives) -w, --window #[KMG] TCP window size (socket buffer size) -B, --bind bind to a specific interface or multicast address -M, --set-mss # set TCP maximum segment size (MTU - 40 bytes) -N, --nodelay set TCP no delay, disabling Nagle's Algorithm -6, --version6 use IPv6 -S, --tos N set the IP 'type of service' -Z, --zerocopy use a 'zero copy' method of sending data [KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga- Report bugs to <iperf-users@lists.sourceforge.net> #
クライアント側で「-i 1」や「-P 2」「-V」「-N」等を指定して実行してみると、また違った結果を確認できます。
あとがき
iperf3 を利用するケースとしては、新しいインフラを構築した時や設定を変更した時の、サーバー間のスループット測定(サーバ自体のI/F速度や、間にあるスイッチなどのネットワーク機器を含めたスループット測定)を行いたい時になると思います。
iperf3 は実際にファイルを送る事はしないで、ネットワークパフォーマンスを測定します。また、TCP/UDPの指定や、オプションの使い分け、実行結果の読み取り方などを学んでおくなど、iperf3 の特徴を理解して使う必要があると思います。とても便利そうなツールなので、必要に応じて使っていきたいと思います。