Raspberry Pi 4にUSB3.0のNICを刺してベンチマーク


# はじめに
　自宅では常駐サーバとしてRaspberry Pi 3が活躍していました。しかしネットワークが弱く、拡張もUSB2.0なので限界が来ていました。そして今日ついに、Gigabit EthernetとUSB3.0に対応したRaspberry Pi 4が手元に届き、帯域がどれくらい広くなったのか検証という流れです。ここまで強化されると、NAS、ルータ、VPNゲート、など幅が広がるので無駄にはならないと思います。
 

# 構成
　手元にあった機材を刺しただけなのでチューニングは一切してないです。

- Raspbian GNU/Linux 10 (buster)
- iperf 3.6 (Raspbian側)
- iperf 3.1.3 (Server側)
- Pi 4 4GB


<img width="600" alt="jpg" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/228197/5f5143e5-8b20-0d90-4070-f898ab8dd33a.jpeg">


 
# 測定開始

まずはストレートに測定…無事USB2.0の壁を突破していることがわかります。

```
PS > .\iperf3.exe -c 192.168.10.10
Connecting to host 192.168.10.10, port 5201
[  4] local 192.168.10.1 port 64757 connected to 192.168.10.10 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec   107 MBytes   895 Mbits/sec
[  4]   1.00-2.00   sec   106 MBytes   889 Mbits/sec
[  4]   2.00-3.00   sec   107 MBytes   894 Mbits/sec
[  4]   3.00-4.00   sec   107 MBytes   894 Mbits/sec
[  4]   4.00-5.00   sec   106 MBytes   893 Mbits/sec
[  4]   5.00-6.00   sec   106 MBytes   893 Mbits/sec
[  4]   6.00-7.00   sec   106 MBytes   891 Mbits/sec
[  4]   7.00-8.00   sec   106 MBytes   889 Mbits/sec
[  4]   8.00-9.00   sec   107 MBytes   898 Mbits/sec
[  4]   9.00-10.00  sec   106 MBytes   891 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-10.00  sec  1.04 GBytes   893 Mbits/sec                  sender
[  4]   0.00-10.00  sec  1.04 GBytes   893 Mbits/sec                  receiver

iperf Done.
```


図だとこんな感じです。

<img width="600" alt="jpg" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/228197/ebec52b7-9679-6a16-6410-8bf87072df79.jpeg">

次にRaspberry Piのほうでipv4フォワードを有効にしてパケットを転送してもらいます。
ルーターと同じ挙動をするので私としては期待をしていました。
結果は以下の通りですが、理論値？チューニング次第？設定ミス？
EdgeRouterは同じような実測値なので正しいのかもしれないです。


<img width="600" alt="jpg" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/228197/d7786030-d64a-68ed-e239-1a79e151d55e.jpeg">

最後にせっかく2本NICを刺したので流せるだけ流してみました。


<img width="600" alt="jpg" src="https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/228197/5c1199f3-752a-f304-588c-56e629ebbcfa.jpeg">

# おわりに
　本来、こんなネットワーク寄りな使い方は少ないと思いますが、7700円で省電力で小型なマシンがここまで進化しているのは感動ものです。
　L2通信ではよく速度がでてるのでUSB3.0でSSDを刺してNAS化などが良さそうですね。



# 記録
後半の図だけのところの結果です。

L2通信時

```
PS > .\iperf3.exe -c 192.168.10.10
Connecting to host 192.168.10.10, port 5201
[  4] local 192.168.10.1 port 64757 connected to 192.168.10.10 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec   107 MBytes   895 Mbits/sec
[  4]   1.00-2.00   sec   106 MBytes   889 Mbits/sec
[  4]   2.00-3.00   sec   107 MBytes   894 Mbits/sec
[  4]   3.00-4.00   sec   107 MBytes   894 Mbits/sec
[  4]   4.00-5.00   sec   106 MBytes   893 Mbits/sec
[  4]   5.00-6.00   sec   106 MBytes   893 Mbits/sec
[  4]   6.00-7.00   sec   106 MBytes   891 Mbits/sec
[  4]   7.00-8.00   sec   106 MBytes   889 Mbits/sec
[  4]   8.00-9.00   sec   107 MBytes   898 Mbits/sec
[  4]   9.00-10.00  sec   106 MBytes   891 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-10.00  sec  1.04 GBytes   893 Mbits/sec                  sender
[  4]   0.00-10.00  sec  1.04 GBytes   893 Mbits/sec                  receiver

iperf Done.
```

