rvoip-dialog-core
RFC 3261 SIP Dialog Management Layer for the rvoip VoIP stack, providing clean separation between session coordination and SIP protocol operations.
Overview
rvoip-dialog-core
implements the SIP dialog layer as defined in RFC 3261, serving as the protocol processing engine between session coordination (handled by session-core
) and transaction reliability (handled by transaction-core
). This crate manages SIP dialogs, routes messages within dialog contexts, and coordinates with the session layer through well-defined events.
Features
✅ Completed Features
-
SIP Protocol Processing
- ✅ INVITE dialog creation and management
- ✅ BYE dialog termination handling
- ✅ REGISTER processing with registration coordination
- ✅ ACK routing within confirmed dialogs
- ✅ CANCEL request handling for early dialogs
- ✅ Re-INVITE support for session modifications
-
Dialog State Management
- ✅ RFC 3261 compliant dialog state machine
- ✅ Early dialog handling (1xx responses)
- ✅ Confirmed dialog management (2xx responses)
- ✅ Dialog identification using Call-ID, tags, and CSeq
- ✅ Proper dialog lifetime management
- ✅ Dialog routing table maintenance
-
SIP Header Management
- ✅ Call-ID generation and validation
- ✅ From/To tag management
- ✅ CSeq number sequencing
- ✅ Via header processing for routing
- ✅ Contact header management
- ✅ Route/Record-Route header handling
-
Session Coordination
- ✅ Event-driven architecture with
session-core
- ✅ SDP negotiation coordination
- ✅ Incoming call notification events
- ✅ Call answered/terminated event propagation
- ✅ Registration event handling
- ✅ Event-driven architecture with
-
Recovery & Reliability
- ✅ Dialog recovery from failures
- ✅ Transaction correlation with dialogs
- ✅ Graceful error handling and cleanup
- ✅ Dialog expiration and cleanup
🚧 Planned Features
-
Advanced Dialog Management
- 🚧 Dialog forking support for parallel searches
- 🚧 Dialog replacement (RFC 3891) support
- 🚧 Enhanced dialog recovery mechanisms
- 🚧 Dialog transfer coordination
-
Protocol Extensions
- 🚧 SUBSCRIBE/NOTIFY dialog handling
- 🚧 REFER method support for call transfers
- 🚧 MESSAGE method for instant messaging
- 🚧 UPDATE method for mid-dialog updates
-
Performance Optimizations
- 🚧 Dialog caching and indexing improvements
- 🚧 Memory-optimized dialog storage
- 🚧 High-throughput dialog processing
- 🚧 Concurrent dialog operation batching
-
Event System Integration
- 🚧 Integration with infra-common event bus
- 🚧 Priority-based event processing
- 🚧 Advanced event filtering and routing
Architecture
🏗️ Architecture Position
┌─────────────────────────────────────────┐
│ Application Layer │
│ (client-core, call-engine) │
├─────────────────────────────────────────┤
│ Session Layer │
│ (session-core) │
├─────────────────────────────────────────┤
│ Dialog Layer │
│ (dialog-core) ⬅️ YOU ARE HERE │
├─────────────────────────────────────────┤
│ Transaction Layer │
│ (transaction-core) │
├─────────────────────────────────────────┤
│ Transport Layer │
│ (sip-transport) │
└─────────────────────────────────────────┘
Dialog Management Architecture
Dialog State Machine
Usage
Basic Dialog Creation
use ;
use TransactionManager;
use UdpTransport;
use Arc;
async
Outgoing Call Example
use ;
use ;
async
Registration Handling
async
Dialog Recovery
use ;
async
Relationship to Other Crates
Core Dependencies
rvoip-sip-core
: Provides SIP message types, parsing, and core protocol structuresrvoip-transaction-core
: Handles transaction reliability and retransmissionrvoip-sip-transport
: Provides network transport abstractiontokio
: Async runtime for concurrent dialog processingasync-trait
: Async trait support for transport abstraction
Optional Dependencies
rvoip-infra-common
: Event bus integration (planned)serde
: Serialization support for dialog persistence (recovery feature)tracing
: Enhanced logging and observability (monitoring feature)
Integration with rvoip Stack
┌─────────────────────────────────────────┐
│ Application Layer │
│ (client-core, call-engine) │
├─────────────────────────────────────────┤
│ rvoip-session-core │ ← Coordinates sessions
│ ↕️ │
│ rvoip-dialog-core ⬅️ YOU ARE HERE │ ← Manages SIP dialogs
│ ↕️ │
│ rvoip-transaction-core │ ← Handles reliability
├─────────────────────────────────────────┤
│ rvoip-sip-transport │ ← Network transport
└─────────────────────────────────────────┘
The dialog layer provides:
- Upward Interface: Session coordination events to
session-core
- Downward Interface: Transaction requests to
transaction-core
- Horizontal Interface: Dialog state queries for other components
Performance Characteristics
Dialog Operations
- Dialog Creation: O(1) with optimized hash-based storage
- Dialog Lookup: O(1) average case with efficient routing table
- Message Routing: O(1) for established dialogs, O(log n) for routing decisions
- Dialog Cleanup: Batched cleanup to minimize lock contention
Memory Management
- Dialog Storage: Memory-efficient with reference counting for shared data
- Event Processing: Zero-copy event propagation where possible
- Header Processing: Cached header parsing to avoid repeated work
- Transaction Correlation: Optimized correlation tables
Concurrency
- Read-Heavy Workloads: Optimized with
RwLock
for dialog access - Write Operations: Minimized lock scope for dialog modifications
- Event Processing: Async processing with configurable buffer sizes
- Resource Cleanup: Background cleanup tasks to avoid blocking
Error Handling
The crate provides comprehensive error handling with categorized error types:
use ;
match dialog_result
Error Categories
Testing
Run the comprehensive test suite:
# Run all tests
# Run with specific features
# Run integration tests
# Run RFC compliance tests
# Run with SIPp interoperability tests
# Run performance benchmarks
Features
The crate supports the following optional features:
recovery
(default): Dialog recovery and persistence capabilitiesevents
(default): Enhanced event system with filteringmonitoring
(default): Metrics and observability supporttesting
: Additional test utilities and mock implementations
Disable default features and enable only what you need:
[]
= { = "0.1", = false, = ["recovery"] }
Examples
The examples/
directory contains comprehensive examples:
basic_dialog.rs
- Basic dialog creation and managementdialog_recovery.rs
- Dialog recovery and failure handlingmulti_dialog.rs
- Managing multiple concurrent dialogsoutgoing_call.rs
- Complete outgoing call flowregistration_server.rs
- Registration processing examplesession_coordination.rs
- Integration with session-core
Run examples:
🔧 Core API
DialogManager
The main interface for dialog management:
Session Coordination Events
Events sent to session-core
for session management:
🔍 Integration with RVOIP
This crate is designed to be used by session-core
as its dialog management layer:
// In session-core
use ;
Future Improvements
See TODO.md for a comprehensive list of planned enhancements, including:
- Advanced dialog forking and parallel search support
- Enhanced dialog recovery mechanisms with persistent state
- Integration with infra-common event bus for high-throughput processing
- Performance optimizations for high-scale deployments
- Protocol extensions (SUBSCRIBE/NOTIFY, REFER, MESSAGE)
- Advanced monitoring and diagnostics capabilities
🚀 Development Status
This crate is part of the RVOIP architecture refactoring to establish clean layer separation. Current status:
- ✅ Core dialog management implemented
- ✅ Basic protocol handling (INVITE, BYE, REGISTER)
- ✅ Session coordination events
- 🚧 Advanced recovery mechanisms
- 🚧 Performance optimizations
- 🚧 Protocol extensions
Contributing
Contributions are welcome! Please see the main rvoip contributing guidelines for details.
When contributing to dialog-core:
- Ensure proper RFC 3261 compliance
- Maintain clean layer separation
- Add comprehensive tests for new functionality
- Update documentation and examples
- Follow the existing API patterns
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.