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:
This example demonstrates:
- Creating UDP/TCP connections
- Sending raw SIP messages
- Basic message handling
2. Endpoint, TransportLayer and Transaction
For more advanced usage with transaction handling:
This example shows:
- Creating and configuring an Endpoint
- Setting up TransportLayer with multiple transports
- Handling SIP transactions (client and server)
- Processing various SIP methods (OPTIONS, REGISTER, MESSAGE)
3. SIP User Agent (Register/Invite)
A complete SIP user agent implementation:
Features:
- User registration with SIP registrar
- Making and receiving INVITE calls
- Call establishment and termination
- Dialog management
- Authentication handling
4. SIP Proxy (Register/Invite)
A SIP proxy server implementation:
Features:
- SIP message routing
- Registration handling
- Call forwarding
- Multiple transport support
- Load balancing
API Usage Guide
1. Simple SIP Connection
use ;
// Create UDP connection
let connection = create_connection.await?;
// Send raw SIP message
let sip_message = "MESSAGE sip:test@example.com SIP/2.0\r\n...";
connection.send_raw.await?;
2. Using Endpoint and Transactions
use ;
use TransportLayer;
// Build endpoint
let transport_layer = new;
let endpoint = new
.with_transport_layer
.build;
// Handle incoming transactions
let mut incoming = endpoint.incoming_transactions;
while let Some = incoming.recv.await
3. Creating a User Agent
use ;
// Create dialog layer
let dialog_layer = new;
// Register with server
let register_dialog = dialog_layer.create_register_dialog.await?;
// Make outgoing call
let invite_dialog = dialog_layer.create_invite_dialog.await?;
4. Implementing a Proxy
use Endpoint;
// Create proxy endpoint
let proxy = new
.with_transport_layer
.build;
// Handle incoming requests
let mut incoming = proxy.incoming_transactions;
while let Some = incoming.recv.await
Running Tests
Unit Tests
RFC 3261 Compliance Tests
# Run all compliance tests
# Run specific compliance test suites
Integration Tests
# Test with real SIP scenarios
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.