sip y xmpp: amigos para siempre

Post on 19-May-2015

3.498 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Slides (in Spanish) from the talk I gave at Telefónica R&D. Talk was about what features SIP and XMPP share which go beyond VoIP and how to implement a gateway functionality between them.

TRANSCRIPT

SIP y XMPP: amigos para siempreSaúl Ibarra Corretgé | AG Projects

Saturday, October 6, 2012

¡Hola!

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Intro

• Hola, soy @saghul

• En VoIP desde el 2005

• Vamos a hablar de SIP y XMPP

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

AG Projects

• Infraestructura SIP

• SIP Thor: Plataforma SIP con escalabilidad horizontal mediante P2P

• Proyectos Open Source

• Blink

• SIP SIMPLE SDK

• SylkServer

• MediaProxy

• OpenXCAP

• MSRPRelay

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Entendiendo SIP y XMPP

• Ambos son protocolos de señalización

• Nos permiten establecer sesiones multimedia

• Mensajería Instantánea y Presencia

• Pero son MUY distintos

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

SIP

• Session Initiation Protocol - RFC 3261

• Creado para iniciar, mantener y terminar sesiones multimedia

• Mayormente utilizado en sesiones de audio y video, y conferencias

• Diseñado para que la inteligencia esté en el User Agent

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

XMPP

• eXtensible Messaging and Presence Protocol - RFC 6120, 6121

• Creado para mensajería y presencia

• Mayormente utilizado para IM

• Diseñado para que la inteligencia esté en el servidor

Saturday, October 6, 2012

Mensajería Instantánea

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

IM con SIP

• Tipo SMS: SIP MESSAGE

• No hay relación entre mensajes

• Si el transporte es UDP, orden no garantizado

• Utiliza el path de la señalización

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

IM con SIP

• Basado en sesiones: MSRP

• Igual que una llamada

• Conexión TCP entre los dispositivos

• Múltiples aplicaciones sobre MSRP

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

MSRP

• Message Session Relay Protocol - RFC4575

• Se negocia con SDP, igual que un stream de audio

• Aplicaciones: chat, transferencia de ficheros, compartir escritorio

•TLS es mandatory

• Usado en RCS

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

IM con SIP

MESSAGE sip:saul@ag-projects.com SIP/2.0Via: SIP/2.0/UDP 192.168.99.53:58291;rport;branch=z9hG4bKPjLOuZqe0g8SRst9ipMax-Forwards: 70From: "Saúl" <sip:saghul@sip2sip.info>;tag=QPQ0E6QCFPv8Nx7F3uGPgkmoPvibIZDSTo: <sip:saul@ag-projects.com>Call-ID: Us.Cphs4LMENWqaKvgR3MDup4Ak4eee2CSeq: 50270 MESSAGEUser-Agent: Blink Pro 2.0.0 (MacOSX)Content-Type: text/plainContent-Length: 3

foo

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

IM con SIP

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

IM con SIP

v=0o=- 3557072827 3557072827 IN IP4 192.168.99.53s=Blink Pro 2.0.0 (MacOSX)c=IN IP4 192.168.99.53t=0 0m=message 2855 TCP/TLS/MSRP *a=path:msrps://192.168.99.53:2855/2da6282242d37bc5909b;tcpa=accept-types:message/cpim text/* application/im-iscomposing+xmla=accept-wrapped-types:*a=setup:activem=audio 50002 RTP/AVP 103 102 9 0 8 101a=rtcp:50003a=rtpmap:103 speex/16000a=rtpmap:102 speex/8000a=rtpmap:9 G722/8000a=rtpmap:0 PCMU/8000a=rtpmap:8 PCMA/8000a=rtpmap:101 telephone-event/8000a=fmtp:101 0-15a=sendrecv

{ }

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

IM con SIP

• SIP MESSAGE es más frágil

• Con MSRP es necesario aceptar la sesión

• Es posible usar early media

