ESP32/README.md

131 lines
2.0 KiB
Markdown

# ESP32 iperf
Network performance testing tool for ESP32 based on iperf2.
## Features
- TCP and UDP client/server modes
- Bandwidth measurement
- Packet loss detection (UDP)
- Console-based control interface
- WiFi station mode support
## Hardware Requirements
- ESP32, ESP32-S2, or ESP32-S3 development board
- WiFi network
## Software Requirements
- ESP-IDF v5.0 or later
- iperf2 or iperf3 for testing with PC
## Building
1. Set up ESP-IDF environment:
```bash
. $HOME/Code/esp32/esp-idf/export.sh
```
2. Set the target chip (choose one):
```bash
# For ESP32
idf.py set-target esp32
# For ESP32-S2
idf.py set-target esp32s2
# For ESP32-S3
idf.py set-target esp32s3
```
3. Configure WiFi credentials:
```bash
idf.py menuconfig
```
Navigate to "ESP32 iperf Configuration" and set your SSID and password.
4. Build the project:
```bash
idf.py build
```
5. Flash to your device:
```bash
idf.py -p /dev/ttyUSB0 flash monitor
```
## Usage
### TCP Server Mode
On ESP32:
```
iperf> iperf -s
```
On PC:
```bash
iperf -c <ESP32_IP>
```
### TCP Client Mode
On PC:
```bash
iperf -s
```
On ESP32:
```
iperf> iperf -c <PC_IP>
```
### UDP Mode
Add `-u` flag for UDP testing:
```
iperf> iperf -s -u
iperf> iperf -c <IP> -u
```
### Options
- `-s` : Run as server
- `-c <ip>` : Run as client, connecting to server IP
- `-u` : Use UDP instead of TCP
- `-p <port>` : Port number (default: 5001)
- `-t <time>` : Test duration in seconds (default: 30)
- `-b <bw>` : Bandwidth limit for UDP in Mbps
- `-a` : Abort running test
### Examples
```bash
# TCP client test for 10 seconds
iperf -c 192.168.1.100 -t 10
# UDP server on port 5002
iperf -s -u -p 5002
# Stop running test
iperf -a
```
## Project Structure
```
esp32-iperf/
├── CMakeLists.txt
├── main/
│ ├── CMakeLists.txt
│ ├── Kconfig.projbuild
│ ├── main.c # WiFi initialization and console
│ ├── iperf.c # iperf implementation
│ └── iperf.h # iperf header
└── README.md
```
## Author
Bob - Creator of iperf2
## License
Open source