技術者になりたい何か

技術者になりたい何かの覚書的な何かです

Linuxで回線速度とかスループットとか

ちょっと前に作ったDebian Server兼ルータ機のスループット的なものを計測してみる。

 

■前提

ルータ機のip a

$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:13:3b:2f:23:f3 brd ff:ff:ff:ff:ff:ff
inet 221.118.111.147/24 brd 255.255.255.255 scope global enp2s0
valid_lft forever preferred_lft forever
3: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:1d:60:fc:50:b0 brd ff:ff:ff:ff:ff:ff
inet 192.168.11.1/24 brd 192.168.11.255 scope global enp3s0
valid_lft forever preferred_lft forever

enp2s0側をCATVモデムに繋いでWAN側、enp3s0をLAN側にしています。
テストに使用したクライアント機はLAN側にぶら下がってるうちの一つ。
有線接続のArch Linuxになります。

■speedtest-cliで回線速度

github.com

pipはPythonのパッケージ管理ツールらしい。
DebianデフォルトのPythonには付属してなかったっぽいので、DLしてインストール。

$ curl -O https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
Collecting pip
Downloading pip-9.0.2-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 514kB/s
Collecting setuptools
Downloading setuptools-39.0.0-py2.py3-none-any.whl (569kB)
100% |████████████████████████████████| 573kB 1.2MB/s
Collecting wheel
Downloading wheel-0.30.0-py2.py3-none-any.whl (49kB)
100% |████████████████████████████████| 51kB 4.0MB/s
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.2 setuptools-39.0.0 wheel-0.30.0

$ python -m pip -V
pip 9.0.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)

 

 

speedtest-cliインストール

$ sudo pip install speedtest-cli
Collecting speedtest-cli
Downloading speedtest_cli-2.0.0-py2.py3-none-any.whl
Installing collected packages: speedtest-cli
Successfully installed speedtest-cli-2.0.0

実行。

$ speedtest-cli
Retrieving speedtest.net configuration...
Testing from XXXXXXXXXX(xxx.xxx.xxx.xxxx)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by rxy (individual) (Osaka) [156.41 km]: 35.733 ms
Testing download speed................................................................................
Download: 12.41 Mbit/s
Testing upload speed...............................................................................................
.Upload: 4.48 Mbit/s

あるぇー?なんか遅くね?

Mbit/sなので、8倍してMbpsが出ます。
DL 100Mbps, UL 36Mbpsくらいか。

ちなみにこのサーバ機じゃなくて、メインのPCから速度JPで測ってみたら
306 ms 108.39 Mb/s 7.68 Mb/s
だってー。

なんで間のルータより速度出てんだろうか。

■iperf3でLAN内のPCからの速度

・Server側
iperf3 -s で立ち上げておく。
5201ポートで待ち受けるので、必要に応じてポート開放。
(今回はLAN内のPCからやったのでなし)

$ iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.11.2, port 60242
[ 5] local 192.168.11.1 port 5201 connected to 192.168.11.2 port 60244
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-1.00 sec 108 MBytes 904 Mbits/sec
[ 5] 1.00-2.00 sec 112 MBytes 941 Mbits/sec
[ 5] 2.00-3.00 sec 112 MBytes 941 Mbits/sec
[ 5] 3.00-4.00 sec 112 MBytes 940 Mbits/sec
[ 5] 4.00-5.00 sec 112 MBytes 941 Mbits/sec
[ 5] 5.00-6.00 sec 112 MBytes 941 Mbits/sec
[ 5] 6.00-7.00 sec 111 MBytes 934 Mbits/sec
[ 5] 7.00-8.00 sec 112 MBytes 941 Mbits/sec
[ 5] 8.00-9.00 sec 112 MBytes 941 Mbits/sec
[ 5] 9.00-10.00 sec 112 MBytes 941 Mbits/sec
[ 5] 10.00-10.04 sec 3.99 MBytes 940 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-10.04 sec 0.00 Bytes 0.00 bits/sec sender
[ 5] 0.00-10.04 sec 1.09 GBytes 937 Mbits/sec receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

・Client側
iperf3 -c [IP]

$ iperf3 -c 192.168.11.1
Connecting to host 192.168.11.1, port 5201
[ 5] local 192.168.11.2 port 60244 connected to 192.168.11.1 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.00 sec 112 MBytes 938 Mbits/sec 0 84.8 KBytes
[ 5] 1.00-2.00 sec 112 MBytes 942 Mbits/sec 0 84.8 KBytes
[ 5] 2.00-3.00 sec 112 MBytes 941 Mbits/sec 0 94.7 KBytes
[ 5] 3.00-4.00 sec 112 MBytes 940 Mbits/sec 0 99.0 KBytes
[ 5] 4.00-5.00 sec 112 MBytes 942 Mbits/sec 0 99.0 KBytes
[ 5] 5.00-6.00 sec 112 MBytes 942 Mbits/sec 0 160 KBytes
[ 5] 6.00-7.00 sec 111 MBytes 935 Mbits/sec 0 194 KBytes
[ 5] 7.00-8.00 sec 112 MBytes 941 Mbits/sec 0 194 KBytes
[ 5] 8.00-9.00 sec 112 MBytes 941 Mbits/sec 0 194 KBytes
[ 5] 9.00-10.00 sec 112 MBytes 941 Mbits/sec 0 194 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 1.09 GBytes 940 Mbits/sec 0 sender
[ 5] 0.00-10.00 sec 1.09 GBytes 940 Mbits/sec receiver

