Native usrsctp SCTP transport for aiortc RTCDataChannel.
The package leaves aiortc's RTCPeerConnection, DCEP, DTLS and ICE paths in
place and replaces aiortc's pure-Python SCTP transport with a small CPython
extension backed by usrsctp.
Current source is built around:
- aiortc 1.15.0
- usrsctp 0.9.5.0
- SCTP MTU 1200
- 4 MiB send / receive buffers
- delayed SACK frequency 2, 20 ms
- 10 ms userspace timer tick
Install the wheel, then install the replacement before creating any
RTCPeerConnection:
from aiortc_native_sctp import install_native_sctp
install_native_sctp()
from aiortc import RTCPeerConnectionExisting aiortc application code does not otherwise need to change.
Requirements:
- Python development environment
- Visual Studio C++ Build Tools
- CMake
- Git
From a normal PowerShell in this repository:
.\build-windows.ps1The script:
- clones
usrsctp0.9.5.0 into.build\usrsctp-srcif needed; - builds a static usrsctp library into
.build\usrsctp-install; - builds
aiortc_native_sctpas a wheel intodist\; - installs that wheel into the current Python environment;
- runs the loopback native SCTP smoke test.
To use an existing usrsctp source tree instead:
.\build-windows.ps1 -UsrsctpSource C:\path\to\usrsctpRequirements:
- Python development environment
- C/C++ build tools
- CMake
- Git
From this repository:
./build-linux.shTo select a Python interpreter:
PYTHON=python3.12 ./build-linux.shTo use an existing usrsctp source tree:
./build-linux.sh /path/to/usrsctpEverything is built under .build/; the wheel is written to dist/, then
installed into the selected Python environment and smoke-tested.
Requirements:
- Python development environment
- Xcode Command Line Tools
- CMake
- Git
From this repository:
./build-macos.shThe script builds for the current machine architecture (arm64 or x86_64).
You can override the interpreter or architecture when needed:
PYTHON=python3.12 ./build-macos.sh
ARCH=arm64 ./build-macos.shTo use an existing usrsctp source tree:
./build-macos.sh /path/to/usrsctpIf MACOSX_DEPLOYMENT_TARGET is already set, the same target is passed to the
usrsctp CMake build and the Python wheel build environment.
If usrsctp is already installed somewhere:
$env:USRSCTP_ROOT = "C:\path\to\usrsctp-install"
python -m pip install build
python -m build --wheelThe wheel is written to dist\.
A Git VCS dependency builds from source, so it still needs a local usrsctp
build and USRSCTP_ROOT:
aiortc-native-sctp @ git+https://github.com/nuwainfo/aiortc-native-sctp.git@main
For machines where you do not want to compile usrsctp, upload your prebuilt
wheel to a GitHub Release and point requirements.txt directly at that wheel,
for example:
aiortc-native-sctp @ https://github.com/nuwainfo/aiortc-native-sctp/releases/download/v0.1.0/aiortc_native_sctp-0.1.0-cp312-cp312-win_amd64.whl ; sys_platform == "win32" and python_version == "3.12"
After installation:
python -m aiortc_native_sctp.smokeThe smoke test creates two in-process AF_CONN associations, transfers a 256 KiB message and verifies its stream id, PPID and contents.
usrsctp is not vendored in this repository. The Windows build script fetches
the 0.9.5.0 source tree when needed. If you publish statically linked wheels,
retain the upstream usrsctp license and notices with your distribution.