SIPREC Technical Documentation
Complete technical guide for implementing and deploying SIPREC recording solutions.
Overview
SIPREC (Session Initiation Protocol Recording) is a protocol defined in RFC 7865 and RFC 7866 that enables compliant SIP systems to record call sessions. Our implementation provides a robust, scalable solution for enterprise call recording needs.
// Example: Basic SIPREC initialization
package main
import (
"github.com/loreste/siprec"
"log"
)
func main() {
server := siprec.NewServer(siprec.Config{
Address: ":5060",
TLS: true,
Storage: "s3://recordings",
})
if err := server.Start(); err != nil {
log.Fatal(err)
}
}
Architecture
System Components
- SIP Proxy: Handles SIP signaling and session establishment
- Media Server: Manages RTP/SRTP streams and transcoding
- Storage Engine: Configurable backend (local, S3, Azure, GCS)
- Metadata Service: Stores call details and indexing
- WebSocket API: Real-time streaming and monitoring
Protocol Flow
┌─────────┐ INVITE ┌──────────┐ INVITE ┌─────────┐ │ SRC │ ───────────────> │ SIPREC │ ───────────────> │ SRS │ │ (UA) │ │ CLIENT │ │ SERVER │ └─────────┘ <─────────────── └──────────┘ <─────────────── └─────────┘ 200 OK 200 OK ═══════════════════════════════════════════ RTP/SRTP Media Flow ═══════════════════════════════════════════
High Availability
Our architecture supports active-active clustering with automatic failover:
- Load balancing across multiple recording servers
- Automatic session migration on node failure
- Distributed metadata storage with replication
- Zero-downtime rolling updates
Installation
System Requirements
- Go 1.20 or higher
- Linux (kernel 3.10+), macOS, or Windows Server 2016+
- Minimum 4GB RAM, 8GB recommended
- 10GB disk space for application and logs
- Additional storage for recordings
Quick Start
# Clone the repository
git clone https://github.com/loreste/siprec.git
cd siprec
# Build the binary
make build
# Run with default configuration
./siprec --config config.yaml
# Or use Docker
docker run -p 5060:5060 -p 8080:8080 loreste/siprec:latest
Production Deployment
# Install as systemd service
sudo make install-systemd
# Configure environment
sudo cp .env.example /etc/siprec/.env
sudo nano /etc/siprec/.env
# Start the service
sudo systemctl start siprec
sudo systemctl enable siprec
# Check status
sudo systemctl status siprec
Configuration
Basic Configuration
# config.yaml
server:
address: ":5060"
tls:
enabled: true
cert_file: "/etc/siprec/cert.pem"
key_file: "/etc/siprec/key.pem"
media:
port_range: "10000-20000"
codecs:
- G.711
- G.729
- opus
storage:
type: "s3"
s3:
bucket: "call-recordings"
region: "us-east-1"
encryption: true
metadata:
type: "postgresql"
connection: "postgres://user:pass@localhost/siprec"
logging:
level: "info"
format: "json"
output: "/var/log/siprec/siprec.log"
Advanced Options
Parameter | Type | Default | Description |
---|---|---|---|
server.max_connections | int | 10000 | Maximum concurrent connections |
media.buffer_size | int | 160 | RTP packet buffer size |
storage.retention_days | int | 90 | Recording retention period |
cluster.enabled | bool | false | Enable clustering mode |
API Reference
REST API
GET /api/v1/recordings
List all recordings with optional filters
curl -X GET https://api.siprec.local/api/v1/recordings \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"start_date": "2024-01-01",
"end_date": "2024-01-31",
"caller": "+1234567890",
"limit": 100
}'
POST /api/v1/recordings/start
Manually start a recording session
curl -X POST https://api.siprec.local/api/v1/recordings/start \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"session_id": "call-123456",
"participants": [
{"uri": "sip:alice@example.com", "name": "Alice"},
{"uri": "sip:bob@example.com", "name": "Bob"}
],
"metadata": {
"department": "sales",
"campaign": "Q1-2024"
}
}'
WebSocket API
// Real-time streaming example
const ws = new WebSocket('wss://api.siprec.local/ws/stream');
ws.onopen = () => {
ws.send(JSON.stringify({
action: 'subscribe',
session_id: 'call-123456',
format: 'wav'
}));
};
ws.onmessage = (event) => {
const audioData = event.data;
// Process audio stream
};
Security
Encryption
- Signaling: TLS 1.3 for all SIP communications
- Media: SRTP with AES-256 encryption
- Storage: At-rest encryption using AES-256-GCM
- API: OAuth 2.0 / JWT authentication
Access Control
# Role-based access control configuration
auth:
provider: "oauth2"
oauth2:
issuer: "https://auth.company.com"
audience: "siprec-api"
roles:
- name: "admin"
permissions: ["read", "write", "delete", "manage"]
- name: "supervisor"
permissions: ["read", "write", "export"]
- name: "agent"
permissions: ["read"]
ip_whitelist:
- "10.0.0.0/8"
- "192.168.0.0/16"
Compliance
Our solution meets industry compliance standards:
- PCI DSS Level 1 certified
- GDPR compliant with data retention controls
- HIPAA ready with BAA available
- SOC 2 Type II attestation
Performance
Benchmarks
Metric | Value | Configuration |
---|---|---|
Concurrent Sessions | 10,000 | Single node, 16 cores, 32GB RAM |
Media Latency | < 50ms | End-to-end recording delay |
Storage Throughput | 1 Gbps | S3 backend, multi-part upload |
API Response Time | < 100ms | 95th percentile |
Optimization Tips
- Use SSD storage for metadata database
- Enable connection pooling for database
- Configure appropriate buffer sizes for your network
- Use CDN for recording playback
- Enable compression for long-term storage
Troubleshooting
Common Issues
No audio in recordings
Symptom: Recording files are created but contain no audio
Solution:
- Check firewall rules for RTP port range (10000-20000)
- Verify SRTP is properly negotiated
- Check codec compatibility
# Debug RTP traffic
tcpdump -i any -n port 5060 or portrange 10000-20000
# Check SIPREC logs
tail -f /var/log/siprec/siprec.log | grep -E "RTP|SRTP|codec"
High CPU usage
Symptom: CPU usage above 80% with moderate load
Solution:
- Disable unnecessary codec transcoding
- Increase worker threads
- Enable hardware acceleration if available
Debug Mode
# Enable debug logging
./siprec --debug --log-level=trace
# Enable SIP message tracing
./siprec --sip-trace --sip-trace-file=/tmp/sip.pcap
# Performance profiling
./siprec --pprof --pprof-addr=:6060