Showing posts with label Gigabit. Show all posts
Showing posts with label Gigabit. Show all posts

Tuesday, 25 November 2014

Banana Pi USB 2.0 'Gigabit' Ethernet Adapter throughput test

Banana Pi USB 2.0 'Gigabit' Ethernet Adapter throughput test

I bought a cheap USB 2.0 to Gigabit Ethernet Adapter (Maximum Data Transfer Rate 480 Mbps according to the website), mostly because I wanted to see how it performed on a Raspberry Pi, so now I'm running the same tests on my new board the Banana Pi. It can never reach 480Mbps, but it will be interesting to see how much throughput it can actually achieve.

As usual, I have censored any identifying information about my local network or personal hardware.

Hardware Configuration:

Banana Pi
RAM 1024MB
no overclocking
Inbuilt 10/100/1000 NIC is not connected.
Top USB port has USB 2.0 to Gigabit Ethernet Adapter plugged in and plugged.into router
Bottom USB port is empty





      
+---+  +------+         +------+           +----------------+
|BPi|->|USB2.0|->1Gbps->|router|->200Mbps->|Remote webserver|
+---+  +------+ Ethernet+------+ Internet  +----------------+
      
480Mibps             |
                         1Gbps Ethernet
                            |
                            v
                     +-------------+
                     |LAN webserver|
                     +-------------+


Software Configuration: 

I had to add in an extra three lines for this new USB eth1 NIC to get it working on the Banana Pi, the lines in bold below.

root@bananapi ~ # cat /etc/network/interfaces
allow-hotplug eth1
auto lo
iface lo inet loopback
auto eth0
 
iface eth0 inet dhcp
auto eth1 
iface eth1 inet dhcp

root@bananapi ~ #

root@bananapi ~ # lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0424:7500 Standard Microsystems Corp. LAN7500 Ethernet 10/100/1000 Adapter
Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@bananapi ~ # lsusb -t
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=sw-ohci/1p, 12M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=sw-ehci/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Vendor Specific Class, Driver=smsc75xx, 480M

/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=sw-ohci/1p, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=sw-ehci/1p, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=sw_hcd_host0/1p, 480M

root@bananapi ~ # ethtool eth1
Settings for eth1:
        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/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/Half 1000baseT/Full
        Link partner advertised pause frame use: Symmetric Receive-only
        Link partner advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full

        Port: MII
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes
root@bananapi ~ #

root@bananapi ~ # netstat -i
Kernel Interface table
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0         0      0      0 0             4      0      0      0 BMU
eth1       1500 0       457      0      0 0           485      0      0      0 BMRU
lo        16436 0         1      0      0 0             1      0      0      0 LRU
root@bananapi ~ #

root@bananapi ~ # ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 80:3f:5d:**:**:**
          inet addr:
*.*.*.*  Bcast:*.*.*.*  Mask:*.*.*.* 
          inet6 addr: fe80::823f:5dff:fe08:69ad/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:470 errors:0 dropped:0 overruns:0 frame:0
          TX packets:502 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:37207 (36.3 KiB)  TX bytes:72520 (70.8 KiB)

root@bananapi ~ #

Internet Test (via a 200Mbit/sec broadband connection)


Download a single 100MiB file to the Pi through the USB 2.0 Gigabit Ethernet Adapter and send the downloaded data to /dev/null.

root@bananapi ~ # time wget http://qrng.physik.hu-berlin.de/files/speedtest-100MB.bin -O /dev/null
--2010-01-01 00:17:55--  http://qrng.physik.hu-berlin.de/files/speedtest-100MB.bin
Resolving qrng.physik.hu-berlin.de (qrng.physik.hu-berlin.de)... 141.20.41.134
Connecting to qrng.physik.hu-berlin.de (qrng.physik.hu-berlin.de)|141.20.41.134|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: ‘/dev/null’

/dev/null                                           100%[=====================================================================================================================>] 100.00M  11.4MB/s   in 16s

2010-01-01 00:18:11 (6.21 MB/s) - ‘/dev/null’ saved [104857600/104857600]

