OpenThread Border Router (OTBR) is an open-source implementation of a Thread Border Router, which connects a Thread network to other IP-based networks (e.g., Wi-Fi or Ethernet). It provides end-to-end IP connectivity, DNS-based service discovery (mDNS/SRP), DHCPv6 Prefix Delegation, NAT64, and External Thread Commissioning.
The project is primarily written in C++11 and C99, and is designed to run on POSIX-compliant operating systems like Linux. It leverages the OpenThread stack and provides additional services to act as a border router.
otbr-agent: The main agent process that manages the Thread interface and coordinates other services.- mDNS: Supports multiple mDNS providers including Avahi, mDNSResponder, and OpenThread's built-in mDNS.
- Web GUI: An optional web interface for managing the border router.
- REST API: A RESTful interface for monitoring and configuration.
- DBus Server: Provides a DBus interface for external applications to interact with OTBR.
The project uses CMake as its build system and Ninja as the preferred build tool.
You can install all necessary dependencies using the bootstrap script:
./script/bootstrapTo build the project with default options:
./script/cmake-buildYou can pass CMake options to the script:
./script/cmake-build -DOTBR_DBUS=ON -DOTBR_WEB=ONOTBR uses a comprehensive test suite including unit tests and simulation-based integration tests.
# Run all tests
./script/test build check simulationOTBR follows the OpenThread coding conventions, which are enforced using clang-format.
- Indentation: 4 spaces.
- Naming:
UpperCamelCasefor classes, structures, enums, methods, and functions.lowerCamelCasefor variables and parameters.
- Variable Prefixes:
mfor class/structure members (e.g.,mInterfaceName).afor function/method parameters (e.g.,aPacket).gfor global variables (e.g.,gLogFacility).sfor static variables (e.g.,sInstance).kfor constant variables (e.g.,kDefaultInterfaceName).
- Headers: Use Doxygen for documentation and standard include guards.
Always run the following script before submitting changes to ensure compliance with the style guide:
./script/make-prettyTo check if the code is correctly formatted:
./script/make-pretty checkPublic APIs and significant internal logic should be documented using Doxygen-style comments. You can build the documentation with:
./script/test doxygen