• ¿Routing basado en presencia?

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

IM con XMPP

• Distintos tipos de stanzas para IM

• El servidor inserta nuestra identidad

• Sin soporte para sesiones, son “implícitas”

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

IM con XMPP

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

IM con XMPP

<message from="saul@ag-projects.com/Psi+" type="chat" xml:lang="en" to="saghul@gmail.com/λ3DD1000D" id="aaf0a"> <body>foo</body> <active xmlns="http://jabber.org/protocol/chatstates"/> <request xmlns="urn:xmpp:receipts"/></message>

Saturday, October 6, 2012

Presencia

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Presencia con SIP

• Modelo PubSub, publicación - subscripción

• Iniciado por el usuario

• No se usa un modelo end to end

• Servidores Presence Agent

• Autorización: XCAP

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

XCAP

• XML Configuration Access Protocol - RFC4825

• Almacena documentos XML, modificables mediante HTTP

• Apliaciones

• Autorización

• Lista de contactos

• Estado offlineSaturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Presencia con SIP

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

<presence ...> <tuple id="SID-2af16065-6f4c-40a5-8bee-c38678776dec"> <status> <basic>open</basic> <agp-pidf:extended>available</agp-pidf:extended> </status> <c:display-name>saghul</c:display-name> <c:map>Netherlands/Wageningen</c:map> <c:icon>https://...</c:icon> <agp-pidf:device-info id="2af16065-6f4c-40a5-8bee-c38678776dec"> <agp-pidf:description>hal</agp-pidf:description> <agp-pidf:user-agent>Blink Pro 2.0.0 (MacOSX)</agp-pidf:user-agent> <agp-pidf:time-offset>120</agp-pidf:time-offset> </agp-pidf:device-info> <caps:servcaps> <caps:audio>true</caps:audio> <caps:message>true</caps:message> <caps:text>true</caps:text> <agp-caps:file-transfer>true</agp-caps:file-transfer> <agp-caps:screen-sharing>true</agp-caps:screen-sharing> </caps:servcaps> <rpid:user-input idle-threshold="600">active</rpid:user-input> <contact>sip:saghul@test.sip2sip.info</contact> <note>At work!</note> <timestamp>2012-09-19T22:09:56.929088+02:00</timestamp> </tuple> ...</presence>

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Presencia con XMPP

• Modelo Push - el servidor envía los datos a todos

• Iniciado automáticamente por el servidor

• Sólo contempla presencia “básica”

• Presencia extendida

• Personal Eventing Protocol - XEP-0163

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Presencia con XMPP

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Presencia con XMPP

<presence> <status>ready to rock!</status> <priority>50</priority> <c xmlns="http://jabber.org/protocol/caps" node="http://psi-dev.googlecode.com/caps" ver="0.15" ext="ca cs cv e-time ep-notify-2 last-act mr sxe whiteboard"/> <x xmlns="vcard-temp:x:update"> <photo>6185d7579dab3063e71a09fcd0506a769c72af5e</photo> </x></presence>

Saturday, October 6, 2012

Sesiones con RTP

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Audio y Video con SIP

• SIP y SDP para señalización, RTP para el transporte del payload

• Encriptación: SRTP, ZRTP*

• Soporte para múltiples streams

• Soporte para distintas fuentes dentro de un mismo stream

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Audio y Vídeo con SIP

