Skip to content

Thread: support OpenThread Simulator support#42841

Open
bukepo wants to merge 1 commit into
project-chip:masterfrom
bukepo:add-ot-ns
Open

Thread: support OpenThread Simulator support#42841
bukepo wants to merge 1 commit into
project-chip:masterfrom
bukepo:add-ot-ns

Conversation

@bukepo

@bukepo bukepo commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

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 otns modifier is added to enable this variant. otns depends on openthread-endpoint modifier.

A GN build argument chip_enable_otns is 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:

Testing

Added a new build test just to ensure the all-clusters-app can be built with otns enabled. To fully validate the functionality, otns has to be used.

@bukepo bukepo added the changing-git-submodules-on-purpose This PR is changing git submodules on intentionally (and it is not a "commit all" typo/mistake) label Jan 28, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread examples/platform/linux/AppMain.cpp Outdated
@github-actions

github-actions Bot commented Jan 28, 2026

Copy link
Copy Markdown

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)
platform target config section ac0beeb 8dafcbe change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1106440 1106440 0 0.0
RAM 178978 178978 0 0.0
bl702 lighting-app bl702+eth FLASH 661210 661210 0 0.0
RAM 135049 135049 0 0.0
bl702+wifi FLASH 837050 837050 0 0.0
RAM 124517 124517 0 0.0
bl706+mfd+rpc+littlefs FLASH 1070974 1070974 0 0.0
RAM 117389 117389 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 903548 903548 0 0.0
RAM 105964 105964 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 983620 983620 0 0.0
RAM 109884 109884 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 771284 771284 0 0.0
RAM 103408 103408 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 784320 784320 0 0.0
RAM 108736 108736 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 729456 729456 0 0.0
RAM 97484 97484 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 714032 714032 0 0.0
RAM 97692 97692 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 555340 555340 0 0.0
RAM 205496 205496 0 0.0
lock CC3235SF_LAUNCHXL FLASH 589224 589224 0 0.0
RAM 205752 205752 0 0.0
efr32 lock-app BRD4187C FLASH 967312 967304 -8 -0.0
RAM 123656 123656 0 0.0
BRD4338a FLASH 761124 761124 0 0.0
RAM 236944 236944 0 0.0
window-app BRD4187C FLASH 1063584 1063576 -8 -0.0
RAM 124780 124780 0 0.0
esp32 all-clusters-app c3devkit DRAM 98124 98124 0 0.0
FLASH 1583502 1583502 0 0.0
IRAM 93514 93514 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 934732 934732 0 0.0
RAM 161904 161904 0 0.0
nxp contact mcxw71+release FLASH 744632 744632 0 0.0
RAM 67152 67152 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1694660 1694660 0 0.0
RAM 214404 214404 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1597300 1597300 0 0.0
RAM 211476 211476 0 0.0
light cy8ckit_062s2_43012 FLASH 1460940 1460940 0 0.0
RAM 197808 197808 0 0.0
lock cy8ckit_062s2_43012 FLASH 1495044 1495044 0 0.0
RAM 225688 225688 0 0.0
qpg lighting-app qpg6200+debug FLASH 838716 838236 -480 -0.1
RAM 128032 127968 -64 -0.0
lock-app qpg6200+debug FLASH 777164 776752 -412 -0.1
RAM 118972 118908 -64 -0.1
realtek light-switch-app rtl8777g FLASH 701992 701992 0 0.0
RAM 113548 113548 0 0.0
lighting-app rtl8777g FLASH 743872 743872 0 0.0
RAM 114768 114768 0 0.0
stm32 light STM32WB5MM-DK FLASH 470804 470804 0 0.0
RAM 141408 141408 0 0.0
telink bridge-app tl7218x FLASH 711642 711642 0 0.0
RAM 93088 93088 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 797432 797432 0 0.0
RAM 41272 41272 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 788762 788762 0 0.0
RAM 96172 96172 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 717432 717432 0 0.0
RAM 54264 54264 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 753242 753242 0 0.0
RAM 73288 73288 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 721814 721814 0 0.0
RAM 34992 34992 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 609728 609728 0 0.0
RAM 117960 117960 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 822266 822270 4 0.0
RAM 94560 94560 0 0.0

