RootCanal is a virtual Bluetooth Controller. RootCanal aims reducing the overhead of writing and deploying end-to-end tests on Bluetooth devices by taking away the physical layer.
The emulation of Bluetooth features on RootCanal is limited to features that have direct consequences on connected hosts. The accurate implementation of HCI commands and events is thus critical to RootCanal's goal, while accurate emulation of the scheduler and base-band is out of scope.
RootCanal can be natively built or installed pre-compiled though the PyPI
rootcanal package. Both options have been tested with linux-x86_64 and
macos-arm64, windows is not yet supported.
sudo apt install bazel rustc cargo
cargo install pdl-compiler --version 0.3.2
git clone https://github.com/google/rootcanal.git
cd rootcanal
git submodule update --init
bazel run :rootcanal
pip install rootcanal
python -m rootcanal
The following configuration options are implemented:
-
--test_port(default6401) Configure the TCP port for the test channel. -
--hci_port(default6402) Configure the TCP port for the HCI server. -
--link_port(default6403) Configure the TCP port for the link server. -
--link_ble_port(default6404) Configure the TCP port for the BLE link server. -
--controller_properties_file(default"") Configure the path to a custom Controller configuration file. All properties defined inmodel/controller/controller_properties.hcan be edited to test with a specific controller setup. The format of the configuration file is defined byproto/rootcanal/configuration.proto. -
--enable_hci_sniffer(defaultfalse) Capture PCAP traces for all connected HCI hosts. The PCAP traces are saved in the current directory. -
--enable_baseband_sniffer(defaultfalse) Capture PCAP traces for all base-band packets exchanged between connection HCI hosts. The PCAP traces are saved in the current directory. This option is useful to inspect and debug RootCanal's implementation.
All RootCanal instances expose four TCP ports:
- HCI channel
- Test channel
- BR_EDR Phy channel
- LE Phy channel
The HCI channel implements the Bluetooth UART transport protocol (a.k.a. H4) over TCP. Each new connection on the HCI port spawns a new virtual controller.
The test channel uses a simple custom protocol to send control commands to RootCanal. You can connect to it using scripts/test_channel.py.
The physical channels use a custom protocol described in packets/link_layer_packets.pdl. The protocol simplifies the LL and LMP protocol packets defined in the Bluetooth specification to abstract over negotiation details.
Warning The protocol can change in backward incompatible ways, be careful when depending on it.
Controllers can exchanges link layer packets only when they are part of the same phy. One controller can be added to multiple phys, the simplest example begin BR/EDR and LE dual phys.
- LL Privacy
- Extended Advertising
- Periodic Advertising
- Channel Sounding (under development)
- Connection Subrating
- LE Power Control Requests
- Connected Isochronous Stream
- Broadcast Isochronous Stream (under development)