iperf Done. 

 

0.00-10.04sec で 平均937Mbits/sec


■ethtoolで接続状況

ens2s0(WAN側)

$ sudo ethtool enp2s0
Settings for enp2s0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000033 (51)
drv probe ifdown ifup
Link detected: yes

ens3s0(LAN側)

$ sudo ethtool enp3s0
Settings for enp3s0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Link partner advertised pause frame use: Symmetric
Link partner advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: ug
Current message level: 0x00000033 (51)
drv probe ifdown ifup
Link detected: yes


Speed: 1000Mb/s
Duplex: Full
なので、1000baseTでfull duplex接続。ちゃんと認識してる。

■dstat

オプション無しだと一通りの状況。
$ dstat
You did not select any stats, using -cdngy by default.
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
0 0 100 0 0 0| 953B 4611B| 0 0 | 0 2B| 125 101
0 0 100 0 0 0| 0 0 |9706B 10k| 0 0 | 99 137
0 0 100 0 0 0| 0 0 |9204B 9188B| 0 0 | 77 103
1 0 99 0 0 0| 0 0 | 48k 48k| 0 0 | 273 274
1 0 99 0 0 0| 0 0 | 12k 12k| 0 0 | 138 156
0 0 100 0 0 0| 0 0 | 15k 15k| 0 0 | 147 83
1 0 98 2 0 0| 0 32k| 11k 11k| 0 0 | 123 122
0 0 100 0 0 0| 0 8192B| 15k 15k| 0 0 | 137 96
1 0 100 0 0 0| 0 0 | 12k 12k| 0 0 | 86 85
1 0 98 1 0 1| 0 16k| 488k 487k| 0 0 | 943 152
0 0 100 0 0 0| 0 0 | 13k 13k| 0 0 | 120 75

-n 1 オプションで一秒ごと

$ dstat -n 1
-net/total-
recv send
0 0
10k 9977B
504k 504k
9400B 9020B
9806B 9486B
9276B 9136B 

一秒ごと表示したまま、speedtest-cli

$ dstat -n 1
-net/total-
recv send
0 0
12k 12k
9571B 9305B
9668B 9452B
9857B 9537B
9778B 9398B
9591B 9271B
9332B 9128B
319k 22k
10k 10k
10k 9904B
10k 9512B
11k 11k
9251B 9065B
17k 16k
9288B 9102B
9875B 9555B
25k 25k
9450B 9430B
9655B 9109B
9755B 9603B
11k 10k
11k 10k
-net/total-
recv send
12k 12k
13k 13k
2443k 43k
10k 9743B
9067B 8927B
9322B 9116B
9462B 9142B
7118k 108k
4543k 51k
1114k 37k
9713B 9453B
9791B 9771B
198k 21k
9773B 9453B
26k 549k
10k 9711B
25k 25k
26k 26k
20k 20k
81k 1952k
72k 2226k
63k 1568k
30k 760k
-net/total-
recv send
12k 11k
27k 26k
13k 13k
19k 22k
9610B 9470B
9457B 9017B

 
同じくクライアント機で速度JPの測定中。


$ dstat -n 1
-net/total-
recv send
0 0
21M 21M
25M 25M
25M 25M
22M 22M
23M 23M
26M 26M
24M 24M
22M 22M
25M 25M
26M 26M
24M 24M
25M 25M
22M 22M
25M 25M
26M 26M
25M 25M
20M 20M
25M 25M
25M 25M
7775k 7774k
12k 11k
976k 976k
-net/total-
recv send
2271k 2271k
2313k 2313k
2199k 2199k
2292k 2291k
2233k 2234k
2288k 2287k
2167k 2166k
2273k 2272k
2229k 2229k
2230k 2224k
2241k 2247k
2278k 2278k
2283k 2282k
2246k 2246k
2246k 2245k
2334k 2331k
2259k 2262k
2160k 2160k
2215k 2210k
1111k 1115k
11k 11k
9735B 9595B
25k 25k
-net/total-
recv send
9780B 9580B

サーバ機自体でspeedtest-cli実行してるときよりクライアント機で速度JPやってるときのほうが大分大きいですが・・・

というわけでクライアント機でspeedtest-cliをやってみたよ。

$ speedtest-cli
Retrieving speedtest.net configuration...
Testing from Community Network Center (221.118.111.147)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by rxy (individual) (Osaka) [156.41 km]: 34.233 ms
Testing download speed................................................................................
Download: 111.79 Mbit/s
Testing upload speed......................................................................................................
Upload: 13.92 Mbit/s

何この違い・・・

ルータ機を挟んで外に繋がってるはずなのにクライアントの方が速度出てるってのがよくわからないですが、
既製品のルータ使ってたときよりクライアントは若干早くなってるので良しとします。