Corso di Applicazioni Telematiche A.A. 2009-10 Prof. Simon Pietro - - PowerPoint PPT Presentation

corso di applicazioni telematiche
SMART_READER_LITE
LIVE PREVIEW

Corso di Applicazioni Telematiche A.A. 2009-10 Prof. Simon Pietro - - PowerPoint PPT Presentation

XMPP Extensible Messaging and Presence Protocol Corso di Applicazioni Telematiche A.A. 2009-10 Prof. Simon Pietro Romano Universit degli Studi di Napoli Federico II Facolt di Ingegneria XMPP: eXtensible Messaging and Presence Protocol


slide-1
SLIDE 1

XMPP Extensible Messaging and Presence Protocol

Corso di Applicazioni Telematiche

A.A. 2009-10

  • Prof. Simon Pietro Romano

Università degli Studi di Napoli Federico II Facoltà di Ingegneria

slide-2
SLIDE 2

XMPP: eXtensible Messaging and Presence Protocol

  • Formerly known as Jabber
  • Jeremie Miller began the project in 1998
  • first release in May 2000
  • The project's main product was jabberd
  • XML-based
  • Extensible to other features
  • Open
  • open standard
  • open source implementations
  • open system
slide-3
SLIDE 3

XMPP: eXtensible Messaging and Presence Protocol

  • Standardization
  • IETF XMPP Working Group (2002)
  • RFC 3920: Core features
  • RFC 3921: Instant Messaging and Presence
slide-4
SLIDE 4

RFC 3920: Overview and Architecture

  • … is a protocol for streaming Extensible Markup

Language (XML) elements in order to exchange structured information in close to real time between any two network endpoints…

  • Architecture
  • XMPP servers
  • XMPP servers
  • Manage TCP connections
  • route messages
  • server-to-server (5269)
  • XMPP clients
  • connect to server (5222)
  • multiple resources simultaneously
  • Gateway
  • translates XMPP into the protocol used by a foreign (non-XMPP)

messaging system

slide-5
SLIDE 5

RFC 3920: Addressing Scheme

  • All XMPP entities are uniquely addressable
  • JID (Jabber Identifier)

[ node "@" ] domain [ "/" resource ]

  • domain identifier: FQDN / address-literal
  • FQDN (Fully Qualified Domain Name ): (sub-domain_1)".“(sub-

domain) domain)

  • address-literal: IPv4address / IPv6address
  • usually represents servers or gateways (REQUIRED)
  • node identifier
  • a simple string
  • usually represents a client (OPTIONAL)
  • resource identifier
  • usually represents a specific session, connection or object

belonging to the entity associated with a node identifier (OPTIONAL).

slide-6
SLIDE 6

JID: examples

  • domain

meetecho.com

  • node@domain

tcastaldi@meetecho.com

  • node@domain/resource

tcastaldi@meetecho.com/Spark tcastaldi@meetecho.com/iMeetecho

6

slide-7
SLIDE 7

XML example

slide-8
SLIDE 8

RFC 3920: XML Stream

  • XML Stream
  • container for the exchange of XML Stanzas between

any two entities over a network

  • start
  • <stream> tag with appropriate attributes

and namespace

  • end
  • </stream> tag
  • end
  • </stream> tag
  • the stream enables unidirectional communication
  • qualified by the default namespace for the stream
  • jabber:client (client and server )
  • jabber:server (server-to-server)
slide-9
SLIDE 9

Stream example

  • 1. Client initiates stream to server

<?xml version='1.0'?> <stream:stream to='example.com' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>

  • 2. Server responds by sending a stream tag to
  • 2. Server responds by sending a stream tag to

client

<?xml version='1.0'?> <stream:stream from='example.com' id='someid' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>

…encryption, authentication, and resource binding…

9

slide-10
SLIDE 10

Encryption: use of TLS

  • Method for securing the stream
  • Transport Layer Security (TLS) protocol
  • "STARTTLS" extension
  • namespace name

– 'urn:ietf:params:xml:ns:xmpp-tls‘

  • 3. Server sends the STARTTLS extension to client
  • 3. Server sends the STARTTLS extension to client

<stream:features> <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'> <required/> </starttls> <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'> <mechanism>DIGEST-MD5</mechanism> <mechanism>PLAIN</mechanism> </mechanisms> </stream:features>

10

slide-11
SLIDE 11

Use of TLS (2)

  • 4. Client sends the STARTTLS command to server

<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>

  • 5. Server informs client that it is allowed to proceed

<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>

  • 6. Client and server attempt to complete TLS

negotiation over the existing TCP connection negotiation over the existing TCP connection

  • 7. If TLS negotiation is successful, client initiates a new

stream to server

  • 8. Server responds by sending a stream header to client

along with any available stream features

  • 9. Client continues with SASL negotiation

11

slide-12
SLIDE 12

RFC 3920: XML Stanza

  • XML Stanza
  • discrete semantic unit of structured information

