diff --git a/examples/openthread/ot_br/main/esp_ot_br.c b/examples/openthread/ot_br/main/esp_ot_br.c index 82cade357d..c9bb84eff0 100644 --- a/examples/openthread/ot_br/main/esp_ot_br.c +++ b/examples/openthread/ot_br/main/esp_ot_br.c @@ -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 diff --git a/examples/openthread/ot_br/main/idf_component.yml b/examples/openthread/ot_br/main/idf_component.yml index b00b26c7bb..3dca30645e 100644 --- a/examples/openthread/ot_br/main/idf_component.yml +++ b/examples/openthread/ot_br/main/idf_component.yml @@ -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: diff --git a/examples/openthread/ot_cli/README.md b/examples/openthread/ot_cli/README.md index e640eeb29e..53be344946 100644 --- a/examples/openthread/ot_cli/README.md +++ b/examples/openthread/ot_cli/README.md @@ -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 +``` diff --git a/examples/openthread/ot_cli/main/esp_ot_cli.c b/examples/openthread/ot_cli/main/esp_ot_cli.c index 88bf550931..44a7d1abe8 100644 --- a/examples/openthread/ot_cli/main/esp_ot_cli.c +++ b/examples/openthread/ot_cli/main/esp_ot_cli.c @@ -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 = { diff --git a/examples/openthread/ot_cli/main/idf_component.yml b/examples/openthread/ot_cli/main/idf_component.yml index 079266490f..49621895d6 100644 --- a/examples/openthread/ot_cli/main/idf_component.yml +++ b/examples/openthread/ot_cli/main/idf_component.yml @@ -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: diff --git a/examples/openthread/ot_common_components/ot_examples_common/CMakeLists.txt b/examples/openthread/ot_common_components/ot_examples_common/CMakeLists.txt index 321063eb94..b78a93b927 100644 --- a/examples/openthread/ot_common_components/ot_examples_common/CMakeLists.txt +++ b/examples/openthread/ot_common_components/ot_examples_common/CMakeLists.txt @@ -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 ) diff --git a/examples/openthread/ot_common_components/ot_examples_common/Kconfig.projbuild b/examples/openthread/ot_common_components/ot_examples_common/Kconfig.projbuild index 94e38cf6c1..0bca5c2987 100644 --- a/examples/openthread/ot_common_components/ot_examples_common/Kconfig.projbuild +++ b/examples/openthread/ot_common_components/ot_examples_common/Kconfig.projbuild @@ -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 diff --git a/examples/openthread/ot_common_components/ot_examples_common/idf_component.yml b/examples/openthread/ot_common_components/ot_examples_common/idf_component.yml index 77b231f2a7..64b8f724c2 100644 --- a/examples/openthread/ot_common_components/ot_examples_common/idf_component.yml +++ b/examples/openthread/ot_common_components/ot_examples_common/idf_component.yml @@ -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 diff --git a/examples/openthread/ot_common_components/ot_examples_common/include/ot_examples_common.h b/examples/openthread/ot_common_components/ot_examples_common/include/ot_examples_common.h index 9c7ab22964..0c5c298c09 100644 --- a/examples/openthread/ot_common_components/ot_examples_common/include/ot_examples_common.h +++ b/examples/openthread/ot_common_components/ot_examples_common/include/ot_examples_common.h @@ -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); diff --git a/examples/openthread/ot_common_components/ot_examples_common/ot_console.c b/examples/openthread/ot_common_components/ot_examples_common/ot_console.c index a293adf38c..6c679941d3 100644 --- a/examples/openthread/ot_common_components/ot_examples_common/ot_console.c +++ b/examples/openthread/ot_common_components/ot_examples_common/ot_console.c @@ -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 } diff --git a/examples/openthread/ot_trel/main/esp_ot_trel.c b/examples/openthread/ot_trel/main/esp_ot_trel.c index d8a4c20bc8..5ffd6dc610 100644 --- a/examples/openthread/ot_trel/main/esp_ot_trel.c +++ b/examples/openthread/ot_trel/main/esp_ot_trel.c @@ -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 = { diff --git a/examples/openthread/ot_trel/main/idf_component.yml b/examples/openthread/ot_trel/main/idf_component.yml index 4318a41630..cb9759faca 100644 --- a/examples/openthread/ot_trel/main/idf_component.yml +++ b/examples/openthread/ot_trel/main/idf_component.yml @@ -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"