宅内 LAN などのネットワークの実行速度を測ることの出来る「iperf3」というアプリの Windows版の使い方をメモとして残しておくことにします。
■ 「iperf」とは?
「iperf」は、クライアントとサーバーの間のネットワーク帯域幅と実効速度を測定するためのツールです。これを使うことで、新たに設置した機器が期待した性能を発揮出来ているかといった事や、スループット低下のなんらかの原因になったりしていないかといった事を知る手掛かりとすることができます。
iperf は、以下のリンクのサイトからダウンロードすることができます。お使いのプラットフォームに合わせたものを選択して下さい。Windows や Mac を初め、Linux のいくつかのディストリビューションや、iOS、Android用のものなどが用意されています。
Windows版の場合、2020年10月の時点では「3.1.3(2016.6.8 リリース)」が最新バージョンとなるようです。ZIPファイルになっているので任意の場所に解凍してください。但し、コマンドラインで操作する必要があるため、あまり深い階層にしたり日本語のディレクトリには置かない方がよいでしょう。サーバー側とクライアント側それぞれに用意しておく必要があります。
■ サーバー側の準備
現在の Windows 10 では、コマンドプロンプトに代わって Windows PowerShell がデフォルトのシステムコンソールになっているのですが、iperf に関してはコマンドプロンプトで操作した方が簡単なのでそちらで話を進めていきます。(Windows PowerShell でも操作は可能です。)
スタートボタンのメニューから「Windows システムツール」→「コマンドプロンプト」でコマンドプロンプトを立ち上げたら「cd」コマンドを利用して iperf を格納しているディレクトリを指定します。例えば「Utility」フォルダ下の「iperf-3」に格納している場合は、
cd C:\Utility\iperf-3
次に、iperf を「-s」のオプションを付けてサーバーモードで起動します。
iperf3 -s
以下の様な待受中の表示になればサーバーの起動OKです。この場合は 5201番ポートで待ち受け状態にあることを示しています。不都合がある場合は「-p」オプションで別のポートを指定することも可能です。
----------------------------------------------------------- Server listening on 5201 -----------------------------------------------------------
サーバーモードの iperf を終了させる場合は、「Ctrl」+「c」で良いようです。
■ クライアント側の準備
次にクライアント側を準備します。コマンドプロンプトで iperf の格納されたフォルダを指定する所までは同じです。今回はクライアントモードで起動するので、「-c」のオプションを付けて起動します。
iperf3 -c (サーバーアドレス) ※ サーバーアドレスが 192.168.1.11 の場合は、 iperf3 -c 192.168.1.11 と入力
正常にサーバーと接続できればすぐに 10秒間のベンチマークが始まり、サーバー側とクライアント側それぞれのコンソールにログが出力され、再度サーバー側は待ち受け状態になります。
ところが、テストしようとした所、「iperf3: error - unable to connect to server: Connection timed out」でエラーとなってしまいました。ping は通るのにおかしいなと思って原因を探ってみた所、どうやらセキュリティ対策ソフトのファイアウォールが弾いてしまっている様子。一時的にファイアウォールを無効にして再度テストしてみた所、無事に通りました。
こちらは L2スイッチを介してメインPC とサブPC の間の速度を測ってみた際のサーバー側の表示ですが、クライアント側でもほぼ同じ様なログが表示され、標準状態ではベンチマーク中の 1秒毎に流れたトラフィックの量と、10秒間の平均値を見ることができます。
Accepted connection from (クライアント側アドレス), port 57071 [ 5] local (サーバー側アドレス) port 5201 connected to (クライアント側アドレス) port 57072 [ ID] Interval Transfer Bandwidth [ 5] 0.00-1.00 sec 107 MBytes 896 Mbits/sec [ 5] 1.00-2.00 sec 92.2 MBytes 773 Mbits/sec [ 5] 2.00-3.00 sec 107 MBytes 901 Mbits/sec [ 5] 3.00-4.00 sec 108 MBytes 907 Mbits/sec [ 5] 4.00-5.00 sec 109 MBytes 916 Mbits/sec [ 5] 5.00-6.00 sec 105 MBytes 882 Mbits/sec [ 5] 6.00-7.00 sec 110 MBytes 919 Mbits/sec [ 5] 7.00-8.00 sec 107 MBytes 900 Mbits/sec [ 5] 8.00-9.00 sec 109 MBytes 916 Mbits/sec [ 5] 9.00-10.00 sec 108 MBytes 909 Mbits/sec [ 5] 10.00-10.02 sec 1.72 MBytes 913 Mbits/sec - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bandwidth [ 5] 0.00-10.02 sec 0.00 Bytes 0.00 bits/sec sender [ 5] 0.00-10.02 sec 1.04 GBytes 892 Mbits/sec receiver
サーバー側は「Ctrl」+「c」で終了させるまでずっと待機中のままですが、クライアント側はベンチが終われば勝手にコネクションを切って終了します。
■ iperf3 のコマンド一覧
ちなみに「-h」とすると iperf3 で使えるオプションコマンドの一覧を見ることができます。
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 -F, --file name xmit/recv the specified file -B, --bindbind to a specific interface -V, --verbose more detailed output -J, --json output in JSON format --logfile f send output to a log file -d, --debug emit debugging output -v, --version show version information and quit -h, --help show this message and quit Server specific: -s, --server run in server mode -D, --daemon run the server as a daemon -I, --pidfile file write PID file -1, --one-off handle one client connection then exit Client specific: -c, --client run in client mode, connecting to -u, --udp use UDP rather than TCP -b, --bandwidth #[KMG][/#] target bandwidth in bits/sec (0 for unlimited) (default 1 Mbit/sec for UDP, unlimited for TCP) (optional slash and packet count for burst mode) -t, --time # time in seconds to transmit for (default 10 secs) -n, --bytes #[KMG] number of bytes to transmit (instead of -t) -k, --blockcount #[KMG] number of blocks (packets) to transmit (instead of -t or -n) -l, --len #[KMG] length of buffer to read or write (default 128 KB for TCP, 8 KB for UDP) --cport bind to a specific client port (TCP and UDP, default: ephemeral port) -P, --parallel # number of parallel client streams to run -R, --reverse run in reverse mode (server sends, client receives) -w, --window #[KMG] set window size / socket buffer size -M, --set-mss # set TCP/SCTP maximum segment size (MTU - 40 bytes) -N, --no-delay set TCP/SCTP no delay, disabling Nagle's Algorithm -4, --version4 only use IPv4 -6, --version6 only use IPv6 -S, --tos N set the IP 'type of service' -Z, --zerocopy use a 'zero copy' method of sending data -O, --omit N omit the first n seconds -T, --title str prefix every output line with this string --get-server-output get results from server --udp-counters-64bit use 64-bit counters in UDP test packets [KMG] indicates options that support a K/M/G suffix for kilo-, mega-, or giga- iperf3 homepage at: http://software.es.net/iperf/ Report bugs to: https://github.com/esnet/iperf
接続ポートの指定の他、jsonフォーマットでベンチ結果のファイル出力などをさせることが可能です。
以上のように、iperf を使って PC間のスループットを計測したり、VPNで接続した回線の状況を調べるなどネットワークパフォーマンスの測定を行うことができます。ルーターの性能差を見たりするのにも良さそうですね。
ちなみに iOS、iPad OS版のクライアントアプリは以下のリンクから入手することが出来ます。