Skip to main content

BSWorld

English | 简体中文

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.

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

Clone and install BSWorld:

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.

BSWorld participants connected through independent virtual Controllers or as complete firmware to a shared BabbleSim PHY
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

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

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bsworld 1.1.4
File Size Uploaded Provenance Actions
bsworld-1.1.4.tar.gz 2.3 MB With provenance Details for bsworld-1.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bsworld 1.1.4
File Interpreter ABI Platform Actions
bsworld-1.1.4-py3-none-any.whl Python 3 none any Details for bsworld-1.1.4-py3-none-any.whl

Total release size: 2.3 MB

Release files / bsworld-1.1.4.tar.gz

Download URL bsworld-1.1.4.tar.gz
Size 2.3 MB
Tags Source
SHA-256 checksum
How to use checksums
bda5d68b7255b1ff498c77ad3751ef96da7cfcfe209a694e37d05a91fa62f77b
BLAKE2b-256 checksum
How to use checksums
f52c175efb17bb443cb48d90efe4d03c4c0dadaca1e8a3320b6807d579a8b333
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 log

Release files / bsworld-1.1.4-py3-none-any.whl

Download URL bsworld-1.1.4-py3-none-any.whl
Size 51.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
91f0e17f4291d82fa82f621f38592dc86e6c8fbcd2d8e487ff3db8f3905f7891
BLAKE2b-256 checksum
How to use checksums
a6a3d2c2f4b359f57bb5b6f6458bebc6e2957e4f6d1e35e8cb2b6e993f768ce7
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 log

Security for bsworld 1.1.4

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.

Select from 2 files

Attestation for bsworld-1.1.4.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 log

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

Release history Release notifications | RSS feed

This release

1.1.4 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page