BSWorld
BSWorld is a deterministic simulation framework for testing Bluetooth Hosts and Applications on Linux. A pytest scenario defines the device topology and expected behavior; BSWorld runs the participants on a shared BabbleSim radio and simulation clock, then archives logs and protocol traces.
Use BSWorld to:
- Test open-source Host stacks such as Zephyr, NuttX, BlueZ, NimBLE, Bumble, and TrouBLE without modifying their source code.
- Run without hardware: Hosts connect over standard H4 HCI to virtual Controllers, or complete firmware joins the PHY with its own Controller and radio.
- Keep Application logs, HCI BTSnoop captures, PHY logs, and Ellisys traces for debugging failures.
- Simulate many devices in one scenario. Repeated runs of the same scenario produce consistent logs and timing, regardless of host load or scheduling.
- Share one discrete simulation clock across all devices. Scenarios are isolated and run in parallel with pytest-xdist, up to 100 times faster than real time.
- Inject attenuation, interference, WLAN activity, and recorded radio signals.
Quick Start
BSWorld runs on Linux/x86_64. The published Docker image includes Python, BSWorld, and the firmware required by the integration tests.
Docker (Recommended)
Install Docker Engine, then run the packaged integration tests:
sudo docker pull ghcr.io/xiaomi/bsworld:latest
mkdir -p .cache/docker-results
# The published image runs as UID/GID 1000.
sudo chown 1000:1000 .cache/docker-results
sudo docker run --rm \
-e PYTHONPATH=/workspace \
--mount "type=bind,src=$PWD/.cache/docker-results,dst=/output" \
ghcr.io/xiaomi/bsworld:latest
Results are written to .cache/docker-results, including pytest.xml, process logs, HCI captures, and RF traces. See the Docker guide to run a selected suite, test the current checkout, choose an image version, or build an image.
Local Linux
Development and test commands require Python 3.12 or newer. On Ubuntu 24.04, install the required tools:
sudo apt-get update
sudo apt-get install -y \
bash ca-certificates curl git repo file make binutils build-essential \
python3.12 python3.12-dev python3.12-venv python3-pip \
gcc-multilib g++-multilib coreutils findutils grep sed
Install BSWorld from PyPI. Add the bumble extra to run Bumble Hosts in tests:
python3.12 -m pip install bsworld # or 'bsworld[bumble]'
To develop BSWorld, clone it and install BSWorld and the bscontroller in the repository from source:
git clone https://github.com/XiaoMi/bsworld.git
cd bsworld
export BSWORLD_ROOT="$PWD"
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install -e components/bscontroller -e '.[test]'
Run the development checks:
ruff check src tests
pytest tests/unit -q
Build and Test
Fetch the BabbleSim revisions selected by components/babblesim.xml:
mkdir -p "$BSWORLD_ROOT/.cache/babblesim"
cd "$BSWORLD_ROOT/.cache/babblesim"
repo init --standalone-manifest --depth=1 -u "file://$BSWORLD_ROOT/components/babblesim.xml"
repo sync -c --no-tags
Set the output paths and build every component:
export BSIM_OUT_PATH="$PWD/build"
export BSIM_COMPONENTS_PATH="$PWD/components"
export BSIM_BUILD_FAIL_ASAP=1
make -j"$(nproc)" everything
Run the Bumble scenarios on BSController, which need no other binaries:
cd "$BSWORLD_ROOT"
pytest tests/integration/bumble -n auto -k '[bscontroller]'
Test Controller Variants
Integration scenarios run with both the Zephyr Controller ([zephyr]) and Python BSController ([bscontroller]); [zephyr] cases are skipped when the Zephyr Controller is not built. See Virtual Controllers.
Select one implementation with its pytest parameter ID:
pytest tests/integration -n auto -v -k '[zephyr]'
pytest tests/integration -n auto -v -k '[bscontroller]'
Supported Integrations
| Environment | Validated behavior | Guide |
|---|---|---|
| Zephyr Bluetooth shell | Advertising and scanning, interference and recovery, connections and GATT, LL procedures, pairing and privacy, periodic advertising; complete firmware against Host-only shells on either Controller and against Bumble | Zephyr tests |
| Bumble Python Host | Advertising, scanning, connections, periodic advertising and synchronization | Bumble tests |
| Linux and BlueZ under QEMU | Controller setup, advertising, scanning, connection and disconnection through the Linux Bluetooth subsystem | BlueZ tests |
| TrouBLE Rust Host | Advertising, connection, Battery Service discovery, reads and notifications | TrouBLE tests |
| NuttX BTSak | Advertising, scanning, multiple advertisers, interference and recovery | BTSak tests |
| Apache NimBLE | Discovery, connection, GATT and subscription on NuttX; discovery and connection under QEMU | NuttX tests · QEMU tests |
Technical Architecture
BSWorld keeps each Application and Host stack on its native interface. Every Host connects through standard HCI to an independent Zephyr Controller process or Python BSController worker. Complete Zephyr firmware includes its own Controller and radio and joins the PHY directly; see Complete firmware. All Controllers, complete firmware and interference sources share the BabbleSim PHY and simulation clock.
Figure 1: BSWorld architecture
The virtual Controllers implement HCI commands, events, ACL data, Link Layer procedures, and radio transmission and reception. A topology can mix RTOS, Python, QEMU-based Linux and complete Zephyr participants with either Controller implementation. See Virtual Controllers to choose and configure them.
HCI traffic is saved as hciN.snoop for Wireshark or another BTSnoop-capable tool. Radio traffic is saved as babblesim/ellisys.bttrp for Ellisys. See Logs, traces, and captures for locations and a recommended investigation order.
Discrete-Time Scheduling
| Time base | Meaning |
|---|---|
| Simulation time | Defines protocol timers, packet timing, RF events, asyncio waits, and test timeouts. It advances only after all participants synchronize. |
| Wall-clock time | Measures how long the test takes on the host. CPU load and Linux scheduling affect this duration but not protocol timing. |
BSWorld registers Applications, Controllers, interference devices, and pytest in the same simulation. A shared synchronization barrier keeps them on one timeline, so a protocol interval such as T_IFS = 150 μs remains 150 μs regardless of host load. After topology startup, standard asyncio waits and timeouts use simulation time; see Async waiting and simulation time.
Repeatability assumes identical binaries and inputs and controlled random sources. External networks, wall-clock-driven services, and other unadapted Host I/O can still introduce nondeterminism.
Documentation
- Writing tests and RF scenarios: define topologies, integrate Applications, wait with asyncio, and configure RF conditions.
- Virtual Controllers: choose between the Zephyr and Python Controllers, run a scenario against both, and configure BSController.
- Logs, traces, and captures: locate and analyze test artifacts.
- Development checks: run unit tests, lint, and coverage.
- Docker guide: run published images, select suites, and build local images.
Community
License
BSWorld is licensed under the Apache License 2.0. Third-party components retain their own licenses; see Third-Party Notices.
Metadata
Release files for bsworld 1.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bsworld-1.1.3.tar.gz | 2.3 MB | With provenance | Details for bsworld-1.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bsworld-1.1.3-py3-none-any.whl | Python 3 | none | any | Details for bsworld-1.1.3-py3-none-any.whl |
Total release size: 2.3 MB
Release files / bsworld-1.1.3.tar.gz
| Download URL | bsworld-1.1.3.tar.gz |
|---|---|
| Size | 2.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b38bbfd7d8f984859e07775f7e336352a91a616fe3d099b64fcf310d581d161
|
|
BLAKE2b-256 checksum How to use checksums |
bdd4428f1b9e557ac1970bb558e8c726af3f28941ffebb56d82799d6d23c19f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logRelease files / bsworld-1.1.3-py3-none-any.whl
| Download URL | bsworld-1.1.3-py3-none-any.whl |
|---|---|
| Size | 51.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4aba119df5c78ebf90b05b0e4907daf7b3ee9ef03d3c0d6775702978b9e145c9
|
|
BLAKE2b-256 checksum How to use checksums |
85fe3e7e7c882ea1953486820a1bcd5bc9682955308e9c3471c520489aecec1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logSecurity for bsworld 1.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for bsworld-1.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.