wget http://qrng.physik.hu-berlin.de/files/speedtest-100MB.bin -O /dev/null  0.25s user 2.22s system 14% cpu 16.559 total
root@bananapi ~ #

LAN Test

Download a single 100MiB file to the Pi through USB 2.0 Gigabit Ethernet Adapter and send the downloaded data to /dev/null. The data source is on the Local network from a machine with a 1 Gbit/sec NIC patched directly into the router with the data being read from a RAM disk to maximise read speed.
root@webserver:~# apt-get install nginx nginx-common nginx-full
root@webserver:~# /usr/sbin/nginx &
root@webserver:~# mkdir /usr/share/nginx/www/ramdisk
root@webserver:~# chmod 777 /usr/share/nginx/www/ramdisk
root@webserver:~# free -m
root@webserver:~# mount -t tmpfs -o size=256M tmpfs /usr/share/nginx/www/ramdisk
root@webserver:~# cp speedtest-100MB.bin /usr/share/nginx/www/ramdisk


root@bananapi ~ # time wget http://*.*.*.*/ramdisk/speedtest-100MB.bin -O /dev/null
--2014-11-20 21:10:47--  http://
*.*.*.*/ramdisk/speedtest-100MB.bin
Connecting to
*.*.*.*:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: ‘/dev/null’

/dev/null                                           100%[=====================================================================================================================>] 100.00M  39.5MB/s   in 2.5s

2014-11-20 21:10:50 (39.5 MB/s) - ‘/dev/null’ saved [104857600/104857600]

wget http://
*.*.*.*/ramdisk/speedtest-100MB.bin -O /dev/null  0.24s user 1.60s system 71% cpu 2.572 total
root@bananapi ~ #


Results
Peak Internet transfer rate 10.87MiB/sec (91.2Mbps) - about 13 hops away
Average Internet throughput 6.04MiB/sec - about 13 hops away.

Because this server is so many hops away it's throughput varies wildly with time of day and is effected by so  many uncontrolled fluctuations on every hop in between. This result is more an example of a typical Internet based throughput than a maximum throughput.




Peak LAN download transfer rate 38.88 MiB/sec (326.15Mbps) - for 1000Mbps (even limited to USB 2.0 480Mbps) this is a very good throughput.
Average LAN download throughput 38.88 MiB/sec - for 1000Mbps (even limited to USB 2.0 480Mbps) this is a very good throughput.

I'm very pleased with the USB 2.0 Gigabit Ethernet Adapter result for the Banana Pi. I was expecting a result somewhere between 20 MiB/sec and 40 MiB/sec. 


I enabled jumbo frames ("sudo ifconfig eth1 mtu 9000") on the webserver and on the Banana Pi to see if I could get a better result, but I couldn't get it to work. I'm not quite sure why, yet but I'm still looking into it.

Additional testing

I decided to try the test in reverse. Install a webserver on the Banana P, and make a 128MiB ramdisk to download a file from the Banana Pi through USB 2.0, through the USB 2.0 Gigabit Ethernet Adapter down to the midrange PC with a Gigabit NIC, and then throw the data away.
root@bananapi ~ # apt-get install nginx
root@bananapi ~ # mkdir /var/www/html/ramdisk
root@bananapi ~ #  chmod 777 /var/www/html/ramdiskroot@bananapi ~ #  free -m 
root@bananapi ~ #  mount -t tmpfs -o size=128M tmpfs /var/www/html/ramdisk
root@bananapi ~ #  cp speedtest-100MB.bin /var/www/html/ramdisk

midrangepc $ time wget http://*.*.*.*/ramdisk/speedtest-100MB.bin -O /dev/null
--2014-11-20 22:39:33--  http://
*.*.*.*/ramdisk/speedtest-100MB.bin
Connecting to
*.*.*.*:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: `/dev/null'

100%[=================================================================================================================================================================>] 104,857,600 19.8MB/s   in 5.1s

2014-11-20 22:39:38 (19.7 MB/s) - `/dev/null' saved [104857600/104857600]


