Description
What is SIP?
The Session Initiation Protocol (SIP) is the IETF standard, defined in RFC 3261 in 2002, that sets up, modifies and tears down real-time sessions — above all VoIP calls. It is a text protocol that reads like HTTP: a caller sends a request such as INVITE sip:+12025550123@trunk.example.net SIP/2.0, the other side answers with numbered responses — 100 Trying, 180 Ringing, 200 OK — and the caller confirms with ACK; either side ends the call with BYE. Headers such as Via, From, To, Call-ID and CSeq identify the call and route each message, by default on port 5060 (UDP or TCP) or 5061 for TLS.
SIP carries no audio. The voice travels separately as RTP packets (SRTP when encrypted), and the two ends agree codecs, IP addresses and ports through an SDP offer inside the INVITE and an answer inside the 200 OK. That split explains SIP's most famous failure: a call that rings and connects perfectly but has one-way or no audio, because signalling got through while a firewall or NAT blocked the media.
A SIP trunk is where businesses meet the protocol: a SIP connection between a company's PBX, contact centre or CPaaS platform and a carrier, replacing physical phone lines and letting calls reach the Public Switched Telephone Network (PSTN). In browsers and apps the counterpart is WebRTC, which uses the same RTP media ideas with its own signalling. The WhatsApp Business Calling API can hand calls to a business's own SIP infrastructure too, so contact centres often end up speaking SIP even when the customer called from WhatsApp; the WhatsApp Calling over SIP page covers that integration.
Key takeaways
- SIP (RFC 3261) is the text protocol that sets up, changes and ends VoIP calls with requests such as INVITE, ACK and BYE.
- SIP only signals: audio travels separately on RTP, with codecs and addresses agreed through an SDP offer and answer.
- A call is answered with 200 OK and confirmed with ACK; either side ends it with BYE.
- A SIP trunk connects a PBX, contact centre or CPaaS platform to a carrier and, through it, to the PSTN.
- Rings-but-no-audio is almost always blocked RTP or a private IP in the SDP, not a SIP signalling fault.
Mechanics
How does SIP work?
step 1 — Register or authenticate
Phones and softphones send
REGISTERso a registrar knows where to reach them. Trunks usually authenticate by IP allow-list or by digest challenges, answering the first INVITE with401or407and expecting it again with credentials.step 2 — INVITE with an SDP offer
The caller sends INVITE with an SDP body listing its codecs (for example G.711 A-law and telephone-event for keypad tones) and the IP and port where it wants audio. Each hop answers
100 Tryingto stop retransmissions.step 3 — Ringing, answer and ACK
The callee side returns
180 Ringing(or183 Session Progresswith early media), then200 OKcarrying the SDP answer. The caller sendsACK, completing the three-way handshake — billing usually starts at the 200 OK.step 4 — Media on RTP, changes in-dialog
Audio flows as RTP between the agreed addresses, often through a session border controller. Hold, codec changes and transfers use re-INVITE,
UPDATEorREFERinside the same dialog.step 5 — End the call
Either side sends
BYE, answered by200 OK. An INVITE that has not been answered yet is cancelled withCANCEL, and the original INVITE then ends with487 Request Terminated.
Usage
SIP in code
INVITE sip:+12025550123@trunk.example.net SIP/2.0Via: SIP/2.0/TLS 203.0.113.10:5061;branch=z9hG4bK776asdhdsMax-Forwards: 70From: "Support" <sip:+918000000000@pbx.example.com>;tag=1928301774To: <sip:+12025550123@trunk.example.net>Call-ID: a84b4c76e66710@pbx.example.comCSeq: 314159 INVITEContact: <sip:support@203.0.113.10:5061;transport=tls>Content-Type: application/sdpContent-Length: 173v=0o=- 2890844526 2890844526 IN IP4 203.0.113.10s=-c=IN IP4 203.0.113.10t=0 0m=audio 49170 RTP/AVP 8 101a=rtpmap:8 PCMA/8000a=rtpmap:101 telephone-event/8000
The c= and m= lines say where to send audio. If they carry a private address such as 192.168.x.x, the far end's audio never arrives.
Properties
SIP: key facts and limits
- Standard
- RFC 3261 (June 2002)
- Default ports
- 5060 UDP/TCP, 5061 TLS
- Core methods
- INVITE, ACK, BYE, CANCEL, REGISTER, OPTIONS
- Response classes
- 1xx provisional, 2xx success, 3xx redirect, 4xx client, 5xx server, 6xx global
- Media
- RTP or SRTP, negotiated with SDP offer/answer
- Common codecs
- G.711 (PCMA/PCMU), G.729, Opus
Caveats
Common mistakes with SIP
Calls ring but have no audio
The SDP advertises a private IP, or a firewall blocks the RTP port range. Put a session border controller at the edge, open the RTP range explicitly and enable symmetric RTP, then check the c= line in a trace.
Duplicate calls over UDP
Over UDP an INVITE is retransmitted until a provisional response arrives. Answer
100 Tryingfast, match retransmissions by Call-ID and branch, or move signalling to TCP or TLS.Caller ID the trunk will not accept
Many trunks reject calls with
403when the From or P-Asserted-Identity number is not one you are allowed to present. Agree the presentable numbers with the carrier; in India, rules on mixing internet calls with the public network are strict, so check with a licensed operator.No codec in common
If the offer lists only wideband codecs and the trunk supports G.711, the call fails with
488. Always include G.711 in the offer for PSTN-bound calls.An unprotected SIP port on the internet
Scanners hit port 5060 constantly, and a weak password means toll fraud by morning. Restrict by IP, use strong digest credentials, rate-limit registrations and prefer TLS.
Why it matters
Why does SIP matter?
Almost every business voice system — IVR menus, contact-centre diallers, cloud telephony desks, voice OTP providers and WhatsApp calling integrations — is glued together with SIP. When a call fails, the SIP response is the diagnosis: 404 Not Found for a number the trunk cannot route, 403 Forbidden when the trunk rejects your caller ID, 486 Busy Here, 487 Request Terminated after a CANCEL, 488 Not Acceptable Here for a codec mismatch, 503 Service Unavailable from an overloaded carrier. Developers who can read a SIP trace fix in minutes what otherwise becomes days of tickets with a carrier.
Example
Example: A Gurugram contact centre moves to a SIP trunk
A Gurugram contact centre replaces its physical lines with a SIP trunk to its carrier. On day one, outbound calls ring and connect, but agents hear nothing. A packet capture shows the 200 OK arriving correctly and the PBX's SDP advertising its private 10.x address, so the carrier sends audio nowhere. The team puts a session border controller at the edge to rewrite the SDP, opens the RTP port range to the carrier only, and moves signalling to TLS on 5061. A week later, a burst of 403 Forbidden responses turns out to be a campaign presenting a caller ID the carrier had not authorised; the fix is a number change, not a code change.
Notes
Best practices for SIP
- Capture a SIP trace (a packet capture or a tool such as sngrep) before guessing at the cause of a failed call.
- Use TLS for signalling and SRTP for media on any trunk that crosses the public internet.
- Send periodic OPTIONS requests to detect a dead trunk before customers do.
- Log the final SIP response code and reason phrase for every call attempt.
Questions
SIP FAQs
- What is the difference between SIP and VoIP?
- VoIP is the idea of carrying voice over IP networks; SIP is the signalling protocol most VoIP systems use to set calls up and end them. The voice itself travels in RTP packets, not in SIP.
- What is a SIP trunk?
- A SIP trunk is a SIP connection between a business phone system and a carrier that replaces physical phone lines. It carries many simultaneous calls and lets the system call, and be called from, ordinary phone numbers on the PSTN.
- Should I use SIP or WebRTC?
- Use WebRTC to put calling inside a browser or app, and SIP to connect phone systems, contact centres and carriers. Many products use both, with a gateway translating WebRTC calls into SIP for the carrier side.
- Does the WhatsApp Business Calling API support SIP?
- Yes. Meta's Calling API can deliver WhatsApp calls to a business's own SIP infrastructure, so a contact centre can answer them alongside phone calls instead of handling WebRTC media itself.