No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0237.xml 22KB

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Roster Versioning</title>
  10. <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 been modified, thus saving bandwidth during session establishment.</abstract>
  12. <number>0237</number>
  13. <status>Obsolete</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XMPP IM</spec>
  20. </dependencies>
  21. <supersedes/>
  22. <supersededby>
  23. <spec>RFC 6121</spec>
  24. </supersededby>
  25. <shortname>N/A</shortname>
  26. <schemaloc>
  27. <ns>feature</ns>
  28. <url></url>
  29. </schemaloc>
  30. &stpeter;
  31. &dcridland;
  32. <revision>
  33. <version>1.3</version>
  34. <date>2012-02-08</date>
  35. <initials>psa</initials>
  36. <remark><p>Per a vote of the XMPP Council, changed status to Obsolete since roster versioning was folded into RFC 6121.</p></remark>
  37. </revision>
  38. <revision>
  39. <version>1.2</version>
  40. <date>2011-03-16</date>
  41. <initials>psa</initials>
  42. <remark><p>Corrected stream features definition to note that it is always voluntary-to-negotiate.</p></remark>
  43. </revision>
  44. <revision>
  45. <version>1.1</version>
  46. <date>2010-03-05</date>
  47. <initials>psa</initials>
  48. <remark><p>Corrected rules about when to include the ver attribute.</p></remark>
  49. </revision>
  50. <revision>
  51. <version>1.0</version>
  52. <date>2009-05-27</date>
  53. <initials>psa</initials>
  54. <remark><p>Per a vote of the XMPP Council, advanced specification to Draft.</p></remark>
  55. </revision>
  56. <revision>
  57. <version>0.12</version>
  58. <date>2009-05-14</date>
  59. <initials>psa</initials>
  60. <remark><p>Moved information about sending pushes to non-normative implementation guidelines; modified examples to reduce confusion.</p></remark>
  61. </revision>
  62. <revision>
  63. <version>0.11</version>
  64. <date>2009-04-30</date>
  65. <initials>dc/psa</initials>
  66. <remark><p>Added implementation guidelines.</p></remark>
  67. </revision>
  68. <revision>
  69. <version>0.10</version>
  70. <date>2009-04-27</date>
  71. <initials>psa</initials>
  72. <remark><p>Modified ver attribute to be an opaque identifier instead of (necessarily) a strictly-increasing sequence number; specified that an empty version ID indicates that the client wishes to bootstrap the use of roster versioning.</p></remark>
  73. </revision>
  74. <revision>
  75. <version>0.9</version>
  76. <date>2009-04-22</date>
  77. <initials>psa</initials>
  78. <remark><p>Further clarified several implementation notes.</p></remark>
  79. </revision>
  80. <revision>
  81. <version>0.8</version>
  82. <date>2009-04-20</date>
  83. <initials>psa</initials>
  84. <remark><p>Defined schema for stream feature; adjusted some wording for improved clarity.</p></remark>
  85. </revision>
  86. <revision>
  87. <version>0.7</version>
  88. <date>2009-04-17</date>
  89. <initials>psa</initials>
  90. <remark><p>Modified the underlying model per list consensus; added more detailed scenarios to illustrate usage.</p></remark>
  91. </revision>
  92. <revision>
  93. <version>0.6</version>
  94. <date>2009-03-31</date>
  95. <initials>psa</initials>
  96. <remark><p>Clarified definition of ver attribute.</p></remark>
  97. </revision>
  98. <revision>
  99. <version>0.5</version>
  100. <date>2009-02-19</date>
  101. <initials>psa</initials>
  102. <remark><p>Reverted to a roster-specific method and modified presentation to enable incorporation into the revisions to RFC 3921.</p></remark>
  103. </revision>
  104. <revision>
  105. <version>0.4</version>
  106. <date>2008-09-17</date>
  107. <initials>psa</initials>
  108. <remark><p>Defined new namespace and generalized to handle service discovery and other use cases in addition to rosters.</p></remark>
  109. </revision>
  110. <revision>
  111. <version>0.3</version>
  112. <date>2008-04-21</date>
  113. <initials>psa</initials>
  114. <remark><p>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.</p></remark>
  115. </revision>
  116. <revision>
  117. <version>0.2</version>
  118. <date>2008-03-06</date>
  119. <initials>psa</initials>
  120. <remark><p>Renamed to data sequencing; clarified server behavior.</p></remark>
  121. </revision>
  122. <revision>
  123. <version>0.1</version>
  124. <date>2008-03-05</date>
  125. <initials>psa</initials>
  126. <remark><p>Initial published version; per Council consensus, removed optionality regarding semantics of the version attribute.</p></remark>
  127. </revision>
  128. <revision>
  129. <version>0.0.3</version>
  130. <date>2008-03-05</date>
  131. <initials>psa</initials>
  132. <remark><p>Corrected semantics of version attribute (should be a strictly increasing sequence number but may be any unique identifier).</p></remark>
  133. </revision>
  134. <revision>
  135. <version>0.0.2</version>
  136. <date>2008-03-04</date>
  137. <initials>psa</initials>
  138. <remark><p>Clarified description of roster diff; added diff attribute and specified its use in roster results; specified use of version attribute in roster pushes.</p></remark>
  139. </revision>
  140. <revision>
  141. <version>0.0.1</version>
  142. <date>2008-03-04</date>
  143. <initials>psa</initials>
  144. <remark><p>First draft.</p></remark>
  145. </revision>
  146. </header>
  147. <section1 topic='Introduction' anchor='intro'>
  148. <p>Although XMPP rosters can become quite large, they tend to 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 been modified. This document defines a small modification to the XMPP roster protocol specified in &xmppim; that enables "versioning" of roster information.</p>
  149. <p>The basic model is that if the client specifies a version ID when it requests the roster, the server returns an empty IQ-result. If the roster has been modified, the server sends versioned 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, modifying its local version ID with each roster push it receives. This enables the client to receive only the items that have been modified, not the entire roster.</p>
  150. <p>Note: The protocol described herein has been incorporated into &rfc6121;.</p>
  151. </section1>
  152. <section1 topic='Protocol' anchor='proto'>
  153. <section2 topic='Stream Feature' anchor='feature'>
  154. <p>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 &lt;ver/&gt; element qualified by the 'urn:xmpp:features:rosterver' namespace.</p>
  155. <example caption="Stream features"><![CDATA[
  156. <stream:features>
  157. <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
  158. <required/>
  159. </bind>
  160. <ver xmlns='urn:xmpp:features:rosterver'/>
  161. </stream:features>
  162. ]]></example>
  163. <p>The roster versioning stream feature is merely informative and therefore is never mandatory-to-negotiate.</p>
  164. </section2>
  165. <section2 topic='Data Format' anchor='format'>
  166. <p>This document adds a new 'ver' attribute to the &QUERY; element qualified by the 'jabber:iq:roster' namespace, defined as follows.</p>
  167. <p class='def'><strong>Definition:</strong> The <strong>'ver' attribute</strong> is a string that identifies a particular version of the roster information. The value MUST be generated only by the server and MUST be treated by the client as opaque. The server can use any appropriate method for generating the version ID, such as a hash of the roster data or a strictly-increasing sequence number.</p>
  168. </section2>
  169. <section2 topic='Client Request' anchor='request'>
  170. <p>If a client supports roster versioning and the server to which it has connected advertises support for roster versioning as described under <link url='#feature'>Stream Feature</link>, then the client MUST include the 'ver' element in its request for the roster. If the server does not advertise support for roster versioning, the client MUST NOT include the 'ver' attribute. If the client includes the 'ver' attribute in its roster get, it sets the attribute's value to the version ID associated with its last cache of the roster.</p>
  171. <example caption="Roster get with version ID"><![CDATA[
  172. C: <iq from='romeo@montague.lit/home' id='r1h3vzp7' to='romeo@montague.lit' type='get'>
  173. <query xmlns='jabber:iq:roster' ver='ver14'/>
  174. </iq>
  175. ]]></example>
  176. <p>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 the empty string (i.e., <strong>ver=""</strong>).</p>
  177. <p>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.</p>
  178. </section2>
  179. <section2 topic='Server Response' anchor='response-result'>
  180. <p>Whether or not the roster has been modified since the version ID enumerated by the client, the server MUST either return the complete roster as described in RFC 3921 (including a 'ver' attribute that signals the latest version) or return an empty IQ-result (thus indicating that any roster modifications will be sent via roster pushes, as described below). In general, unless returning the complete roster would (1) use less bandwidth than sending individual roster pushes to the client (e.g., if the roster contains only a few items) or (2) the server cannot associate the version ID with any previous version it has on file, the server SHOULD send an empty IQ-result and then send the modifications (if any) via roster pushes.</p>
  181. <example caption="Empty roster result"><![CDATA[
  182. S: <iq from='romeo@montague.lit' id='r1h3vzp7' to='romeo@montague.lit/home' type='result'/>
  183. ]]></example>
  184. <p>Note: This empty IQ-result is different from an empty &QUERY;, thus disambiguating this usage from an empty roster.</p>
  185. <p>If the roster has not been modified since the version ID enumerated by the client, the server will simply not send any roster pushes to the client (until and unless some relevant event triggers a roster push during the lifetime of the client's session).</p>
  186. <p>If the roster has been modified since the version ID 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 ID enumerated by the client. (We call a roster push that is sent for purposes of roster version synchronization an "interim roster push".)</p>
  187. <p class='def'><strong>Definition:</strong> A <strong>"roster modification"</strong> is any modification 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 would not result in a roster push to a connected client do not necessitate a change to the version.</p>
  188. <example caption="Roster pushes"><![CDATA[
  189. S: <iq from='romeo@montague.lit' id='ah382g67' to='romeo@montague.lit/home' type='set'>
  190. <query xmlns='jabber:iq:roster' ver='ver34'>
  191. <item jid='tybalt@shakespeare.lit' subscription='remove'/>
  192. </query>
  193. </iq>
  194. S: <iq from='romeo@montague.lit' id='b2gs90j5' to='romeo@montague.lit/home' type='set'>
  195. <query xmlns='jabber:iq:roster' ver='ver42'>
  196. <item jid='bill@shakespeare.lit' subscription='both'/>
  197. </query>
  198. </iq>
  199. S: <iq from='romeo@montague.lit' id='c73gs419' to='romeo@montague.lit/home' type='set'>
  200. <query xmlns='jabber:iq:roster' ver='ver72'>
  201. <item jid='nurse@shakespeare.lit' name='Nurse' subscription='to'>
  202. <group>Servants</group>
  203. </item>
  204. </query>
  205. </iq>
  206. S: <iq from='romeo@montague.lit' id='dh361f35' to='romeo@montague.lit/home' type='set'>
  207. <query xmlns='jabber:iq:roster' ver='ver96'>
  208. <item jid='juliet@shakespeare.lit' name='Juliet' subscription='both'>
  209. <group>VIPs</group>
  210. </item>
  211. </query>
  212. </iq>
  213. ]]></example>
  214. <p>These "interim roster pushes" can be understood as follows:</p>
  215. <ol>
  216. <li>Imagine that the client had an active presence session for the entire time between its cached roster version (say, "ver14") and the new roster version (say, "ver96").</li>
  217. <li>During that time, the client might have received roster pushes related to various roster versions. However, some of those roster pushes might have contained intermediate updates to the same roster item (e.g., modifications to the subscription state for bill@shakespeare.lit from "none" to "to" and from "to" to "both").</li>
  218. <li>The interim roster pushes would not include all of the intermediate steps, only the final result of all modifications applied to each item while the client was in fact offline (say, "ver34", "ver42", "ver72", and "ver96").</li>
  219. </ol>
  220. <p>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 <em>push</em> it received during the session that was disconnected, not the version associated with the roster <em>result</em> it received at the start of the session that was disconnected.</p>
  221. <p>When roster versioning is enabled, the server MUST include the updated roster version with each roster push. Roster pushes MUST occur in order of modification and the version contained in a roster push MUST be unique.</p>
  222. </section2>
  223. </section1>
  224. <section1 topic='Examples' anchor='examples'>
  225. <p>This section provides a detailed scenario that illustrates the use of roster versioning. In this example the client gets disconnected before the server has had a chance to send all of its roster pushes, but this is immaterial to the synchronization process.</p>
  226. <example caption="The roster synchronization process"><![CDATA[
  227. C: <iq from='romeo@montague.lit/home' id='r1h3vzp7' to='romeo@montague.lit' type='get'>
  228. <query xmlns='jabber:iq:roster' ver='ver14'/>
  229. </iq>
  230. S: <iq from='romeo@montague.lit' id='r1h3vzp7' to='romeo@montague.lit/home' type='result'/>
  231. S: <iq from='romeo@montague.lit' id='ah382g67' to='romeo@montague.lit/home' type='set'>
  232. <query xmlns='jabber:iq:roster' ver='ver34'>
  233. <item jid='tybalt@shakespeare.lit' subscription='remove'/>
  234. </query>
  235. </iq>
  236. S: <iq from='romeo@montague.lit' id='b2gs90j5' to='romeo@montague.lit/home' type='set'>
  237. <query xmlns='jabber:iq:roster' ver='ver42'>
  238. <item jid='bill@shakespeare.lit' subscription='both'/>
  239. </query>
  240. </iq>
  241. S: </stream:stream>
  242. [ reconnection ]
  243. C: <iq from='romeo@montague.lit/home' id='r2xa7gf9' to='romeo@montague.lit' type='get'>
  244. <query xmlns='jabber:iq:roster' ver='ver42'/>
  245. </iq>
  246. S: <iq from='romeo@montague.lit' id='r2xa7gf9' to='romeo@montague.lit/home' type='result'/>
  247. S: <iq from='romeo@montague.lit' id='c73gs419' to='romeo@montague.lit/home' type='set'>
  248. <query xmlns='jabber:iq:roster' ver='ver72'>
  249. <item jid='nurse@shakespeare.lit' name='Nurse' subscription='to'>
  250. <group>Servants</group>
  251. </item>
  252. </query>
  253. </iq>
  254. S: <iq from='romeo@montague.lit' id='dh361f35' to='romeo@montague.lit/home' type='set'>
  255. <query xmlns='jabber:iq:roster' ver='ver96'>
  256. <item jid='juliet@shakespeare.lit' name='Juliet' subscription='both'>
  257. <group>VIPs</group>
  258. </item>
  259. </query>
  260. </iq>
  261. ]]></example>
  262. </section1>
  263. <section1 topic='Implementation Guidelines' anchor='impl'>
  264. <p>This specification is specifically designed to allow for a wide range of implementation choices. These range from highly simplistic but inefficient, to very efficient but quite complex.</p>
  265. <p>This section provides suggestions, rather than instructions, on some lightweight approaches to conforming with the specification.</p>
  266. <section2 topic='Syntactic Conformance' anchor='impl-syntactic'>
  267. <p>A server can conform to this specification by accepting and ignoring the 'ver' attribute in requests, and providing an empty 'ver' attribute in each roster push.</p>
  268. <p>This provides no efficiency savings for clients.</p>
  269. </section2>
  270. <section2 topic='Exact-Match Conformance' anchor='impl-exactmatch'>
  271. <p>Using some digest (hash) of the roster, a server can identify unchanged rosters, and handle the case where the client sends a ver corresponding to the current roster state.</p>
  272. <p>This will account for the majority of cases, and represents a substantial saving. Server implementors are advised to canonicalize the form and ordering of roster items prior to applying the hash function. This hash function need not be cryptographically secure, merely resistent to collisions, and it is advisable to pick one that is fast to compute.</p>
  273. <p>No additional data need be stored, although storing the current hash will yield some performance advantage. This strategy is thought to be relatively safe in the face of data loss on the server.</p>
  274. </section2>
  275. <section2 topic='Add-Only Conformance' anchor='impl-addonly'>
  276. <p>Using a strictly increasing sequence for the 'ver' attribute, a server can "stamp" each roster item with its last change, and the roster as a whole with its last deletion. The server returns either the entire roster -- if a deletion has occured since the client's ver value -- or those changed items.</p>
  277. <p>Deletions are thought to be rare compared to additions and modifications, and as such this approach captures almost all changes. The additional storage cost is also low.</p>
  278. <p>Implementors could combine this strategy with the previous one, detecting a sequence of modifications yielding the same roster as the client has cached already, by constructing a ver attribute containing both a hash and sequence value. This might provide some resilience in the case of data loss.</p>
  279. <p>Implementors are advised that a pure timestamp is not suitable for this approach, since under some circumstances system clocks can go backwards (e.g., because of an adjustment based on an update triggered by use of the Network Time Protocol as described in &rfc0958;).</p>
  280. </section2>
  281. <section2 topic='Sending Pushes' anchor='impl-push'>
  282. <p>There are two primary approaches to server-side generation of the 'ver' attribute: complete roster hashes and strictly increasing sequence numbers. Whether the server will send roster pushes varies depending on the approach taken. For instance, 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 modification to the item's 'name' attribute and then a modification back to the original value), then a server that implements the "complete roster hashes" approach would not consider the item to have been modified for purposes of roster versioning and therefore would not push the item to the client in an interim roster push; however, a server that implements the "strictly increasing sequence numbers" approach would send a roster push in this situtation.</p>
  283. </section2>
  284. <section2 topic='Client Implementation Guidelines' anchor='impl-client'>
  285. <p>Client implementors are reminded that the value of the 'ver' attribute is entirely opaque, and they should behave identically with each strategy described above by simply conforming to the specification. The only storage requirement for this specification is the last seen 'ver' attribute.</p>
  286. </section2>
  287. </section1>
  288. <section1 topic='Security Considerations' anchor='security'>
  289. <p>It is possible that client-side caching of roster information across sessions (rather than holding them in memory only for the life of a session) could introduce new vulnerabilities, such as misuse by malware. Implementations are advised to appropriately protect cached roster data.</p>
  290. </section1>
  291. <section1 topic='IANA Considerations' anchor='iana'>
  292. <p>This document requires no interaction with &IANA;.</p>
  293. </section1>
  294. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  295. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  296. <p>This specification defines the following XML namespace:</p>
  297. <ul>
  298. <li>urn:xmpp:features:rosterver</li>
  299. </ul>
  300. <p>Upon advancement of this specification from a status of Experimental to a status of Draft, the &REGISTRAR; shall add the foregoing namespace to the registry located at &STREAMFEATURES;, as described in Section 4 of &xep0053;.</p>
  301. </section2>
  302. </section1>
  303. <section1 topic='XML Schemas' anchor='schemas'>
  304. <section2 topic='jabber:iq:roster' anchor='schemas-roster'>
  305. <p>This specification proposes addition of the 'ver' attribute to the schema for the 'jabber:iq:roster' namespace.</p>
  306. </section2>
  307. <section2 topic='Stream Feature' anchor='schemas-feature'>
  308. <code><![CDATA[
  309. <?xml version='1.0' encoding='UTF-8'?>
  310. <xs:schema
  311. xmlns:xs=''
  312. targetNamespace='urn:xmpp:features:rosterver'
  313. xmlns='urn:xmpp:features:rosterver'
  314. elementFormDefault='qualified'>
  315. <xs:annotation>
  316. <xs:documentation>
  317. The protocol documented by this schema is defined in
  318. RFC 6121:
  319. </xs:documentation>
  320. </xs:annotation>
  321. <xs:element name='ver' type='empty'/>
  322. <xs:simpleType name='empty'>
  323. <xs:restriction base='xs:string'>
  324. <xs:enumeration value=''/>
  325. </xs:restriction>
  326. </xs:simpleType>
  327. </xs:schema>
  328. ]]></code>
  329. </section2>
  330. </section1>
  331. <section1 topic='Acknowledgements' anchor='ack'>
  332. <p>Thanks to Dave Cridland, Richard Dobson, Leonid Evdokimov, Fabio Forno, Alexander Gnauck, Juha Hartikainen, Joe Hildebrand, Waqas Hussain, Justin Karneges, Sachin Khandelwal, Curtis King, Jonas Lindberg, Pedro Melo, Matthew Wild, Jiří Zárevúcký, and Florian Zeitz for their comments.</p>
  333. </section1>
  334. </xep>