Share
Embed
SIP 101 Presentation
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.
2600hz
June 20, 2012
Transcript
30 slides
-
SIP is a Signaling Protocol for Sessions • Session
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 -
INVITE sip:[email protected]:5060 SIP/2.0 From: ”SKANKY HOE" <sip:[email protected]>
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) -
INVITE sip:[email protected]:5060 SIP/2.0 From: ”SKANKY HOE" <sip:[email protected]>
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 -
INVITE sip:[email protected]:5060 SIP/2.0 From: ”SKANKY HOE" <sip:[email protected]>
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 -
INVITE sip:[email protected]:5060 SIP/2.0 From: ”SKANKY HOE" <sip:[email protected]>
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. -
INVITE sip:[email protected]:5060 SIP/2.0 From: ”SKANKY HOE" <sip:[email protected]>
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 Call-‐ID iden1fies this unique connec1on / conversa1on. Should never change during a call or registra1on. Sample SIP Packet CALL-ID Identifies this conversation / connection -
INVITE sip:[email protected]:5060 SIP/2.0 From: ”SKANKY HOE" <sip:[email protected]>
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. -
INVITE sip:[email protected]:5060 SIP/2.0 From: ”SKANKY HOE" <sip:[email protected]>
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 User-‐Agent iden1fies what type of phone or switch generated this packet. Sample SIP Packet USER-AGENT Friendly identifier. -
INVITE sip:[email protected]:5060 SIP/2.0 From: ”SKANKY HOE" <sip:[email protected]>
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 Count-‐down to death in a loop! Sample SIP Packet MAX FORWARDS Loop detection -
INVITE sip:[email protected]:5060 SIP/2.0 From: ”SKANKY HOE" <sip:[email protected]>
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 -
INVITE sip:[email protected]:5060 SIP/2.0 From: ”SKANKY HOE" <sip:[email protected]>
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 -
v=0 o=root 7626 7626 IN IP4 72.249.1.111
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 DESCRIPTION TAG Can be anything. Often contains a copy of the SDP IP -
v=0 o=root 7626 7626 IN IP4 72.249.1.111
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 TIME TAG Usually 0 0 because this is actually part of SIP, not SDP -
v=0 o=root 7626 7626 IN IP4 72.249.1.111
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 TYPE OF SESSION Can be unicast or multicast. Unicast can be indicated by a space or – sign. -
v=0 o=root 7626 7626 IN IP4 72.249.1.111
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 IP ADDRESS FOR RTP RECEIPT Very important, often misunderstood. This is the IP you want to RECEIVE audio on. -
v=0 o=root 7626 7626 IN IP4 72.249.1.111
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. -
v=0 o=root 7626 7626 IN IP4 72.249.1.111
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 NOTE THE PREFERENCE LIST! Matches the codecs defined below in the attribute section. Common codecs aren’t listed. -
v=0 o=root 7626 7626 IN IP4 72.249.1.111
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 CODEC DESCRIPTIONS AND ATTRIBUTES Default codecs not actually required -
v=0 o=root 7626 7626 IN IP4 72.249.1.111
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 RTP ATTRIBUTES More general attributes -
Yup, I heard ya! SIP/2.0 100 Trying
From: ”SKANKY HOE" <sip:[email protected]> To: <sip:[email protected]> Call-‐ID: 490dffec2cafa2772a11eec8716e CSeq: 102 INVITE User-‐Agent: 2600hz Max-‐Forwards: 30 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE Sample Response -‐ Transi1onal -
Yup, I heard ya! SIP/2.0 100 Trying
From: ”SKANKY HOE" <sip:[email protected]> To: <sip:[email protected]> Call-‐ID: 490dffec2cafa2772a11eec8716e CSeq: 102 INVITE User-‐Agent: 2600hz Max-‐Forwards: 30 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE Sample Response -‐ Transi1onal -
I’m Ringing The Handset SIP/2.0 180 Ringing
From: ”SKANKY HOE" <sip:[email protected]> To: <sip:[email protected]> Call-‐ID: 490dffec2cafa2772a11eec8716e CSeq: 102 INVITE User-‐Agent: 2600hz Max-‐Forwards: 30 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE Sample Response -‐ Transi1onal -
They Answered! SIP/2.0 200 OK From: ”SKANKY
HOE" <sip:[email protected]> To: <sip:[email protected]> Call-‐ID: 490dffec2cafa2772a11eec8716e [ … ] o=FreeSWITCH 1340177972 1340177973 IN IP4 108.166.87.71 s=FreeSWITCH c=IN IP4 108.166.87.71 t=0 0 m=audio 24036 RTP/AVP 0 101 a=rtpmap:0 PCMU/8000 a=rtpmap:101 telephone-‐event/8000 a=fmtp:101 0-‐16 a=silenceSupp:off -‐ -‐ -‐ -‐ a=p1me:20 Sample Response -‐ Transi1onal -
They Answered! SIP/2.0 200 OK From: ”SKANKY
HOE" <sip:[email protected]> To: <sip:[email protected]> Call-‐ID: 490dffec2cafa2772a11eec8716e [ … ] o=FreeSWITCH 1340177972 1340177973 IN IP4 108.166.87.71 s=FreeSWITCH c=IN IP4 108.166.87.71 t=0 0 m=audio 24036 RTP/AVP 0 101 a=rtpmap:0 PCMU/8000 a=rtpmap:101 telephone-‐event/8000 a=fmtp:101 0-‐16 a=silenceSupp:off -‐ -‐ -‐ -‐ a=p1me:20 Sample Response -‐ Connect -
Sequence Number -‐ Unique for each transac1on -‐
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 -
General Thoughts -‐ Call-‐IDs oren represent a device’s en1re
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 -
Retries -‐ Same Call-‐ID & Sequence number from the
sending device Timeouts -‐ Cancels from FreeSWITCH (note the defaults in FS) -‐ Who cancelled first? Stop blaming FreeSWITCH J -‐ RECOVERY_ON_TIMER_EXPIRE!!! -‐ PROGRESS_TIMEOUT in some cases Errors! -‐ Wrong Contact: string or missing proxy/transport tags -‐ OK, blame FreeSWITCH SIP Headers Debugging -
Can Cover If People Want -‐ T.38 Setup (not
actual protocol) -‐ BLF No1fies (two forms) ß my knowledge is s1ll light here but growing -‐ REGISTER / AUTH -‐ Video Codecs -‐ Codec Preferences -‐ Security / TLS/SSL / ZRTP -‐ [email protected] -‐ SEND ME TOPICS FOR TRAINING! SIP Headers Debugging