The small viking in your nRF7002.

zperf - Evaluating the nRF7002's Wi-Fi Performance in YOUR RF Environment

Oct 3, 2023

zperf is a Zephyr shell utility modeled after and used in conjunction with the Linux iperf command line tool. If you haven't used the shell module in Zephyr before, be sure to check out Golioth's guide on using and customizing it:

How to add custom shell commands in Zephyr - Golioth
Adding custom shell commands in Zephyr is a great way to interact with your device, from setting values to making custom data readouts.

To get started, ensure you have the latest nRF Connect SDK installed. Let's start by cloning the Wi-Fi shell example:

Once it has been cloned, create a new build configuration for the 7002DK:

Be sure to build the version without the _ns extension.

To make sure zperf is enabled as a console command, click the "Add fragment" button and select the "overlay-zperf.conf" file:

Now build your configuration and program your 7002DK:

Using your terminal emulator of choice, select the second enumerated serial port. For me, this was /dev/ttyACM1.

Let's connect to our local Wi-Fi network and run some zperf commands!

Conduct a Wi-Fi scan with the following command:

$ wifi connect <YOUR_SSID> <YOUR_PASSWORD>

After waiting for a few seconds, you should see the IP assigned to your device with DHCP. Be sure to take note of this address!

Now that we are connected, ensure that you have iperf installed by running:

$ iperf -v

If you don't have it installed it should be available on most package managers. For Ubuntu:

$ sudo apt install iperf

Let's test the upload speed of the nRF7002 by setting up iperf to run as a UDP server. Run the following command on the host machine to determine your IP:

$ ip addr

You should see output similar to this:

My local IP for my computer happens to be 192.168.0.130. Let's use that to set up our iperf server:

$ iperf -s -l 1K -u -B <YOUR_IP>

Here we go! It is waiting for communication from our device. Run the following through the Zephyr shell:

$ zperf udp upload <YOUR_IP> 5001 <DURATION_SEC> <PACKET_SIZE> <BPS>
$ zperf udp upload 192.168.0.130 5001 10 1K 10M

If you'd prefer a longer sample, you can always change "10" to something larger like "60." You can also change the target transmit speed. Let's try something like:

$ zperf udp upload 192.168.0.130 5001 60 1K 80M

You can squeeze some performance out of the 7002 if you're able to keep up with it! The rate on the server side will often differ and be lower than on the device side:

Still, ~24Mbps is 3 MB over the air. If the above packet loss is too high for your application, a more reasonable target data rate is somewhere between 10-15Mbps.

Let's see how quickly we can download from the network with the 7002. Use the following commands:

$ zperf udp download 5001

On the host side:

$ iperf -l 1K -u -c <DEVICE_IP> -b <BPS>

I see a typical download maximum of ~9Mbps.

You can run the commands above for TCP as well as UDP. The extra overhead of TCP will show slightly lower throughput. I've compiled a reference list of commands for iperf and zperf that you can refer to below:

iperf commands

  • UDP server
$ iperf -s -l 1K -u -B <SERVER_IPV4_ADDR>
  • TCP server
$ iperf -s -l 1K -B <SERVER_IPV4_ADDR>
  • UDP client
$ iperf -l 1K -u -c <DEVICE_IPV4_ADDR> -b <TARGET_OUTPUT_BPS>
  • TCP client
$ iperf -l 1K -c <DEVICE_IPV4_ADDR> -b <TARGET_OUTPUT_BPS>

Wi-Fi commands

  • Wi-Fi scan
$ wifi scan
  • Wi-Fi connect
$ wifi connect <SSID> <PASS_KEY>

zperf commands

  • UDP server
$ zperf udp upload <SERVER_IPV4_ADDR> <PORT> <DURATION> <PACKET_SIZE> <OUTPUT_BPS>
  • TCP server
$ zperf tcp upload <SERVER_IPV4_ADDR> <PORT> <DURATION> <PACKET_SIZE> <OUTPUT_BPS>
  • UDP client
$ zperf udp download <PORT>
  • TCP client
$ zperf tcp download <PORT>

Thanks for reading!