JEP-0168: Resource Application Priority

This document defines an XMPP presence extension to indicate the priority of XMPP resources for applications other than messaging.


WARNING: Consideration of this JEP has been Deferred by the Jabber Software Foundation. Implementation of the protocol described herein is not recommended.


JEP Information

Status: Deferred
Type: Standards Track
Number: 0168
Version: 0.2
Last Updated: 2005-12-19
JIG: Standards JIG
Approving Body: Jabber Council
Dependencies: XMPP Core, XMPP IM, JEP-0030
Supersedes: None
Superseded By: None
Short Name: rap
Wiki Page: <http://wiki.jabber.org/index.php/Resource Application Priority (JEP-0168)>

Author Information

Peter Saint-Andre

Email: stpeter@jabber.org
JID: stpeter@jabber.org

Joe Hildebrand

Email: jhildebrand@jabber.com
JID: hildjj@jabber.org

Legal Notice

This Jabber Enhancement Proposal is copyright 1999 - 2006 by the Jabber Software Foundation (JSF) and is in full conformance with the JSF's Intellectual Property Rights Policy <http://www.jabber.org/jsf/ipr-policy.shtml>. This material may be distributed only subject to the terms and conditions set forth in the Creative Commons Attribution License (<http://creativecommons.org/licenses/by/2.5/>).

Discussion Venue

The preferred venue for discussion of this document is the Standards-JIG discussion list: <http://mail.jabber.org/mailman/listinfo/standards-jig>.

Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 3920) and XMPP IM (RFC 3921) specifications contributed by the Jabber Software 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 JEP 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.

Conformance Terms

The following 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".


Table of Contents

1. Introduction
2. Service Discovery
3. Application Priority
4. Flagging the Primary Resource for a Given Application Type
5. Requesting RAP Data Via IQ
6. Security Considerations
7. IANA Considerations
8. Jabber Registrar Considerations
8.1. Protocol Namespaces
8.2. Application Types Registry
8.2.1. Process
8.2.2. Initial Registration
9. XML Schemas
9.1. RAP
9.2. RAP Request
Notes
Revision History


1. Introduction

Within the Extensible Messaging and Presence Protocol (XMPP; see RFC 3920 [1]), presence indicates availability for communication -- specifically, communication via XMPP messaging (usually in the form of "instant messaging" or IM as described in RFC 3921 [2]). However, a wide variety of entities might provide XMPP presence, including entities that are not primarily focused on IM (e.g., phones) or even entities that do not support XMPP messaging at all.

Consider a scenario in which a contact wants to initiate a voice chat with a user who has the following three XMPP resources:

Table 1: Application Presence

Resource Messaging Priority Voice Chat Priority
desktop 10 5
pda 5 -1
mobile -1 10

If the contact chooses the resource with which it initiates a voice chat based on the user's default XMPP presence priority (i.e., priority for XMPP messaging), the resulting behavior could be misleading (i.e., initiating the voice chat with the "desktop" resource rather than the "mobile" resource).

What is needed is a way for the user's clients to indicate that the application priority for the three resources is different from the standard XMPP messaging priority. This document defines such a mechanism via an optional XMPP presence extension.

In addition, this document also defines a way for an XMPP server to flag which resource it considers to be primary for any given application type, if it has information -- such as communication preferences -- that can help determine the primary resource.

2. Service Discovery

In order to discover whether a server or other entity supports this protocol, an entity MUST use Service Discovery [3].

Example 1. Entity queries a server regarding protocol support

<iq type='get'
    from='juliet@capulet.com/balcony'
    to='capulet.com'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
  

If the queried entity supports resource application presence, it MUST return a feature of "http://jabber.org/protocol/rap":

Example 2. Server communicates protocol support for RAP

<iq type='result'
    from='capulet.com'
    to='juliet@capulet.com/balcony'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    ...
    <feature var='http://jabber.org/protocol/rap'/>
    ...
  </query>
</iq>
  

If the queried entity supports resource application presence as well as RAP requests (see the Requesting RAP Data Via IQ section of this document), it MUST return features of "http://jabber.org/protocol/rap" and "http://jabber.org/protocol/raprequest":

Example 3. Server communicates protocol support for RAP as well as RAP Request

<iq type='result'
    from='capulet.com'
    to='juliet@capulet.com/balcony'
    id='disco1'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    ...
    <feature var='http://jabber.org/protocol/rap'/>
    <feature var='http://jabber.org/protocol/raprequest'/>
    ...
  </query>
</iq>
  

3. Application Priority

Consider the three resources ("desktop", "pda", and "mobile") mentioned above. The presence stanzas received by a contact for those three resources would be as follows:

Example 4. Contact receives presence from user

<presence from='juliet@capulet.com/desktop' to='romeo@montague.net/home'>
  <priority>10</priority>
  <rap xmlns='http://jabber.org/protocol/rap' app='jingle-audio' num='5'/>
</presence>

