XMPP Extensible Messaging and Presence Protocol

Corso di Applicazioni Telematiche A.A. 2010-11 Prof. Simon Pietro Romano

Università degli Studi di Napoli Federico II Facoltà di Ingegneria 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

2 XMPP: eXtensible Messaging and Presence Protocol

• Standardization • IETF XMPP Working Group (2002) • RFC 3920: Core features • RFC 3921: and Presence

3 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…

s2s • Architecture XMPP XMPP XMPP XMPP XMPP XMPP XMPP • XMPP servers Client Server Server Client • manage TCP connections • route No-XMPP Foreign No-XMPP Foreign • server-to-server (5269) XMPP messagi Messaging Gateway ng Client XMPP Client • XMPP clients network • connect to server (5222) • multiple resources simultaneously • Gateway • translates XMPP into the protocol used by a foreign (non-XMPP) messaging system

4 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) • 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).

5 JID: examples

•domain meetecho.com

•node@domain [email protected]

•node@domain/resource [email protected]/Spark [email protected]/iMeetecho

6 XML example

•XML-based communication

7 RFC 3920: XML Stream and Stanzas • XML Stream • container for the exchange of XML Stanzas between any two entities over a network • start  tag with appropriate attributes and namespace • end  tag • the stream enables unidirectional communication • qualified by the default namespace for the stream

• jabber:client (client and server )

• jabber:server (server-to-server)

8 Stream example

1. Client initiates stream to server 2. Server responds by sending a stream tag to client …encryption, authentication, and resource binding…

9 Encryption: use of TLS • Method for securing the stream • (TLS) protocol • "STARTTLS" extension • namespace name – 'urn:ietf:params:xml:ns:-tls‘ 3. Server sends the STARTTLS extension to client DIGEST-MD5 PLAIN 10 Use of TLS (2)

4. Client sends the STARTTLS command to server 5. Server informs client that it is allowed to proceed 6. Client and server attempt to complete TLS 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 With encryption

12 Without encryption

13 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

14 XMPP stanzas

• defined stanzas are: • entity pushes information to another entity • availaibility information • info/query request-response mechanism • qualified by the default namespace for the stream • Common Attributes • to, from, type, id, xml:lang

Art thou not Romeo, and a Montague?

15 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 • Exchange messages with other users • Exchange with other users • Manage subscriptions to and from other users • Manage items in a (in XMPP this is called a "roster") • Block communications to or from specific other users

16 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 • contains the topic of the message • the textual content of the message • identifier that is used for tracking a conversation thread The balcony scene! La scena del balcone! Wherefore art thou, Romeo? Perché sei tu, Romeo?

17 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 • specifies the particular availability status • away, chat, dnd = "Do Not Disturb“ and xa = "eXtended Away" • a description of availability status • the priority level of the resource [-128, +127]

dnd Wooing Juliet 1

18 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

Friends 19 Demo scenario

XMPP XMPP Client Client

XMPP

XMPP XMPP Server Server

20 XEP: XMPP Extension Protocol XEP-0166:

occurs over the XMPP "channel" . • How it worksJuliet This is a test. If this were a real file... session-initiate ack session-accept ack 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= • In the context of Jingle audio sessions • = audio • is the preferred port • is whatever profile is negotiated • is the payload-type ID • static payload-type: m=audio 9999 RTP/AVP 13 • dynamic payload-type a=rtpmap:96 speex/16000 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 • 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

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 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- file transfers by encoding all data using base64 • Other binary data like encrypted conversations or graphic icons are embedded using the same method.

24 Open source XMPP servers… • chime () http://www.codecobra.com/chime/ • DJabberd (Perl) http://danga.com/djabberd/ • (Erlang) Home page and Community Site • jabberd14 (C) http://jabberd.org/ • (C) http://jabberd2.xiaoka.com/ • (Wildfire) (Java) 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/

25 … and free clients

J2ME (MIDP2.0)/WinCE • Bombusmod J2ME (MIDP2.0) • Cross-platform Tcl/ • Exodus Windows • Gabber / GTK+ • Cross-platform GTK+ • GOIM Cross-platform Eclipse Rich Client Platform • 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 • Cross-platform Tcl/Tk • Wija Java 26 Igniterealtime.org: client and server

• Server • Openfire 3.7.0 • Client • Spark 2.6.0 • Smack lib • smack_3_2_0.zip

• Web site • http://www.igniterealtime.org

27 Spark: how to write a plugin

• http://www.igniterealtime.org/builds/sparkplug_kit/docs /latest/sparkplug_dev_guide.html

28 Getting Started Writing Spark plugins

29 Implement “Plugin” interface

30 Spark API

31 Next Lesson

• Smack library • Spark plugin • Openfire plugin

• Binaries • http://www.igniterealtime.org/downloads/index.jsp • Source code • http://www.igniterealtime.org/downloads/source.jsp

32 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 • http://www.ietf.org/rfc/rfc3921.txt

• XEP-0166: Jingle • http://www.xmpp.org/extensions/xep-0166.html

33 Domande?

34