Raspberry Pi 4 is capable of moving data over the network at reasonable speeds but there is a huge difference between WiFi and Ethernet performance, especially if you prefer to store your data on SSD drives and not on SD cards.
Table of Contents
First of all, it’s good to keep in mind that we can’t trust the benchmarks completely. Real-world performance can depend on many factors and it’s always good to reproduce the same tests with your own hardware and in your own environment. Also, some tests can better reflect your workloads so you may tweak the input according to your needs.
Here is what my test does:
- generate 1 GB of random data on my laptop
- send this data to my Raspberry Pi and measure the average speed
- fetch this data from my Raspberry Pi and measure the average speed
I repeated this test with four different configurations:
- Raspberry Pi that uses WiFi and stores data on SD card
- Raspberry Pi that uses WiFi and stores data on SSD drive
- Raspberry Pi that uses Ethernet and stores data on SD card
- Raspberry Pi that uses Ethernet and stores data on SSD drive
That’s it. Now, it’s time to generate that random data.
Generating Test Data
We can use
dd to generate a new file and
/dev/urandom is a great data source:
dd if=/dev/urandom of=big.file bs=64M count=16 iflag=fullblock
Let’s clarify these arguments and their purpose:
if- input file. In our case, we attach our input to the stream of random data which is available on any Linux distribution.
of- output file. It’s a name of the file we want to create. Fell free to use any name you want.
bs- in our case, it means that we want to generate our random file piece by piece and there should be
countpieces in it. It also means that we can tweak both arguments, the only important thing is that
countshould be close to our target size (1 GB).
count- as mentioned above, it’s just a multiplier for
Testing Transfer Speed Over WiFi and Ethernet
Let’s send some data to Raspberry Pi (
Laptop --> Pi):
rsync --progress big.file [email protected]:~/big.file
big.file 1,073,741,824 100% 32.10MB/s 0:00:31 (xfr#1, to-chk=0/1)
rsync because it’s easy to use and it reflects my real workloads (syncing a lot of files, doing backups and so on).
Now we can download that big file from the Raspberry Pi and measure the average transfer speed (
Laptop <-- Pi):
rsync --progress [email protected]:~/big.file big.file.back
big.file 1,073,741,824 100% 42.69MB/s 0:00:23 (xfr#1, to-chk=0/1)
That’s it. I repeated this test for each of tested setups and here are the results:
- Raspberry Pi that uses WiFi and stores data on SD card:
Laptop --> Pi7.28 MB/s
Laptop <-- Pi10.09 MB/s2
- Raspberry Pi that uses WiFi and stores data on SSD drive:
Laptop --> Pi6.98 MB/s
Laptop <-- Pi10.25 MB/s
- Raspberry Pi that uses Ethernet and stores data on SD card:
Laptop --> Pi19.95 MB/s
Laptop <-- Pi42.40 MB/s
- Raspberry Pi that uses Ethernet and stores data on SSD drive:
Laptop --> Pi42.57 MB/s
Laptop <-- Pi42.69 MB/s
Interesting results, but let’s try an alternative approach to measuring network throughput before jumping to any conclusions.
Testing Raspberry Pi 4 Throughput With iPerf
We can easily measure “raw” network performance by moving as much data as possible between two computers for a certain period of time. One of those computers has to play a role of a client by generating a lot of gibberish and sending it to the second machine which can simply discard all of that traffic upon arrival.
There are many ways to perform such a test but
iperf is a kind of an industry standard and it’s very easy to use, which makes it a good choice for our quick test.
Let’s make Raspberry Pi 4 a server:
ssh [email protected] sudo apt install iperf iperf --server
Server listening on TCP port 5001 TCP window size: 85.3 KByte (default)
Now, we can use
iperf from another computer and instruct it to connect to a Raspberry Pi in order to measure the network throughput between them:
sudo apt install iperf iperf --client pi.local
Client connecting to cloud.local, TCP port 5001 TCP window size: 85.0 KByte (default) [ ID] Interval Transfer Bandwidth [ 3] 0.0-10.0 sec 1.10 GBytes 942 Mbits/sec
Here are my results for wired and WiFi connections:
Seems like both tests point to the same conclusion.
Although using WiFi is more convenient because it gives you more flexibility, don’t expect your network transfer speed to be anywhere above 10 MB/s if you connect your Raspberry Pi wirelessly. 10 MB/s is actually not that bad if you use an SD card because many modern SD cards can’t write more than 10 MB per second, although they can read a bit faster and not being able to use this extra reading speed is the main drawback of using WiFi on a Raspberry Pi 4.
Things get a bit different if you prefer to store your data on an SSD drive. Modern SSD’s can move gigabytes in seconds but your WiFi connection wouldn’t allow you to use any that extra throughput. Switching to a wired connection boosts transfer speed up to about 30-40 MB/s, which is better, but still a far cry from the theoretical limit of 125 MB/s (that’s the max speed of a gigabit Ethernet adapter that is used in Raspberry Pi 4).
If you have an idea how to boost file transfer speed even further, I’d appreciate if you share it with me via email.