EC2でiperfを使ってネットワークスループットを計測してみた。

2014.08.29

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

iperf(アイパーフ)は、ネットワークスループットを測定するためのフリーのソフトウェアです。 Windows版の他にもMac版、Linux版もあります。

iperfの使い方

iperfは、2台のサーバにインストールし、一方をクライアント、もう一方をサーバとして、2つ1組で使用します。

iperf書式
    iperf [-s | -c IPアドレス] [オプション]
  -s サーバモード
  -c クライアントモード -cの後サーバのIPアドレスを指定
    オプションの種類(抜粋)
     -i 指定した秒ごとに測定値を表示
     -p 待受けポート番号を指定(デフォルト:5001)
     -u UDPモードで起動(デフォルト:TCPモード)
     -b UDPの帯域を指定(デフォルト:1Mbps)

※オプションは他にもあります。ヘルプを確認してください。

構成

今回、EC2の2台(t2.micro)の間でiperfを利用して測定してみました。 同じサブネット内で検証しております。

インストール

googleで調べた結果、epelのレポジトリを有効にする必要がありました。

[ec2-user@ip-10-0-11-84 ~]$ sudo yum install iperf --enablerepo=epel
読み込んだプラグイン:priorities, update-motd, upgrade-helper
970 packages excluded due to repository priority protections
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ iperf.x86_64 0:2.0.5-11.el6 を インストール
--> 依存性解決を終了しました。
依存性を解決しました
# 省略
インストール中:
 iperf          x86_64          2.0.5-11.el6            epel           53 k
トランザクションの要約
============================================================================
インストール  1 パッケージ
総ダウンロード容量: 53 k
インストール容量: 122 k
Is this ok [y/d/N]: y
Downloading packages:

警告: /var/cache/yum/x86_64/latest/epel/packages/iperf-2.0.5-11.el6.x86_64.rpm: ヘッダー V3 RSA/SHA256 Signature、鍵 ID 0608b895: NOKEY

iperf-2.0.5-11.el6.x86_64.rpm の公開鍵がインストールされていません
iperf-2.0.5-11.el6.x86_64.rpm                        |  53 kB     00:00     

file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 から鍵を取得中です。
Importing GPG key 0x0608B895:
 Userid     : "EPEL (6) <epel@fedoraproject.org>"
 Fingerprint: 8c3b e96a f230 9184 da5c 0dae 3b49 df2a 0608 b895
 Package    : epel-release-6-8.9.amzn1.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
上記の処理を行います。よろしいでしょうか? [y/N]y

Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : iperf-2.0.5-11.el6.x [################### ] 1/1
  検証中                  : iperf-2.0.5-11.el6.x86_64                   1/1 
インストール:
  iperf.x86_64 0:2.0.5-11.el6                                               
完了しました!
[ec2-user@ip-10-0-11-84 ~]$

Security Groupの設定

測定の前に、測定に必要なtcpポートをSecurity Groupの設定を追加しましょう。 スクリーンショット_2014-08-29_12_50_53

iperfクライアント側の実施結果

[ec2-user@ip-10-0-11-84 ~]$ iperf -c 10.0.11.85
------------------------------------------------------------
Client connecting to 10.0.11.85, TCP port 5001
TCP window size: 95.2 KByte (default)
------------------------------------------------------------
[  3] local 10.0.11.84 port 50948 connected with 10.0.11.85 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.18 GBytes  1.01 Gbits/sec

iperfサーバ側の実施結果

[ec2-user@ip-10-0-11-85 ~]$ iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 10.0.11.85 port 5001 connected with 10.0.11.84 port 50948
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.0 sec  1.18 GBytes  1.01 Gbits/sec

応用編

UDPを使用した測定を行うと、パケットロスの数や、ジッタ(受信パケットの遅延のばらつき)の値を表示できます。

iperfクライアント側のUDPでの実施結果

[ec2-user@ip-10-0-11-84 ~]$ iperf -c 10.0.11.85 -u -i 1
------------------------------------------------------------
Client connecting to 10.0.11.85, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size:  208 KByte (default)
------------------------------------------------------------
[  3] local 10.0.11.84 port 36020 connected with 10.0.11.85 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec   129 KBytes  1.06 Mbits/sec
[  3]  1.0- 2.0 sec   128 KBytes  1.05 Mbits/sec
[  3]  2.0- 3.0 sec   128 KBytes  1.05 Mbits/sec
[  3]  3.0- 4.0 sec   128 KBytes  1.05 Mbits/sec
[  3]  4.0- 5.0 sec   128 KBytes  1.05 Mbits/sec
[  3]  5.0- 6.0 sec   128 KBytes  1.05 Mbits/sec
[  3]  6.0- 7.0 sec   129 KBytes  1.06 Mbits/sec
[  3]  7.0- 8.0 sec   128 KBytes  1.05 Mbits/sec
[  3]  8.0- 9.0 sec   128 KBytes  1.05 Mbits/sec
[  3]  9.0-10.0 sec   128 KBytes  1.05 Mbits/sec
[  3]  0.0-10.0 sec  1.25 MBytes  1.05 Mbits/sec
[  3] Sent 893 datagrams
[  3] Server Report:
[  3]  0.0-10.0 sec  1.25 MBytes  1.05 Mbits/sec   0.068 ms    0/  893 (0%)
[ec2-user@ip-10-0-11-84 ~]$

iperfサーバ側のUDPでの実施結果

[ec2-user@ip-10-0-11-85 ~]$ iperf -s -u -i 1
------------------------------------------------------------
Server listening on UDP port 5001
Receiving 1470 byte datagrams
UDP buffer size:  208 KByte (default)
------------------------------------------------------------
[  3] local 10.0.11.85 port 5001 connected with 10.0.11.84 port 36020
[ ID] Interval       Transfer     Bandwidth        Jitter   Lost/Total Datagrams
[  3]  0.0- 1.0 sec   128 KBytes  1.05 Mbits/sec   0.048 ms    0/   89 (0%)
[  3]  1.0- 2.0 sec   128 KBytes  1.05 Mbits/sec   0.058 ms    0/   89 (0%)
[  3]  2.0- 3.0 sec   128 KBytes  1.05 Mbits/sec   0.028 ms    0/   89 (0%)
[  3]  3.0- 4.0 sec   128 KBytes  1.05 Mbits/sec   0.065 ms    0/   89 (0%)
[  3]  4.0- 5.0 sec   128 KBytes  1.05 Mbits/sec   0.044 ms    0/   89 (0%)
[  3]  5.0- 6.0 sec   128 KBytes  1.05 Mbits/sec   0.048 ms    0/   89 (0%)
[  3]  6.0- 7.0 sec   129 KBytes  1.06 Mbits/sec   0.053 ms    0/   90 (0%)
[  3]  7.0- 8.0 sec   128 KBytes  1.05 Mbits/sec   0.041 ms    0/   89 (0%)
[  3]  8.0- 9.0 sec   128 KBytes  1.05 Mbits/sec   0.033 ms    0/   89 (0%)
[  3]  9.0-10.0 sec   128 KBytes  1.05 Mbits/sec   0.073 ms    0/   89 (0%)
[  3]  0.0-10.0 sec  1.25 MBytes  1.05 Mbits/sec   0.069 ms    0/  893 (0%)
[ec2-user@ip-10-0-11-85 ~]$