real    0m5.075s
user    0m0.268s
sys     0m1.592s
midrangepc $





Average LAN upload throughput 19.6 MiB/sec (156.8Mbps)

I'm not quite sure why upload is always less than download throughput rates, it is something that I'll have to think about for a while.

For two final tests I decided to unplug the USB 2.0 Gigabit ethernet adapter and use the Banana Pi's actual builtin Gigabit NIC and just get the average throughput in each direction (using a ramdisk on each machine to upload the file from as fast as possible).

Midrange server as the webserver: 101 MB/s (Banana Pi as the client, running wget) [808Mbps 96.3MiB/sec]
Banana Pi as the webserver: 71.5 MB/s (Midrange PC server as the client, running wget) [572Mbps 68.2MiB/sec]



Thursday, 20 November 2014

Comparison of Raspberry Pi vs Beaglebone Black vs Banana Pi

Update (2015-2): I'll update the below when I get more info on the new BCM2836 chip used in the Raspberry Pi Generation 2 model B. It CPU performance should jump up by about six, the RAM has doubled, but the GPU is the same as is everything else. RAM performance will be the same, no clocking improvement, just size. The quad core CPU (ARMv7) does now have NEON support so SIMD, should improve data processing ability. But the real bottleneck to the RPi is getting data into and out of the CPU from the real world, it is like a giant head sitting on a straw.


CPU

From each of the /proc/cpuinfo files shown below, in theory if an application is single threaded the Banana Pi should win, and if it is multithreaded the Banana Pi should still win. I have not run any direct benchmark, just looking at the BogoMIPS and the Features supported by each ARM chip.

Raspberry Pi (Model A,B,B+,A+ all have the same ARM1176JZF-S)
------------
Processor       : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 697.95
Features        : swp half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2708
Revision        : 000f

BeagleBone Black
----------------
processor    : 0
model name    : ARMv7 Processor rev 2 (v7l)
BogoMIPS    : 990.68
Features    : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls
CPU implementer    : 0x41
CPU architecture: 7
CPU variant    : 0x3
CPU part    : 0xc08
CPU revision    : 2

Hardware    : Generic AM33XX (Flattened Device Tree)
Revision    : 0000
Serial        : 0000000000000000


Banana Pi (The Banana Pro has the same Allwinner A20)
---------
Processor       : ARMv7 Processor rev 4 (v7l)
processor       : 0
BogoMIPS        : 2004.17

processor       : 1
BogoMIPS        : 2011.05

Features        : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 4

Hardware        : sun7i
Revision        : 0000



Video/GPU


Raspberry Pi:  Broadcom VideoCore IV (Graphics and compute) 24 GFLOPS
Beaglebone Black: PowerVR SGX530 (200 MHz) (Graphics, video encoding, decoding only) 1.6 GFLOPS
 Banana Pi: ARM Mali400MP2 dual GPU core (Grahpics, video encoding, decoding only) 6.3 GFLOPS 


RAM


Raspberry Pi ( A, A+, B rev 1): 256MiB DDR
Raspberry Pi (B rev 2, B+): 512MiB DDR
BeagleBone Black: 512MiB DDR3L
Banana Pi: 1024MiB DDR3

[DDR3 is 1.35 volt and DDR3L 1.25 volt (lower power = less heat = longer life)]

 

USB


Raspberry Pi A: 1 x Standard A host port (direct).
Raspberry Pi B: 2 x Standard A host port (via hub with Ethernet).
Raspberry Pi A+: 1 x Standard A host port (direct).
Raspberry Pi B+: 4 x Standard A host port (via hub with Ethernet).
Beaglebone Black: 1 x Standard A host port (direct) 1x mini B device port (direct)
Banana Pi: 2 x Standard A host port (direct) 1x mini AB OTG port (direct)
 

Ethernet

Raspberry Pi (B, B+): 10/100Mbps (shared USB)
Beaglebone Black: 10/100Mbps
Banana Pi: 10/100/1000Mbps

Storage


SD/microSD

Raspberry Pi A,B: SD card
Raspberry Pi A+, B+:  microSD card
Beaglebone Black:  microSD card
Banana Pi:  SD card