that is sent over an XML stream

  • exists at the direct child level of the root
  • exists at the direct child level of the root

<stream> element

slide-13
SLIDE 13

XMPP stanzas

  • defined stanzas are:
  • <message> entity pushes information to another entity
  • <presence> availaibility information
  • <iq>

info/query request-response mechanism

  • qualified by the default namespace for the stream
  • qualified by the default namespace for the stream
  • Common Attributes
  • to, from, type, id, xml:lang

<message type='chat' from='juliet@exmpl.com' to='romeo@exmpl.net'> <body>Art thou not Romeo, and a Montague?</body> </message>

13

slide-14
SLIDE 14

RFC 3921: Instant Messaging and Presence

  • Describes extensions to and applications of the

core features XMPP that provide the basic instant messaging (IM) and presence functionality

  • Requirements
  • Requirements
  • Exchange messages with other users
  • Exchange presence information with other users
  • Manage subscriptions to and from other users
  • Manage items in a contact list (in XMPP this is

called a "roster")

  • Block communications to or from specific other

users

slide-15
SLIDE 15

RFC 3921: Message Syntax

  • Possible values of types for Message packets
  • chat: sent in the context of a one-to-one chat
  • groupchat: sent in the context of a multi-user chat
  • Child Elements
  • <subject/> contains the topic of the message
  • <body/> the textual content of the message
  • <body/> the textual content of the message
  • <thread/> identifier that is used for tracking a

conversation thread

<message to='romeo@ex.net' from='juliet@exm.com/balcony' type='chat' xml:lang='en'> <subject>The balcony scene!</subject> <subject xml:lang=‘it'>La scena del balcone!</subject> <body>Wherefore art thou, Romeo?</body> <body xml:lang=‘it'>Perché sei tu, Romeo?</body> </message>

slide-16
SLIDE 16

RFC 3921: Presence Syntax

  • Possible values of types for Presence packets
  • subscribe: the sender wishes to subscribe to the recipient's

presence

  • unavailable: signals that the entity is no longer available
  • probe: request for an entity's current presence
  • Child Elements
  • <show/> specifies the particular availability status
  • <show/> specifies the particular availability status
  • away, chat, dnd = "Do Not Disturb“ and xa = "eXtended Away"
  • <status/> a description of availability status
  • <priority/> the priority level of the resource [-128, +127]

<presence xml:lang='en'> <show>dnd</show> <status>Wooing Rupert</status> <priority>1</priority> </presence>

slide-17
SLIDE 17

RFC 3921: IQ Syntax

  • Extended namespace
  • defines all data contained within the child element
  • Possible values of types for IQ packets
  • get
  • set
  • result
  • Use case: retrieving One's Roster on Login
  • 'jabber:iq:roster' namespace
  • 'jabber:iq:roster' namespace

<iq from='juliet@example.com/balcony' type='get' id='roster_1'> <query xmlns='jabber:iq:roster'/> </iq> <iq to='juliet@example.com/balcony' type='result' id='roster_1'> <query xmlns='jabber:iq:roster'> <item jid='romeo@example.net' name='Romeo‘ subscription='both'> <group>Friends</group> </item> </query> </iq>

slide-18
SLIDE 18

XEP: XMPP Extension Protocol

  • Is a pure XMPP signalling protocol
  • Designed to interwork with SIP
  • Initiating and managing media sessions between two XMPP

entities

  • negotiation occurs over the XMPP "channel"
  • media is exchanged outside the XMPP using RTP, UDP….
  • How it works: File transfer

!""#$%

  • How it works: File transfer

% &

slide-19
SLIDE 19

XEP: XMPP Extension Protocol

  • Is a pure XMPP signalling protocol
  • Designed to interwork with SIP
  • Initiating and managing media sessions between two XMPP

entities

  • negotiation occurs over the XMPP "channel"
  • media is exchanged outside the XMPP using RTP, UDP….
  • How it works: File transfer

!""#$%

<iq from=‘romeo@shakespeare.lit/castle' id='jingle1' to=‘juliet@shakespeare.lit/castle' type='set'> <jingle xmlns='urn:xmpp:tmp:jingle' action='session-initiate' initiator=‘romeo@shakespeare.lit/castle' sid='851ba2'> <content creator='initiator' name='a-file-offer'> <description xmlns='urn:xmpp:tmp:jingle:apps:file-transfer'> <offer> <file xmlns='http://jabber.org/protocol/si/profile/file-

  • How it works: File transfer

% &

  • <offer>

<file xmlns='http://jabber.org/protocol/si/profile/file- transfer' name='test.txt' size='1022' hash='552da749930852c69ae5d2141d3766b1' date='1969-07-21T02:56:15Z'> <desc>This is a test. If this were a real file...</desc> </file> </offer> </description> <transport xmlns='urn:xmpp:tmp:jingle:transports:bytestreams'/> </content> </jingle> </iq>

slide-20
SLIDE 20

