LoginSignup
0
0

More than 3 years have passed since last update.

CentOS on Raspberry Pi : 通信回線のスピード計測

Posted at

CentOS on Raspberry Pi で通信回線の速度を計測する方法を記録として残しておきます。

speedtest を使う方法

以下のページを参考にさせて頂きました。
cliでインターネットの速度計測

まずは、yumコマンド で python-setuptools のインストール

[root@mame-t08 ~]# yum install python-setuptools
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.yz.yamagata-u.ac.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ python-setuptools.noarch 0:0.9.8-7.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

==================================================================================================
 Package                       アーキテクチャー   バージョン               リポジトリー      容量
==================================================================================================
インストール中:
 python-setuptools             noarch             0.9.8-7.el7              base             397 k

トランザクションの要約
==================================================================================================
インストール  1 パッケージ

総ダウンロード容量: 397 k
インストール容量: 1.9 M
Is this ok [y/d/N]: y
Downloading packages:
python-setuptools-0.9.8-7.el7.noarch.rpm                                   | 397 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : python-setuptools-0.9.8-7.el7.noarch                              1/1
  検証中                  : python-setuptools-0.9.8-7.el7.noarch                              1/1

インストール:
  python-setuptools.noarch 0:0.9.8-7.el7

完了しました!
[root@mame-t08 ~]#

次は、easy_installコマンドで speedtest-cli をインストール

[root@mame-t08 ~]# easy_install speedtest-cli
Searching for speedtest-cli
Best match: speedtest-cli 2.1.2
Processing speedtest_cli-2.1.2-py2.7.egg
speedtest-cli 2.1.2 is already the active version in easy-install.pth
Installing speedtest script to /usr/bin
Installing speedtest-cli script to /usr/bin

Using /usr/lib/python2.7/site-packages/speedtest_cli-2.1.2-py2.7.egg
Processing dependencies for speedtest-cli
Finished processing dependencies for speedtest-cli
[root@mame-t08 ~]#

続いて、speedtest コマンドで回線スピードを計測

[root@mame-t08 ~]# speedtest
Retrieving speedtest.net configuration...
Testing from So-net (***.***.***.***)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by GLBB Japan (Tokyo) [23.34 km]: 6.307 ms
Testing download speed................................................................................
Download: 235.88 Mbit/s
Testing upload speed................................................................................................
Upload: 140.70 Mbit/s
[root@mame-t08 ~]#

接続先サーバーを指定しての、回線スピード計測

[root@mame-t08 ~]# speedtest --server 3706
Retrieving speedtest.net configuration...
Testing from So-net (***.***.***.***)...
Retrieving speedtest.net server list...
Retrieving information for the selected server...
Hosted by Khabarovsk [RU] - OJSC MegaFon (Far East) (Khabarovsk) [1472.51 km]: 584.853 ms
Testing download speed................................................................................
Download: 13.82 Mbit/s
Testing upload speed................................................................................................
Upload: 11.45 Mbit/s
[root@mame-t08 ~]#

iperf3 を使う方法

iperf3 は、2台のマシン間の通信速度を計測するコマンドです。1台に iperf を サーバーとして起動し、もう1台で iperf をクライアントとして起動し、クライアントからサーバーへ通信を行い回線スピードを計測します。

今回、私は サーバーは、Microsoft Azure に CentOS7.9 のVMを建て、そこに iperf3 をインストールしています。
クライアント側は、CentOS on Raspberry Pi 4 を使っています。

まずは、yumコマンドでインストール(2台とも同じ)

[root@mame-t08 ~]# yum install iperf3
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.yz.yamagata-u.ac.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ iperf3.aarch64 0:3.1.7-2.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

==================================================================================================
 Package              アーキテクチャー      バージョン                   リポジトリー        容量
==================================================================================================
インストール中:
 iperf3               aarch64               3.1.7-2.el7                  base                73 k

トランザクションの要約
==================================================================================================
インストール  1 パッケージ

総ダウンロード容量: 73 k
インストール容量: 252 k
Is this ok [y/d/N]: y
Downloading packages:
iperf3-3.1.7-2.el7.aarch64.rpm                                             |  73 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : iperf3-3.1.7-2.el7.aarch64                                        1/1
  検証中                  : iperf3-3.1.7-2.el7.aarch64                                        1/1

インストール:
  iperf3.aarch64 0:3.1.7-2.el7

完了しました!
[root@mame-t08 ~]#

サーバー側で iperf3 を起動します。
iperf3 は、デフォルトで ポート番号 5201 で通信を待ち受けるので、firewall-cmd で port を開けておく必要があります。
Azure使っている場合は、Azureポータル上で、ネットワーク設定で、ポート番号 5201 の受信設定も必要です。
起動するとコンソールは表示待機状態になります。

[*****@***** ~]$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

続いて、クライアント側で iperf3 を起動します。...* の箇所は、接続先サーバーのIPアドレスを入力してください。

[root@mame-t08 ~]# iperf3 -c **.**.**.***

通信が始まると、サーバー側にもクライアント側にも通信の状況が表示されます。

[root@mame-t06 ~]# iperf3 -c **.**.**.***
Connecting to host **.**.**.***, port 5201
[  4] local 192.168.100.8 port 39910 connected to **.**.**.*** port 5201
[ ID] Interval           Transfer     Bandwidth       Retr  Cwnd
[  4]   0.00-1.00   sec  38.1 MBytes   320 Mbits/sec   68   1.06 MBytes
[  4]   1.00-2.00   sec  36.2 MBytes   304 Mbits/sec    0   1.18 MBytes
[  4]   2.00-3.00   sec  36.2 MBytes   304 Mbits/sec    0   1.28 MBytes
[  4]   3.00-4.00   sec  36.2 MBytes   304 Mbits/sec    0   1.36 MBytes
[  4]   4.00-5.00   sec  36.2 MBytes   304 Mbits/sec   13   1012 KBytes
[  4]   5.00-6.00   sec  36.2 MBytes   304 Mbits/sec    0   1.06 MBytes
[  4]   6.00-7.00   sec  36.2 MBytes   304 Mbits/sec    0   1.12 MBytes

クライアント側で、[ctl]+[c]で計測をストップすると、統計情報が表示されます。

^C[  4]   7.00-7.31   sec  11.2 MBytes   301 Mbits/sec    0   1.13 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth       Retr
[  4]   0.00-7.31   sec   267 MBytes   306 Mbits/sec   81             sender
[  4]   0.00-7.31   sec  0.00 Bytes  0.00 bits/sec                  receiver
iperf3: interrupt - the client has terminated
[root@mame-t08 ~]#

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0