Add example run OTNS with OT-BR and Matter accessories.#784
Add example run OTNS with OT-BR and Matter accessories.#784francoismichel wants to merge 2 commits intoopenthread:mainfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
The README contains a tutorial. The Dockerfile currently uses a fork of OT-NS and a fork of Matter and applies a patch to these forks as well. Once these forks and patches get intergrated into the mainline repos, we will update this example accordingly.
6e1a84a to
9f48bef
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces a Docker-based development environment for simulating Thread networks using OTNS, Matter, and OT-BR. It includes a multi-stage Dockerfile, a helper script for cross-platform execution, and detailed documentation. Review feedback identified a critical issue with an invalid Go version that would prevent the build, a potential configuration conflict caused by hardcoding the network interface name in the OTBR setup, and a suggestion to parameterize the Docker image name for better flexibility.
| FROM ubuntu:24.04 | ||
|
|
||
| ARG TARGETARCH | ||
| ARG GO_VERSION=1.26.2 |
There was a problem hiding this comment.
@francoismichel While I would ignore this comment :) , OTNS is built and tested for Go 1.23 currently. Maybe it doesn't matter much, but Go 1.23 may be sufficient.
There was a problem hiding this comment.
I'm seeing this from https://go.dev/doc/devel/release#go1.26.minor :
go1.26.2 (released 2026-04-07) includes security fixes to the go command, the compiler, and the archive/tar, crypto/tls, crypto/x509, html/template, and os packages, as well as bug fixes to the go command, the go fix command, the compiler, the linker, the runtime, and the net, net/http, and net/url packages. See the Go 1.26.2 milestone on our issue tracker for details
I had to use a recent version of go because the go compiler had errors when cross-compiling from arm64 to amd64 that got fixed in the latest versions.
| INFRA_IF_NAME=eth0 WEB_GUI=1 NAT64=1 OTBR_MDNS=mDNSResponder ./script/bootstrap | ||
|
|
||
| # Stub systemctl so setup doesn't try to start/enable services during docker build | ||
| RUN ln -sf /bin/true /usr/local/bin/systemctl | ||
|
|
||
| # Run setup to install binaries, DBus config, ot-ctl, etc. | ||
| RUN HOME=/root && cd /home/otns/ot-br-posix && \ | ||
| INFRA_IF_NAME=eth0 WEB_GUI=1 NAT64=1 OTBR_MDNS=mDNSResponder DOCKER=1 FIREWALL=0 ./script/setup |
There was a problem hiding this comment.
Hardcoding INFRA_IF_NAME=eth0 during the OTBR setup phase can cause issues when running the container on Linux hosts with --network host (as configured in run-docker.sh), where the primary network interface might not be named eth0. While the entrypoint script attempts to detect the backbone interface at runtime, the OTBR configuration generated during script/setup (e.g., agent options, firewall rules) may still contain hardcoded references to eth0.
Consider using a BUILD_ARG for the interface name or updating the configuration dynamically in the entrypoint script.
|
|
||
| set -e | ||
|
|
||
| IMAGE_NAME="framichel/otns-matter" |
There was a problem hiding this comment.
The IMAGE_NAME is hardcoded to a specific user's Docker Hub namespace (framichel/). For a generic example in the repository, it is better to use a more neutral name or allow it to be overridden via an environment variable.
| IMAGE_NAME="framichel/otns-matter" | |
| IMAGE_NAME="${OTNS_MATTER_IMAGE:-otns-matter}" |
| @@ -0,0 +1,169 @@ | |||
| # OTNS + Matter + OT-BR Docker Environment | |||
| @@ -0,0 +1,86 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
Add standard OpenThread license header.
| @@ -0,0 +1,408 @@ | |||
| # Dockerfile for OTNS + OT-BR + Matter all-clusters-app development environment | |||
There was a problem hiding this comment.
Add standard OpenThread license header.
Here is an example allowing to run OT-BR in OTNS, routing over the infrastructure interface, and run simulated Matter nodes in the mesh. This allows real processes and real devices to communicate with simulated nodes (including Matter nodes) running in OTNS.
The README contains a tutorial. The Dockerfile currently uses a fork of OT-NS and a fork of Matter and applies a patch to these forks as well. Once these forks and patches get intergrated into the mainline repos, we will update this example accordingly.