Sei sulla pagina 1di 10

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

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

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

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

XMPP Architecture
Communication happens client to server and server
to server.

Port: 5222-3

Port: 5269

Dott. Fabio Calefato

XMPP Architecture (contd)


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

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

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

Core Stanzas
<message/>
push mechanism through which one entity pushes
information to another

<presence/>
a basic publish-subscribe to broadcast an entitys
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

Streams and Stanzas (Contd)


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 stanzas 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 cant maintain persistent TCP connections to servers

A complete list (there are tens and tens) is available at jabber.org


Dott. Fabio Calefato

12

A typical scenario (1)


Romeo e Giulietta
jabber.capulet.lit

jabber.montague.lit
Conn. Established: 5222
jabber.shakespeare.lit

Dott. Fabio Calefato

13

A typical scenario (1)


Romeo begins by negotiating
a stream with montague.lit

Romeo e Giulietta

jabber.capulet.lit

Stream
Stream
jabber.montague.lit

<iq type=get
from=romeo@montague.lit/pda>
<query xmlns=jabber:iq:roster/>
</iq>

Conn. Established: 5222


jabber.shakespeare.lit

Dott. Fabio Calefato

14

A typical scenario (2)


Romeo gets his contact list by
exchanging <iq/> stanzas w/
montague.lit

Romeo e Giulietta

jabber.capulet.lit

iq: Roster
iq: Roster
jabber.montague.lit
Conn. Established: 5222

<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/>
jabber.shakespeare.lit
</query>
</iq>

Dott. Fabio Calefato

15

A typical scenario (3)


Romeo sends a presence stanza to
montague. lit, which broadcasts it to
his contacts:
<presence
from=romeo@montague.lit/pda/>
jabber.capulet.lit

Romeo e Giulietta

Presence

[server magic here]


jabber.montague.lit
Conn. fissa: 5222

Conn. temporary: 5269

<presence
from=romeo@montague.lit/pda
to=juliet@capulet.lit/>
jabber.shakespeare.lit
<presence
from=romeo@montague.lit/pda
to=mercutio@shakespeare.lit/>

Dott. Fabio Calefato

16

A typical scenario (4)


If online, Romeos contacts return
presence stanzasPresence
to him:

Romeo e Giulietta

Presence
jabber.montague.lit
Conn. fissa: 5222

Conn. temporanea: 5269

<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
jabber.shakespeare.lit
to=romeo@montague.lit/pda
from=mercutio@shakespeare.lit/
home/>

Dott. Fabio Calefato

17

A typical scenario (5)


Romeo and Juliet exchange
message stanzas:

Romeo e Giulietta

Message

<message
from=romeo@montague.lit/pda
jabber.capulet.lit
to=juliet@capulet.lit>
<body>hi!</body>
</message>

Message
Message
jabber.montague.lit
Conn. fissa: 5222

Conn. temporanea: 5269

<message from=juliet@capulet.
lit/balcony to=romeo@montague.
lit/pda>
jabber.shakespeare.lit
<body>hi yourself!</body>
</message>

Dott. Fabio Calefato

18

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 lIM? Jabber!
Michele Salvemini
Dott. Fabio Calefato

19

10

Potrebbero piacerti anche