<presence from='juliet@capulet.com/pda' to='romeo@montague.net/home'>
  <priority>5</priority>
  <rap xmlns='http://jabber.org/protocol/rap' app='jingle-audio' num='-1'/>
</presence>

<presence from='juliet@capulet.com/mobile' to='romeo@montague.net/home'>
  <priority>-1</priority>
  <rap xmlns='http://jabber.org/protocol/rap' app='jingle-audio' num='10'/>
</presence>
  

(Note: This protocol uses a 'num' attribute rather than a 'priority' attribute to reduce confusion with XMPP presence and also to save some bytes.)

The following business rules apply to resource application presence provided by the client:

  1. A client SHOULD NOT specify resource application presence if the priority for that application is not different from the resource's XMPP messaging priority.
  2. A client MUST NOT generate a <rap/> element that has an 'app' attribute whose value is "im" or that has no 'app' attribute (since the default 'app' is "im").

4. Flagging the Primary Resource for a Given Application Type

The user's server may have special information that enables it to flag a resource as primary for a given application type. For instance, the server may include a communication policy service that enables the user to define (outside the context of any presence priorities) that she would prefer to be called at her "desktop" resource only between the hours of 9:00 AM and 5:00 PM local time, prefer to be called on her mobile at all other times, and so on.

The XML for representing the primary resource related to a specific application type is extremely simple: the server may add a <primary/> child to the relevant RAP element. Here is an example:

Example 5. Primary resource flag

<presence from='juliet@capulet.com/mobile'>
  <priority>-1</priority>
  <rap xmlns='http://jabber.org/protocol/rap' app='jingle-audio' num='10'>
    <primary/>
  </rap>
</presence>
  

The following business rules apply to resource flagging by the server:

  1. A server MAY add the primary resource flag to the presence broadcasts generated by the resource it determines is "most available" for a given application type.
  2. Because the default 'app' is "im", to flag the primary resource for XMPP messaging the server SHOULD NOT include an 'app' attribute, SHOULD NOT include a 'num' attribute, and MUST include a <primary/> child.
  3. An available resource that has specified a negative priority for an application type MUST NOT be flagged as the primary resource for that application type.
  4. A client SHOULD NOT include the primary resource flag in presence stanzas that it generates; however, if a client includes the primary resource flag in a presence stanza, the server SHOULD remove or overwrite the flag.
  5. In response to a presence probe, a server SHOULD send presence from the primary resource first (this enables the receiving client to skip any local most-available algorithms it might implement).
  6. If the primary resource changes, a server MUST push presence (including the primary resource flag) for the new primary resource. If the change in primary resource occurs because of a presence broadcast from the current primary resource, the server MUST push presence from the current primary resource (without the primary resource flag) before pushing presence from the new primary resource (including the primary resource flag).

5. Requesting RAP Data Via IQ

In the interest of saving bandwidth, a server MAY choose to strip all RAP data out of presence stanzas and instead provide RAP data only on request via IQ interactions. (Note: see the Security Considerations section of this document for an important proviso regarding access to RAP data.) A likely scenario is as follows:

  1. Contact's client sends disco#info request to user's client and discovers that user's client supports the 'http://jabber.org/protocol/rap' namespace.
  2. User's client publishes RAP extensions but user's server strips them out in presence broadcasts.
  3. User decides to initiate a non-IM interaction with contact.
  4. Contact's client notices the lack of RAP data from user (despite discovered support) and sends disco#info request to user's server, which signals that it supports the 'http://jabber.org/protocol/raprequest' namespace.
  5. Contact's client sends RAP request to user's bare JID.
  6. If contact is authorized to view user's presence data, user's server returns the latest RAP data for all of the user's resources.

An example protocol flow for the last two steps is as follows...

First, the contact's client requests the user's RAP data by sending a request to the user's bare JID:

Example 6. Contact requests RAP data from user's server

<iq type='get' from='romeo@montague.net/home' to='juliet@capulet.com'>
  <raprequest xmlns='http://jabber.org/protocol/raprequest'/>
</iq>
  

On behalf of the user, the user's server then returns the full <presence/> stanzas (containing RAP data) for each of the user's connected clients:

Example 7. User's server returns RAP data

<iq type='result' from='romeo@montague.net/home' to='juliet@capulet.com'>
  <raprequest xmlns='http://jabber.org/protocol/raprequest'>
    <presence from='juliet@capulet.com/desktop' xmlns='jabber:client'>
      <priority>10</priority>
      <rap xmlns='http://jabber.org/protocol/rap' app='jingle-audio' num='5'/>
    </presence>
    <presence from='juliet@capulet.com/pda' xmlns='jabber:client'>
      <priority>5</priority>
      <rap xmlns='http://jabber.org/protocol/rap' app='jingle-audio' num='-1'/>
    </presence>
    <presence from='juliet@capulet.com/mobile' xmlns='jabber:client'>
      <priority>-1</priority>
      <rap xmlns='http://jabber.org/protocol/rap' app='jingle-audio' num='10'/>
    </presence>
  </raprequest>
</iq>
  

Note: The XML data of the server's response to a RAP request may seem to be potentially confusing, but it is fully consistent with Namespaces in XML [4] as well as the schemas for the 'jabber:client' and 'http://jabber.org/protocol/raprequest' namespaces.

6. Security Considerations

Neither client publishing of resource application priority nor server flagging of the primary resource introduces any known security vulnerabilities or compromises of user privacy.

If a server supports RAP requests, it MUST carefully control access to RAP data in order to guard against presence leaks and directory harvest attacks. Specifically, if the requesting entity is not authorized (e.g., a contact with a presence subscription of "both" or "from" as described in RFC 3921) or is not explicitly trusted (e.g., a server in a trusted network), the server MUST return a <forbidden/> error in response to RAP requests.

7. IANA Considerations

This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [5].

8. Jabber Registrar Considerations

8.1 Protocol Namespaces

The Jabber Registrar [6] shall include the following namespaces in its registry of protocol namespaces:

8.2 Application Types Registry

The Jabber Registrar shall maintain a registry of application types. Although strictly speaking this should not be necessary, it is desirable to maintain a list of "short names" for various application types rather than using long XML namespaces, especially in presence broadcasts. For example, a short name of "jingle-audio" is only 12 characters long, whereas the full XML namespace "http://jabber.org/protocol/jingle/sessions/audio" is 48 characters long. The difference can be quite significant when many presence stanzas are sent.

8.2.1 Process

In order to submit new values to this registry, the registrant must define an XML fragment of the following form and either include it in the relevant Jabber Enhancement Proposal or send it to the email address <registrar@jabber.org>:

<app>
  <name>the value of the 'app' attribute</name>
  <ns>the full namespace associated with the relevant protocol</ns>
  <desc>a natural-language description of the application type</desc>
  <doc>the document in which this application type is specified</doc>
</app>
      

8.2.2 Initial Registration

<app>
  <name>im</name>
  <ns>jabber:client</ns>
  <desc>Standard XMPP messaging</desc>
  <doc>RFC 3921</doc>
</app>

<app>
  <name>jingle-audio</name>
  <ns>http://jabber.org/protocol/jingle/sessions/audio</ns>
  <desc>Jingle audio sessions</desc>
  <doc>JEP-0167</doc>
</app>
      

9. XML Schemas

9.1 RAP

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://jabber.org/protocol/rap'
    xmlns='http://jabber.org/protocol/rap'
    elementFormDefault='qualified'>

  <xs:element name='rap'>
    <xs:complexType>
      <xs:sequence>
        <xs:element name='primary' type='empty' minOccurs='0'/>
      </xs:sequence>
      <xs:attribute name='app' type='xs:nmtoken' default='message'/>
      <xs:attribute name='num' type='xs:byte'/>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name='empty'>
    <xs:restriction base='xs:string'>
      <xs:enumeration value=''/>
    </xs:restriction>
  </xs:simpleType>
</xs:schema>

    

9.2 RAP Request

<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://jabber.org/protocol/raprequest'
    xmlns='http://jabber.org/protocol/raprequest'
    elementFormDefault='qualified'>

  <xs:import namespace='jabber:client'/>

  <xs:element name='raprequest'>
    <xs:complexType>
      <xs:sequence xmlns:xmpp='jabber:client'>
        <xs:element name='xmpp:presence' minOccurs='0'/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

    


Notes

1. RFC 3920: Extensible Messaging and Presence Protocol (XMPP): Core <http://www.ietf.org/rfc/rfc3920.txt>.

2. RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence <http://www.ietf.org/rfc/rfc3921.txt>.

3. JEP-0030: Service Discovery <http://www.jabber.org/jeps/jep-0030.html>.

4. Namespaces in XML <http://www.w3.org/TR/REC-xml-names/>.

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 Jabber Registrar maintains a list of reserved Jabber protocol namespaces as well as registries of parameters used in the context of protocols approved by the Jabber Software Foundation. For further information, see <http://www.jabber.org/registrar/>.


Revision History

Version 0.2 (2005-12-19)

Clarified structure of, and added schema for, RAP request namespace. (psa)

Version 0.1 (2005-12-15)

Initial JEP version. (psa)

Version 0.0.6 (2005-11-29)

Document cleanup. (psa)

Version 0.0.5 (2005-11-17)

Added support for RAP requests via IQ. (psa)

Version 0.0.4 (2005-10-27)

Defined registry of application types; clarified business rules; corrected schema. (psa/jjh)

Version 0.0.3 (2005-10-24)

Broadened previous resource flagging proposal to include priority for applications other than messaging. (psa/jjh)

Version 0.0.2 (2005-09-26)

Added more business rules and examples; defined service discovery guidelines. (psa/jjh)

Version 0.0.1 (2005-09-23)

First draft. (psa/jjh)


END