ルーティング時

```
PS > .\iperf3.exe -c 192.168.12.1 -t 10
Connecting to host 192.168.12.1, port 5201
[  4] local 192.168.10.1 port 49385 connected to 192.168.12.1 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec  54.6 MBytes   458 Mbits/sec
[  4]   1.00-2.00   sec  57.0 MBytes   479 Mbits/sec
[  4]   2.00-3.00   sec  56.9 MBytes   477 Mbits/sec
[  4]   3.00-4.00   sec  58.9 MBytes   494 Mbits/sec
[  4]   4.00-5.00   sec  57.8 MBytes   484 Mbits/sec
[  4]   5.00-6.00   sec  56.4 MBytes   473 Mbits/sec
[  4]   6.00-7.00   sec  56.5 MBytes   474 Mbits/sec
[  4]   7.00-8.00   sec  57.4 MBytes   482 Mbits/sec
[  4]   8.00-9.00   sec  58.4 MBytes   490 Mbits/sec
[  4]   9.00-10.00  sec  58.5 MBytes   490 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-10.00  sec   572 MBytes   480 Mbits/sec                  sender
[  4]   0.00-10.00  sec   572 MBytes   480 Mbits/sec                  receiver

iperf Done.
```

ローカルホスト

```
root@raspberrypi:/home/pi# iperf3 -c localhost
Connecting to host localhost, port 5201
[  5] local ::1 port 57828 connected to ::1 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   656 MBytes  5.50 Gbits/sec    0   1.06 MBytes       
[  5]   1.00-2.00   sec   674 MBytes  5.65 Gbits/sec    0   1.06 MBytes       
[  5]   2.00-3.00   sec   672 MBytes  5.64 Gbits/sec    0   1.06 MBytes       
[  5]   3.00-4.00   sec   671 MBytes  5.63 Gbits/sec    0   1.06 MBytes       
[  5]   4.00-5.00   sec   672 MBytes  5.64 Gbits/sec    0   1.06 MBytes       
[  5]   5.00-6.00   sec   675 MBytes  5.66 Gbits/sec    0   1.06 MBytes       
[  5]   6.00-7.00   sec   669 MBytes  5.61 Gbits/sec    0   1.06 MBytes       
[  5]   7.00-8.00   sec   671 MBytes  5.63 Gbits/sec    0   1.06 MBytes       
[  5]   8.00-9.00   sec   666 MBytes  5.59 Gbits/sec    0   1.06 MBytes       
[  5]   9.00-10.00  sec   666 MBytes  5.59 Gbits/sec    0   1.06 MBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  6.54 GBytes  5.62 Gbits/sec    0             sender
[  5]   0.00-10.04  sec  6.53 GBytes  5.59 Gbits/sec                  receiver

iperf Done.
```

ルーティング中にL2通信で割込み

```
PS > .\iperf3.exe -c 192.168.11.10 -t 10
Connecting to host 192.168.11.10, port 5201
[  4] local 192.168.11.1 port 49553 connected to 192.168.11.10 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec  39.8 MBytes   333 Mbits/sec
[  4]   1.00-2.00   sec  66.1 MBytes   555 Mbits/sec
[  4]   2.00-3.00   sec  67.2 MBytes   564 Mbits/sec
[  4]   3.00-4.00   sec  68.6 MBytes   576 Mbits/sec
[  4]   4.00-5.00   sec  66.9 MBytes   560 Mbits/sec
[  4]   5.00-6.00   sec  65.6 MBytes   551 Mbits/sec
[  4]   6.00-7.00   sec  66.2 MBytes   556 Mbits/sec
[  4]   7.00-8.00   sec  67.4 MBytes   565 Mbits/sec
[  4]   8.00-9.00   sec  66.2 MBytes   555 Mbits/sec
[  4]   9.00-10.00  sec  68.0 MBytes   571 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-10.00  sec   642 MBytes   539 Mbits/sec                  sender
[  4]   0.00-10.00  sec   642 MBytes   539 Mbits/sec                  receiver

iperf Done.
```

