Skip to content

Add example run OTNS with OT-BR and Matter accessories.#784

Open
francoismichel wants to merge 2 commits intoopenthread:mainfrom
francoismichel:matter-otbr-example
Open

Add example run OTNS with OT-BR and Matter accessories.#784
francoismichel wants to merge 2 commits intoopenthread:mainfrom
francoismichel:matter-otbr-example

Conversation

@francoismichel
Copy link
Copy Markdown

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.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 17, 2026

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.
Copy link
Copy Markdown

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

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 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The Go version 1.26.2 is invalid as it has not been released yet (the current stable version is 1.23.x). This will cause the wget command at line 80 to fail, preventing the Docker image from building.

ARG GO_VERSION=1.23.4

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.

@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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Comment on lines +327 to +334
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

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.

Suggested change
IMAGE_NAME="framichel/otns-matter"
IMAGE_NAME="${OTNS_MATTER_IMAGE:-otns-matter}"

@jwhui jwhui requested a review from Vyrastas April 17, 2026 18:36
@@ -0,0 +1,169 @@
# OTNS + Matter + OT-BR Docker Environment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Vyrastas , can you help review this README?

@@ -0,0 +1,86 @@
#!/bin/bash
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add standard OpenThread license header.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in b5f6bfc

@@ -0,0 +1,408 @@
# Dockerfile for OTNS + OT-BR + Matter all-clusters-app development environment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add standard OpenThread license header.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in b5f6bfc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants