Abstract: | This specification defines a proposed modification to the XMPP roster protocol that enables versioning of rosters such that the server will not send the roster to the client if the roster has not changed, thus saving bandwidth during session establishment. |
Author: | Peter Saint-Andre |
Copyright: | © 1999 - 2009 XMPP Standards Foundation. SEE LEGAL NOTICES. |
Status: | Proposed |
Type: | Standards Track |
Version: | 0.7 |
Last Updated: | 2009-04-17 |
NOTICE: This document is currently within Last Call or under consideration by the XMPP Council for advancement to the next stage in the XSF standards process.
1. Introduction
2. Protocol
2.1. Data Format
2.2. Client Request
2.3. Server Response
3. Examples
4. Stream Feature
5. Security Considerations
6. IANA Considerations
7. XMPP Registrar Considerations
7.1. Protocol Namespaces
8. XML Schemas
9. Acknowledgements
Appendices
A: Document Information
B: Author Information
C: Legal Notices
D: Relation to XMPP
E: Discussion Venue
F: Requirements Conformance
G: Notes
H: Revision History
Although XMPP rosters can become quite large, they change infrequently. Therefore it can be inefficient for the server to send the roster to the client during session establishment if the roster has not changed. This document defines a small modification to the XMPP roster protocol specified in XMPP IM [1] that enables "versioning" of roster information; when the client requests the roster it specifies its latest version, and the server will simply inform the client that it is up to date if the roster has not changed.
The basic model is that if the client request the roster and specifies a version number, the server returns an empty IQ-result. If the roster has changed, the server sends numbered roster pushes for each roster item that has been touched in any way since the version specified by the client. The client processes each roster push as it normally would, incrementing its local version number with each roster push.
Note: This document describes a protocol or best practice that is intended for incorporation into the specification that will supersede RFC 3921 [2] within the Internet Standards Process, i.e., rfc3921bis [3]. This document is provided only for the purpose of open community discussion of the potential modification and will be obsoleted as soon as the relevant RFC is published.
This document adds a new 'ver' attribute to the <query/> element qualified by the 'jabber:iq:roster' namespace, defined as follows:
Definition: The 'ver' attribute is a strictly increasing sequence number that is increased (but not necessarily incremented-by-one) with any modification to the roster data. The value of the attribute MUST be a non-negative 64-bit integer, MUST be changed only by the server, and MUST be treated by the client as opaque. The server MUST ensure that each change to the roster data will result in a different sequence number and that the sequence number associated with a given roster modification will be greater than the sequence number associated with any previous roster modification. (Note: This rule effectively disallows the use of the system clock as a sequence number, since if the system time changes, e.g. because of an adjustment based on an NTP RFC 958 [4] update, the next generated value might be less than the previous one.)
For purposes of this specification, a "roster modification" is any change to the roster data that would result in a roster push to a connected client. Therefore internal states related to roster processing within the server that do not result in a roster push do not necessitate a change to the sequence number. If a series of roster modifications result in a roster item that does not differ from the version cached by the client (e.g., a change to the item's 'name' attribute and then a change back to the original value), the server MUST consider the item to have been changed and MUST send the item to the client (typically via a roster push).
If a client supports roster versioning, it SHOULD include the 'ver' element in its request for the roster, where the 'ver' attribute is set to the sequence number associated with its last cache of the roster.
C: <iq from='romeo@montague.lit/home' id='r1h3vzp7' to='romeo@montague.lit' type='get'> <query xmlns='jabber:iq:roster' ver='299'/> </iq>
If the client has not yet cached the roster or the cache is lost or corrupted, but the client wishes to bootstrap the use of roster versioning, it MUST set the 'ver' attribute to a value of zero (0).
Naturally, if the client does not support roster versioning or does not wish to bootstrap the use of roster versioning, it will behave like an RFC-3921-compliant client by not including the 'ver' attribute.
Whether or not the roster has changed since the version enumerated by the client, the server MUST either return the complete roster as described in RFC 3921 or return an empty IQ-result (thus indicating that roster changes will be sent via roster pushes, as described below). In general, unless returning the complete roster would use less bandwidth than sending individual roster pushes to the client (e.g., if the roster contains only a few items), the server SHOULD send an empty IQ-result and then send the modifications via roster pushes.
S: <iq from='romeo@montague.lit' id='r1h3vzp7' to='romeo@montague.lit/home' type='result'/>
Note: This empty IQ-result is different from an empty <query/>, thus disambiguating this usage from an empty roster.
If the roster has not changed since the version enumerated by the client, the server will simply not send any roster pushes to the client (until and unless some relevant event triggers a push during the lifetime of the client's session).
If the roster has changed since the version enumerated by the client, the server MUST then send one roster push to the client for each roster item that has been modified since the version enumerated by the client.
S: <iq from='romeo@montague.lit' id='ah382g67' to='romeo@montague.lit/home' type='set'> <query xmlns='jabber:iq:roster' ver='303'> <item jid='shylock@shakespeare.lit' subscription='remove'/> </query> </iq> S: <iq from='romeo@montague.lit' id='b2gs90j5' to='romeo@montague.lit/home' type='set'> <query xmlns='jabber:iq:roster' ver='307'> <item jid='bill@shakespeare.lit' subscription='both'/> </query> </iq> S: <iq from='romeo@montague.lit' id='c73gs419' to='romeo@montague.lit/home' type='set'> <query xmlns='jabber:iq:roster' ver='311'> <item jid='nurse@shakespeare.lit' name='Nurse' subscription='to'> <group>Servants</group> </item> </query> </iq> S: <iq from='romeo@montague.lit' id='dh361f35' to='romeo@montague.lit/home' type='set'> <query xmlns='jabber:iq:roster' ver='315'> <item jid='juliet@shakespeare.lit' name='Juliet' subscription='both'> <group>Friends</group> </item> </query> </iq>
These "interim roster pushes" can be understood as follows:
The client MUST handle an "interim roster push" in the same way it handles any roster push (indeed, from the client's perspective it cannot tell the difference between an "interim" roster push and a "live" roster push). If the client's session ends before it receives all of the interim roster pushes, when requesting the roster after reconnection it SHOULD request the version associated with the last roster push it received, not the version associated with the last roster result it received.
When roster versioning is enabled, the server MUST include the updated roster version number with each roster push. Roster pushes MUST occur in sequence order and the version number contained in a roster push MUST be unique.
This section provides a detailed scenario that illustrates the use of roster versioning. In this example the client gets disconnected before it the server has had a chance to send all of its roster pushes, but this is immaterial to the synchronization process.
C: <iq from='romeo@montague.lit/home' id='r1h3vzp7' to='romeo@montague.lit' type='get'> <query xmlns='jabber:iq:roster' ver='299'/> </iq> S: <iq from='romeo@montague.lit' id='r1h3vzp7' to='romeo@montague.lit/home' type='result'/> S: <iq from='romeo@montague.lit' id='ah382g67' to='romeo@montague.lit/home' type='set'> <query xmlns='jabber:iq:roster' ver='303'> <item jid='shylock@shakespeare.lit' subscription='remove'/> </query> </iq> S: <iq from='romeo@montague.lit' id='b2gs90j5' to='romeo@montague.lit/home' type='set'> <query xmlns='jabber:iq:roster' ver='307'> <item jid='bill@shakespeare.lit' subscription='both'/> </query> </iq> S: </stream:stream> [ reconnection ] C: <iq from='romeo@montague.lit/home' id='r2xa7gf9' to='romeo@montague.lit' type='get'> <query xmlns='jabber:iq:roster' ver='307'/> </iq> S: <iq from='romeo@montague.lit' id='r2xa7gf9' to='romeo@montague.lit/home' type='result'/> S: <iq from='romeo@montague.lit' id='c73gs419' to='romeo@montague.lit/home' type='set'> <query xmlns='jabber:iq:roster' ver='311'> <item jid='nurse@shakespeare.lit' name='Nurse' subscription='to'> <group>Servants</group> </item> </query> </iq> S: <iq from='romeo@montague.lit' id='dh361f35' to='romeo@montague.lit/home' type='set'> <query xmlns='jabber:iq:roster' ver='315'> <item jid='juliet@shakespeare.lit' name='Juliet' subscription='both'> <group>Friends</group> </item> </query> </iq>
If a server supports roster versioning, it MUST inform the connecting entity when returning stream features during the stream negotiation process; at the latest, when informing a client that resource binding is required. This is done by including a <ver/> element qualified by the 'urn:xmpp:features:rosterver' namespace.
<stream:features> <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'> <required/> </bind> <ver xmlns='urn:xmpp:features:rosterver'> <optional/> </ver> </stream:features>
It is possible that client-side caching of roster information (rather than holding them in memory only for the life of the session) could introduce new vulnerabilities, such as misuse by malware. Implementations are advised to appropriately protect cached roster data.
This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [5].
Until this specification advances to a status of Draft, the associated namespace for its stream feature shall be "urn:xmpp:features:rosterver". Upon advancement of this specification, the XMPP Registrar [6] shall issue a permanent namespace in accordance with the process defined in Section 4 of XMPP Registrar Function [7]; the requested namespace is "urn:xmpp:seq", which is thought to be unique per the XMPP Registrar's requirements.
This specification proposes addition of the 'ver' attribute to the schema for the 'jabber:iq:roster' namespace.
Thanks to Dave Cridland, Richard Dobson, Leonid Evdokimov, Fabio Forno, Alexander Gnauck, Juha Hartikainen, Joe Hildebrand, Justin Karneges, Sachin Khandelwal, Curtis King, Pedro Melo, Matthew Wild, and Jiří Zárevúcký for their comments. The definition of a sequence number borrows concepts and text from RFC 4551 [8]
Series: XEP
Number: 0237
Publisher: XMPP Standards Foundation
Status:
Proposed
Type:
Standards Track
Version: 0.7
Last Updated: 2009-04-17
Approving Body: XMPP Council
Dependencies: XMPP Core, XMPP IM
Supersedes: None
Superseded By: None
Short Name: N/A
Source Control:
HTML
RSS
JabberID:
stpeter@jabber.org
URI:
https://stpeter.im/
The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.
The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.
Discussion on other xmpp.org discussion lists might also be appropriate; see <http://xmpp.org/about/discuss.shtml> for a complete list.
Errata may be sent to <editor@xmpp.org>.
The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".
1. RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://tools.ietf.org/html/rfc3921>.
2. RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://tools.ietf.org/html/rfc3921>.
3. rfc3921bis: proposed revisions to Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://tools.ietf.org/html/draft-saintandre-rfc3921bis>. (work in progress)
4. RFC 958: Network Time Protocol (NTP) <http://tools.ietf.org/html/rfc0958>.
5. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.
6. The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see <http://xmpp.org/registrar/>.
7. XEP-0053: XMPP Registrar Function <http://xmpp.org/extensions/xep-0053.html>.
8. RFC 4551: IMAP Extension for Conditional STORE Operation or Quick Flag Changes Resynchronization <http://tools.ietf.org/html/rfc4551>.
Modified the underlying model per list consensus; added more detailed scenarios to illustrate usage.
(psa)Clarified definition of sequence number.
(psa)Reverted to a roster-specific method and modified presentation to enable incorporation into rfc3921bis.
(psa)Defined new namespace and generalized to handle service discovery and other use cases in addition to rosters.
(psa)Defined protocol solely in terms of full rosters and roster pushes (no more roster diffs); added implementation notes; clarified server behavior if cached version is unavailable.
(psa)Renamed to data sequencing; clarified server behavior.
(psa)Initial published version; per Council consensus, removed optionality regarding semantics of the version attribute.
(psa)Corrected semantics of version attribute (should be a strictly increasing sequence number but may be any unique identifier).
(psa)Clarified description of roster diff; added diff attribute and specified its use in roster results; specified use of version attribute in roster pushes.
(psa)First draft.
(psa)END