rsipstack - A SIP Stack written in Rust
A RFC 3261/3262 compliant SIP stack written in Rust. The goal of this project is to provide a high-performance, reliable, and easy-to-use SIP stack that can be used in various scenarios.
Features
- RFC 3261/3262 Compliant: Full compliance with SIP specification
- Multiple Transport Support: UDP, TCP, TLS, WebSocket (TLS/WebSocket require the
rustlsandwebsocketfeatures, enabled by default). The TLS client goes through a backend seam (platform::tls) — host default is the built-in rustls; embedded stacks can register their own connector - IPv6 & Dual-Stack: listeners on
::serve IPv4 and IPv6; IPv4-mapped peers are canonicalized and UDP sends pick a reachable listener - Transaction Layer: Complete SIP transaction state machine
- Dialog Layer: SIP dialog management
- Reliable Provisionals: PRACK (RFC 3262 / 100rel) support
- Digest Authentication: Built-in authentication support
- no_std / Embedded: alloc-only core with an embassy backend
no_std / Embedded Support
rsipstack compiles without std (alloc-only) for embassy-based targets —
verified on xtensa-esp32s3-none-elf (ESP32-S3):
-
Core SIP codec, transaction, dialog, and UDP transport layers are
no_std+alloc. -
The
platform-embassybackend maps the runtime seams ontoembassy-time/embassy-sync(critical-section based); task spawning is injected once at startup:set_spawn_fn; -
Concurrent waits use the backend-agnostic
select2/select3helpers instead oftokio::select!. -
SIPS (SIP over TLS, client role) goes through the
platform::tls::TlsConnectorseam: register a backend withplatform::tls::set_client_connectorand everyTlsConnection::connectrides it. Host builds without a registered connector keep using the built-in rustls path. -
TCP / WebSocket transports still require
platform-tokio; on embedded, use UDP or SIPS today. -
On no_std, register a
DomainResolverinstead of the tokio DNS resolver.
Compatibility
rsipstack follows RFC 3261 strictly. Stream transports require a valid single
Content-Length, Via received is bare for IPv6, dialogs follow target
refreshes, and transactions match per RFC. See the
CHANGELOG for release-specific behaviour changes.
Use Cases
rsipstack powers production SIP applications and related projects:
- RustPBX — programmable, software-defined PBX
- Active Call — SIP/WebRTC AI voice agent
- SipBot — SIP call-flow bot for testing and simulation
- RustRTC — WebRTC, RTP/SRTP and T.38 media stack used alongside rsipstack
- MiuTURN — TURN server for WebRTC
- Custom SIP proxies, registrars, user agents, and WebRTC SBCs
Quick Start Examples
SIP Proxy Server
A stateful SIP proxy that routes calls between registered users:
# Run proxy server
# Run with external IP
This example demonstrates:
- SIP user registration and location service
- Call routing between registered users
- Transaction forwarding and response handling
- Session management for active calls
- Handling INVITE, BYE, REGISTER, and ACK methods
SIP User Agent Client
A complete SIP client with registration, calling, and media support:
# Local demo proxy
# Register with a SIP server
API Usage Guide
1. Simple SIP Connection
use ;
use ;
use CancellationToken;
// Create UDP connection bound to an ephemeral local port
let cancel_token = new;
let connection = create_connection
.await?;
// Prepare the remote target
let target_addr = new;
// Send raw SIP message
let sip_message = "OPTIONS sip:test@example.com SIP/2.0\r\n...";
connection
.send_raw
.await?;
2. Using Transport Listeners
use ;
use CancellationToken;
// Build a transport layer and register listeners
let cancel_token = new;
let transport_layer = new;
let tcp_listener = new
.await?;
transport_layer.add_transport;
To add TLS or WebSocket listeners, construct a TlsListenerConnection or
WebSocketListenerConnection and register it with transport_layer.add_transport(...).
rustls crypto provider. rsipstack's TLS uses rustls's process-wide crypto provider and builds rustls with
ring. If your application also links theaws-lc-rsbackend (for example throughreqwest's default rustls setup), rustls cannot pick one on its own and the first TLS connection panics with "Could not automatically determine the process-level CryptoProvider". Install a provider once at startup, before creating any TLS transport:default_provider .install_default .expect; // or: rustls::crypto::aws_lc_rs::default_provider().install_default()The installed provider is used for every rustls user in the process, rsipstack included, so it is also where to restrict cipher suites.
The raw TransportEvent stream is an internal API consumed by Endpoint::serve.
To process incoming SIP messages, build an Endpoint around the transport layer and
drive it with endpoint.serve() while consuming transactions via
endpoint.incoming_transactions() (see the next section).
3. Using Endpoint and Transactions
use ;
use ;
use CancellationToken;
// Build endpoint with transport layer
let cancel_token = new;
let transport_layer = new;
let endpoint = new
.with_transport_layer
.with_cancel_token
.build;
// Start endpoint background task
let endpoint_inner = endpoint.inner.clone;
spawn;
// Handle incoming transactions
let mut incoming = endpoint
.incoming_transactions
.expect;
while let Some = incoming.recv.await
4. Creating a User Agent Client
use DialogLayer;
use Registration;
use Credential;
use InviteOption;
use Arc;
// Create dialog layer
let dialog_layer = new;
// Register with server
let credential = Credential ;
let mut registration = new;
let response = registration.register.await?;
// Make outgoing call
let invite_option = InviteOption ;
// Create the dialog state channel (drives `process_dialog`-style loops)
let = dialog_layer.new_dialog_state_channel;
let = dialog_layer.do_invite.await?;
5. Implementing a Proxy
use ;
use ;
use HeadersExt;
use HashMap;
// Handle incoming requests
while let Some = incoming.recv.await
This is a simplified sketch: User, users and incoming are types/values you define yourself
(incoming comes from endpoint.incoming_transactions()?, and User is a struct you implement
that holds the registered user's username and destination SipAddr). A complete, working proxy
is provided in examples/proxy.rs.
Running Tests
Unit Tests
Benchmark Tests
# Run server
# Run client with 1000 calls
The test monitor:
===
============================
Documentation
Contributing
We welcome contributions! Please see our Contributing Guide for details.
License
This project is licensed under the MIT License - see the LICENSE file for details.