@github-actions

github-actions Bot commented Jan 29, 2026

Copy link
Copy Markdown

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)
platform target config section bd1cc4d d2dc3ad change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1106440 1106440 0 0.0
RAM 178978 178978 0 0.0
bl702 lighting-app bl702+eth FLASH 661210 661210 0 0.0
RAM 135049 135049 0 0.0
bl702+wifi FLASH 837050 837050 0 0.0
RAM 124517 124517 0 0.0
bl706+mfd+rpc+littlefs FLASH 1070974 1070974 0 0.0
RAM 117389 117389 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 903548 903548 0 0.0
RAM 105964 105964 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 983620 983620 0 0.0
RAM 109884 109884 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 771284 771284 0 0.0
RAM 103408 103408 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 784320 784320 0 0.0
RAM 108736 108736 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 729456 729456 0 0.0
RAM 97484 97484 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 714032 714032 0 0.0
RAM 97692 97692 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 555340 555340 0 0.0
RAM 205496 205496 0 0.0
lock CC3235SF_LAUNCHXL FLASH 589224 589224 0 0.0
RAM 205752 205752 0 0.0
efr32 lock-app BRD4187C FLASH 967504 967496 -8 -0.0
RAM 125704 125704 0 0.0
BRD4338a FLASH 761332 761332 0 0.0
RAM 237968 237968 0 0.0
window-app BRD4187C FLASH 1063848 1063840 -8 -0.0
RAM 126828 126828 0 0.0
esp32 all-clusters-app c3devkit DRAM 98204 98204 0 0.0
FLASH 1584468 1584468 0 0.0
IRAM 93514 93514 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 935932 935932 0 0.0
RAM 161974 161974 0 0.0
nxp contact mcxw71+release FLASH 744632 744632 0 0.0
RAM 67152 67152 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1696244 1696244 0 0.0
RAM 214484 214484 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1597300 1597300 0 0.0
RAM 211476 211476 0 0.0
light cy8ckit_062s2_43012 FLASH 1460940 1460940 0 0.0
RAM 197808 197808 0 0.0
lock cy8ckit_062s2_43012 FLASH 1495044 1495044 0 0.0
RAM 225688 225688 0 0.0
qpg lighting-app qpg6200+debug FLASH 838716 838236 -480 -0.1
RAM 128032 127968 -64 -0.0
lock-app qpg6200+debug FLASH 777164 776752 -412 -0.1
RAM 118972 118908 -64 -0.1
realtek light-switch-app rtl8777g FLASH 701992 701992 0 0.0
RAM 113548 113548 0 0.0
lighting-app rtl8777g FLASH 743872 743872 0 0.0
RAM 114768 114768 0 0.0
stm32 light STM32WB5MM-DK FLASH 470804 470804 0 0.0
RAM 141408 141408 0 0.0
telink bridge-app tl7218x FLASH 711642 711642 0 0.0
RAM 93088 93088 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 797432 797432 0 0.0
RAM 41272 41272 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 788762 788762 0 0.0
RAM 96172 96172 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 717432 717432 0 0.0
RAM 54264 54264 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 753242 753242 0 0.0
RAM 73288 73288 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 721814 721814 0 0.0
RAM 34992 34992 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 609728 609728 0 0.0
RAM 117960 117960 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 822266 822270 4 0.0
RAM 94560 94560 0 0.0

@bukepo bukepo force-pushed the add-ot-ns branch 3 times, most recently from 74739f2 to 7aa538b Compare February 3, 2026 02:55
@bukepo bukepo requested a review from gmarcosb February 3, 2026 02:55
@github-actions

github-actions Bot commented Feb 3, 2026

