What is SIP?
SIP is the signalling protocol behind most internet phone calls. It finds the person you are calling, makes their phone ring, agrees which codec to use and hangs up at the end. Its messages are plain text and look a lot like HTTP: requests such as INVITE and BYE, and answers such as 180 Ringing and 200 OK.
SIP never carries the voice itself. It hands that job to RTP, using SDP inside its messages to say which address, port and codec each side will use. Office desk phones, many mobile networks for Wi-Fi and 4G calling, video doorbells and call centres all run on SIP.
Think of it like this. SIP is like a hotel switchboard operator. You ask for room 214, the operator finds it, rings it and tells you when someone picks up. Once you are talking, the operator steps away; the conversation itself (RTP) does not go through them.
Step by step
Normal call
7 stepsA phone registers with a password challenge, then calls another phone, talks and hangs up.
Normal call
7 stepsA phone registers with a password challenge, then calls another phone, talks and hangs up.
- 1
Register
Here I am, says the phone
When a SIP phone starts, it sends REGISTER to its server with the address where it can be reached. The server answers 401 with a challenge, because anyone could claim to be ravi.
- 2
Prove the password
Digest answer, then 200 OK
The phone hashes the password together with the server's nonce and sends the result. The password itself never crosses the network. The server checks the hash and stores the binding.
- 3
Invite
INVITE with an SDP offer
Dialing sends an INVITE to the server, which answers 100 Trying and forwards it to the phone where Daniel registered. The SDP inside lists Ravi's address, port and codecs.
- 4
Ringing
180 Ringing
Daniel's phone starts to ring and sends 180 Ringing back. Ravi's phone plays a ringback tone so he knows it is ringing.
- 5
Answer
200 OK and ACK
Daniel picks up and his phone sends 200 OK with its own SDP. Ravi's phone confirms with ACK. Both phones now know where to send voice.
- 6
Talk
RTP flows phone to phone
Voice travels in RTP packets, usually straight between the phones. SIP only sets up and ends the call; it never carries the voice itself.
- 7
Hang up
BYE and 200 OK
Either side can send BYE. The other side answers 200 OK and both stop sending media.
Busy
3 stepsDaniel is already on another call, so his phone answers 486 Busy Here.
Busy
3 stepsDaniel is already on another call, so his phone answers 486 Busy Here.
- 1
Invite
INVITE goes out as usual
Ravi's phone is already registered, so it goes straight to the INVITE. The server answers 100 Trying and forwards the call.
- 2
486 Busy Here
A final no
Daniel's phone is on another call and has no call waiting, so it answers 486 Busy Here. Codes in the 4xx range are final failures for this request.
- 3
ACK each hop
Failures are confirmed hop by hop
For a failure answer, each hop sends its own ACK to the hop before it. Only for a 200 OK does the ACK travel end to end from the caller.
Wrong password
3 stepsA phone set up with the wrong password cannot register, so it cannot make or take calls.
Wrong password
3 stepsA phone set up with the wrong password cannot register, so it cannot make or take calls.
- 1
Register
Challenge as usual
The first REGISTER always gets a 401 challenge. That is normal and not an error.
- 2
Bad answer
The hash does not match
The phone signs the nonce with the wrong password. The server computes a different hash from the password it stores.
- 3
403 Forbidden
Registration refused
The server refuses. Some servers answer 403 Forbidden, others send a fresh 401 challenge. Many servers also block an address after too many failures, because bots guess SIP passwords all day.
Two providers
4 stepsA call between two companies: two SIP proxies, a DNS lookup and stacked Via headers.
Two providers
4 stepsA call between two companies: two SIP proxies, a DNS lookup and stacked Via headers.
- 1
Invite to own server
Ravi calls kenji@example.net
Ravi's phone always sends requests to its own server, called the outbound proxy. It does not need to know where Kenji is.
- 2
Find the other server
DNS SRV lookup
Ravi's server asks DNS for _sip._udp.example.net. The SRV answer names sip.example.net on port 5060, the same idea as MX records for email.
- 3
Proxy to proxy
Each hop adds a Via
The INVITE goes to Kenji's server, which knows where Kenji registered and forwards it. By the time it reaches Kenji it carries three Via lines, one per hop.
- 4
Answer comes back
200 OK retraces the Vias
Each server removes its own Via and passes the answer to the next one down the list. The ACK and the voice can then take a shorter path.
Myths and mix-ups
- SIP does not carry your voice; it only sets up and ends the call while RTP carries the audio.
- A 401 on the first REGISTER is not an error; it is the normal password challenge.
- SIP is not only for phones; video calls, intercoms and door entry systems use it too.
- Port 5060 open to the internet is not harmless; bots constantly try to guess SIP passwords to make paid calls.
Try it yourself
Run these on your own computer to see SIP at work.
Find a domain's SIP server
dig +short SRV _sip._udp.example.comShows priority, weight, port and host if the domain publishes SIP SRV records. Many domains have none.
Watch SIP on your network
sudo tcpdump -n -A -i any udp port 5060Run it while a softphone registers or calls. -A prints the text, so you can read every header.
In a packet viewer
Filter: sip || rtp, then Telephony > VoIP CallsPacket capture tools can draw the ladder of a call and even play back unencrypted RTP audio.
SIP at a glance
- Layer
- Application (7)
- Default port
- 5060 (UDP or TCP), 5061 for SIP over TLS
- Transport
- UDP most often, also TCP, TLS and WebSocket
- Format
- Text, HTTP-like headers, SDP body
- Main methods
- REGISTER, INVITE, ACK, BYE, CANCEL, OPTIONS
- Carries voice?
- No, RTP does
- Standard
- RFC 3261 (2002)
Defined inRFC 3261RFC 8866 (SDP)RFC 3264 (offer and answer)RFC 3263 (locating SIP servers)
Header fields
What SIP puts in its messages, with example values from the stories above.
SIP
- Start line
REGISTER sip:example.com SIP/2.0- Contact
<sip:ravi@192.0.2.20:5060>Where calls for ravi@example.com should be sent.- Expires
3600The phone must register again within an hour, or the server forgets it.- CSeq
2 REGISTERThe number goes up by one for each new request in the same dialog.- WWW-Authenticate
Digest realm="example.com", nonce="ea9c8e88..."A digest challenge. The phone mixes the nonce with the password, so the password itself never travels.- Authorization
Digest username="ravi", response="6629fae49393a05397450978507c4ef1"The server does the same sum with its stored password. If the results match, the password was right.- Meaning
Provisional response1xx answers are progress notes, not the final result.- Via (top)
SIP/2.0/UDP 203.0.113.50:5060;branch=z9hG4bK4b43c2ff8.1Each proxy adds a Via line. Answers retrace these lines in reverse.- Via (second)
SIP/2.0/UDP 192.0.2.20:5060;branch=z9hG4bK74bf9- Max-Forwards
69Lowered by one at each proxy, so a call cannot loop forever.
SDP
- Connection
IN IP4 192.0.2.20The IP address where this phone wants to receive the voice.- Media
audio 49170 RTP/AVP 0 8 101Audio on port 49170, codecs 0 (PCMU), 8 (PCMA) and 101 (keypad tones).
Test yourself
Which SIP message makes the other phone ring?
Questions people ask
What port does SIP use?
5060 for SIP over UDP or TCP and 5061 for SIP over TLS. The voice itself goes over RTP on separate, usually high, UDP ports.
What is the difference between SIP and VoIP?
VoIP is the general idea of making calls over the internet. SIP is the most common protocol used to set those calls up, together with RTP for the audio.
What does SIP 486 Busy Here mean?
The phone you called was reached but cannot take the call, usually because the person is already on a call or pressed reject.
Why does my SIP phone keep showing 401 Unauthorized?
One 401 per registration is normal. If the phone never gets a 200 OK, the username, password or domain set on the phone is wrong.
Is SIP encrypted?
Not by default. SIP over TLS (port 5061) protects the signalling, and SRTP protects the voice. Both must be turned on for a private call.