About Blog Notes Photos Portfolio

Raspberry Pi 4: WiFi vs Wired Connection

Raspberry Pi · Linux · Jan 6, 2020

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.

Illustration

Table of Contents

Preface

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.

Test Structure

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:

  1. Raspberry Pi that uses WiFi and stores data on SD card
  2. Raspberry Pi that uses WiFi and stores data on SSD drive
  3. Raspberry Pi that uses Ethernet and stores data on SD card
  4. 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 count pieces in it. It also means that we can tweak both arguments, the only important thing is that bs * count should be close to our target size (1 GB).
  • count - as mentioned above, it’s just a multiplier for bs

Testing Transfer Speed Over WiFi and Ethernet

Let’s send some data to Raspberry Pi (Laptop --> Pi):

rsync --progress big.file pi@cloud.local:~/big.file
big.file
  1,073,741,824 100%   32.10MB/s    0:00:31 (xfr#1, to-chk=0/1)

I used 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 pi@cloud.local:~/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:

Results

  1. Raspberry Pi that uses WiFi and stores data on SD card:
  • Laptop --> Pi 7.28 MB/s
  • Laptop <-- Pi 10.09 MB/s2
  1. Raspberry Pi that uses WiFi and stores data on SSD drive:
  • Laptop --> Pi 6.98 MB/s
  • Laptop <-- Pi 10.25 MB/s
  1. Raspberry Pi that uses Ethernet and stores data on SD card:
  • Laptop --> Pi 19.95 MB/s
  • Laptop <-- Pi 42.40 MB/s
  1. Raspberry Pi that uses Ethernet and stores data on SSD drive:
  • Laptop --> Pi 42.57 MB/s
  • Laptop <-- Pi 42.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 pi@pi.local
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:

  • WiFi: 85.6 Mbits/sec
  • Wired: 942 Mbits/sec

Seems like both tests point to the same conclusion.

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.

Raspberry Pi   Linux   Networking   Benchmarks   rsync   dd

This page doesn't show ads and the reasons are simple:

  • Most people don't want to see ads (what a surprise)
  • Ads can track you and violate your privacy
  • Ads is the main reason why many websites are so slow

If you find this content valuable or you want to see more content like this, you can leave a tip with bitcoin:

34CXtg7c4Vbw8DZjAwFQVsrbu9eDEbTzbA
bitcoin tips QR