Sunday, 13 April 2014

WeTab WiFi throughput test (Atheros AR9285 Mini PCIe)

WiFi throughput test

I decided to check if my WeTab supported the 5GHz WiFi band, but unfortunately it did not (Atheros chip used only supports the 2.4 GHz frequency band). Then I thought that it might be good idea to have another hardware platform to compare my Raspberry Pi WiFi throughput results with. OK there are many differences even though both were tested around the same time. Different antennas and I'm sure that the WeTab's Wifi driver has been tweaked to extend battery life in favour of maximum throughput. RPi's WiFi is USB based and the WeTab is mini PCIe based.

I have censored any identifying information about my local network or personal hardware (or inserted some fake IP address instead).


Here is a quick summary of both sets of results.

Raspberry Pi Results:
802.11a 20MHz bandwidth (54Mb/s)  Summary: Min 1.51 MiB/sec Max 3.37 MiB/sec
802.11n 20MHz bandwidth (72Mb/s)  Summary: Min 3.77 MiB/sec Max 6.15 MiB/sec
802.11n 40MHz bandwidth (150Mb/s) Summary: Min 4.03 MiB/sec Max 9.67 MiB/sec

WeTab results:
802.11a 20MHz bandwidth (54Mb/s)  Summary: Min 1.02 MiB/sec Max 2.93 MiB/sec
802.11n 20MHz bandwidth (65Mb/s)  Summary: Min 3.34 MiB/sec Max 5.67 MiB/sec
802.11n 40MHz bandwidth (150Mb/s) Summary: Min 2.08 MiB/sec Max 6.14 MiB/sec

Hardware Configuration:

WeTab 3G
(RAM upgraded to 2GiB)
(mSATA SSD upgraded to 120GB) 
Both USB ports are empty.
SD slot is empty.
SIM card slot is empty.

+-----+           +------+           +----------------+
|WeTab|->150Mbps->|router|->200Mbps->|Remote webserver|
+-----+  802.11n  +------+ Internet  +----------------+
                     |
                 1Gbps Ethernet
                     |
                     v
            +-------------+
            |LAN webserver|
            +-------------+



[root@wetab ~]# lsusb
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 003: ID 12d1:1404 Huawei Technologies Co., Ltd. <- WCDMA EM770w
Bus 002 Device 004: ID 04f2:b213 Chicony Electronics Co., Ltd  <- Fujitsu Camera
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 002: ID 0eef:72a1 D-WAV Scientific Co., Ltd     <- TouchScreen
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 004: ID 0cf3:3002 Atheros Communications, Inc.  <- AR3011 Bluetooth
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
[root@wetab ~]# lsusb -t
Bus#  7
`-Dev#   1 Vendor 0x1d6b Product 0x0001
Bus#  6
`-Dev#   1 Vendor 0x1d6b Product 0x0001
  `-Dev#   4 Vendor 0x0cf3 Product 0x3002
Bus#  5
`-Dev#   1 Vendor 0x1d6b Product 0x0001
Bus#  4
`-Dev#   1 Vendor 0x1d6b Product 0x0001
Bus#  3
`-Dev#   1 Vendor 0x1d6b Product 0x0001
  `-Dev#   2 Vendor 0x0eef Product 0x72a1
Bus#  2
`-Dev#   1 Vendor 0x1d6b Product 0x0002
  |-Dev#   3 Vendor 0x12d1 Product 0x1404
  `-Dev#   4 Vendor 0x04f2 Product 0xb213
Bus#  1
`-Dev#   1 Vendor 0x1d6b Product 0x0002
[root@wetab ~]# lspci
00:00.0 Host bridge: Intel Corporation Pineview DMI Bridge
00:02.0 VGA compatible controller: Intel Corporation Pineview Integrated Graphics Controller
00:02.1 Display controller: Intel Corporation Pineview Integrated Graphics Controller
00:1a.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #4 (rev 04)
00:1a.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5 (rev 04)
00:1a.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2 (rev 04)
00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1 (rev 04)
00:1c.2 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 3 (rev 04)
00:1d.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1 (rev 04)
00:1d.1 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 04)
00:1d.2 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3 (rev 04)
00:1d.7 USB Controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1 (rev 04)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev f4)
00:1f.0 ISA bridge: Intel Corporation 82801HEM (ICH8M) LPC Interface Controller (rev 04)
00:1f.1 IDE interface: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller (rev 04)
00:1f.2 IDE interface: Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA IDE Controller (rev 04)
00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller (rev 04)
01:00.0 Network controller: Atheros Communications Inc. AR9285 Wireless Network Adapter (PCI-Express) (rev 01)
02:00.0 Multimedia controller: Broadcom Corporation Device 1615
[root@wetab ~]#  iwconfig wlan0
wlan0     IEEE 802.11bgn  ESSID:"**********"
          Mode:Managed  Frequency:2.472 GHz  Access Point: **:**:**:**:**:**
          Bit Rate=150 Mb/s   Tx-Power=12 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=70/70  Signal level=-48 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
[root@wetab ~]# ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 48:5D:60:**:**:**
          inet addr:192.168.1.123  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::4a5d:60ff:fe22:7652/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1693 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2639 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:750517 (732.9 KiB)  TX bytes:348880 (340.7 KiB)
[root@wetab ~]# 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
lo        16436   0      156      0      0      0      156      0      0      0 LRU
wlan0      1500   0     1712      0      0      0     2659      0      0      0 BMRU
[root@wetab ~]#