XEP: XMPP Extension Protocol

  • Is a pure XMPP signalling protocol
  • Designed to interwork with SIP
  • Initiating and managing media sessions between two XMPP

entities

  • negotiation occurs over the XMPP "channel"
  • media is exchanged outside the XMPP using RTP, UDP….
  • How it works: File transfer

!""#$%

  • How it works: File transfer

% &

  • <iq from=‘juliet@shakespeare.lit/castle'

id='jingle1' to=‘romeo@shakespeare.lit/castle' type='result'/>

slide-21
SLIDE 21

XEP-0167: Jingle Audio via RTP

  • This document specifies an application format for

negotiating Jingle audio sessions, where the media is exchanged over the Realtime Transport Protocol

  • Mapping to Session Description Protocol
  • m=<media> <port> <transport> <fmt list>
  • In the context of Jingle audio sessions
  • <media> = audio

<port> is the preferred port

  • <port> is the preferred port
  • <transport> is whatever profile is negotiated
  • <fmt list> is the payload-type ID
  • static payload-type:
  • dynamic payload-type

m=audio 9999 RTP/AVP 96 a=rtpmap:96 speex/16000 <payload-type id='96' name='speex' clockrate='16000' ptime='40'> <parameter name='vbr' value='on'/> <parameter name='cng' value='on'/> </payload-type> <payload-type id="13" name="CN"/> m=audio 9999 RTP/AVP 13

slide-22
SLIDE 22

Strengths

  • Decentralization
  • anyone can run his own XMPP server
  • there is no central master server
  • Open standards
  • No royalties are required to implement support of these

specifications

  • History
  • History
  • Multiple implementations of the XMPP standards exist for

clients, servers, components, and code libraries

  • Security
  • XMPP servers may be isolated from the public Jabber

network (e.g., on a company intranet)

  • Flexibility
  • Custom functionality can be built on top of XMPP
slide-23
SLIDE 23

Weaknesses

  • Presence data overhead
  • With typically over 70% of XMPP inter-server traffic

being presence data, and close to 60% of it being redundantly transmitted

  • No binary data
  • The way XMPP is encoded as a single long XML
  • The way XMPP is encoded as a single long XML

document makes it impossible to deliver unmodified binary data

  • File transfers are therefore arranged to happen using

external protocols like HTTP

  • If unavoidable, XMPP also provides in-band file

transfers by encoding all data using base64

  • Other binary data like encrypted conversations or

graphic icons are embedded using the same method.

slide-24
SLIDE 24

Demo scenario

XMPP Client

  • XMPP

Client

24

XMPP Server

  • XMPP

Server

slide-25
SLIDE 25

Open source XMPP servers…

  • chime (Java) http://www.codecobra.com/chime/
  • DJabberd (Perl) http://danga.com/djabberd/
  • ejabberd (Erlang) Home page and Community Site
  • jabberd14 (C) http://jabberd.org/
  • jabberd2 (C) http://jabberd2.xiaoka.com/
  • Openfire (Wildfire) (Java)

http://www.igniterealtime.org/projects/openfire/ http://www.igniterealtime.org/projects/openfire/

  • OpenIM (Java) http://www.open-im.net/
  • Pretzel (Python) http://code.google.com/p/pretzel/
  • psyced (LPC) http://www.psyced.org/
  • Tigase (Java) http://www.tigase.org/
  • WPJabber (C) http://spik.wp.pl/jabber.html
  • xmppd.py (Python) http://xmpppy.sourceforge.net/
slide-26
SLIDE 26

… and free clients

  • Bombus J2ME (MIDP2.0)/WinCE
  • Bombusmod J2ME (MIDP2.0)
  • Coccinella Cross-platform Tcl/Tk
  • Exodus Windows
  • Gabber Linux/Unix GTK+
  • Gajim Cross-platform GTK+
  • GOIM Cross-platform Eclipse Rich Client Platform
  • Spark Cross-platform Java
  • Spark Cross-platform Java
  • Gossip Linux/Unix GTK+
  • Jabbim Cross-platform PyQt
  • Jabbin Cross-platform Qt
  • MCabber Cross-platform (ncurses)
  • Mobber J2ME (MIDP1.0)
  • MOO-XMPP MOO
  • Psi Cross-platform Qt
  • Tapioca
  • Tkabber Cross-platform Tcl/Tk
  • Wija Java
slide-27
SLIDE 27

References

  • XMPP Working Group
  • Charter
  • http://www.ietf.org/html.charters/OLD/xmpp-charter.html
  • RFC 3920 XMPP: Core
  • http://www.ietf.org/rfc/rfc3920.txt
  • RFC 3921 XMPP: Instant Messaging and Presence
  • RFC 3921 XMPP: Instant Messaging and Presence
  • http://www.ietf.org/rfc/rfc3921.txt
  • XEP-0166: Jingle
  • http://www.xmpp.org/extensions/xep-0166.html
slide-28
SLIDE 28

Domande?

28