v=0o=- 3557075781 3557075781 IN IP4 192.168.99.53s=Blink Pro 2.0.0 (MacOSX)c=IN IP4 192.168.99.53t=0 0m=audio 50542 RTP/AVP 103 102 9 0 8 101a=rtcp:50544a=rtpmap:103 speex/16000a=rtpmap:102 speex/8000a=rtpmap:9 G722/8000a=rtpmap:0 PCMU/8000a=rtpmap:8 PCMA/8000a=rtpmap:101 telephone-event/8000a=fmtp:101 0-15a=ice-ufrag:453af62fa=ice-pwd:21f8ab2ba=candidate:Sc0a86335 1 UDP 1694498815 62.131.6.55 50542 typ srflx raddr 192.168.99.53 rport 55428a=candidate:Hc0a86335 1 UDP 2130706431 192.168.99.53 55428 typ hosta=candidate:Sc0a86335 2 UDP 1694498814 62.131.6.55 50544 typ srflx raddr 192.168.99.53 rport 52633a=candidate:Hc0a86335 2 UDP 2130706430 192.168.99.53 52633 typ hosta=sendrecv

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

NAT

• RTP viaja sobre UDP

• La mayoría de los usuarios está detrás de NAT

• Necesidad de usar media relays

• ¿O no?

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

ICE

• Interactive Connectivity Establishment - RFC 5425

• Cada usuario presenta sus candidatos para recibir RTP

• Se hacen pruebas usando paquetes STUN

• Se selecciona el candidato ganador

• ¡Audio P2P detrás de NAT!

• Ayuda en situaciones mixtas IPv4 / IPv6Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

ICE

v=0o=- 3557075781 3557075781 IN IP4 192.168.99.53s=Blink Pro 2.0.0 (MacOSX)c=IN IP4 192.168.99.53t=0 0m=audio 50542 RTP/AVP 103 102 9 0 8 101a=rtcp:50544a=rtpmap:103 speex/16000a=rtpmap:102 speex/8000a=rtpmap:9 G722/8000a=rtpmap:0 PCMU/8000a=rtpmap:8 PCMA/8000a=rtpmap:101 telephone-event/8000a=fmtp:101 0-15a=ice-ufrag:453af62fa=ice-pwd:21f8ab2ba=candidate:Sc0a86335 1 UDP 1694498815 62.131.6.55 50542 typ srflx raddr 192.168.99.53 rport 55428a=candidate:Hc0a86335 1 UDP 2130706431 192.168.99.53 55428 typ hosta=candidate:Sc0a86335 2 UDP 1694498814 62.131.6.55 50544 typ srflx raddr 192.168.99.53 rport 52633a=candidate:Hc0a86335 2 UDP 2130706430 192.168.99.53 52633 typ host

{ }Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Audio y Vídeo con XMPP

• Jingle, originalmente creado por Google

• Muy inspirado en SIP

• Stanzas de tipo IQ

• “Un SDP en XML”

• ICE como requisito

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Audio y Vídeo con XMPP<iq from='romeo@montague.lit/orchard' id='ph37a419' to='juliet@capulet.lit/balcony' type='set'>  <jingle xmlns='urn:xmpp:jingle:1' action='session-initiate' initiator='romeo@montague.lit/orchard' sid='a73sjjvkla37jfea'>    <content creator='initiator' name='voice'>      <description xmlns='urn:xmpp:jingle:apps:rtp:1' media='audio'>        <payload-type id='96' name='speex' clockrate='16000'/>        <payload-type id='18' name='G729'/>        <payload-type id='0' name='PCMU' />      </description>      <transport xmlns='urn:xmpp:jingle:transports:ice-udp:1 pwd='asd88fgpdd777uzjYhagZg'          ufrag='8hhy'>        <candidate component='1' foundation='1' generation='0' id='el0747fg11' ip='10.0.1.1'          network='1' port='8998' priority='2130706431' protocol='udp' type='host'/>        <candidate component='1' foundation='2' generation='0' id='y3s2b30v3r' ip='192.0.2.3'          network='1' port='45664' priority='1694498815' protocol='udp' rel-addr='10.0.1.1'          rel-port='8998' type='srflx'/>      </transport>    </content>  </jingle></iq>

Saturday, October 6, 2012

Conferencias

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Conferencias con SIP

• Lo habitual: aburridos mixers de RTP

• Lo interesante: RTP + chat + conference control

• Información: RFC 4575

• Control: RFC 4579

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

<conference-info ... entity="sip:9037396@conference.sip2sip.info" state="full"> <conference-description> <display-text>Ad-hoc conference</display-text> <free-text>Hosted by SylkServer-2.0.0</free-text> </conference-description> <host-info> <web-page>http://sylkserver.com</web-page> </host-info> <conference-state> <user-count>1</user-count> <active>true</active> </conference-state> <users state="full"> <user entity="sip:saghul@sip2sip.info" state="full"> <display-text>Saúl</display-text> <endpoint entity="sip:lcwkhrsu@62.131.6.55:63047" state="full"> <display-text>Saúll</display-text> <status>connected</status> <joining-info> <when>2012-09-19T23:26:18+02:00</when> </joining-info> <media id="186236108"> <type>message</type> </media> </endpoint> </user> </users></conference-info>

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Conferencias con XMPP

• Multi User Chat (MUC): XEP-0045

• Audio y video

• Muji: XEP-0272

• Coin: XEP-0298

• Coin utiliza el payload del RFC 4575

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Conferencias con XMPP<presence from='hag66@shakespeare.lit/pda' id='n13mt3l' to='coven@chat.shakespeare.lit/thirdwitch'> <x xmlns='http://jabber.org/protocol/muc'/></presence>

<presence from='coven@chat.shakespeare.lit/firstwitch' id='3DCB0401-D7CF-4E31-BE05-EDF8D057BFBD' to='hag66@shakespeare.lit/pda'> <x xmlns='http://jabber.org/protocol/muc#user'> <item affiliation='owner' role='moderator'/> </x></presence>

<presence from='coven@chat.shakespeare.lit/secondwitch' id='C2CD9EE3-8421-431E-854A-A2AD0CE2E23D' to='hag66@shakespeare.lit/pda'> <x xmlns='http://jabber.org/protocol/muc#user'> <item affiliation='admin' role='moderator'/> </x></presence>

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Conferencias con XMPP<iq from='romeo@montague.lit/orchard' id='zid615d9' to='juliet@capulet.lit/balcony' type='set'> <conference-info xmlns="urn:ietf:params:xml:ns:conference-info" entity="xmpp:romeo@monague.lit/orchard" state="full" version="1">

<!-- CONFERENCE INFO --> <conference-description> <subject>Ending a relationship</subject> </conference-description>

<!-- CONFERENCE STATE --> <conference-state> <user-count>3</user-count> </conference-state>

<!-- USERS --> <users> <user entity="xmpp:romeo@montague.lit" state="full"> <display-text>Romeo</display-text>

<!-- ENDPOINTS --> <endpoint entity="xmpp:romeo@montague.lit/orchard"> <display-text>Romeo's smartphone</display-text> <status>disconnected</status> ...

Saturday, October 6, 2012

Construyendo un Gateway

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Estado del Arte

• SIP utilizado para audio, video, conferencias y emular la PSTN

• XMPP utilizado para mensajería, presencia y Google Hangouts

• Ambos protocolos funcionarán en los navegadores

• WebSocket + WebRTC

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

SIP y XMPP: ¿qué tienen en común?

• Misma tecnología para audio y video - RTP

• Misma tecnolgía de NAT traversal - ICE

• Payloads compatibles - CPIM

• Mecanismo PUBLISH - SUBSCRIBE

• usuario@dominio

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Combinando SIP y XMPP

• Clientes dual stack

• CUSAX: draft-ivov-xmpp-cusax

• Clientes single stack

• Usar un gateway

• Un gateway transparente

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Un solo stack

• SIP y XMPP fueron diseñados de manera distinta, abstraernos de ellos puede traer problemas

• Menos código, menos bugs

• Configuración más simple

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

SIP SIMPLE Client SDK

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Blink

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

SylkServer

SylkServer

SIP Networks XMPP Networks

ConferencingHigh Definition Audio

Instant MessagingFile Transfer

Presence

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

SylkServer

• SIP Application Server

• Software Libre

• ZeroConf

• Implementado utilizando SIP SIMPLE Client SDK

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

SylkServer: Arquitectura

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

SylkServer: Conferencias

• Audio en HD

• Chat con MSRP

• Información de participantes (RFC 4575)

• Control de conferencias (RFC 4579)

• draft-ietf-simple-chat

• Transferencia de ficheros

• Compartir escritorio

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

SylkServer: gateway XMPP

• Mensajería Instantánea

• SIP MESSAGE

• MSRP

• Presencia

• MUC

• Jingle

• Transferencia de ficheros

• CoinSaturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Diseño del gateway XMPP

• SylkServer es el servidor XMPP autoritativo del dominio

• Sólo soporta conexiones S2S

• Los clientes del dominio local usan SIP

• Routing en base a usuario@dominio (DNS SRV)

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Arquitectura del gateway XMPP

• El servidor no hace AAA

• Despliegue detrás de un proxy SIP

• Conexiones XMPP S2S con otros dominios

• Una única opción de configuración necesaria como mínimo: el dominio

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Arquitectura del gateway XMPP

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Gateway XMPP: IM

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Gateway XMPP: Presencia

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Retos en la implementación

• Servidor XMPP vs Componente XMPP

• Especificaciones incompletas / obsoletas

• Diferencia de conceptos

• ¿Sesiones XMPP?

• SIP PIDF vs Presencia en XMPP

• Conferencias en SIP vs XMPP MUC

• Jingle y Gingle

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Futuro

• La IETF está considerando resucitar los drafts de interoperabilidad SIP - XMPP

• Nuestro roadmap

• Jingle y Gingle

• Transferencia de ficheros

Saturday, October 6, 2012

Desplegando infraestructura SIP

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Problemas habituales

• NAT

• Tamaño de los paquetes SIP

• Escalabilidad

• Entornos hostiles a nivel de networking

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

NAT

• Fácilmente solucionable en el servidor reescribiendo el SDP

• Pero rompe ICE

• OpenSIPS + MediaProxy

• Primera y única solución ICE-friendly

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Soporte ICE en MediaProxy

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

NAT y MSRP

• Uso de relays: MSRPRelay

• Alternative Connection Model (RFC 6135)

• Implementado en SIP SIMPLE SDK

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Tamaño de los paquetes SIP

• ¡Cada vez son más grandes!

• Necesidad de un transporte fiable: TCP

• ¿Es TCP el transporte correcto?

• Facebook Messenger usa MQTT

• Si hay SIP ALGs: TLS

• Para que no husmeen

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Escalabilidad

• ¿Quién balancea la carga del balanceador?

• Red distribuída de servidores: DHT

• Ejemplo: SIP2SIP.info usa SIPThor

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

SIP + DHT

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Entornos hostiles a nivel de netwoking

• “Internet funciona perfectamente. En el puerto 80.”

• SIP sobre TLS, en otro puerto

• RTP vía TURN / TCP

• RTP multiplexing

• WebRTC

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

Saturday, October 6, 2012

AG ProjectsSIP Infrastructure Experts

BYE sip:audience@tid SIP/2.0Via: SIP/2.0/UDP 192.168.99.23:49919;rport;branch=z9hG4bKPjDb30Dx0sH7aMMax-Forwards: 70From: "saghul" <sip:saul@ag-projects.com>;tag=UCpGKVZbQQx7BUKTo: <sip:audience@tid>;tag=as59aef35cCall-ID: DEWDfu63OACwYeQk7MrhmRhRq.1cqqisCSeq: 10633 BYERoute: <sip:81.23.228.129;lr;ftag=UCpGKVZbQQx7BUKY;did=641.a8a9c553>User-Agent: BlinkContent-Length: 0

@saghul

saul@ag-projects.com

sip:saul@ag-projects.com

Saturday, October 6, 2012

top related