I am skipping the Internet test as there are so many uncontrollable variables. And I really want to try and see best case throughputs.

LAN Test

Download a single 100MiB file to the WeTab through WiFi 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 wireless router with the data being read from a RAM disk to maximise read performance.
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@wetab ~]#  wget http://192.168.1.234/ramdisk/speedtest-100MB.bin -O /dev/null ; wget http://192.168.1.234/ramdisk/speedtest-100MB.bin -O /dev/null ; wget http://192.168.1.234/ramdisk/speedtest-100MB.bin -O /dev/null
--2014-04-13 04:32:09--  http://192.168.1.234
/ramdisk/speedtest-100MB.bin
Connecting to
192.168.1.234:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 104857600 (100M) [application/octet-stream]
Saving to: `/dev/null'

... snip ... 


Results

I ran three wget commands in quick succession, and the results listed at the end of each line are the average download rates for the same 100MiB test file.

802.11a 20MHz bandwidth (54Mb/s) 
Summary: Min 1.02MiB/sec Max 2.93MiB/sec

[root@wetab ~]# iwconfig wlan0
wlan0     IEEE 802.11bgn  ESSID:"**********"
          Mode:Managed  Frequency:2.412 GHz  Access Point: **:**:**:**:**:**
          Bit Rate=54 Mb/s   Tx-Power=14 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=70/70  Signal level=-38 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:6  Invalid misc:14   Missed beacon:0
[root@wetab ~]#


channel  1 Frequency:2.412 GHz  1,64 MiB/s 1.74 MiB/s 1.60 MiB/s

channel  2 Frequency:2.417 GHz  2.08 MiB/s 2.03 MiB/s 2.07 MiB/s
channel  3 Frequency:2.422 GHz  2.20 MiB/s 2.25 MiB/s 2.29 MiB/s
channel  4 Frequency:2.427 GHz  1.65 MiB/s 1.68 MiB/s 1.66 MiB/s
channel  5 Frequency:2.432 GHz  2.64 MiB/s 2.77 MiB/s 2.60 MiB/s
channel  6 Frequency:2.437 GHz  1.20 MiB/s 1.18 MiB/s 1.02 MiB/s
channel  7 Frequency:2.442 GHz  2.65 MiB/s 2.72 MiB/s 2.71 MiB/s
channel  8 Frequency:2.447 GHz  2.92 MiB/s 2.87 MiB/s 2.93 MiB/s
channel  9 Frequency:2.452 GHz  2.60 MiB/s 2.63 MiB/s 2.67 MiB/s
channel 10 Frequency:2.457 GHz  2.65 MiB/s 2.53 MiB/s 2.41 MiB/s
channel 11 Frequency:2.462 GHz  1.91 MiB/s 1.95 MiB/s 1.92 MiB/s
channel 12 Frequency:2.467 GHz  1.78 MiB/s 1.74 MiB/s 1.87 MiB/s
channel 13 Frequency:2.472 GHz  2.53 MiB/s 2.53 MiB/s 2.51 MiB/s

 


802.11n 20MHz bandwidth (65Mb/s) 
Summary: Min 3.34MiB/sec Max 5.67MiB/sec

[root@wetab ~]# iwconfig wlan0
wlan0     IEEE 802.11bgn  ESSID:"**********"
          Mode:Managed  Frequency:2.412 GHz  Access Point: **:**:**:**:**:**
          Bit Rate=65 Mb/s   Tx-Power=14 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=70/70  Signal level=-40 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:6  Invalid misc:14   Missed beacon:0
[root@wetab ~]#

channel  1 Frequency:2.412 GHz  4.90 MiB/s 4.01 MiB/s 4.76 MiB/s

channel  2 Frequency:2.417 GHz  4.99 MiB/s 4.97 MiB/s 5.08 MiB/s
channel  3 Frequency:2.422 GHz  3.56 MiB/s 4.10 MiB/s 5.16 MiB/s
channel  4 Frequency:2.427 GHz  5.08 MiB/s 5.28 MiB/s 5.35 MiB/s
channel  5 Frequency:2.432 GHz  5.04 MiB/s 4.91 MiB/s 4.75 MiB/s
channel  6 Frequency:2.437 GHz  3.34 MiB/s 3.64 MiB/s 3.48 MiB/s
channel  7 Frequency:2.442 GHz  5.44 MiB/s 5.60 MiB/s 5.62 MiB/s
channel  8 Frequency:2.447 GHz  5.44 MiB/s 5.50 MiB/s 4.45 MiB/s
channel  9 Frequency:2.452 GHz  5.51 MiB/s 5.67 MiB/s 5.62 MiB/s
channel 10 Frequency:2.457 GHz  5.40 MiB/s 5.58 MiB/s 5.66 MiB/s
channel 11 Frequency:2.462 GHz  5.43 MiB/s 5.49 MiB/s 5.50 MiB/s
channel 12 Frequency:2.467 GHz  5.32 MiB/s 5.41 MiB/s 5.38 MiB/s
channel 13 Frequency:2.472 GHz  5.45 MiB/s 5.50 MiB/s 5.58 MiB/s







802.11n 40MHz bandwidth (150Mb/s)
Summary: Min 2.08MiB/sec Max 6.14MiB/sec


[root@wetab ~]#  iwconfig wlan0
wlan0     IEEE 802.11bgn  ESSID:"**********"
          Mode:Managed  Frequency:2.472 GHz  Access Point: **:**:**:**:**:**
          Bit Rate=150 Mb/s   Tx-Power=12 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:on
          Link Quality=70/70  Signal level=-48 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
[root@wetab ~]#

channel  1L Frequency:2.412 GHz  2.08 MiB/s 4.22 MiB/s 4.37 MiB/s
channel  2L Frequency:2.417 GHz  5.60 MiB/s 5.57 MiB/s 5.45 MiB/s
channel  3L Frequency:2.422 GHz  5.86 MiB/s 5.85 MiB/s 5.87 MiB/s
channel  4L Frequency:2.427 GHz  5.97 MiB/s 5.92 MiB/s 5.75 MiB/s
channel  5L Frequency:2.432 GHz  5.49 MiB/s 5.59 MiB/s 5.58 MiB/s
channel  6L Frequency:2.437 GHz  5.68 MiB/s 5.71 MiB/s 5.71 MiB/s
channel  7L Frequency:2.442 GHz  5.72 MiB/s 5.85 MiB/s 5.92 MiB/s
channel  8L Frequency:2.447 GHz  5.70 MiB/s 5.76 MiB/s 5.78 MiB/s
channel  9L Frequency:2.452 GHz  5.50 MiB/s 5.44 MiB/s 5.56 MiB/s

channel  5U Frequency:2.432 GHz  5.24 MiB/s 5.01 MiB/s 5.11 MiB/s
channel  6L Frequency:2.437 GHz  4.90 MiB/s 4.93 MiB/s 4.49 MiB/s
channel  7L Frequency:2.442 GHz  5.51 MiB/s 5.40 MiB/s 5.27 MiB/s
channel  8L Frequency:2.447 GHz  5.41 MiB/s 5.40 MiB/s 5.95 MiB/s
channel  9L Frequency:2.452 GHz  6.14 MiB/s 5.95 MiB/s 5.96 MiB/s
channel 10L Frequency:2.457 GHz  5.81 MiB/s 5.77 MiB/s 5.87 MiB/s
channel 11L Frequency:2.462 GHz  4.89 MiB/s 4.59 MiB/s 5.49 MiB/s
channel 12L Frequency:2.467 GHz  5.59 MiB/s 5.84 MiB/s 5.70 MiB/s
channel 13L Frequency:2.472 GHz  5.63 MiB/s 5.74 MiB/s 5.75 MiB/s

Monday, 7 April 2014

Part two: Raspberry Pi WiFi throughput test


Update (2015-02): There will be little to no change in throughput performance from the new Raspberry Pi Generation 2 Model B (900MHz quad-core ARM Cortex-A7 BCM2836) over the older Raspberry Pi Model B+ (700MHz ARM11 BCM2835), since the USB performance bottleneck is still the LAN9514 USB/Ethernet controller and will not be improved by additional CPU or RAM.

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.



When I looked at the performance of 802.11n I only looked at the highest possible throughput setting that I could setup (In my case a 150Mbps on a TP-LINK WN725N which is software compatible with 8188eu USB Wifi dongle). But not everyone has a 802.11n WiFi adapter, so I decided to run the tests again but this time to force the Wifi to lower performance modes, to see the different throughput rates. This is wireless so my results will differ than anyone else's but they should give a idea of what kind of real world (non-marketing) throughput to expect.

But one thing to remember is that these are maximum throughput rates, since all WiFi data received is being thrown away. If the data was written to an SD card then four other things would need to be factored in: The make and model of the SD card, the read performance of the card; the write performance of the card and most importantly the age of the card. The more writes you do to a SD card the slower it's overall performance becomes, anyhow the initial performance of most SD cards can be found here

The setup is exactly the same as last time. A midrange Linux PC running a nginx webserver serving a 100MiB file from a 256MiB RAM disk. The data flows through a 1Gigabit/sec full duplex NIC to a home cable modem from there it is sent via WiFi to my USB Raspberry Pi WiFi NIC and finally sent to /dev/null to eliminate any SD/harddisk access times. I set the speed on the broadband router to three different settings:
54Mbit/sec = disable 802.11n.

72Mbit/sec = 802.11n 20MHz bandwidth,
150Mbit/sec = 802.11n 40MHz bandwidth,

And after setting the channel and speed, I confirmed both had actually changed correctly on the RPi with the iwconfig command. I also download the same 100MiB file 3 times in a row and these are the numbers MiB/second numbers on each row below.

e.g.
wget http://192.168.1.100/ramdisk/speedtest-100MB.bin -O /dev/null ; wget http://192.168.1.100/ramdisk/speedtest-100MB.bin -O /dev/null ; wget http://192.168.1.100/ramdisk/speedtest-100MB.bin -O /dev/null


pi@raspberrypi ~ $ sudo iwconfig wlan0
wlan0     IEEE 802.11bgn  ESSID:"**********"  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency:2.472 GHz  Access Point: 80:C6:AB:**:**:**
          Bit Rate: 54 Mb/s   Sensitivity:0/0
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:****-****-****-****-****-****-****-****   Security mode:open
          Power Management:off
          Link Quality=100/100  Signal level=100/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
pi@raspberrypi ~ $



802.11a
802.11 band: 2.4GHz
Bit Rate: 54Mb/s  (6.44MiB/sec)
Bandwidth 20MHz 
Download rate: 1.51 MiB/sec <-> 3.37 MiB/sec
Download rate: 12.67 Mbit/sec <->  28.27 Mbit/sec
channel  1  Frequency:2.412 GHz  2.10 MB/s 2.14 MB/s 2.12 MB/s
channel  2  Frequency:2.417 GHz  1.83 MB/s 1.88 MB/s 1.87 MB/s
channel  3  Frequency:2.422 GHz  1.51 MB/s 1.57 MB/s 1.55 MB/s
channel  4  Frequency:2.427 GHz  1.61 MB/s 1.64 MB/s 1.65 MB/s
channel  5  Frequency:2.432 GHz  2.30 MB/s 2.29 MB/s 2.28 MB/s
channel  6  Frequency:2.437 GHz  2.48 MB/s 2.45 MB/s 2.44 MB/s
channel  7  Frequency:2.442 GHz  2.92 MB/s 2.91 MB/s 2.93 MB/s
channel  8  Frequency:2.447 GHz  2.96 MB/s 2.98 MB/s 2.97 MB/s
channel  9  Frequency:2.452 GHz  2.72 MB/s 2.74 MB/s 2.69 MB/s
channel 10  Frequency:2.457 GHz  3.00 MB/s 3.06 MB/s 3.05 MB/s
channel 11  Frequency:2.462 GHz  2.98 MB/s 3.01 MB/s 3.05 MB/s
channel 12  Frequency:2.467 GHz  3.22 MB/s 3.21 MB/s 3.23 MB/s
channel 13  Frequency:2.472 GHz  3.36 MB/s 3.37 MB/s 3.34 MB/s



802.11n
802.11 band: 2.4GHz
Bit Rate: 72  Mb/s (8.58MiB/sec)
Bandwidth 20MHz
Download rate: 3.77 MiB/sec <-> 6.15 MiB/sec
Download rate: 31.63 Mbit/sec <->  51.59 Mbit/sec

channel  1  Frequency:2.412 GHz  4.47 MiB/s 4.68 MiB/s 4.74 MiB/s
channel  2  Frequency:2.417 GHz  4.28 MiB/s 4.32 MiB/s 4.10 MiB/s
channel  3  Frequency:2.422 GHz  3.82 MiB/s 3.82 MiB/s 3.77 MiB/s
channel  4  Frequency:2.427 GHz  4.08 MiB/s 4.06 MiB/s 4.22 MiB/s
channel  5  Frequency:2.432 GHz  5.15 MiB/s 4.84 MiB/s 4.97 MiB/s
channel  6  Frequency:2.437 GHz  5.27 MiB/s 5.19 MiB/s 5.31 MiB/s
channel  7  Frequency:2.442 GHz  5.47 MiB/s 5.61 MiB/s 5.76 MiB/s
channel  8  Frequency:2.447 GHz  5.92 MiB/s 6.15 MiB/s 6.04 MiB/s
channel  9  Frequency:2.452 GHz  5.45 MiB/s 5.44 MiB/s 5.41 MiB/s
channel 10  Frequency:2.457 GHz  6.04 MiB/s 6.12 MiB/s 6.02 MiB/s
channel 11  Frequency:2.462 GHz  5.72 MiB/s 5.63 MiB/s 5.67 MiB/s
channel 12  Frequency:2.467 GHz  5.78 MiB/s 5.85 MiB/s 5.74 MiB/s
channel 13  Frequency:2.472 GHz  6.07 MiB/s 6.11 MiB/s 6.08 MiB/s



802.11n
802.11 band: 2.4GHz
Bit Rate: 150  Mb/s (17.88MiB/sec)
Bandwidth 40MHz
Download rate: 4.03 MiB/sec <-> 9.67 MiB/sec
Download rate: 33.81 Mbit/sec <-> 81.11 Mbit/sec

channel  1L Frequency:2.412 GHz  8.92 MiB/s 9.24 MiB/s 7.66 MiB/s
channel  2L Frequency:2.417 GHz  8.46 MiB/s 8.99 MiB/s 5.70 MiB/s
channel  3L Frequency:2.422 GHz  9.16 MiB/s 8.41 MiB/s 9.32 MiB/s
channel  4L Frequency:2.427 GHz  5.19 MiB/s 8.62 MiB/s 8.31 MiB/s
channel  5L Frequency:2.432 GHz  4.23 MiB/s 4.37 MiB/s 4.74 MiB/s
channel  6L Frequency:2.437 GHz  4.03 MiB/s 7.91 MiB/s 9.38 MiB/s
channel  7L Frequency:2.442 GHz  8.22 MiB/s 8.01 MiB/s 8.03 MiB/s
channel  8L Frequency:2.447 GHz  9.58 MiB/s 8.12 MiB/s 9.67 MiB/s
channel  9L Frequency:2.452 GHz  5.47 MiB/s 5.26 MiB/s 5.35 MiB/s

channel  5U Frequency:2.432 GHz  7.91 MiB/s 7.92 MiB/s 9.48 MiB/s
channel  6U Frequency:2.437 GHz  7.58 MiB/s 9.05 MiB/s 7.58 MiB/s
channel  7U Frequency:2.442 GHz  7.10 MiB/s 9.48 MiB/s 9.41 MiB/s
channel  8U Frequency:2.447 GHz  9.52 MiB/s 9.38 MiB/s 9.15 MiB/s
channel  9U Frequency:2.452 GHz  9.42 MiB/s 9.22 MiB/s 9.07 MiB/s
channel 10U Frequency:2.457 GHz  8.77 MiB/s 9.46 MiB/s 8.10 MiB/s
channel 11U Frequency:2.462 GHz  8.65 MiB/s 9.30 MiB/s 9.41 MiB/s
channel 12U Frequency:2.467 GHz  8.64 MiB/s 9.01 MiB/s 9.34 MiB/s
channel 13U Frequency:2.472 GHz  9.02 MiB/s 9.55 MiB/s 8.45 MiB/s

My Wifi router supports four 20MHz channels in the 5GHz band (36, 40, 44, 48 [5.180GHz 5.200GHz 5.220GHz 5.240GHz]) but unfortunately my TP-LINK nano USB WN725N only supports the 2.4GHz band (2.4 ~ 2.4835GHz), so I can't test the throughputs in the 5GHz band. Which is a pity, because higher RF frequency means lower penetration depth into objects, so I would expect less interference at higher frequencies.

Sunday, 30 March 2014

Raspberry Pi USB disk throughput test

Update (2015-02): There will be little to no change in throughput performance from the new Raspberry Pi Generation 2 Model B (900MHz quad-core ARM Cortex-A7 BCM2836) over the older Raspberry Pi Model B+ (700MHz ARM11 BCM2835), since the USB performance bottleneck is still the LAN9514 USB/Ethernet controller and will not be improved by additional CPU or RAM.

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.


Hardware Configuration:

Raspberry Pi model B - 512MB model, 128MB of RAM allocated to GPU, no overclocking
Inbuilt 10/100 NIC is connected.
Top USB port is a 2TB USB hard disk drive.
Bottom USB port is empty.

So no keyboard, no mouse. In an ideal world we would have the inbuilt USB NIC disabled (after setting the date and time) as well, but it appears that the RPi has the network module compiled directly into the kernel.
pi@raspberrypi ~ $ zgrep -i smsc95xx /proc/config.gz
CONFIG_USB_NET_SMSC95XX=y
pi@raspberrypi ~ $ sudo modprobe -r smsc95xx
FATAL: Module smsc95xx is builtin.

So to just have a hard disk  and RPi (and internal 3 port USB hub) would require me to recompile the kernel, which would make the results slightly off standard

The HDD that I'm using has an Internal write rate of about 100MiB/sec, so USB throughput should be the cause of any performance bottleneck.

 

Prerequisites:

sudo apt-get install at expect expect-dev



ext2, ext3, ext4, vfat file system write tests 


I split a 2 TB disk into four equal sized partitions.

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 2: Dev 4, If 0, Class=stor., Driver=usb-storage, 480M

pi@raspberrypi ~ $ sudo fdisk -l /dev/sda

Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x1ba9000c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048   976758827   488378390   83  Linux
/dev/sda2       976758828  1953515607   488378390   83  Linux
/dev/sda3      1953515608  2930272387   488378390   83  Linux
/dev/sda4      2930272388  3907029167   488378390    c  W95 FAT32 (LBA)


pi@raspberrypi ~ $ sudo mkfs.ext2 -L ext2 /dev/sda1

pi@raspberrypi ~ $ sudo mkfs.ext3 -L ext3 /dev/sda2
pi@raspberrypi ~ $ sudo mkfs.ext4 -L ext4 /dev/sda3
pi@raspberrypi ~ $ sudo mkfs.vfat -n vfat /dev/sda4
pi@raspberrypi ~ $ cd /media 
pi@raspberrypi /media $ sudo mkdir ext2 ext3 ext4 vfat




pi@raspberrypi ~ $ at midnight

warning: commands will be executed using /bin/sh
at> /home/pi/write-throughputtest.exp 2>&1 >/home/pi/at.output 
at> ^D




pi@raspberrypi ~ $

 


pi@raspberrypi ~ $ cat write-throughputtest.exp
#!/usr/bin/expect -f
#
# This Expect script was generated by autoexpect on Sun Mar 30 16:43:25 2014
set force_conservative 0  ;# set to 1 to force conservative mode even if
                          ;# script wasn't run conservatively originally
if {$force_conservative} {
        set send_slow {1 .1}
        proc send {ignore arg} {
                sleep .1
                exp_send -s -- $arg
        }
}



set timeout -1
spawn $env(SHELL)
match_max 100000

expect "$"
send -- "/bin/bash"
expect "pi@raspberrypi"
send -- "sudo /bin//bash\r"
expect "root@raspberrypi"
send -- "script /home/pi/output-root.txt\r"
expect "Script started, file is /home/pi/output-root.txt\r"
send -- "mount /dev/sda1 /media/ext2\r"
expect "root@raspberrypi"
send -- "mount /dev/sda2 /media/ext3\r"
expect "root@raspberry
pi"
send -- "mount /dev/sda3 /media/ext4\r"
expect "root@raspberry
pi"
send -- "mount /dev/sda4 /media/vfat\r"
expect "root@raspberry
pi"
send -- "/home/pi/write-throughputtest.sh /media/ext2\r"
expect "root@raspberry
pi"
send -- "/home/pi/
write-throughputtest.sh /media/ext3\r"
expect "root@raspberry
pi"
send -- "/home/pi/
write-throughputtest.sh /media/ext4\r"
expect "root@raspberry
pi"
send -- "/home/pi/
write-throughputtest.sh /media/vfat\r"
expect "root@raspberry
pi"
send -- "exit\r"
expect "Script done, file is /home/pi/output-root.txt\r"
send -- "exit\r"
expect "pi@raspberry
pi"
send -- "exit\r"

expect "$"
send -- "exit\r"
expect eof
 


pi@raspberrypi ~ $ cat write-throughputtest.sh
#!/bin/sh
DEST=$1

# 18 x 1GiB = 18GiB
# assuming maximum write 40MiB/sec this should take 8 minutes
# assuming poor write speed of 5 MiB/sec this should take 2 hours
# either way one pass should happen within 12 hours
echo touch $DEST/testbegin-write-starttime
touch $DEST/testbegin-write-starttime
date
echo sync
sync
date

for BS in 8 16 32 64 128 256 \
        512 1024 2048 4096 8192 16384 \
        32768 65536 131072 262144 524288 1048576

do
 COUNT=`expr 1073741824 / $BS`
echo touch $DEST/${BS}b-write-starttime
 touch $DEST/${BS}b-write-starttime
date
echo dd if=/dev/zero of=$DEST/${BS}b-data bs=${BS} count=${COUNT}
 dd if=/dev/zero of=$DEST/${BS}b-data bs=${BS} count=${COUNT}
date
echo touch $DEST/${BS}b-write-endtime
 touch $DEST/${BS}b-write-endtime
date
echo sync
 sync
date
# any delay caused by sync will show up on next starttime
done

echo touch $DEST/testover-write-endtime
touch $DEST/testover-write-endtime
date


pi@raspberrypi ~ $ cat read-throughputtest.sh
#!/bin/sh
SRCE=$1

# 18 x 1GiB = 18GiB

# assuming maximum read 40MiB/sec this should take 8 minutes
# assuming poor read speed of 5 MiB/sec this should take 2 hours
# This script assumes that write-throughputtest.sh was run
# previously to generate the data files.

date
echo sync
sync
date

for BS in 8 16 32 64 128 256 \

        512 1024 2048 4096 8192 16384 \
        32768 65536 131072 262144 524288 1048576

do

 COUNT=`expr 1073741824 / $BS`
date
echo dd of=/dev/null if=$SRCE/${BS}b-data bs=${BS} count=${COUNT}
 dd of=/dev/null if=$SRCE/${BS}b-data bs=${BS} count=${COUNT}
date
echo sync
 sync
date
done

date


pi@raspberrypi ~ $



 Results

USB disk performance check Raspberry Pi normal USB (internal 3 port hub)


Raspberry Pi Model B USB disk write results
-----------------------------------------------------------
block             filesystem type
size   -------------------------------------------            
(bytes)ext2       ext3       ext4       vfat
8       0.2 MiB/s  0.3 MiB/s  0.3 MiB/s  0.8 MiB/s
16      0.4 MiB/s  0.5 MiB/s  0.6 MiB/s  1.5 MiB/s
32      0.9 MiB/s  1.0 MiB/s  1.1 MiB/s  2.9 MiB/s
64      2.5 MiB/s  1.8 MiB/s  1.9 MiB/s  4.4 MiB/s
128     4.7 MiB/s  3.2 MiB/s  3.5 MiB/s  6.3 MiB/s
256     7.4 MiB/s  5.5 MiB/s  6.1 MiB/s  9.4 MiB/s
512    10.6 MiB/s  8.5 MiB/s  9.5 MiB/s 12.2 MiB/s
1k     14.9 MiB/s 11.3 MiB/s 13.8 MiB/s 13.1 MiB/s
2k     18.4 MiB/s 14.2 MiB/s 18.6 MiB/s 15.1 MiB/s
4k     20.8 MiB/s 17.7 MiB/s 22.5 MiB/s 17.0 MiB/s
8k     21.3 MiB/s 18.6 MiB/s 22.8 MiB/s 16.7 MiB/s
16k    21.3 MiB/s 19.0 MiB/s 22.4 MiB/s 17.0 MiB/s
32k    21.3 MiB/s 19.0 MiB/s 22.5 MiB/s 16.9 MiB/s
64k    20.7 MiB/s 18.7 MiB/s 22.9 MiB/s 16.9 MiB/s
128k   21.3 MiB/s 18.1 MiB/s 22.7 MiB/s 16.4 MiB/s
256k   21.3 MiB/s 18.4 MiB/s 22.4 MiB/s 16.5 MiB/s
512k   21.6 MiB/s 18.9 MiB/s 22.3 MiB/s 16.8 MiB/s

1M     20.9
MiB/s 19.2 MiB/s 22.4 MiB/s 16.9 MiB/s

For the small block sizes there is almost no disk activity, long pauses with no blinking RED LED's.
I'm begining to wonder if some options in Raspbian have been enabled to extend the life of the RPi SSD.

Raspberry Pi Model B USB disk read results
-----------------------------------------------------------
block             filesystem type
size   -------------------------------------------           
(bytes)ext2       ext3       ext4       vfat
8       1.6 MiB/s  2.0 MiB/s  1.7 MiB/s  1.9 MiB/s
16      3.9 MiB/s  3.5 MiB/s  3.6 MiB/s  3.8 MiB/s
32      6.9 MiB/s  6.7 MiB/s  7.2 MiB/s  6.8 MiB/s
64     
10.5 MiB/s 10.4 MiB/s 10.2 MiB/s 10.4 MiB/s
128    18.0 MiB/s 16.5 MiB/s 15.2 MiB/s 17.0 MiB/s
256    23.3 MiB/s 22.6 MiB/s 22.1 MiB/s 22.2 MiB/s
512    23.2 MiB/s 23.2 MiB/s 23.4 MiB/s 21.7 MiB/s
1k     23.6 MiB/s 23.2 MiB/s 23.6 MiB/s 22.0 MiB/s
2k     23.7 MiB/s 23.2 MiB/s 23.6 MiB/s 22.3 MiB/s
4k     23.6 MiB/s 22.9 MiB/s 23.6 MiB/s 23.3 MiB/s
8k     22.6 MiB/s 22.3 MiB/s 23.7 MiB/s 23.7 MiB/s
16k    23.6 MiB/s 23.6 MiB/s 23.7 MiB/s 23.7 MiB/s
32k    22.4 MiB/s 23.6 MiB/s 22.6 MiB/s 23.7 MiB/s
64k    22.5 MiB/s 23.6 MiB/s 22.7 MiB/s 23.7 MiB/s
128k   23.7 MiB/s 22.4 MiB/s 22.8 MiB/s 23.7 MiB/s
256k   23.7 MiB/s 22.5 MiB/s 23.8 MiB/s 23.7 MiB/s
512k   23.7 MiB/s 22.6 MiB/s 23.7 MiB/s 23.7 MiB/s
1M     23.7 MiB/s 22.4 MiB/s 23.7 MiB/s 23.7 MiB/s




USB disk performance check (midrange desktop PC) - dedicated USB port

For comparison with the above Raspberry Pi results , here are desktop PC results:

midrange desktop PC disk write results (dedicated HS USB 2.0 port)
------------------------------------------------------------------
block             filesystem type
size   -------------------------------------------             
(bytes)ext2       ext3       ext4       vfat
8       6.3 MiB/s  3.8 MiB/s  3.9 MiB/s  5.4 MiB/s
16     12.9 MiB/s  7.6 MiB/s  7.8 MiB/s 11.1 MiB/s
32     26.1 MiB/s 15.0 MiB/s 15.9 MiB/s 19.4 MiB/s
64     34.9 MiB/s 21.1 MiB/s 31.7 MiB/s 23.3 MiB/s
128    34.9 MiB/s 21.8 MiB/s 37.7 MiB/s 24.0 MiB/s
256    34.2 MiB/s 22.2 MiB/s 37.5 MiB/s 23.4 MiB/s
512    34.1 MiB/s 22.7 MiB/s 37.3 MiB/s 23.5 MiB/s
1k     34.1 MiB/s 22.8 MiB/s 37.1 MiB/s 24.7 MiB/s
2k     33.8 MiB/s 22.7 MiB/s 37.5 MiB/s 24.5 MiB/s
4k     34.0 MiB/s 22.3 MiB/s 37.2 MiB/s 24.4 MiB/s
8k     34.1 MiB/s 22.7 MiB/s 37.4 MiB/s 24.9 MiB/s
16k    35.1 MiB/s 22.9 MiB/s 37.5 MiB/s 23.7 MiB/s
32k    36.0 MiB/s 22.7 MiB/s 37.5 MiB/s 25.4 MiB/s
64k    35.4 MiB/s 23.5 MiB/s 37.6 MiB/s 24.8 MiB/s
128k   35.3 MiB/s 23.1 MiB/s 37.2 MiB/s 24.4 MiB/s
256k   35.6 MiB/s 23.0 MiB/s 37.6 MiB/s 25.5 MiB/s
512k   35.9 MiB/s 23.3 MiB/s 37.6 MiB/s 25.2 MiB/s
1M     35.9 MiB/s 22.7 MiB/s 37.6 MiB/s 25.2 MiB/s

For High Speed USB 2.0 the maximum data rate is about 40MB/sec (38.1MiB/sec) None of the tested filesystems hit this but ext4 did come closest, but not on the Raspberry Pi unfortunately.

('lsusb -t' does shows 480M, which in theory would correspond to 57.2MiB/sec, but there protocol overheads within USB. The maximum should be 53.248 MB/s, but this appears to be deliberately limited to around 30-42MB/sec to maintain interoperability with USB stacks in OS'es over throughput speed).

midrange desktop PC disk read results (dedicated HS USB 2.0 port)
-----------------------------------------------------------------
block             filesystem type
size   -------------------------------------------            
(bytes)ext2       ext3       ext4       vfat
8      18.4 MiB/s 16.8 MiB/s 18.4 MiB/s 18.6 MiB/s
16     32.5 MiB/s 29.3 MiB/s 36.6 MiB/s 35.0 MiB/s
32     32.5 MiB/s 29.0 MiB/s 35.9 MiB/s 34.5 MiB/s
64     33.6 MiB/s 30.4 MiB/s 36.2 MiB/s 35.6 MiB/s
128    33.3 MiB/s 29.9 MiB/s 36.0 MiB/s 35.0 MiB/s
256    32.7 MiB/s 30.3 MiB/s 36.1 MiB/s 34.8 MiB/s
512    33.4 MiB/s 29.9 MiB/s 36.0 MiB/s 35.0 MiB/s
1k     33.5 MiB/s 30.2 MiB/s 36.2 MiB/s 35.9 MiB/s
2k     33.7 MiB/s 30.7 MiB/s 36.4 MiB/s 34.7 MiB/s
4k     34.0 MiB/s 30.5 MiB/s 36.1 MiB/s 35.9 MiB/s
8k     34.0 MiB/s 30.8 MiB/s 36.4 MiB/s 35.4 MiB/s
16k    34.0 MiB/s 30.9 MiB/s 36.4 MiB/s 35.5 MiB/s
32k    34.0 MiB/s 30.7 MiB/s 36.5 MiB/s 35.2 MiB/s
64k    33.7 MiB/s 30.4 MiB/s 36.4 MiB/s 35.2 MiB/s
128k   33.5 MiB/s 30.7 MiB/s 36.4 MiB/s 36.0 MiB/s
256k   33.4 MiB/s 30.5 MiB/s 36.4 MiB/s 34.8 MiB/s
512k   33.5 MiB/s 30.5 MiB/s 36.1 MiB/s 35.8 MiB/s
1M     33.2 MiB/s 30.5 MiB/s 36.5 MiB/s 35.7 MiB/s



I really wonder what the USB performance is for a Model A, which does not have an internal 3 port USB hub inside with a USB NIC connected to one of the ports. For all of the tests above there was basically no network traffic to/from the RPi, and even with that the performance of the USB  is not all that great. But even so it does appear that USB is the fastest way to get data into and out of the Raspberry Pi.


Internal disk performance check (midrange desktop PC)

I reconnected the same 2TB disk to a dedicated 1.5Gbit/sec eSATA port on the back of the desktop PC just to confirm that USB was in fact the bottleneck for data transfers. And to verify that there were no problems with the hard disk that I used.

midrange desktop PC disk write results (1.5 Gbit/sec eSATA port)
------------------------------------------------------------------
block             filesystem type
size   -------------------------------------------            
(bytes)ext2       ext3       ext4       vfat
8       7.2 MiB/s  4.2 MiB/s  4.2 MiB/s  6.4 MiB/s
16     14.6 MiB/s  8.4 MiB/s  8.6 MiB/s 12.3 MiB/s
32     28.5 MiB/s 16.2 MiB/s 16.9 MiB/s 22.0 MiB/s
64     55.9 MiB/s 29.2 MiB/s 34.3 MiB/s 35.5 MiB/s
128    72.1 MiB/s 53.7 MiB/s 61.8 MiB/s 47.8 MiB/s
256    69.4 MiB/s 64.6 MiB/s 59.4 MiB/s 52.4 MiB/s
512    68.3 MiB/s 63.2 MiB/s 58.7 MiB/s 52.7 MiB/s
1k     66.9 MiB/s 62.1 MiB/s 58.4 MiB/s 54.1 MiB/s
2k     66.2 MiB/s 61.4 MiB/s 58.7 MiB/s 54.1 MiB/s
4k     64.8 MiB/s 60.7 MiB/s 58.1 MiB/s 54.1 MiB/s
8k     64.3 MiB/s 60.2 MiB/s 57.3 MiB/s 53.5 MiB/s
16k    64.5 MiB/s 60.6 MiB/s 57.2 MiB/s 52.5 MiB/s
32k    63.2 MiB/s 59.7 MiB/s 56.9 MiB/s 55.4 MiB/s
64k    63.4 MiB/s 60.7 MiB/s 56.8 MiB/s 53.3 MiB/s
128k   62.8 MiB/s 59.2 MiB/s 56.6 MiB/s 53.0 MiB/s
256k   62.6 MiB/s 59.6 MiB/s 56.4 MiB/s 53.1 MiB/s
512k   62.1 MiB/s 58.7 MiB/s 55.3 MiB/s 52.2 MiB/s
1M     61.6 MiB/s 58.3 MiB/s 53.9 MiB/s 52.3 MiB/s



midrange desktop PC disk read results (1.5 Gbit/sec eSATA port)
-----------------------------------------------------------------
block             filesystem type
size   -------------------------------------------           
(bytes)ext2       ext3       ext4       vfat
8      18.7MiB/s  18.6MiB/s  18.5MiB/s  18.5MiB/s
16     36.4MiB/s  36.4MiB/s  36.8MiB/s  36.6MiB/s
32     71.2MiB/s  70.1MiB/s  72.5MiB/s  70.0MiB/s
64    117.3MiB/s 110.6MiB/s  98.2MiB/s  82.3MiB/s
128   116.3MiB/s 111.6MiB/s  98.2MiB/s  82.8MiB/s
256   117.3Mib/s 110.6MiB/s  98.2MiB/s  81.9MiB/s
512   117.3Mib/s 110.6MiB/s  99.2MiB/s  81.3MiB/s
1k    116.3MiB/s 109.7MiB/s  98.2MiB/s  81.3MiB/s
2k    118.3MiB/s 108.7MiB/s  97.3MiB/s  81.3MiB/s
4k    117.3Mib/s 108.7MiB/s  96.3MiB/s  81.3MiB/s
8k    117.3Mib/s 108.7MiB/s  95.2MiB/s  81.3MiB/s
16k   118.3MiB/s 108.7MiB/s  95.4MiB/s  81.3MiB/s
32k   118.3MiB/s 108.7MiB/s  95.4MiB/s  81.3MiB/s
64k   118.3MiB/s 108.7MiB/s  95.3MiB/s  81.3MiB/s
128k  118.3MiB/s 108.7MiB/s  95.3MiB/s  81.0MiB/s
256k  118.3MiB/s 108.7MiB/s  95.2MiB/s  81.4MiB/s
512k  118.3MiB/s 108.7MiB/s  94.7MiB/s  81.3MiB/s
1M    118.3MiB/s 107.8MiB/s  94.2MiB/s  81.3MiB/s


All the results say that the HDD was functioning within expected parameters. So all transfer limits (64+ bytes) were due to USB protocol limitation or the 3 port USB hub internal to the Raspberry Pi.