Thread: support OpenThread Simulator support#42841
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for the OpenThread Simulator (ot-ns), which is a valuable addition for evaluating Matter performance over Thread. The changes are well-structured, introducing a new otns build modifier and the necessary GN arguments and source code modifications to integrate the simulator. The implementation is mostly clean, with one opportunity for improvement to avoid a const_cast.
|
PR #42841: Size comparison from ac0beeb to 8dafcbe Full report (35 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
|
|
PR #42841: Size comparison from bd1cc4d to d2dc3ad Full report (35 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
|
74739f2 to
7aa538b
Compare
|
PR #42841: Size comparison from 14e806b to 7aa538b Full report (30 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, qpg, realtek, stm32, telink)
|
| "./scripts/build/build_examples.py \ | ||
| --target linux-x64-all-clusters-no-wifi-openthread-endpoint-otns-clang \ | ||
| build | ||
| " |
There was a problem hiding this comment.
When I run this command, it seems to just build but not run any test. Could you add a README.md that describes the basics of how to manually run the otns with Matter nodes to collect some simple metrics?
2026-02-03 13:33:07 INFO - linux-x64-all-clusters-no-wifi-openthread-endpoint-otns-clang: 35s
2026-02-03 13:33:07 INFO Total build time: 35s
There was a problem hiding this comment.
I'll probably add some explanation in ot-ns about the expectation of nodes. This commit only adds the basic support. There is additional work that needs to be done. We may add some documentation when the whole feature is complete.
gmarcosb
left a comment
There was a problem hiding this comment.
Overall looks good, but I left some comments on openthread/ot-ns#742 about the lacking flexibility of the otns app, i.e. over-dependence on $PATH + hard-coded Matter node type (instead of allowing CLI arguments) may make integration difficult
There was a problem hiding this comment.
Pull request overview
This PR adds support for the OpenThread Network Simulator (ot-ns) to enable Thread radio performance simulation for Matter applications. The implementation introduces an otns build modifier that depends on the openthread-endpoint modifier and includes necessary build configuration changes, command-line argument updates, and a new GitHub workflow for build validation.
Changes:
- Added ot-ns submodule and platform-specific build configuration
- Introduced
chip_enable_otnsGN build argument with corresponding dependency checks - Updated command-line interface to use generic
--thread-argsinstead of--thread-node-id
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| third_party/ot-ns/repo | Added ot-ns submodule reference |
| third_party/openthread/platforms/otns/BUILD.gn | Created build configuration for otns platform |
| src/system/BUILD.gn | Added assertion to enforce otns dependency on openthread endpoints |
| src/platform/device.gni | Declared chip_enable_otns build argument |
| src/platform/Linux/BUILD.gn | Added conditional dependency on otns vs simulation platform |
| scripts/tests/chiptest/test_definition.py | Updated test infrastructure to use new thread arguments format |
| scripts/build/testdata/all_targets_linux_x64.txt | Added otns modifier to build targets |
| scripts/build/builders/host.py | Implemented otns build configuration logic |
| scripts/build/build/targets.py | Registered otns as a build modifier |
| examples/platform/linux/Options.h | Changed thread configuration from single node ID to argument vector |
| examples/platform/linux/Options.cpp | Updated option parsing for flexible thread arguments |
| examples/platform/linux/BUILD.gn | Added conditional otns dependencies and preprocessor defines |
| examples/platform/linux/AppMain.cpp | Refactored thread initialization to support multiple arguments |
| .gitmodules | Added ot-ns submodule configuration |
| .github/workflows/build.yaml | Added build workflow for otns variant |
| self.extra_gn_options.append('chip_logging_backend="syslog"') | ||
| self.extra_gn_options.append('chip_enable_otns=true') | ||
| self.extra_gn_options.append('openthread_config_otns_enable=true') | ||
| self.extra_gn_options.append('import("//build_overrides/chip.gni")') |
There was a problem hiding this comment.
The GN import statement is being added via extra_gn_options, which is unconventional. GN imports should typically be placed in the BUILD.gn file header. Consider whether this import can be structured differently or if there's a more idiomatic way to include this configuration.
| self.extra_gn_options.append('import("//build_overrides/chip.gni")') |
| args.push_back(argv[0]); | ||
| for (auto & arg : LinuxDeviceOptions::GetInstance().mThreadArgs) | ||
| { | ||
| args.push_back(arg.data()); |
There was a problem hiding this comment.
Using arg.data() on temporary string objects from a vector can lead to dangling pointers. The std::string objects in mThreadArgs are not temporaries, but calling .data() returns a pointer that could become invalid if the vector is modified. Since the vector is not modified after this point and before otSysInit is called, this is safe, but consider using const_cast<char*>(arg.c_str()) for clarity about the lifetime guarantee.
| args.push_back(arg.data()); | |
| args.push_back(const_cast<char *>(arg.c_str())); |
…hip-tool can provision directly through OTNS
Summary
This commit adds OpenThread simulator(https://github.com/openthread/ot-ns) support. OpenThread simulator can simulate Thread radio performance, which could be used to evaluate the Matter performance under different Thread radio situations.
A
otnsmodifier is added to enable this variant.otnsdepends onopenthread-endpointmodifier.A GN build argument
chip_enable_otnsis added to control whether to enable this mode or not.Related issues
This reuses work in #42336. OpenThread simulation platform is using real time clock, while the simulator can use virtual time.
This PR depends on:
1/0openthread/openthread#12345Testing
Added a new build test just to ensure the all-clusters-app can be built with
otnsenabled. To fully validate the functionality,otnshas to be used.