GSMCalls

VoIP & SIP

SIPAlso known as Session Initiation Protocol

Definition

SIP (Session Initiation Protocol) is the IETF signalling protocol, defined in RFC 3261, that sets up, modifies and ends real-time sessions such as voice and video calls over IP. SIP negotiates who is calling whom and which codecs to use; the audio itself travels separately over RTP.

How SIP works

SIP is a text-based request/response protocol modelled on HTTP. A user agent sends a request, such as INVITE, and receives numbered responses. The body of an INVITE usually carries an SDP (Session Description Protocol, RFC 8866) offer listing the IP address, port and codecs for the media; the answer picks from it, following the offer/answer model of RFC 3264.

MethodPurpose
REGISTERTells a registrar where a user or trunk can currently be reached
INVITEStarts a call (or re-negotiates media with a re-INVITE)
ACKConfirms the final response to an INVITE
BYEEnds an established call
CANCELAbandons a call that has not been answered yet
OPTIONSQueries capabilities; widely used as a keep-alive / health check

Responses are grouped by class: 1xx provisional (100 Trying, 180 Ringing, 183 Session Progress), 2xx success (200 OK), 3xx redirection, 4xx client errors (401/407 authentication, 404 not found, 486 busy), 5xx server errors and 6xx global failures.

Transports and ports

SIP runs over UDP or TCP on port 5060 and over TLS on port 5061 (the sips: URI scheme). Browsers use SIP over WebSocket (RFC 7118) for WebRTC calling. Because SIP carries IP addresses inside its messages, it needs help crossing NAT; see NAT traversal and SBC.

SIP in GSM gateway deployments

A SIP trunk is simply a SIP connection between two systems. GSMCalls connects to PBXs, SBCs and softswitches as a standard SIP trunk over UDP, TCP or TLS, with registration or IP authentication, and uses OPTIONS checks to watch trunk health. See the FreePBX setup guide for a worked example.

Frequently asked questions

What port does SIP use?

UDP and TCP port 5060 by default, and TCP port 5061 for SIP over TLS. The audio uses separate RTP ports negotiated in SDP.

What is a SIP 183 Session Progress?

A provisional response that usually carries early media, such as ringback tones or network announcements, before the call is answered.

Is SIP secure?

Plain SIP over UDP is unencrypted. Use SIP over TLS for signalling and SRTP for media, plus strong passwords, IP allow-lists and an SBC or firewall to stop scanning and toll fraud.

What does a 401 or 407 SIP response mean?

The server is challenging the request for credentials using digest authentication. The client resends the request with an Authorization or Proxy-Authorization header.

Further reading

All glossary terms