Real-Time Protocols

SIP Call Flow: Understanding Session Setup

How a SIP call is established and terminated: INVITE, provisional responses, 200 OK, ACK, BYE, and common error scenarios explained with diagrams.

SIP Architecture Overview

SIP (Session Initiation Protocol, RFC 3261) is a signaling protocol for establishing, modifying, and terminating multimedia sessions — primarily VoIP calls. SIP handles the *setup* of a call; the actual audio/video is carried separately over RTP (Real-time Transport Protocol).

Key SIP components:

  • User Agent Client (UAC): initiates requests (the caller)
  • User Agent Server (UAS): responds to requests (the callee)
  • SIP Proxy: routes requests between UAC and UAS
  • SIP Registrar: maps user@domain to a current IP/port
  • SIP URI: sip:[email protected] or sips:[email protected] (TLS)

INVITE Transaction

A call begins with an INVITE request from the caller. The INVITE body contains an SDP (Session Description Protocol) offer describing the caller's audio capabilities:

INVITE sip:[email protected] SIP/2.0
Via: SIP/2.0/UDP alice-pc.example.com:5060;branch=z9hG4bK776asdhds
From: Alice <sip:[email protected]>;tag=1928301774
To: Bob <sip:[email protected]>
Call-ID: [email protected]
CSeq: 314159 INVITE
Content-Type: application/sdp

v=0
o=alice 2890844526 2890844526 IN IP4 alice-pc.example.com
m=audio 49170 RTP/AVP 0
a=rtpmap:0 PCMU/8000

Provisional Responses

Before the callee answers, the SIP proxy and UAS send provisional responses (1xx):

SIP/2.0 100 Trying

100 Trying — sent by the proxy to stop the UAC from retransmitting the INVITE. Does not indicate Bob's phone is ringing yet.

SIP/2.0 180 Ringing

180 Ringing — Bob's phone is alerting. The caller hears a ringback tone.

SIP/2.0 183 Session Progress

183 Session Progress — used with early media (e.g., playing an announcement before the call is answered).

200 OK and ACK

When Bob answers, his UA sends 200 OK with an SDP *answer* (his audio capabilities):

SIP/2.0 200 OK
From: Alice <sip:[email protected]>;tag=1928301774
To: Bob <sip:[email protected]>;tag=a6c85cf
Content-Type: application/sdp

m=audio 3456 RTP/AVP 0
a=rtpmap:0 PCMU/8000

Alice's UA sends an ACK to confirm receipt of the 200 OK. The ACK completes the three-way handshake:

ACK sip:[email protected] SIP/2.0

After the ACK, RTP audio begins flowing directly between Alice and Bob (peer-to-peer, bypassing the SIP proxy).

BYE and Call Termination

Either party can end the call by sending BYE:

BYE sip:[email protected] SIP/2.0
From: Bob <sip:[email protected]>;tag=a6c85cf
To: Alice <sip:[email protected]>;tag=1928301774
Call-ID: [email protected]

The other side responds with 200 OK, and both UAs release the RTP session.

SIP Registration Flow

Before receiving calls, a UA registers its current location with a Registrar so the proxy knows where to route INVITEs:

REGISTER sip:example.com SIP/2.0
From: Alice <sip:[email protected]>
To: Alice <sip:[email protected]>
Contact: <sip:[email protected]:5060>
Expires: 3600

The registrar responds with 200 OK listing active bindings. Re-registration must occur before the Expires interval ends.

SIP Error Scenarios

CodeMeaningCommon Cause
`486 Busy Here`Callee is busyAnother call in progress
`487 Request Terminated`INVITE was cancelledCaller hung up before answer
`404 Not Found`User not foundNot registered
`408 Request Timeout`No responseNetwork issue
`503 Service Unavailable`Proxy unavailableOverload or downtime

487 Request Terminated is not an error — it is the normal flow when a caller hangs up before the callee answers. Seeing large numbers of 487s in logs is normal for interactive calling applications.

Giao thức liên quan

Thuật ngữ liên quan

Thêm trong Real-Time Protocols