1 / 65

SIP for geeks!

SIP for geeks!. Kundan Singh Nov 2010 http://kundansingh.com kundan10@gmail.com. SIP for geeks!. SIP [acronym] – Session Initiation Protocol

emysliwiec
Download Presentation

SIP for geeks!

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SIP for geeks! Kundan Singh Nov 2010 http://kundansingh.com kundan10@gmail.com

  2. SIP for geeks! SIP [acronym] – Session Initiation Protocol “a very simple text-based application-layer control protocol to create, modify and terminate sessions such as Internet telephony and multimedia conferences with one or more participants.” • geek [slang] – noun • “a computer expert or enthusiast (a term of pride as self-reference, but often considered offensive when used by outsiders.)”

  3. Who am I? PhD from Columbia University in 2006 on reliable, scalable & interoperable Internet telephony Student of Prof. Henning Schulzrinne who is co-inventor of SIP, RTP, RTSP Worked at Adobe with Dr. Henry Sinnreich who is considered God Father of SIP Worked on SIP since 1999, building prototypes, systems. Worked at Tokbox and 6Connex on web-based video communication Worked on open source projects p2p-sip, videocity, flash-videoio, restlite, rtmplite, siprtmp VoIP researcher Software architect Systems engineer

  4. What will you learn? Voice Sampling Encoding Transport Motivation Dive-in Syntax Semantics Call flow Extensions Scripting Hands-on Iptel.org Jain-sipapi 39peers siprtmp Challenges On Web NAT traversal Security Audio quality Walled garden History Competition IETF, RFC Ecosystem References 15 min 45 min 30 min 15 min 15 min = total 2hr What is the big picture? How does everything fit together? Where to look for more information?

  5. Audio packet transfer • Digitization(e.g., sampling at 8kHz, 16 bits per sample, i.e, 128 kb/s or 320 bytes per 20 ms) • Real-time compression/encoding (e.g., G.729A at 8 kb/s) • Transportto remote IP address and port number over UDP (Why not TCP?) • Processing on receiver side is the reverse

  6. +127 +0 -127 Sampling, Quantization, Encoding 10101111…01101101 Encode each quantized sample into 8 bit code word PCM: 8000 x 8 bits = 64 kb/s Other techniques (differential coding, linear prediction) 2.4 kb/s to 64 kb/s What is narrowband/wideband? What are frame vs sample-based codecs? Sample at twice the highest voice frequency 2 x 4000=8000 Hz (interval of 125 µsec) Round off samples to one of 256 levels (introduces noise)

  7. Voice codecs

  8. timeline Sender 1 2 3 4 5 6 7 (a) (b) 1 2 3 5 7 6 Receiver Problems with UDP • Unreliable UDP • Packet loss • Out-of-order (very rarely) • Jitter (delay variation)

  9. read 20 ms packet sendto(remote IP:port) microphone write get 20 ms packet speaker put Received packet recvfrom() Playout buffer while (true) { buf = read(au,20ms); //blocks if (!silence) sendto(remote, buf); … buf = get(20 ms); write(au, buf); } playout buffer while (true) { buf = recvfrom(...); // blocks put(buf); }

  10. 8 9 0 1 2 3 4 1 2 3 4 5 6 7 8 9 0 2 3 4 1 2 3 5 7 6 0 2 1 0 9 3 2 2 3 2 1 1 2 1 3 5 7 5 7 6 8 7 9 8 2 Playout buffer • What is the its purpose? • What should be the buffer size? • How to do adaptive delay adjustment? • Why do you need sequence number? Sender Receiver http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.54.9716

  11. Timestamp vs sequence number Playout time vs packet loss detection • Silence suppression • Variable length packets Sender t1 t2 t3 t4 t5 t6 t7 t8 t9 Silence … 5 6 7 1 2 3 4 5 6 7 1 2 3 4 Receiver

  12. 8 bits 8 bits 16 bits Real-time Transport Protocol (RTP) IP header V CC M Payload type Sequence number P X UDP header Timestamp (proportional to sampling time) RTP Header Source identifier (SSrc) Encoded Audio Optional contributors’ list (CSrc) msg RTP: media transport RTCP: QoS feedback sendto(…, msg, …) recvfrom(…, msg, …)

  13. RTP-based conference ssrc=5263 ssrc=7182 224.1.2.3:8000 Session identified using receive IP address + port ssrc=2639 ssrc=9844

  14. RTP-based conference Mixer mixes multiple streams, and puts rtp.ssrcsof contributors in the mixed packet as rtp.csrc Transcoder converts one encoding to another. Typically to accommodate heterogeneous bandwidth links. -law Mixer Transcoder  -law  G.729 G.729 -law -law

  15. RTP FAQ • Who uses RTP? • Is RTP a transport or application protocol? • Is RTP secure? What are SRTP, ZRTP? • Is RTP header a big overhead? • Is RTCP needed for two-party voice calls? http://www.cs.columbia.edu/~hgs/rtp/

  16. INVITE for a call using µ-law and G.729 at 202.16.49.27:8000 OK using µ-law at 128.59.19.194 Bob=>192.1.2.3 Alice=>128.59.19.194 Where is Alice? 128.59.19.194 Sam 154.28.32.112 Henry=>125.33.2.81 Why do you need signaling? Bob 202.16.49.27 Alice 128.59.19.194 • Locate destination user • Negotiate session parameters Sam 154.28.32.112 Henry 125.33.2.81

  17. What will you learn? Voice Sampling Encoding Transport Motivation Dive-in Syntax Semantics Call flow Extensions Scripting Hands-on iptel.org jain-sipapi 39peers siprtmp Challenges On Web NAT traversal Security Audio quality Walled garden History Competition IETF, RFC Ecosystem References

  18. HTTP GET, POST, HEAD, PUT, DELETE SIP REGISTER, INVITE, BYE, CANCEL, ACK, OPTIONS, … Text-based protocol Request-response Headers and body SMTP HELO, MAIL, RCPT, DATA, QUIT RTSP SETUP, TEARDOWN, PLAY, RECORD, DESCRIBE, …

  19. yahoo.com alice24@yahoo.com tel:12125551234 alice@columbia.edu 1234@columbia.edu tel:19172223333 Alice.Smith@columbia.edu columbia.edu pc12.columbia.edu Addressing Examples: “Alice Smith” <sip:alice@columbia.edu> sip:alice@128.59.19.194:5070 sip:alice@columbia.edu;user=phone;transport=tcp What is address-of-record (AoR)? What is sips URI? What is tel URI? – RFC 3966

  20. Lookup Two stage lookup similar to email: DNS: to locate server for a domain Database: locate user within a domain office.com Bob home.com Alice 128.59.19.194 columbia.edu yahoo.com Jane 128.59.19.61 $ dig –t naptr columbia.edu columbia.edu. 3600 IN NAPTR 1 0 "s" "SIP+D2U" "" _sip._udp.columbia.edu. columbia.edu. 3600 IN NAPTR 2 0 "s" "SIP+D2T" "" _sip._tcp.columbia.edu. $ dig –t srv _sip._udp.columbia.edu _sip._udp.columbia.edu. 3600 IN SRV 1010 5060 cocoa.cc.columbia.edu. _sip._udp.columbia.edu. 3600 IN SRV 1010 5060 eclair.cc.columbia.edu. $ dig –t a cocoa.cc.columbia.edu cocoa.cc.columbia.edu. 3600 IN A 128.59.59.199 How to do failover and load sharing?

  21. INVITE sip:alice@home.com SIP/2.0 Via: SIP/2.0/UDP 202.16.49.27:5060;branch=z9hG4bK74bf9 Max-Forwards: 70 From: “Bob” <bob@office.com>;tag=9fxced76s1 To: “Alice” <alice@home.com> Call-ID: 384827@202.16.49.27 CSeq: 1 INVITE Contact: <sip:bob@202.16.49.27> Subject: How are you? Content-Type: application/sdp Content-Length: 151 ... Request Response SIP/2.0 200 OK Via: SIP/2.0/UDP 202.16.49.27:5060;branch=z9hG4bK74bf9 From: “Bob” <bob@office.com>;tag=9fxced76s1 To: “Alice” <alice@home.com>;tag=8321234356 Call-ID: 384827@202.16.49.27 CSeq: 1 INVITE Contact: <sip:alice@128.59.19.194> Content-Type: application/sdp Content-Length: 147 ... What are WS and CRLF?

  22. Requests

  23. Responses

  24. Header examples

  25. SIP trapezoid INVITE INVITE INVITE 100 Trying 100 Trying 180 Ringing 180 Ringing 180 Ringing 200 OK 200 OK 200 OK ACK BYE 200 OK Example call flow Proxy Proxy UA UA office.com home.com alice@home.com bob@office.com RTP media session What is an outbound proxy?

  26. UDP Most common Low state overhead But small max packet size TCP: Use with SSL Large message bodies NAT/firewall traversal Connection setup overhead Head of line blocking for trunks (use SCTP instead) Transport reliability Request retransmissions Exponential back-off INVITE vs non-INVITE Transport Why is ACK needed for INVITE response?

  27. Response follows the reverse request path Via header in SIP message records the request path Request routing decision at each hop Usually direct end-to-end transport after initial request Forcing request path: Record-route and Route headers. Request forking: parallel vs sequential (use q-value in Contact) Caller and callee info: further govern request routing Via: c.yahoo.com Via: b.example.com Via: a.home.com Via: b.example.com Via: a.home.com Via: a.home.com Via: c.yahoo.com Via: b.example.com Via: a.home.com Via: a.home.com Via: b.example.com Via: a.home.com alice@home.com bob@example.com bob@yahoo.com bob@ip2.yahoo.com 302 moved INVITE 486 busy 200 OK Message routing q=1.0 q=0.7 q=0.2

  28. (13) Example call setup (9) ok Alice (8) @residence.net (10) @visiting.com (6) unavailable (7) (6) (5) (3) invite (4) moved @school.edu (12) ok (6) Bob (2) moved (11) cancel @home.com (1) invite @lab.school.edu @yahoo.com

  29. SIP user agent IP phone, PC, conference bridge,… SIP redirect server returns new location for requests SIP stateless proxy routes call requests SIP (forking) stateful proxy routes call requests SIP registrar accepts name to address mapping Location server maintains name to address mapping Maintaining state stateless: each request and each response handled independently Fast load balancing proxies; robust (transaction) stateful: remember a whole request/response transaction Enterprise servers, . . . call stateful: remember a call from beginning to end Billing, NAT traversal, . . . Elements Other entities: outbound proxy, back-to-back user agent (b2bua), application-level-gateway (ALG), … Typically implemented in a single software or box

  30. SIP FAQ • What is a SIP transaction? • What is a SIP dialog? • What is early media? • What is re-INVITE? • Why do you need record-route? • What is request forking? http://www.cs.columbia.edu/sip/

  31. RTP To port 8000 RTP To port 6780 Session negotiation INVITE alice@home.com I can support -lawand G.729 Send me audio at 202.16.49.27:6780 Bob Alice 128.59.19.194 202.16.49.27 OK; I can support -law Send me audio at 128.59.19.194:8000 ACK How to modify media session?

  32. Session Description Protocol (SDP) INVITE sip:alice@home.com SIP/2.0 ... Content-Type: application/sdp Content-Length: 151 v=0 o=bob 26172 27162 IN IP4 202.16.49.27 s=- c=IN IP4 202.16.49.27 t=0 0 m=audio6780 RTP/AVP 0 8 5 97 98 a=rtpmap:97 iLBC/8000 a=rtpmap:98 telephone-event/8000 m=video 6790 RTP/AVP 31 What is offer/answer? What is telephone-event?

  33. SIP is…, SIP is not … • Core protocol for establishing sessions • Allows transport of session description • Allows change of parameters in mid-session • Terminate session • NOT for distribution of multimedia data • NOT suitable for media gateway control • . . . • SIP applications typically fall in following categories: • setting up VoIP calls • setting up multimedia conferences • event notification => IM and presence • text and general messaging • signaling transport

  34. What is the real value in SIP? • Open system • Advanced services

  35. Telephony Call routing speed dial, call forwarding, “follow me”, filtering/blocking (in/out), do-not-disturb, distinctive ringing,… Call handling auto-answer, auto-attendant, voice-mail, … Multi-party call waiting, call transfer (blind/consultative), conference call, park, pickup, music-on-hold, monitoring, … Internet Presence enabled place call only if callee is available, invite participants when all are online and not busy, … Unified messaging receive email, IM alert for new voice mail, or when someone joins your conference, … Web enabled click-to-call, web conference, view conference status and voice-mails on web, … what phone has is not enough! Programmable services

  36. Programming services If somebody is calling the third-time, allow mobile. Try office and home in parallel, if that fails, try home. Allow call to mobile if I’ve talked to person before. If on tele-marketing list, forward to dial-a-joke. Try office during day, and mobile in evening. …

  37. Where do the services reside? Double ringing sound when boss calls… Enter your authentication PIN for billing… Use finger for locating user… B2BUA Endpoint Make call when boss is online … Proxy/registrar Forward to office phone during day, and home phone during evening… Endpoint Service control in endpoint vs network?

  38. Endpoint call control • Language for End System Services (LESS) • Direct user interaction, direct media control • Handle converged information, e.g., call, presence, email • Example: call a friend when he comes online • <less name="online_call" require="generic presence ui"> • <notification status="online" priority="0.5"> • <address-switch field="origin"> • <address is=“alice@home.com"> • <call /> • <alert sound=“ring.au" text="Calling …" /> • </address> • </address-switch> • </notification> • </less>

  39. Network call control SIP-CGI RFC 3050, CPL, servlets Priority.pl SIP_FROM SIP_TO stdin CGI-PROXY-REQUEST stdout if (defined $ENV{SIP_FROM} && $ENV{SIP_FROM} =~ /sip:boss@mycompany.com/) { foreach $reg (get_regs()) { print "CGI-PROXY-REQUEST $reg SIP/2.0\n"; print "Priority: urgent\n\n"; } } Urgent SIP proxy Phone Low-priority Voicemail

  40. Call transfer Blind/consultation/attended B A C active call REFER C Referred-By: B INVITE C Referred-By: B BYE A active call

  41. SIP SIP B2BUA and 3pcc B Back-to-back UA • Incoming call triggers outgoing call Services • Calling card • Anonymizer A C INVITE OK (SDP1) ACK INVITE (SDP1) OK (SDP2) ACK INVITE (SDP2) OK ACK

  42. Endpoint based Redirect after 10s alice@vmail.yahoo.com Proxy controls Voicemail acts like a phone vmail.pl SIP_FROM SIP_TO stdin CGI-PROXY-REQUEST stdout If no response accept after 15s Voicemail

  43. Internet Internet user VXML Voice gateway HTML • Voice and telephony functions • VoiceXML browser Web server Service logic (CGI, servlet, JSP) VoiceXML Gateway VXML Browser PSTN Telephone IVR platform • Voice and telephony functions • (ASR, TTS, DTMF) • Service logic (application specific)

  44. VoiceXML contd. <form> <field name=‘id’> <prompt> Your ID, please. </prompt> </field> <block> <submit next=“url”/> </block> </form> <form action=“url”> Enter your Id: <input name=‘id’> <input type=‘submit’> </form> Telephony, speech synthesis or audio output, user input and grammar, program flow, variable and properties, error handling, …

  45. Interworking with telephone sip:bob@home.com +1-415-123-4567 • Translating audio (µ-law/A-law) • Translating signaling (PRI/T1,ISUP) • Overlap signaling • Advanced features in SIP are lost in PSTN • Translating identifiers (phone number) • Determining transition points Telephone network Telephone subscriber SIP/PSTN gateway SIP server IP endpoint Telephone to IP Gateway knows the SIP server • <sip:4567@gateway2.example.com;user=phone> ENUM – E164 numbering (using DNS) • +1 212 9397042 => 2.4.0.7.9.3.9.2.1.2.1.e164.arpa => sip:hgs@cs.columbia.edu • Suitable for relatively “static” contacts IP to telephone Static mapping • 1-212854xxxx=>@gw1.columbia.edu Gateway information is dynamic: • Overlapping networks, multiple providers, Load balancing Telephony routing over IP (TRIP) • Route advertisement, can be implemented in outbound proxy, suitable for current hierarchical network +1 @service.mci.com at 4¢/min +1212 @nyc.gw.com at 1¢/min +1212939 @itgw1.columbia.edu free

  46. Summary of services • Call forwarding: basic INVITE behavior • Call transfer: REFER method • Call hold: set media to 0.0.0.0 • Caller id: From, plus extensions • DTMF carriage: carry as RTP (RFC 2833) • Calling card: B2BUA + voice server • Voicemail: UA, proxy, media server • Programming: CGI, CPL, servlet, LESS, CCXML, VoiceXML, SECE, …

  47. What will you learn? Voice Sampling Encoding Transport Motivation Dive-in Syntax Semantics Call flow Extensions Scripting Hands-on iptel.org jain-sipapi 39peers siprtmp Challenges On Web NAT traversal Security Audio quality Walled garden History Competition IETF, RFC Ecosystem References

  48. Hands-on exercises • Experiment with iptel.org to understand SIP message format • Walk-through of JAIN SIP API reference implementation • Programming server with SIP express router (SER) • Walk-through of 39peers Python stack • Experiment with siprtmp for Flash-to-SIP call

  49. What will you learn? Voice Sampling Encoding Transport Motivation Dive-in Syntax Semantics Call flow Extensions Scripting Hands-on iptel.org jain-sipapi 39peers siprtmp Challenges On Web NAT traversal Security Audio quality Walled garden History Competition IETF, RFC Ecosystem References

  50. JavaScript API

More Related