rsipstack - A SIP Stack written in Rust
WIP This is a work in progress and is not yet ready for production use.
A RFC 3261 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 Compliant: Full compliance with SIP specification
- Multiple Transport Support: UDP, TCP, TLS, WebSocket
- Transaction Layer: Complete SIP transaction state machine
- Dialog Layer: SIP dialog management
- Digest Authentication: Built-in authentication support
- High Performance: Built with Rust for maximum performance
- Easy to Use: Simple and intuitive API design
TODO
- Transport support
- UDP
- TCP
- TLS
- WebSocket
- Digest Authentication
- Transaction Layer
- Dialog Layer
- WASM target
Use Cases
This SIP stack can be used in various scenarios, including but not limited to:
- Integration with WebRTC for browser-based communication, such as WebRTC SBC.
- Building custom SIP proxies or registrars
- Building custom SIP user agents (SIP.js alternative)
Why Rust?
We are a group of developers who are passionate about SIP and Rust. We believe that Rust is a great language for building high-performance network applications, and we want to bring the power of Rust to the SIP/WebRTC/SFU world.
Quick Start Examples
1. Simple SIP Connection
The most basic way to use rsipstack is through direct SIP connections, supporting both UDP and TCP transports:
# Run as UDP server (default)
# Run as UDP client sending messages to a server
# Run as TCP server
This example demonstrates:
- Creating UDP/TCP connections and listeners
- Sending raw SIP messages (OPTIONS, MESSAGE, REGISTER)
- Handling incoming SIP requests and responses
- Basic SIP message parsing and creation
2. 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
3. SIP User Agent Client
A complete SIP client with registration, calling, and media support:
# Local demo proxy
# Register with a SIP server
This example demonstrates:
- SIP user registration with digest authentication
- Making and receiving SIP calls (INVITE/BYE)
- Dialog management for call sessions
- RTP media streaming with file playback
- STUN support for NAT traversal
API Usage Guide
1. Simple SIP Connection
use ;
// Create UDP connection
let connection = create_connection.await?;
// Send raw SIP message
let sip_message = "OPTIONS sip:test@example.com SIP/2.0\r\n...";
connection.send_raw.await?;
2. Using Endpoint and Transactions
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;
// Handle incoming transactions
let mut incoming = endpoint.incoming_transactions;
while let Some = incoming.recv.await
3. Creating a User Agent Client
use ;
use Credential;
// Create dialog layer
let dialog_layer = new;
// Register with server
let credential = Credential ;
let registration = new?;
// Make outgoing call
let invite_option = InviteOption ;
let invite_dialog = dialog_layer.create_invite_dialog.await?;
4. Implementing a Proxy
use Transaction;
use HashMap;
// Handle incoming requests
while let Some = incoming.recv.await
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.