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-0265.xml 10KB

  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>Out-of-Band Stream Data</title>
  10. <abstract>This specification defines how to send parts of an XML stream over a direct connection between peers. This allows to send large stanzas or binary data without blocking the XML stream for other stanzas.</abstract>
  12. <number>0265</number>
  13. <status>Deferred</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XEP-0166</spec>
  20. <spec>XEP-0260</spec>
  21. </dependencies>
  22. <supersedes/>
  23. <supersededby/>
  24. <shortname>NOT_YET_ASSIGNED</shortname>
  25. &dmeyer;
  26. <revision>
  27. <version>0.1</version>
  28. <date>2009-04-02</date>
  29. <initials>psa</initials>
  30. <remark><p>Initial published version.</p></remark>
  31. </revision>
  32. <revision>
  33. <version>0.0.2</version>
  34. <date>2009-03-30</date>
  35. <initials>dm</initials>
  36. <remark><p>Simplify Example; Restrict Usage; Add abort</p></remark>
  37. </revision>
  38. <revision>
  39. <version>0.0.1</version>
  40. <date>2009-03-08</date>
  41. <initials>dm</initials>
  42. <remark><p>First draft</p></remark>
  43. </revision>
  44. </header>
  45. <section1 topic='Introduction' anchor='intro'>
  46. <p>XMPP uses one XML stream between two peers, either between client and server, between servers, or between clients directly. If a client sends a stanza to a client, either routed over the server or directly, it can not send another stanza at the same time. If an XMPP extension defines very large stanzas, the communication is blocked until this stanza is fully sent to the server. A client or server may also define a maximum stanza size for communication. A future extension to query a remote file server could create such huge stanzas: a directory listing with thousands of photos, each with additional metadata, could produce stanzas of one megabyte or longer. The same is true for TV listings of a remote TV tuner device. Besides text data, a stanza may also contain binary data Base64 encoded. This also increases the stanza size.</p>
  47. <p>This document defines a mechanism to transmit parts of a stanza over a separate end-to-end connection using Jingle. XML data and binary data (without being Base64 encoded) can be transmitted over the external link to keep the actual XML stanza small.</p>
  48. </section1>
  49. <section1 topic='Protocol Flow' anchor='proto'>
  50. <p>If a client wants to send a large stanza to a peer, it can remove large elements from the stanza and replace it with a &lt;oob/&gt; element of the 'urn:xmpp:jingle:apps:out-of-band:0' namespace. The definition of "large" depends on the use case and available bandwidth of the stream to the server. It is RECOMMENDED to send stanzas smaller than 4096 Bytes directly because the overhead of the additional stream is too high. If a client knows in advance that it will send or receive several large stanzas or binary data it SHOULD open the out-of-band data stream. One larger chunk may not be worth opening a Jingle session. A client MUST NOT send In-Band Bytestream stanzas out of band because there may be a reason why it is an In-Band Bytestream and not something else such as SOCKS5.</p>
  51. <p>Before a client sends such a stanza to its peer, it MUST open the out of band stream first. It has to initiate a Jingle session and MUST NOT send the stanza it wants to send until the out-of-band stream is open. The following example is based on 'Discovering the Items Associated with a Jabber Entity' &xep0030;.</p>
  52. <example caption="Requesting All Items"><![CDATA[
  53. <iq from=''
  54. to=''
  55. id='hfgte45w'
  56. type='get'>
  57. <query xmlns=''/>
  58. </iq>
  59. ]]></example>
  60. <p>Normally we would expect the peer to answer with an IQ return stanza with the list of items. But if the listing is very large, the client may decide to send it over an extra stream. Instead of sending the IQ result, it opens a Jingle session.</p>
  61. <example caption="Home Server Initiates Jingle Session"><![CDATA[
  62. <iq from=''
  63. to=''
  64. id='xn28s7gk'
  65. type='set'>
  66. <jingle xmlns='urn:xmpp:jingle:0'>
  67. action='session-initiate'
  68. initiator=''
  69. sid='a73sjjvkla37jfea'>
  70. <content creator='initiator' name='oob'>
  71. <description xmlns='urn:xmpp:jingle:apps:out-of-band:0'/>
  72. <transport xmlns='urn:xmpp:jingle:transports:s5b:0'
  73. sid='vj3hs98y'
  74. mode='tcp'>
  75. <streamhost
  76. jid=''
  77. host=''
  78. port='5086'/>
  79. </transport>
  80. <security xmlns='urn:xmpp:jingle:security:xtls:0'>
  81. <fingerprint>RomeoX509CertificateHash</fingerprint>
  82. <method name='x509'/>
  83. </security>
  84. </content>
  85. </jingle>
  86. </iq>
  87. ]]></example>
  88. <p>The clients open a Jingle session according to &xep0166; with a &xep0260;. For the sake of simplicity this protocol flow is not described here. If the clients opened the Out-of-Band Data Stream, the listing is sent over that stream and a reference is returned in the IQ result of the original request.</p>
  89. <example caption="IQ Result with Out-of-Band Stream Data Reference"><![CDATA[
  90. <iq from=''
  91. to=''
  92. id='hfgte45w'
  93. type='result'>
  94. <oob xmlns='urn:xmpp:jingle:apps:out-of-band:0'
  95. id='hfgte45w-1'
  96. size='6022'
  97. hash='sha1+552da749930852c69ae5d2141d3766b1'
  98. type='text/xml'/>
  99. </iq>
  100. ]]></example>
  101. <p>The receiver MUST replace the &lt;oob/&gt; element with the content with the given id from the Out-of-Band Data Stream. The size and hash arguments are optional, the type MUST be 'text/xml' since an IQ stanza MUST have one child element. The content send out of band MUST have a valid XML header &lt;?xml version='1.0' ?&gt; with one root element. The XML header is ignored and the root element MUST replace the &lt;oob&gt; element.</p>
  102. <p>It is possible to use out of band data everywhere in the XML stream and not only as first element child of the IQ stanza. The XML schema MUST explicit allow the usage of the &lt;oob/&gt; element; it is not possible to replace any arbitrarily part of a stanza with the &lt;oob/&gt; element. The reason for this restriction is to keep implementations simpler if they do not have to expect out of band data everywhere and to keep the stream compliant to the XML schemas.</p>
  103. <p>If the &lt;oob/&gt; element is not the top level child of an IQ or message stanza, the type attribute does not has to be 'text/xml' and may even be omitted. In that case the content with the given id send out of band MUST be treated as if it was embedded in the XML stream using Base64 encoding. This is useful for sending larger chunks of binary data.</p>
  104. </section1>
  105. <section1 topic='Out-of-Band Data Stream' anchor='proto'>
  106. <p>The Out-of-Band Data Stream multiplexes several items into one stream to re-use the stream for several XML elements or binary data without blocking the out-of-band stream with one large item. This avoids negotiating a new Jingle session for each piece of data. The syntax is similar to HTTP 1.1 chunked transfer. Each chunk of data has a one line header with the number of bytes in hex of the data and the content identifier. The last chunk of each piece of content is always a chunk with a length of 0.</p>
  107. <example caption="Stream Data Definition"><![CDATA[
  108. stream = *(chunk | last-chunk)
  109. chunk = chunk-size id CRLF chunk-data CRLF
  110. hexdig-nonzero = %x31-39 ; "1"-"9"
  111. chunk-size = hexdig-nonzero *HEXDIG
  112. id = *(ALPHA | DIGIT)
  113. last-chunk = 1*("0") id CRLF CRLF
  114. ]]></example>
  115. <p>In the given example the &lt;oob/&gt; element specifies that the query result is sent out of band and has a size of 6022 bytes. The out of band content requires a valid XML header which adds another 23 bytes. If each chunk has 4096 bytes (0x1000 in hex) the data is split into two chunks (4096 and 1949 bytes). The following data is sent over the out of band stream:</p>
  116. <example caption="Stream Data with XEP-0030 Items"><![CDATA[
  117. 1000 hfgte45w CRLF
  118. <?xml version='1.0' ?>
  119. <query xmlns=''>
  120. ... 4096 Bytes including the XML header ... CRLF
  121. 79d hfgte45w CRLF
  122. ... Last 1949 Bytes ... CRLF
  123. 0 hfgte45w CRLF CRLF
  124. ]]></example>
  125. </section1>
  126. <section1 topic='Abort Content Sending' anchor='abort'>
  127. <p>If a client is not not interested in the out of band data (anymore) it MAY abort the sending of a content with a given identifier to save bandwidth. This may happen for large binary data and the client was only interested in the first bytes, e.g. to detect the file type and that it can not decode it.</p>
  128. <example caption="Abort Content"><![CDATA[
  129. <iq from=''
  130. to=''
  131. id='hfytewp9'
  132. type='set'>
  133. <abort xmlns='urn:xmpp:jingle:apps:out-of-band:0'
  134. id='hfgte45w'/>
  135. </iq>
  136. ]]></example>
  137. <p>The peer SHOULD send a last chunk with the length of zero out of band and acknowledge the abortion.</p>
  138. <example caption="Acknowledge Abort"><![CDATA[
  139. <iq from=''
  140. to=''
  141. id='hfytewp9'
  142. type='result'/>
  143. ]]></example>
  144. </section1>
  145. <section1 topic='Security Considerations' anchor='security'>
  146. <p>The Jingle session SHOULD include TLS as specified in &xtls;. Even if the peers can not verify each others certificates, the leap of faith approach provides at least the same amount of security as if the data where send inside the XML stream.</p>
  147. </section1>
  148. <section1 topic='IANA Considerations' anchor='iana'>
  149. <p>This document requires no interaction with &IANA;.</p>
  150. </section1>
  151. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  152. <p>XMPP Registrar considerations will be provided in a later version of
  153. this document.</p>
  154. </section1>
  155. <section1 topic='XML Schema' anchor='schema'>
  156. <p>The XML schema will be provided in a later version of this document.</p>
  157. </section1>
  158. </xep>