Merge branch 'feat/migrate_iperf_cmd' into 'master'

feat(iperf): migrate iperf to use iperf-cmd component

See merge request espressif/esp-idf!44872
This commit is contained in:
Shu Chen
2026-01-14 02:58:45 +00:00
12 changed files with 86 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*
@@ -97,6 +97,7 @@ void app_main(void)
#if CONFIG_OPENTHREAD_CLI
ot_console_start();
ot_register_external_commands();
#endif
#if CONFIG_ESP_COEX_EXTERNAL_COEXIST_ENABLE

View File

@@ -1,7 +1,7 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_ot_cli_extension:
version: "~1.4.0"
version: "~2.0.0"
espressif/mdns: "^1.0.3"
## Required IDF version
idf:

View File

@@ -128,5 +128,49 @@ You can refer to the [extension command](https://github.com/espressif/esp-thread
The following examples are supported by `ot_cli`:
* TCP and UDP Example
* Iperf Example
## Using iPerf to measure bandwidth
iPerf is a tool used to obtain TCP or UDP throughput on the Thread network. To run iPerf, you need to have two Thread devices on the same network.
Refer to [the iperf-cmd component](https://components.espressif.com/components/espressif/iperf-cmd) for details on specific configurations.
### Typical usage on a thread network
For measuring the TCP throughput, first create an iperf service on one node:
```bash
> iperf -V -s -t 20 -i 3 -p 5001 -f k
Done
```
Then create an iperf client connecting to the service on another node. Note that the [ML-EID](https://openthread.io/guides/thread-primer/ipv6-addressing#unicast_address_types) address is used for iperf.
```bash
> ipaddr mleid
fdde:ad00:beef:0:a7c6:6311:9c8c:271b
Done
> iperf -V -c fdde:ad00:beef:0:a7c6:6311:9c8c:271b -t 20 -i 1 -p 5001 -l 85 -f k
Done
[ ID] Interval Transfer Bandwidth
[ 1] 0.0- 1.0 sec 3.15 KBytes 25.16 Kbits/sec
[ 1] 1.0- 2.0 sec 2.89 KBytes 23.12 Kbits/sec
[ 1] 2.0- 3.0 sec 2.98 KBytes 23.80 Kbits/sec
...
[ 1] 9.0-10.0 sec 2.55 KBytes 20.40 Kbits/sec
[ 1] 0.0-10.0 sec 27.80 KBytes 22.24 Kbits/sec
```
For measuring the UDP throughput, first create an iperf service similarly:
```bash
> iperf -V -u -s -t 20 -i 3 -p 5001 -f k
Done
```
Then create an iperf client:
```bash
> iperf -V -u -c fdde:ad00:beef:0:a7c6:6311:9c8c:271b -t 20 -i 1 -p 5001 -l 85 -f k
Done
```

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*
@@ -58,6 +58,7 @@ void app_main(void)
#if CONFIG_OPENTHREAD_CLI
ot_console_start();
ot_register_external_commands();
#endif
static esp_openthread_config_t config = {

View File

@@ -1,7 +1,7 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_ot_cli_extension:
version: "~1.4.0"
version: "~2.0.0"
idf:
version: ">=4.1.0"
ot_led:

View File

@@ -15,5 +15,5 @@ endif()
idf_component_register(
SRCS "${srcs}"
INCLUDE_DIRS "include"
PRIV_REQUIRES console cmd_system esp_coex openthread
PRIV_REQUIRES console cmd_system esp_coex openthread iperf-cmd iperf
)

View File

@@ -9,6 +9,16 @@ menu "Config for OpenThread Examples"
If enabled, the Openthread Device will create or connect to Thread network with pre-configured
network parameters automatically. Otherwise, user need to configure Thread via CLI command manually.
menu "External Console Commands"
config OPENTHREAD_IPERF_CMD_ENABLE
bool "Enable iperf command"
depends on OPENTHREAD_FTD || OPENTHREAD_MTD
default y
help
If enabled, iperf will be registered and available as a console command.
This allows network performance testing using iperf over the Thread network.
endmenu # External Console Commands
menu "External coexist wire type and pin config"
depends on ESP_COEX_EXTERNAL_COEXIST_ENABLE

View File

@@ -1,4 +1,5 @@
## IDF Component Manager Manifest File
dependencies:
espressif/iperf-cmd: "^1.0.0"
cmd_system:
path: ${IDF_PATH}/examples/system/console/advanced/components/cmd_system

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*
@@ -61,3 +61,9 @@ void ot_console_start(void);
*
*/
void ot_network_auto_start(void);
/**
* @brief Register external system commands (e.g., iperf).
*
*/
void ot_register_external_commands(void);

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*
@@ -18,6 +18,10 @@
#include "esp_console.h"
#include "cmd_system.h"
#if CONFIG_OPENTHREAD_IPERF_CMD_ENABLE
#include "iperf_cmd.h"
#endif
void ot_console_start(void)
{
esp_console_repl_t *repl = NULL;
@@ -43,6 +47,12 @@ void ot_console_start(void)
#error Unsupported console type
#endif
ESP_ERROR_CHECK(esp_console_start_repl(repl));
register_system();
}
void ot_register_external_commands(void)
{
register_system();
#if CONFIG_OPENTHREAD_IPERF_CMD_ENABLE
iperf_cmd_register_iperf();
#endif
}

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*
@@ -44,7 +44,6 @@
#include "esp_ot_cli_extension.h"
#endif // CONFIG_OPENTHREAD_CLI_ESP_EXTENSION
#define TAG "ot_esp_trel"
void app_main(void)
@@ -68,6 +67,7 @@ void app_main(void)
#if CONFIG_OPENTHREAD_CLI
ot_console_start();
ot_register_external_commands();
#endif
static esp_openthread_config_t config = {

View File

@@ -1,7 +1,7 @@
## IDF Component Manager Manifest File
dependencies:
espressif/esp_ot_cli_extension:
version: "~1.4.0"
version: "~2.0.0"
espressif/mdns: "^1.0.3"
idf:
version: ">=4.1.0"