8-bit eMMC 

Raspberry Pi: None
Beaglebone Black ((Rev B): 2 GB Ångström pre-installed
Beaglebone Black ((Rev C): 4 GB Debian pre-installed
Banana Pi: None

SATA

Raspberry Pi: None
Beaglebone Black: None
Banana Pi: SATA 2.0

Me personally I hate devices with inbuilt flash, 3000-5000 writes per block and the device ready for the bin.


GPIO/Low-level peripherals

Raspberry Pi A, B rev 1: UART, SPI, 2x I²C,MIPI CSI-2, (not yet enabled DSI, CEC)
                                       8-17GPIO pins
Raspberry Pi B rev 2: UART, SPI, 2x I²C,MIPI CSI-2, (not yet enabled DSI, CEC)
                                  12-21GPIO pins

Raspberry Pi A+, B+: UART, SPI, 2x I²C,MIPI CSI-2, (not yet enabled DSI, CEC)
                                   EEPROM ID feature for auto-configuration with add-on "HAT" boards
                                   21-30GPIO pins

Beaglebone Black: 4xUART(1xTX only), 8x PWM, LCD, GPMC, MMC1, 2x SPI, 2x I²C, 7xADC(1.8v), 2x CAN bus, 4 Timers, 25xPRU
                                  65 GPIO pins
Banana Pi:  UART, SPI, I²C, CAN, ADC, PWM
                  CSI (or 21 additional GPIO pins), LCD display LVDS (or 36 additional GPIO pins)
                  7-17 GPIO pins (or 7-74 GPIO pins if CSI and LCD are re-purposed)
                  IR receiver
                  On board microphone

Overall I'd probably pick the Beaglebone Black as having the best GPIO/Low-level peripherals support (and very easy access to the pins).


Power

Raspberry Pi A: 500mA-1000mA
Raspberry Pi B: 700-1000mA
Raspberry Pi A+:  500mA-2000mA
Raspberry Pi B+: 600-2000mA
Beaglebone Black: 300–500 mA @5 V
Banana Pi: 200mA*-2000mA (*requires 700-800mA during boot)


Weight

Raspberry Pi A:  45 g (1.6 oz)
Raspberry Pi B:  45 g (1.6 oz)
Raspberry Pi A+:   23 g (0.81 oz)
Raspberry Pi B+:  45 g (1.6 oz)
Beaglebone Black: 39.68 g (1.400 oz)
Banana Pi:  48 g (1.7 oz)



My conclusion would be if it is light weight I needed, then I'd go with a Pro Trinket (2.6g/0.09oz), unless I needed a 1920x1080HD camera as well then it would be the Raspberry Pi A+ (23g/0.81oz) with a camera module (3g/0.11oz). If it was easily accessible GPIO that I needed, with loads of inputs and outputs I'd pick the Beaglebone Black (It is a great piece of open hardware) 7ADC is nice. And finally if it was shoving large amounts of data about fast, or processing that data, I'd pick the Banana Pi (With SATA 2.0, Gigabit Ethernet and 1GiB of RAM it is an impressive piece of kit) or it's newer incarnation of hardware the Banana Pro (with builtin WiFi).

There are larger communities built up around the Raspberry Pi and Beaglebone Black, than there is around the Banana Pi/Pro hardware.  So if you have a problem, sometimes you may have to solve it yourself rather than looking for a quick fix from someone else in the community  who had the same problem already.

Wednesday, 5 November 2014

Banana Pi: Gigabit Ethernet throughput test

Gigabit Ethernet throughput test

I have censored any identifying information about my local network or personal hardware.

Hardware Configuration:

Banana Pi 1024MB of RAM
Inbuilt 10/100/1000 NIC plugged.into router
Top USB port is empty
Bottom USB port is empty.
mini USB OTG (power only)





+---------+           +------+           +----------------+
|Banana pi|-->1Gbps-->|router|->200Mbps->|Remote webserver|
+---------+  Ethernet +------+ Internet  +----------------+
                         |
                      1Gbps Ethernet
                         |
                         v
                 +-------------+
                 |LAN webserver|
                 +-------------+



root@bananapi ~ # apt-cache search lsusb 
usbutils - Linux USB utilities
root@bananapi ~ # apt-get install usbutils
root@bananapi ~ # lsusb -t
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=sw-ohci/1p, 12M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=sw-ehci/1p, 480M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=sw-ohci/1p, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=sw-ehci/1p, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=sw_hcd_host0/1p, 480M
root@bananapi ~ # apt-cache search ethtool
ethtool - display or change Ethernet device settings

root@bananapi ~ # apt-get install ethtool
root@bananapi ~ # ethtool eth0
Settings for eth0:
        Supported ports: [ TP AUI BNC MII FIBRE ]
        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: No
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 0
        Transceiver: external
        Auto-negotiation: on
        Current message level: 0x0000003f (63)
                               drv probe link timer ifdown ifup
        Link detected: yes
root@bananapi ~ # netstat -i
Kernel Interface table
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0       950      0      0 0           991      0      0      0 BMRU
lo        16436 0         0      0      0 0             0      0      0      0 LRU
root@bananapi ~ #


Internet Test (via a 200Mbit/sec broadband connection)


Download a single 100MiB file to the Pi through 100Mbps Ethernet and send the downloaded data to /dev/null. This is to focus the test solely on the Ethernet throughput (and USB throughput) and nothing else.

root@bananapi:~# time wget http://qrng.physik.hu-berlin.de/files/speedtest-100MB.bin -O /dev/null
--2014-11-05 10:14:24--  http://qrng.physik.hu-berlin.de/files/speedtest-100MB.bin
Resolving qrng.physik.hu-berlin.de (qrng.physik.hu-berlin.de)... 141.20.41.134
Connecting to qrng.physik.hu-berlin.de (qrng.physik.hu-berlin.de)|141.20.41.134|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: `/dev/null'

100%[======================================================================================================================================================================>] 104,857,600 21.8M/s   in 10s

2014-11-05 10:14:34 (9.66 MB/s) - `/dev/null' saved [104857600/104857600]


real    0m10.483s
user    0m0.280s
sys     0m2.380s
root@bananapi:~#

LAN Test

Download a single 100MiB file to the Pi through 100Mbps Ethernet and send the downloaded data to /dev/null. The data source is on the Local network from a machine with a 1 Gbit/sec NIC patched directly into the router with the data being read from a RAM disk to maximise read speed.
root@webserver:~# apt-get install nginx nginx-common nginx-full
root@webserver:~# /usr/sbin/nginx &
root@webserver:~# mkdir /usr/share/nginx/www/ramdisk
root@webserver:~# chmod 777 /usr/share/nginx/www/ramdisk
root@webserver:~# free -m
root@webserver:~# mount -t tmpfs -o size=256M tmpfs /usr/share/nginx/www/ramdisk
root@webserver:~# cp speedtest-100MB.bin /usr/share/nginx/www/ramdisk


root@bananapi:~# time wget http://*.*.*.*/ramdisk/speedtest-100MB.bin -O /dev/null
--2014-11-05 10:19:15--  http://
*.*.*.*/ramdisk/speedtest-100MB.bin
Connecting to
*.*.*.*:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: `/dev/null'

100%[======================================>] 104,857,600  109M/s   in 0.9s

2014-11-05 10:21:49 (109 MB/s) - `/dev/null' saved [104857600/104857600]


real    0m0.932s
user    0m0.120s
sys     0m0.720s
root@bananapi:~#
 


Results

Internet

Average Internet throughput 9.66MiB/sec - about 13 hops away.
Because this server is so many hops away it's throughput varies wildly with time of day and is effected by so  many uncontrolled fluctuations on every hop in between. This result is more an example of a typical Internet based throughput than a maximum throughput.


Local Area Network

Average LAN throughput  109 MiB/sec (872Mbps) - for 1Gbps this is very close to the maximum throughput. I should probably test again with a much bigger file, but I do not have enough RAM on my server for that.


For every packet there is header information. Source/Destination MAC,  Source/Destination IP,  Source/Destination port, packet length, checksums to check for corruption, etc. (circa 3% of  MTU sized packet) this and packet ACK delays is where the missing 6% overhead has gone. You will never see more than 112.06MiB/sec throughput on a 1Gbps Ethernet card using TCP/IP.

I'm delighted with the LAN Gigabit Ethernet result for the Banana Pi, it blows a Raspberry Pi out of the water. I was half expecting there to be some CPU problem that the hardware could never get anywhere near gigabit, but this hardware totally rocks. Given the choice to buy a RPi model A+/B+ or a Banana Pi/Pro, I'd pick the Banana every time now. 

I have not tested a BeagleBone Black, but it only has 512MB of RAM and 10/100Mbit/sec ethernet. Looking at some benchmarks it looks to me like the Banana Pi/Pro with its two CPU cores may each be over two times as powerful as the single core in the BeagleBone Black. So over four times the performance for multithreaded applications or double the performance for single threaded applications.

Saturday, 3 May 2014

Raspberry Pi USB 2.0 'Gigabit' Ethernet Adapter throughput test

 

Update (2015-02): RaspBerry Pi Generation 2 model B - Since this USB 2.0 'Gigabit' Ethernet adapter throughput was performance bound by low CPU there should be some improvement with this new board. One can only hope that it would be closer to the Banana Pi performance with the same adapter of 39.5 MB/s (download) and 19.7 MB/s (upload) instead of RPi B non-overclocked performance of 12.5 MB/s (download) and 12.3 MB/s (upload). I would need a new RPi2B board to do tests, but worst case its performance should (still) be better than the builtin 10/100 NIC. In fact thinking about it a bit more because of the 5 port USB hub internal to the RPi2B, its performance will not be as high as the Banana Pi with dedicated USB 2.0 ports. So in theory it should be slower than the Banana Pi, but faster than a RPi B/B+ at transferring data.

Update (2014-07): There is a new RPi model B+ with 4 USB ports (well 5 in fact when you include ethernet using a LAN9514 chip instead of 3 ports using the LAN9512 in the model B). Just to be clear the tests below were done on the model B. If and when I repeat the the tests with a model B+ I do not expect to see better performance.

Raspberry Pi USB 2.0 'Gigabit' Ethernet Adapter throughput test

I bought a cheap USB 2.0 to Gigabit Ethernet Adapter (Maximum Data Transfer Rate 480 Mbps according to the website), mostly because I wanted to see how it performed on a Raspberry Pi. It can never reach 480Mbps, but it will be interesting to see how much throughput it can achieve.

As usual, I have censored any identifying information about my local network or personal hardware.

Hardware Configuration:

Raspberry Pi model B - 512MB model, 128MB of RAM allocated to GPU, no overclocking
Inbuilt 10/100 NIC is not connected.
Top USB port is empty
Bottom USB port has USB 2.0 to Gigabit Ethernet Adapter plugged in and plugged.into router





      
+---+  +------+         +------+           +----------------+
|RPi|->|USB2.0|->1Gbps->|router|->200Mbps->|Remote webserver|
+---+  +------+ Ethernet+------+ Internet  +----------------+
      
480Mibps             |
                         1Gbps Ethernet
                            |
                            v
                     +-------------+
                     |LAN webserver|
                     +-------------+


Software Configuration: 

I had to add in an extra two lines for this new USB eth1 NIC to get it working on the Raspberry Pi, the last two lines below.

pi@raspberrypi ~ $ cat /etc/network/interfaces
auto lo

iface lo inet loopback

iface eth0 inet dhcp

allow-hotplug wlan0

iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

allow-hotplug eth1

iface eth1 inet dhcp
pi@raspberrypi ~ $

pi@raspberrypi ~ $ lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/3p, 480M
        |__ Port 1: Dev 3, If 0, Class=vend., Driver=smsc95xx, 480M
        |__ Port 3: Dev 4, If 0, Class=vend., Driver=smsc75xx, 480M

pi@raspberrypi ~ $ sudo ethtool eth1
Settings for eth1:
        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/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/Half 1000baseT/Full
        Link partner advertised pause frame use: Symmetric Receive-only
        Link partner advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full

        Port: MII
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbag
        Wake-on: d
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes
pi@raspberrypi ~ $  netstat -i
Kernel Interface table
Iface   MTU Met   RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500 0         0      0      0 0             0      0      0      0 BMU
eth1       1500 0       377      0      0 0           382      0      0      0 BMRU
lo        65536 0        14      0      0 0            14      0      0      0 LRU

pi@raspberrypi ~ $ ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 80:3f:5d:**:**:**
          inet addr:*.*.*.*  Bcast:*.*.*.*  Mask:*.*.*.*
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:385 errors:0 dropped:0 overruns:0 frame:0
          TX packets:390 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:29012 (28.3 KiB)  TX bytes:50254 (49.0 KiB)

pi@raspberrypi ~ $


Internet Test (via a 200Mbit/sec broadband connection)


Download a single 100MiB file to the Pi through the USB 2.0 Gigabit Ethernet Adapter and send the downloaded data to /dev/null.

pi@raspberrypi ~$ time time wget http://qrng.physik.hu-berlin.de/files/speedtest-100MB.bin -O /dev/null
time wget http://qrng.physik.hu-berlin.de/files/speedtest-100MB.bin -O /dev/null
--2014-05-04 01:06:23--  http://qrng.physik.hu-berlin.de/files/speedtest-100MB.bin
Resolving qrng.physik.hu-berlin.de (qrng.physik.hu-berlin.de)... 141.20.41.134
Connecting to qrng.physik.hu-berlin.de (qrng.physik.hu-berlin.de)|141.20.41.134|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: `/dev/null'

100%[=====================================================================>] 104,857,600 1.07M/s   in 2m 26s

2014-05-04 01:08:49 (701 KB/s) - `/dev/null' saved [104857600/104857600]


real    2m26.290s
user    0m0.880s
sys     0m3.130s
pi@raspberrypi ~ $


LAN Test

Download a single 100MiB file to the Pi through USB 2.0 Gigabit Ethernet Adapter and send the downloaded data to /dev/null. The data source is on the Local network from a machine with a 1 Gbit/sec NIC patched directly into the router with the data being read from a RAM disk to maximise read speed.
root@webserver:~# apt-get install nginx nginx-common nginx-full
root@webserver:~# /usr/sbin/nginx &
root@webserver:~# mkdir /usr/share/nginx/www/ramdisk
root@webserver:~# chmod 777 /usr/share/nginx/www/ramdisk
root@webserver:~# free -m
root@webserver:~# mount -t tmpfs -o size=256M tmpfs /usr/share/nginx/www/ramdisk
root@webserver:~# cp speedtest-100MB.bin /usr/share/nginx/www/ramdisk


pi@raspberrypi ~$  time wget http://*.*.*.*/ramdisk/speedtest-100MB.bin -O /dev/null
--2014-05-04 01:17:24--  http://*.*.*.*/ramdisk/speedtest-100MB.bin
Connecting to *.*.*.*:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: `/dev/null'

100%[=====================================================================>] 104,857,600 12.6M/s   in 8.0s

2014-05-04 01:17:32 (12.5 MB/s) - `/dev/null' saved [104857600/104857600]


real    0m8.049s
user    0m0.600s
sys     0m2.310s

pi@raspberrypi ~ $


Results
Peak Internet transfer rate 1.07MiB/sec (8.98Mbps) - about 13 hops away
Average Internet throughput 701KiB/sec - about 13 hops away.

Because this server is so many hops away it's throughput varies wildly with time of day and is effected by so  many uncontrolled fluctuations on every hop in between. This result is more an example of a typical Internet based throughput than a maximum throughput.







Peak LAN transfer rate 12.6 MiB/sec (105.7Mbps) - for 1000Mbps (even limited to USB 2.0 480Mbps) this is not a very good throughput.
Average LAN throughput 12.5 MiB/sec - for 1000Mbps (even limited to USB 2.0 480Mbps) this is not a very good throughput.

I'm not very pleased with the USB 2.0 Gigabit Ethernet Adapter result for the Raspberry Pi. I was expecting a result somewhere between 20 MiB/sec and 40 MiB/sec. I tried to enable jumbo frames ("sudo ifconfig eth1 mtu 9000") on the webserver and on the Raspberry Pi to see if I could get a better result, but I couldn't get it to work. I'm not quite sure why, yet but I'm still looking into it.

Additional testing

I decided to try the test in reverse. Install a webserver on the Raspberry P, and make a 128MiB ramdisk to download a file from the Raspberry Pi through USB 2.0, through the USB 2.0 Gigabit Ethernet Adapter down to the midrange PC with a Gigabit NIC, and then throw the data away.
pi@raspberrypi ~ $ sudo apt-get install nginx
pi@raspberrypi ~ $ sudo mkdir /usr/share/nginx/www/ramdisk 
pi@raspberrypi ~ $ sudo chmod 777 /usr/share/nginx/www/ramdisk
pi@raspberrypi ~ $ free -m 
pi@raspberrypi ~ $ sudo mount -t tmpfs -o size=128M tmpfs /usr/share/nginx/www/ramdisk
pi@raspberrypi ~ $  sudo cp speedtest-100MB.bin /usr/share/nginx/www/ramdisk

midrangepc $ time wget http://*.*.*.*/ramdisk/speedtest-100MB.bin -O /dev/null
--2014-05-04 17:56:38--  http://*.*.*.*/ramdisk/speedtest-100MB.bin
Connecting to *.*.*.*:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: `/dev/null'

100%[======================================>] 104,857,600 12.3M/s   in 7.8s

2014-05-04 17:56:46 (12.2 MB/s) - `/dev/null' saved [104857600/104857600]


real    0m7.819s
user    0m0.392s
sys     0m1.744s
midrangepc $


No better than before, slightly less, same general transfer rate. But I did notice one thing, that the CPU load on the Raspberry Pi hit the roof during the transfer, so I overclocked it from 700 to 1000 MHz ("sudo raspi-config") and ran the exact same test again.

midrangepc $ time wget http://*.*.*.*/ramdisk/speedtest-100MB.bin -O /dev/null
--2014-05-04 18:06:22--  http://*.*.*.*/ramdisk/speedtest-100MB.bin
Connecting to *.*.*.*:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: `/dev/null'

100%[======================================>] 104,857,600 17.0M/s   in 6.1s

2014-05-04 18:06:28 (16.4 MB/s) - `/dev/null' saved [104857600/104857600]


real    0m6.094s
user    0m0.312s
sys     0m1.588s
midrangepc$


Faster, so empirically it looks like there is not enough CPU grunt in the RPi to saturate this hardware to it's maximum throughput potential. Maybe the smsc75xx driver on the RPi which pushes data to the Microchip's LAN7500 Hi-Speed USB 2.0 to 10/100/1000 Ethernet Controller chip, is CPU bound and needs to be optimised for the ARM architecture. Or maybe this is just as good as it gets on the RPi, that it is already fully optimised.

I have searched the web and some people are seeing throughput of 38.2MB/sec (305.6Mibps) using a MacBook Air using the same USB 2.0 Gigabit Ethernet Adapter. Browsing through the latest Linux kernel log file for updates to smsc75xx there was a patch for jumbo frames, which may not be in the RPi kernel yet, which could explain my problems trying to use jumbo frames above. Reading through the source code for the smsc75xx.c driver is giving me a headache, so I think that I will just accept the probable fact that this hardware does not perform all that well on a RPi. And it appears to be CPU bound.

Update (Nov 2014): I ran the above tests on a Banana Pi and managed to achieve 39.5 MB/s (download) and 19.7 MB/s (upload). But it is not really required, since the Banana Pi has a builtin 10/100/1000Mbps NIC that I have tested that can download at 109 MB/sec (872Mbps) and upload data at 71.5 MB/s (572Mbps).