SIP

The Session Initiation Protocol (SIP) is an application-layer control (signaling) protocol for creating, modifying, and terminating sessions with one or more participants. Defined in RFC 3261 — SIP: Session Initiation Protocol, SIP is used for Internet telephone calls, multimedia distribution, and multimedia conferences.

Transport and addressing

SIP typically uses:

  • Port 5060 — Unencrypted signaling over tcp or UDP
  • Port 5061 — Encrypted signaling over TLS

SIP is an ASCII-based protocol with a request/response model similar to http. SIP clients use URIs with an e-mail-like format:

  • sip:205@192.168.1.100
  • sip:username@pbx.com
  • sip:205@192.168.1.100:5060

SIP requests/methods

MethodPurpose
INVITEInvite an account to participate in a call session
ACKAcknowledge an INVITE request
CANCELCancel a pending request
REGISTERRegister a user with a SIP server
OPTIONSList information about the capabilities of a caller
BYETerminate a session between two users in a call
REFERIndicate that the recipient should contact a third party
SUBSCRIBERequest current state and state updates from a remote node
NOTIFYNotify a SIP node that an event requested by SUBSCRIBE has occurred

Example SIP INVITE request

INVITE sip:201@192.168.1.104 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.102;rport;branch=z9hG4bKvbxaoqar
Max-Forwards: 70
To: <sip:201@192.168.1.104>
From: "NightRanger" <sip:nightranger@192.168.1.102>;tag=eihgg
Call-ID: hfxsabthoymshub@backtrack
CSeq: 649 INVITE
Contact: <sip:nightranger@192.168.1.102>
Content-Type: application/sdp
Allow: INVITE,ACK,BYE,CANCEL,OPTIONS,PRACK,REFER,NOTIFY,SUBSCRIBE,INFO,MESSAGE
Supported: replaces,norefersub,100rel
User-Agent: Twinkle/1.2
Content-Length: 310

SIP responses

CodeClass
1xxInformational
2xxSuccessful — action received, understood, accepted
3xxRedirection
4xxRequest failure — bad syntax or cannot be fulfilled at server
5xxServer failure — valid request but server failed
6xxGlobal failure — cannot be fulfilled at any server

Example SIP call flow

  1. Calling phone sends INVITE.
  2. Called phone responds 100 (Trying).
  3. Called phone rings and responds 180 (Ringing).
  4. Caller picks up; called phone responds 200 (OK).
  5. Calling phone sends ACK.
  6. Conversation begins via RTP.
  7. Caller hangs up; BYE is sent.
  8. Other party responds 200 (OK).

Security considerations

SIP is a common target for VoIP attacks: enumeration of extensions, registration hijacking, call eavesdropping, and toll fraud. Unencrypted SIP on port 5060 exposes signaling in plaintext. Tools such as svmap, svwar, and svcrack (from the SIPVicious suite) are used to scan and attack SIP infrastructure.

Sources

Related: tcp, wireshark, ipsec