An introductory presentation on SIP (Session Initiation Protocol) given by 2600hz CEO / Co-Founder Darren Schreiber during the weekly FreeSWITCH Conference Call. A more in-depth second part is also available.
Ini1a1on Protocol – Nego1ates a session, or a connec1on, between two par1es – Mostly consists of connec1on headers (things that wouldn’t prac1cally work or fit in binary TCP/UDP headers) – Can op1onally offer payloads with the connec1on headers (SDP) – RFC 3261 • Session Descrip1on Protocol – SDP is Separate from SIP – Offer / Answer Model – RFC 3264 Understanding SIP
To: <sip:[email protected]> Contact: <sip:[email protected]:1234> Call-‐ID: 490dffec2cafa2772a11eec8716e CSeq: 102 INVITE User-‐Agent: 2600hz Max-‐Forwards: 30 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE Content-‐Type: applica1on/sdp Content-‐Length: 180 v=0 s=session c=IN IP4 67.231.8.9 m=audio 35918 RTP/AVP 0 18 8 3 101 a=rtpmap:101 telephone-‐event/8000 Sample SIP Packet This is SIP (Describes Connection – i.e. how to get from point A to point B) This is SDP (Describes Content)
To: <sip:[email protected]> Contact: <sip:[email protected]:1234> Call-‐ID: 490dffec2cafa2772a11eec8716e CSeq: 102 INVITE User-‐Agent: 2600hz Max-‐Forwards: 30 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE Here we INVITE someone “[email protected]” to connect. NOTE: This isn’t network rou1ng informa1on Sample SIP Packet METHOD + ARGUMENTS Method is the action being requested Arguments are the details about the action
To: <sip:[email protected]> Contact: <sip:[email protected]:1234> Call-‐ID: 490dffec2cafa2772a11eec8716e CSeq: 102 INVITE User-‐Agent: 2600hz Max-‐Forwards: 30 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE Caller “Skanky Hoe” is calling 1-‐415-‐886-‐7900. We don’t know the recipient par1es Caller-‐ID so we don’t offer it. Sample SIP Packet TO & FROM Identification headers Can be used for BTN, ANI, Caller-ID
To: <sip:[email protected]> Contact: <sip:[email protected]:1234> Call-‐ID: 490dffec2cafa2772a11eec8716e CSeq: 102 INVITE User-‐Agent: 2600hz Max-‐Forwards: 30 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE Contact says “here’s the network port/IP to reach me at”. Can contain tags used by the switching system, like ;transport=TCP. Sample SIP Packet CONTACT Usually matches the From: but not always. Can contain tags.
To: <sip:[email protected]> Contact: <sip:[email protected]:1234> Call-‐ID: 490dffec2cafa2772a11eec8716e CSeq: 102 INVITE User-‐Agent: 2600hz Max-‐Forwards: 30 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE Sequence number is a sequen1al number that increases for each packet send and receive. Keeps things in order. Used for removing duplicate packets as well (IMPORTANT! Why do we have dupes?) Sample SIP Packet CSEQ Sequence number.
To: <sip:[email protected]> Contact: <sip:[email protected]:1234> Call-‐ID: 490dffec2cafa2772a11eec8716e CSeq: 102 INVITE User-‐Agent: 2600hz Max-‐Forwards: 30 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE Content-‐Type: applica1on/sdp Content-‐Length: 334 Feature list supported by the end device Sample SIP Packet SUPPORTED FEATURES List of what this phone allows for METHODs
To: <sip:[email protected]> Contact: <sip:[email protected]:1234> Call-‐ID: 490dffec2cafa2772a11eec8716e CSeq: 102 INVITE User-‐Agent: 2600hz Max-‐Forwards: 30 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE Content-‐Type: applica1on/sdp Content-‐Length: 334 Feature list supported by the end device Sample SIP Packet WHAT KIND OF AUDIO/VIDEO/ STREAM/ MESSAGE Content Type of the communication after it’s setup
t=0 0 s=session c=IN IP4 72.249.1.111 m=audio 22222 RTP/AVP 0 18 8 3 101 a=rtpmap:0 PCMU/8000 a=rtpmap:18 G729/8000 a=fmtp:18 annexb=no a=rtpmap:8 PCMA/8000 a=rtpmap:3 GSM/8000 a=rtpmap:101 telephone-‐event/8000 a=fmtp:101 0-‐16 a=silenceSupp:off -‐ -‐ -‐ -‐ a=p1me:20 a=sendrecv Sample SDP Packet MEDIA TYPE, PORT AND PREFERENCES Very important, often misunderstood. This is the PORT you want to RECEIVE audio on. Also includes a codec preference list.
Transac1ons make up a dialog -‐ No duplicates in the en1re dialog -‐ Retries can be discarded -‐ SIP Retries! Call-‐ID iden1fies conversa1on -‐ Includes REGISTER, INVITE, NOTIFY SIP Headers Analyzed
registra1on history if the IP or other info hasn’t changed and there’s been no denials/rejects -‐ Useful for debugging -‐ Call Forwarding Fun with To/From and Method URIs -‐ The device crea1ng the packet ALWAYS has full control over what port and IP to send media to SIP Headers Anaylzed