---
title: "How to protect RP2040 from network flood?"
url: "https://maker.wiznet.io/viktor/projects/how-to-protect-rp2040-from-network-flood/"
markdown_url: "https://maker.wiznet.io/viktor/projects/how-to-protect-rp2040-from-network-flood/md"
type: "WCC: WIZnet Created Content"
author: "Viktor Shin"
author_url: "https://www.hackster.io/viktor-shin/how-to-protect-rp2040-from-network-flood-af49cf"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Viktor Shin"
original_url: "https://www.hackster.io/viktor-shin/how-to-protect-rp2040-from-network-flood-af49cf"
published: "2022-10-12"
language: "en"
tags: ["Security"]
hardware: ["Raspberry Pi Pico", "WIZnet W5100S-EVB-Pico"]
likes: 19
views: 10154
comments: 3
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# How to protect RP2040 from network flood?

> Let's find out which Ethernet IC can protect RP2040 by performing network stress test!

Original author: Viktor Shin (source: https://www.hackster.io/viktor-shin/how-to-protect-rp2040-from-network-flood-af49cf)

## Components

- **Raspberry Pi Pico** x 1 ([docs](https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html))
- **WIZnet W5100S-EVB-Pico** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5100S/w5100s-evb-pico))
- Software: **iperf** ([docs](https://iperf.fr/iperf-doc.php))
- Software: **Jorge Oliveira LOIC** ([docs](https://github.com/NewEraCracker/LOIC/wiki))

## Article

## **Introduction**

This post was inspired by [this project](https://www.instructables.com/How-to-make-unattackable-secure-arduino-IoT-device/). Since RP2040 introduction, there have been multiple projects presenting how to add Ethernet connectivity to RP2040.

I decided to test how various solutions would behave under network stress attack.

The purpose of this post is not about reaching best network performance but to test how performance is changing when network stress tool is working.

## **Setup**

Overall test idea is simple. I will run TCP server on RP2040. Raspberry Pi Pico or W5100S-EVB-Pico will be connected to same network as PC. On PC I will run iperf client to check network performance and LOIC - to do network stress test.

For test I decided to proceed with three setups:

- RP2040 + WIZnet W5100S + Hardwired TCP/IP Stack

- RP2040 + ENC28J60 + LWIP

- RP2040 + WIZnet W5100S + LWIP

### **Test 1. WIZnet W5100S + Hardwired TCP/IP Stack**

I used loopback example from [RP2040-HAT-C SDK](https://github.com/Wiznet/RP2040-HAT-C). For this test W5100S was set to PHY_100 mode, DMA was enabled.

You may view first test results in below video

[Embedded media](https://www.youtube.com/embed/TSAhqmx37Lc?rel=0)

I noticed that "Requested" & "failed" numbers do not change, and realized that it happened because only one socket was opened and iperf already connected to it. Therefore, I re-run the test with all 4 sockets opened on W5100S-EVB-Pico (W5100S has 4 independent sockets). The result can be seen in below video.

[Embedded media](https://www.youtube.com/embed/vH0wh4k4PQI?rel=0)

**It can be seen that network performance doesn't change whenLOIC starts flooding the packets.**

### **Test 2. ENC28J60 + LWIP**

For this test I modified a bit code from [https://github.com/Juddling/pi-pico-enc28j60](https://github.com/Juddling/pi-pico-enc28j60,)

I added lwiperf test code, so that application would not only respond to ping requests but also run iperf server.

The result is shown in next video

[Embedded media](https://www.youtube.com/embed/zcKQi7iJ5Vg?rel=0)

**As can be seen, once LOIC starts flooding, network performance drops to zero.**

### **Test 3. W5100S + LWIP**

When Pico W was introduced, LWIP was included in [Pico SDK](https://github.com/raspberrypi/pico-sdk).

Since W5100S supports MACRAW mode, I wanted to see what happens if W5100S is used along with LWIP.

Code used for testing can be found here: <https://github.com/TeddyWiz/wiznet_driver>

[https://github.com/TeddyWiz/pico-examples](https://github.com/TeddyWiz/pico-examples.git)

<https://github.com/TeddyWiz/pico-sdk>

The result is shown on next video:

[Embedded media](https://www.youtube.com/embed/64T3ZOVm3tw?rel=0)

**As can be seen, network performance dropsa bit and fluctuates. I believe that W5100S is still filtering and protecting from flood packets.**

## **Conclusion**

It is clear that flood attacks are not effective when W5100S is used.

P.S. I am aware of another option with RP2040 + LAN8720, I am planning to do same test for this setup as well.

---

Source: https://maker.wiznet.io/viktor/projects/how-to-protect-rp2040-from-network-flood/