ルーティング中にL2通信割込みされた

```
PS > .\iperf3.exe -c 192.168.12.1 -t 10
Connecting to host 192.168.12.1, port 5201
[  4] local 192.168.10.1 port 49375 connected to 192.168.12.1 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec  42.8 MBytes   359 Mbits/sec
[  4]   1.00-2.00   sec  40.2 MBytes   338 Mbits/sec
[  4]   2.00-3.00   sec  39.9 MBytes   335 Mbits/sec
[  4]   3.00-4.00   sec  40.2 MBytes   337 Mbits/sec
[  4]   4.00-5.00   sec  41.8 MBytes   350 Mbits/sec
[  4]   5.00-6.00   sec  40.9 MBytes   343 Mbits/sec
[  4]   6.00-7.00   sec  41.9 MBytes   352 Mbits/sec
[  4]   7.00-8.00   sec  46.6 MBytes   391 Mbits/sec
[  4]   8.00-9.00   sec  41.5 MBytes   348 Mbits/sec
[  4]   9.00-10.00  sec  45.9 MBytes   385 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-10.00  sec   422 MBytes   354 Mbits/sec                  sender
[  4]   0.00-10.00  sec   422 MBytes   354 Mbits/sec                  receiver

iperf Done.
```

L2通信時にルーティング割込み

```
PS > .\iperf3.exe -c 192.168.11.10 -t 20
Connecting to host 192.168.11.10, port 5201
[  4] local 192.168.11.1 port 49372 connected to 192.168.11.10 port 5201
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-1.00   sec   108 MBytes   902 Mbits/sec
[  4]   1.00-2.00   sec   113 MBytes   947 Mbits/sec
[  4]   2.00-3.00   sec   113 MBytes   948 Mbits/sec
[  4]   3.00-4.00   sec   113 MBytes   948 Mbits/sec
[  4]   4.00-5.00   sec   113 MBytes   945 Mbits/sec
[  4]   5.00-6.00   sec   113 MBytes   946 Mbits/sec
[  4]   6.00-7.00   sec   113 MBytes   948 Mbits/sec
[  4]   7.00-8.00   sec   113 MBytes   948 Mbits/sec
[  4]   8.00-9.00   sec   113 MBytes   949 Mbits/sec
[  4]   9.00-10.00  sec   113 MBytes   948 Mbits/sec
[  4]  10.00-11.00  sec  80.4 MBytes   674 Mbits/sec
[  4]  11.00-12.00  sec  41.6 MBytes   349 Mbits/sec
[  4]  12.00-13.00  sec  61.1 MBytes   513 Mbits/sec
[  4]  13.00-14.00  sec  53.6 MBytes   450 Mbits/sec
[  4]  14.00-15.00  sec  42.4 MBytes   355 Mbits/sec
[  4]  15.00-16.00  sec  59.0 MBytes   495 Mbits/sec
[  4]  16.00-17.00  sec  49.9 MBytes   418 Mbits/sec
[  4]  17.00-18.00  sec  51.9 MBytes   435 Mbits/sec
[  4]  18.00-19.00  sec  35.4 MBytes   297 Mbits/sec
[  4]  19.00-20.00  sec  57.1 MBytes   480 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-20.00  sec  1.62 GBytes   695 Mbits/sec                  sender
[  4]   0.00-20.00  sec  1.62 GBytes   695 Mbits/sec                  receiver

iperf Done.
```