Copy link
Copy Markdown

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)
platform target config section 14e806b 7aa538b change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1106386 1106388 2 0.0
RAM 179010 179010 0 0.0
bl702 lighting-app bl702+eth FLASH 661414 661414 0 0.0
RAM 135065 135065 0 0.0
bl702+wifi FLASH 837004 837004 0 0.0
RAM 124549 124549 0 0.0
bl706+mfd+rpc+littlefs FLASH 1071538 1071540 2 0.0
RAM 117453 117453 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 903992 903994 2 0.0
RAM 106028 106028 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 984440 984442 2 0.0
RAM 109940 109940 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 771628 771628 0 0.0
RAM 103456 103456 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 784600 784600 0 0.0
RAM 108776 108776 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 729728 729728 0 0.0
RAM 97532 97532 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 714264 714264 0 0.0
RAM 97732 97732 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 555380 555380 0 0.0
RAM 205512 205512 0 0.0
lock CC3235SF_LAUNCHXL FLASH 589416 589416 0 0.0
RAM 205792 205792 0 0.0
efr32 lock-app BRD4187C FLASH 967792 967784 -8 -0.0
RAM 125732 125732 0 0.0
BRD4338a FLASH 761364 761356 -8 -0.0
RAM 238024 238024 0 0.0
window-app BRD4187C FLASH 1064600 1064592 -8 -0.0
RAM 126888 126888 0 0.0
esp32 all-clusters-app c3devkit DRAM 98252 98252 0 0.0
FLASH 1585272 1585272 0 0.0
IRAM 93514 93514 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 936440 936440 0 0.0
RAM 162039 162039 0 0.0
qpg lighting-app qpg6200+debug FLASH 839204 838740 -464 -0.1
RAM 128064 128000 -64 -0.0
lock-app qpg6200+debug FLASH 777452 777088 -364 -0.0
RAM 119004 118940 -64 -0.1
realtek light-switch-app rtl8777g FLASH 702320 702320 0 0.0
RAM 113596 113596 0 0.0
lighting-app rtl8777g FLASH 744216 744216 0 0.0
RAM 114808 114808 0 0.0
stm32 light STM32WB5MM-DK FLASH 471116 471116 0 0.0
RAM 141464 141464 0 0.0
telink bridge-app tl7218x FLASH 712356 712356 0 0.0
RAM 93136 93136 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 797918 797918 0 0.0
RAM 41320 41320 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 789254 789254 0 0.0
RAM 96220 96220 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 717918 717918 0 0.0
RAM 54312 54312 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 753728 753728 0 0.0
RAM 73336 73336 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 722294 722294 0 0.0
RAM 35040 35040 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 610222 610222 0 0.0
RAM 118008 118008 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 822758 822762 4 0.0
RAM 94608 94608 0 0.0

"./scripts/build/build_examples.py \
--target linux-x64-all-clusters-no-wifi-openthread-endpoint-otns-clang \
build
"

@turon turon Feb 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bukepo bukepo Feb 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify mergify Bot added the conflict label Feb 9, 2026

@gmarcosb gmarcosb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread examples/platform/linux/AppMain.cpp
@mergify mergify Bot removed the conflict label Feb 13, 2026
@bukepo bukepo marked this pull request as ready for review February 13, 2026 23:12
Copilot AI review requested due to automatic review settings February 13, 2026 23:12
@pullapprove pullapprove Bot requested a review from andy31415 February 13, 2026 23:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_otns GN build argument with corresponding dependency checks
  • Updated command-line interface to use generic --thread-args instead 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")')

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
self.extra_gn_options.append('import("//build_overrides/chip.gni")')

Copilot uses AI. Check for mistakes.
args.push_back(argv[0]);
for (auto & arg : LinuxDeviceOptions::GetInstance().mThreadArgs)
{
args.push_back(arg.data());

Copilot AI Feb 13, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
args.push_back(arg.data());
args.push_back(const_cast<char *>(arg.c_str()));

Copilot uses AI. Check for mistakes.
gmarcosb added a commit to gmarcosb/connectedhomeip that referenced this pull request Mar 4, 2026
…hip-tool can provision directly through OTNS
@gmarcosb gmarcosb mentioned this pull request Mar 4, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changing-git-submodules-on-purpose This PR is changing git submodules on intentionally (and it is not a "commit all" typo/mistake) examples github linux platform review - pending scripts system workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants