XMPP: Extensible Messaging and Presence Protocol Sistemi per la Collaborazione in Rete 2006-07 Fabio Calefato Jabber & XMPP Jabber is an open alternative to closed instant messaging (IM) and presence services. The Extensible Messaging and Presence Protocol (XMPP) is at its core. XMPP protocol defines how to stream XML content XMPP is being used to build A large open IM network A wide range of XML-based applications Dott. Fabio Calefato 2 1
A bit of History Jabber project started in 1999 by Jeremie Miller to develop an open alternative to IM systems 04/01/1999: 1st release of the Jabberd server Jabber Software Foundation contributed the Jabber core XML streaming protocols to the IETF as XMPP in 2002 IETF approved in 2004 the resulting specifications as XMPP RFCs 3920-3923 Dott. Fabio Calefato 3 XMPP extensible Messaging and Presence Protocol Promoted by Jabber Software Foundation Aims at being the standard for Instant Messaging Set of XML-based protocols Programming language independent OS / architecture independent Client-server architecture A plethora of clients, servers and APIs in whatever language Dott. Fabio Calefato 4 2
XMPP Architecture Hybrid, similar to Email/SMTP and DNS Users identified by unique JID: user@server/resource Implementation complexity delegated to servers Dott. Fabio Calefato 5 XMPP Architecture Communication happens client to server and server to server. Port: 5222-3 Port: 5269 Dott. Fabio Calefato 6 3
XMPP Architecture (cont d) Unlike many other IM protocols, XMPP allows for Multiple Point Of Presence (MPOP) MPOP enables users to connect with the same address from multiple locations or devices but only to receive messages at the selected resource: Each location or device is assigned a resource identifier and a priority number Incoming messages and presence info routed to the highest-priority resource Messaging a specific resource still possible by explicitly targeting it: userid@domain/target_resource XMPP addresses can be associated not only with people but also with any other network-aware entity (devices, terminals, routers) Dott. Fabio Calefato 7 montague.lit capulet.lit JID: romeo@montague.lit/pda Priority: 5 :-) JID: romeo@montague.lit/office Priority: 3 JID: juliet@capulet.lit/home Priority: 0 Dott. Fabio Calefato 8 4
Streams and Core Stanzas XMPP deals in XML Streams - containers for exchanging XML elements between any two entities over a network Stanzas - the first-level child elements sent over those streams) Dott. Fabio Calefato 9 Core Stanzas <message/> push mechanism through which one entity pushes information to another <presence/> a basic publish-subscribe to broadcast an entity s network availability (online, busy ) <iq/> (info/query) is a request/response mechanism, similar to HTTP, that lets entities make requests of and receive responses from each other Dott. Fabio Calefato 10 5
Streams and Stanzas (Cont d) These core stanza provide the delivery semantics or transport layer for near-real-time communications The content of any given stanza is specified by its child elements A stanza s content is pure XML: We can use XMPP to exchange any data that we can represent in XML <message from= juliet@capulet.lit/balcony to= romeo@montague. lit/pda > <body>hi yourself!</body> <myextension>whatever I Want </myextension> </message> Dott. Fabio Calefato 11 XMPP Enhancement Proposals The Jabber/XMPP community continues to innovate the core protocol published by the IETF writing extensions known as JEPS Some key extensions include: XEP-0030: Service Discovery protocol for determining the features supported by other entities on an XMPP network XEP-0045: Multi-User Chat defines a set of protocols for participating in and administering multi-user chat rooms XEP-0096: File Transfer defines how to transfer large or binary files XEP-0071: XHTML-IM is a protocol for exchanging XHTML-formatted messages between XMPP entities. XEP-0124: HTTP Binding defines a binding of XMPP to HTTP for devices that can t maintain persistent TCP connections to servers A complete list (there are tens and tens) is available at jabber.org Dott. Fabio Calefato 12 6
A typical scenario (1) jabber.capulet.lit Conn. Established: 5222 jabber.shakespeare.lit Dott. Fabio Calefato 13 A typical scenario (1) Stream Stream Conn. Established: 5222 Romeo begins by negotiating a stream with montague.lit jabber.capulet.lit <iq type= get from= romeo@montague.lit/pda > <query xmlns= jabber:iq:roster /> </iq> jabber.shakespeare.lit Dott. Fabio Calefato 14 7
A typical scenario (2) iq: Roster iq: Roster Conn. Established: 5222 Romeo gets his contact list by exchanging <iq/> stanzas w/ montague.lit jabber.capulet.lit <iq type= result to= romeo@montague.lit/pda > <query xmlns= jabber:iq:roster > <item jid= juliet@capulet.lit /> <item jid= mercutio@shakespeare.lit /> <item jid= benvolio@shakespeare.lit /> </query> jabber.shakespeare.lit </iq> Dott. Fabio Calefato 15 A typical scenario (3) Presence Conn. fissa: 5222 Conn. temporary: 5269 Romeo sends a presence stanza to montague. lit, which broadcasts it to his contacts: <presence from= romeo@montague.lit/pda /> jabber.capulet.lit [server magic here] <presence from= romeo@montague.lit/pda to= juliet@capulet.lit /> <presence jabber.shakespeare.lit from= romeo@montague.lit/pda to= mercutio@shakespeare.lit /> Dott. Fabio Calefato 16 8
A typical scenario (4) Presence Conn. fissa: 5222 Conn. temporanea: 5269 If online, Romeo s contacts return presence stanzas to him: Presence <presence jabber.capulet.lit to= romeo@montague.lit/pda from= juliet@capulet.lit/balcony /> <presence to= romeo@montague.lit/pda from= juliet@capulet.lit/chamber /> <presence to= romeo@montague.lit/pda jabber.shakespeare.lit from= mercutio@shakespeare.lit/ home /> Dott. Fabio Calefato 17 A typical scenario (5) Message Message Conn. fissa: 5222 Conn. temporanea: 5269 Romeo and Juliet exchange message stanzas: Message <message jabber.capulet.lit from= romeo@montague.lit/pda to= juliet@capulet.lit > <body>hi!</body> </message> <message from= juliet@capulet. lit/balcony to= romeo@montague. lit/pda > jabber.shakespeare.lit <body>hi yourself!</body> </message> Dott. Fabio Calefato 18 9
References Streaming XML with Jabber/XMPP P. Saint-Andre - IEEE Internet Computing, 2005 Jabber Software Foundation http://www.jabber.org/ XMPP Core RFCs 3920-3923 http://www.xmpp.org/rfcs/ The XMPP Public servers list http://www.xmpp.net/ List of recommended XMPP clients http://www.jabber.org/software/clients.shtml List of recommended XMPP severs http://www.jabber.org/software/servers.shtml List all of the known code libraries for Jabber/XMPP development http://www.jabber.org/software/libraries.shtml Chi aiuterà l IM? Jabber! Michele Salvemini Dott. Fabio Calefato 19 10