The Voice Protocol Stack
Înțelegerea protocoalelor VoIP este esențială pentru debugging, optimizare, și integrare voice AI la nivel tehnic.
Protocol Stack
Voice AI, IVR, Call Control
Session Initiation Protocol - Signaling
Real-time Transport Protocol - Media
Transport Layer
Network Layer
SIP (Session Initiation Protocol)
SIP INVITE Example
INVITE sip:+40722123456@carrier.com SIP/2.0 Via: SIP/2.0/UDP pbx.company.com:5060;branch=z9hG4bK776 Max-Forwards: 70 From: "Voice AI" <sip:+40211234567@pbx.company.com>;tag=1928301774 To: <sip:+40722123456@carrier.com> Call-ID: a84b4c76e66710@pbx.company.com CSeq: 314159 INVITE Contact: <sip:+40211234567@192.168.1.100:5060> Content-Type: application/sdp Content-Length: 142 v=0 o=VoiceAI 2890844526 2890844526 IN IP4 192.168.1.100 s=Voice AI Call c=IN IP4 192.168.1.100 t=0 0 m=audio 49170 RTP/AVP 0 8 96 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:96 opus/48000/2
Key SIP Methods
- INVITE - Start call
- ACK - Confirm
- BYE - End call
- CANCEL - Cancel pending
- OPTIONS - Capabilities
- REFER - Transfer
Key Response Codes
- 100 - Trying
- 180 - Ringing
- 200 - OK
- 404 - Not Found
- 486 - Busy
- 503 - Service Unavailable
SIP Call Flow
Caller Server Callee | | | |------- INVITE --------->| | |<------ 100 Trying ------| | | |------- INVITE --------->| | |<------ 100 Trying ------| | |<------ 180 Ringing -----| |<------ 180 Ringing -----| | | |<------ 200 OK ---------| |<------ 200 OK ----------| | |------- ACK ------------>|------- ACK ------------>| | | | |<=============== RTP Media Stream ================>| | | | |------- BYE ------------>|------- BYE ------------>| |<------ 200 OK ----------|<------ 200 OK ---------|
RTP (Real-time Transport Protocol)
RTP Packet Structure
Key Fields
- V - Version (always 2)
- PT - Payload Type (codec)
- Seq - Sequence for ordering
- TS - Timestamp for playback
- SSRC - Source identifier
SDP (Session Description Protocol)
v=0 // Protocol version o=VoiceAI 123 456 IN IP4 10.0.0.1 // Origin s=Voice AI Session // Session name c=IN IP4 10.0.0.1 // Connection info t=0 0 // Timing (0 = permanent) m=audio 49170 RTP/AVP 0 8 96 // Media description a=rtpmap:0 PCMU/8000 // Codec mapping a=rtpmap:8 PCMA/8000 a=rtpmap:96 opus/48000/2 a=fmtp:96 useinbandfec=1 // Codec parameters a=ptime:20 // Packet time 20ms a=sendrecv // Bidirectional
Common Issues & Debugging
One-Way Audio
Usually NAT issue. Check SDP "c=" line has public IP. Verify RTP ports are open în firewall.
Choppy Audio
Check packet loss în RTP stream. Increase jitter buffer. Verify network QoS settings.
Call Drops After 32 Seconds
ACK not received. Check firewall allows SIP responses. Verify symmetric RTP.
No Audio After Transfer
Re-INVITE may have wrong IP/port. Check UPDATE/re-INVITE handling.
Debugging Tools
sngrep
Terminal-based SIP flow viewer. See call ladders în real-time.
Wireshark
Full packet capture. RTP stream analysis, MOS calculation.
Homer
SIP capture server. Historical analysis, call correlation.