Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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>In-Band Bytestreams</title>
  10. <abstract>This specification defines an XMPP protocol extension that enables any two entities to establish a one-to-one bytestream between themselves, where the data is broken down into smaller chunks and transported in-band over XMPP.</abstract>
  11. &LEGALNOTICE;
  12. <number>0047</number>
  13. <status>Final</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. </dependencies>
  19. <supersedes/>
  20. <supersededby/>
  21. <shortname>ibb</shortname>
  22. <schemaloc>
  23. <url>http://www.xmpp.org/schemas/ibb.xsd</url>
  24. </schemaloc>
  25. &infiniti;
  26. &stpeter;
  27. <revision>
  28. <version>2.0</version>
  29. <date>2012-06-22</date>
  30. <initials>psa</initials>
  31. <remark><p>Per a vote of the XMPP Council, advanced to Final; in addition, specified that the 'block-size' attribute defines the size of the data chunk before instead of after base64-encoding, to accord with existing implementations.</p></remark>
  32. </revision>
  33. <revision>
  34. <version>1.3</version>
  35. <date>2011-03-01</date>
  36. <initials>psa</initials>
  37. <remark><p>Clarified error handling, block construction, and bytestream closing.</p></remark>
  38. </revision>
  39. <revision>
  40. <version>1.2</version>
  41. <date>2009-03-17</date>
  42. <initials>psa/jk</initials>
  43. <remark><p>Encouraged use of IQ stanzas rather than message stanzas for sending data; clarified bidirectional nature of IBB; more clearly specified data handling, error conditions, XML syntax, and attribute datatypes; added optional stanza attribute as in XEP-0261.</p></remark>
  44. </revision>
  45. <revision>
  46. <version>1.1</version>
  47. <date>2006-11-21</date>
  48. <initials>jk</initials>
  49. <remark><p>Allowed IQ for delivery.</p></remark>
  50. </revision>
  51. <revision>
  52. <version>1.0</version>
  53. <date>2003-12-10</date>
  54. <initials>psa</initials>
  55. <remark><p>Per a vote of the Jabber Council, advanced status to Draft.</p></remark>
  56. </revision>
  57. <revision>
  58. <version>0.8</version>
  59. <date>2003-12-04</date>
  60. <initials>jk</initials>
  61. <remark><p>Add 'block-size' attribute and usage guidelines</p></remark>
  62. </revision>
  63. <revision>
  64. <version>0.7</version>
  65. <date>2003-05-23</date>
  66. <initials>jk</initials>
  67. <remark><p>Use IQ for shutdown, remove XEP-0022 dependency, loop the counter</p></remark>
  68. </revision>
  69. <revision>
  70. <version>0.6</version>
  71. <date>2003-05-14</date>
  72. <initials>jk</initials>
  73. <remark><p>Use message for delivery</p></remark>
  74. </revision>
  75. <revision>
  76. <version>0.5</version>
  77. <date>2003-04-06</date>
  78. <initials>jk</initials>
  79. <remark><p>Changed newseq to prevseq, added acks, changed seq size to 32-bit</p></remark>
  80. </revision>
  81. <revision>
  82. <version>0.4</version>
  83. <date>2003-03-22</date>
  84. <initials>jk</initials>
  85. <remark><p>Changed protocol, added sequence id</p></remark>
  86. </revision>
  87. <revision>
  88. <version>0.3</version>
  89. <date>2002-12-10</date>
  90. <initials>jk</initials>
  91. <remark><p>Removed the 'comment' block, changed namespace</p></remark>
  92. </revision>
  93. <revision>
  94. <version>0.2</version>
  95. <date>2002-10-10</date>
  96. <initials>jk</initials>
  97. <remark><p>Revised the text</p></remark>
  98. </revision>
  99. <revision>
  100. <version>0.1</version>
  101. <date>2002-09-29</date>
  102. <initials>jk</initials>
  103. <remark><p>Initial version.</p></remark>
  104. </revision>
  105. </header>
  106. <section1 topic='Introduction' anchor='intro'>
  107. <p>This document describes In-Band Bytestreams (IBB), an XMPP protocol extension that enables two entities to establish a virtual bytestream over which they can exchange Base64-encoded chunks of data over XMPP itself. Because IBB provides a generic bytestream, its usage is open-ended. To date it has been used as a fallback method for sending files (see &xep0096; and &xep0234;) when out-of-band methods such as &xep0065; are not available. However, IBB could also be useful for any kind of relatively low-bandwidth activity, such as games, shell sessions, or encrypted text.</p>
  108. </section1>
  109. <section1 topic='Protocol' anchor='protocol'>
  110. <p>IBB as specified in this document defines two protocol aspects:</p>
  111. <ol>
  112. <li>How to set up and tear down an IBB session using &lt;open/&gt; and &lt;close/&gt; elements sent within IQ stanzas.</li>
  113. <li>How to send chunks of IBB data using IQ (or message) stanzas containing &lt;data/&gt; elements.</li>
  114. </ol>
  115. <p>Other methods can be used for setup and teardown, such as &xep0166; as specified in &xep0261;.</p>
  116. <section2 topic='Creating a Bytestream' anchor='create'>
  117. <p>In order to set up an in-band bytestream, the initiator sends an IQ stanza of type "set" containing an &lt;open/&gt; element qualified by the 'http://jabber.org/protocol/ibb' namespace. This element possesses three attributes:</p>
  118. <ul>
  119. <li>The REQUIRED 'block-size' attribute defines the maximum size in bytes of each data chunk (which MUST NOT be greater than 65535).</li>
  120. <li>The REQUIRED 'sid' attribute defines a unique session ID for this IBB session (which MUST match the NMTOKEN datatype).</li>
  121. <li>The OPTIONAL 'stanza' attribute defines whether the data will be sent using IQ stanzas or message stanzas (the default value is "iq")</li>
  122. </ul>
  123. <p>Note: It is RECOMMENDED to send IBB data using IQ stanzas instead of message stanzas because IQ stanzas provide feedback to the sender regarding delivery to the recipient).</p>
  124. <example caption='Initiator requests session'><![CDATA[
  125. <iq from='romeo@montague.net/orchard'
  126. id='jn3h8g65'
  127. to='juliet@capulet.com/balcony'
  128. type='set'>
  129. <open xmlns='http://jabber.org/protocol/ibb'
  130. block-size='4096'
  131. sid='i781hf64'
  132. stanza='iq'/>
  133. </iq>
  134. ]]></example>
  135. <p>If the responder wishes to proceed with the IBB session, it returns an IQ-result to the initiator.</p>
  136. <example caption='Responder accepts session'><![CDATA[
  137. <iq from='juliet@capulet.com/balcony'
  138. id='jn3h8g65'
  139. to='romeo@montague.net/orchard'
  140. type='result'/>
  141. ]]></example>
  142. <p>If the responder does not support IBB, it returns a &unavailable; or &feature; error.</p>
  143. <example caption='Responder does not support IBB'><![CDATA[
  144. <iq from='juliet@capulet.com/balcony'
  145. id='jn3h8g65'
  146. to='romeo@montague.net/orchard'
  147. type='error'>
  148. <error type='cancel'>
  149. <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  150. </error>
  151. </iq>
  152. ]]></example>
  153. <p>If the responder supports IBB but would prefer a smaller block-size, it returns a &constraint; error.</p>
  154. <example caption='Responder prefers smaller chunks'><![CDATA[
  155. <iq from='juliet@capulet.com/balcony'
  156. id='jn3h8g65'
  157. to='romeo@montague.net/orchard'
  158. type='error'>
  159. <error type='modify'>
  160. <resource-constraint xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  161. </error>
  162. </iq>
  163. ]]></example>
  164. <p>If the responder supports IBB but does not wish to proceed with the session, it returns a &notacceptable; error.</p>
  165. <example caption='Responder does not wish to proceed'><![CDATA[
  166. <iq from='juliet@capulet.com/balcony'
  167. id='jn3h8g65'
  168. to='romeo@montague.net/orchard'
  169. type='error'>
  170. <error type='cancel'>
  171. <not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  172. </error>
  173. </iq>
  174. ]]></example>
  175. </section2>
  176. <section2 topic='Sending Data' anchor='send'>
  177. <p>If the responder informs the initiator that it wishes to proceed with the session, the initiator can begin to send data over the bytestream (in addition, because the bytestream is bidirectional, the responder can also send data; see the <link url='#bidi'>Bidirectionality</link> section of this document for details).</p>
  178. <p>Each chunk of data is contained in a &lt;data/&gt; element qualified by the 'http://jabber.org/protocol/ibb' namespace. The data element SHOULD be sent in an IQ stanza to enable proper tracking and throttling, but instead MAY be sent in a message stanza. The data to be sent, prior to base64-encoding and prior to any wrapping in XML, MUST NOT be larger than the 'block-size' determined in the bytestream negotiation.</p>
  179. <example caption='Sending data in an IQ stanza'><![CDATA[
  180. <iq from='romeo@montague.net/orchard'
  181. id='kr91n475'
  182. to='juliet@capulet.com/balcony'
  183. type='set'>
  184. <data xmlns='http://jabber.org/protocol/ibb' seq='0' sid='i781hf64'>
  185. qANQR1DBwU4DX7jmYZnncmUQB/9KuKBddzQH+tZ1ZywKK0yHKnq57kWq+RFtQdCJ
  186. WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu
  187. IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P
  188. AQhYlRjNacGcslkhXqNjK5Va4tuOAPy2n1Q8UUrHbUd0g+xJ9Bm0G0LZXyvCWyKH
  189. kuNEHFQiLuCY6Iv0myq6iX6tjuHehZlFSh80b5BVV9tNLwNR5Eqz1klxMhoghJOA
  190. </data>
  191. </iq>
  192. ]]></example>
  193. <p>Each chunk of data is included as the XML character data of the &lt;data/&gt; element after being encoded as Base64 as specified in Section 4 of &rfc4648;. Each block MUST be a valid base64 block with padding at the end if needed.</p>
  194. <p>The &lt;data/&gt; element MUST possess a 'seq' attribute; this is a 16-bit unsigned integer that acts as a counter for data chunks sent in a particular direction within this session. The 'seq' value starts at 0 (zero) for each sender and MUST be incremented for each packet sent by that entity. Thus, the second chunk sent has a 'seq' value of 1, the third chunk has a 'seq' value of 2, and so on. The counter loops at maximum, so that after value 65535 (2<span class='super'>15</span> - 1) the 'seq' MUST start again at 0.</p>
  195. <p>The &lt;data/&gt; element MUST also possess a 'sid' attribute that ties the data chunk to this particular IBB session.</p>
  196. <p>In the case of IQ stanzas, if the packet can be processed then the recipient MUST reply with an IQ stanza of type "result".</p>
  197. <example caption='Acknowledging data received via IQ'><![CDATA[
  198. <iq from='juliet@capulet.com/balcony'
  199. id='kr91n475'
  200. to='romeo@montague.net/orchard'
  201. type='result'/>
  202. ]]></example>
  203. <p>The sender of a data chunk need not wait for these acknowledgements before sending further stanzas. However, it is RECOMMENDED that the sender does wait in order to minimize the potential for rate-limiting penalties or throttling.</p>
  204. <p>It is possible that delivery of the stanza might fail, in which case the sender's or recipient's server shall return an appropriate error:</p>
  205. <ol>
  206. <li>Because the recipient has gone offline, the recipient's server returns a &recipient; error with a type of 'wait'.</li>
  207. <li>Because a server-to-server link has gone down, the sender's server returns a &timeout; error with a type of 'wait'.</li>
  208. </ol>
  209. <p>Upon receiving an error related to delivery of a &MESSAGE; or &IQ; stanza, the sender SHOULD temporarily suspend the stream but either (1) retry sending at a later time or (2) renegotiate the higher-level session (if any) such as a session controlled via &xep0234;.</p>
  210. <p>It is also possible that there is a problem with the data packet itself, in which case the recipient shall return an appropriate error:</p>
  211. <ol>
  212. <li>Because the session ID is unknown, the recipient returns an &notfound; error with a type of 'cancel'.</li>
  213. <li>Because the sequence number has already been used, the recipient returns an &unexpected; error with a type of 'cancel'.</li>
  214. <li>Because the data is not formatted in accordance with Section 4 of <cite>RFC 4648</cite>, the recipient returns a &badrequest; error with a type of 'cancel'.</li>
  215. </ol>
  216. <p>Upon receiving an error related to the data packet, the sender MUST close the bytestream as described under <link url='#close'>Closing the Bytestream</link>.</p>
  217. <p>Data packets MUST be processed in the order they are received. If an out-of-sequence packet is received for a particular direction within a bytestream (determined by checking the 'seq' attribute), then this indicates that a packet has been lost. The recipient MUST NOT process the data of such an out-of-sequence packet, nor any that follow it within the same bytestream; instead, the recipient MUST close the bytestream as described in the next section.</p>
  218. </section2>
  219. <section2 topic='Closing the Bytestream' anchor='close'>
  220. <p>To close the bytestream, either party sends an IQ-set containing a &lt;close/&gt; element.</p>
  221. <example caption='Closing the bytestream'><![CDATA[
  222. <iq from='romeo@montague.net/orchard'
  223. id='us71g45j'
  224. to='juliet@capulet.com/balcony'
  225. type='set'>
  226. <close xmlns='http://jabber.org/protocol/ibb' sid='i781hf64'/>
  227. </iq>
  228. ]]></example>
  229. <p>The receiving party then acknowledges that the bytestream has been closed by returning an IQ-result (however, the receiving party might wait until it has had a chance to send any remaining data in the other direction, if the bytestream is bidirectional; in this case, the party that sent the original &lt;close/&gt; element SHOULD wait to receive the IQ response from the receiving party before considering the bytestream to be closed).</p>
  230. <example caption='Success response'><![CDATA[
  231. <iq from='juliet@capulet.com/balcony'
  232. id='us71g45j'
  233. to='romeo@montague.net/orchard'
  234. type='result'/>
  235. ]]></example>
  236. <p>It is possible that the recipient of the close notification does not know about the bytestream, in which case it would return an &notfound; error.</p>
  237. <example caption='Recipient does not know about the IBB session'><![CDATA[
  238. <iq type='error'
  239. from='juliet@capulet.com/balcony'
  240. to='romeo@montague.net/orchard'
  241. id='us71g45j'>
  242. <error type='cancel'>
  243. <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  244. </error>
  245. </iq>
  246. ]]></example>
  247. <p>In either case, both parties MUST consider the bytestream to be closed.</p>
  248. </section2>
  249. </section1>
  250. <section1 topic='Bidirectionality' anchor='bidi'>
  251. <p>An in-band bytestream is bidirectional. Therefore, either party to the bytestream is allowed to send data. Each sender MUST initialize the 'seq' attribute to zero and increment the 'seq' value by one with each chunk of data it sends. Each recipient MUST track chunks based on the 'seq' values it receives. The 'seq' values in each direction are independent of the values in the other direction. Thus there are two data sequences for each Session ID.</p>
  252. </section1>
  253. <section1 topic='Use of Message Stanzas' anchor='message'>
  254. <p>It is RECOMMENDED to use IQ stanzas when sending data packets. However, an application MAY use message stanzas instead. If message stanzas are used when sending data packets, the sender SHOULD also use &xep0079; or some other stanza flow-control method. For proper tracking of delivery and processing errors related to data packets, the 'id' attribute SHOULD be used with message stanzas.</p>
  255. <example caption='Sending data in a message stanza'><![CDATA[
  256. <message from='romeo@montague.net/orchard'
  257. id='dsw71gj3'
  258. to='juliet@capulet.com/balcony'>
  259. <data xmlns='http://jabber.org/protocol/ibb' seq='0' sid='i781hf64'>
  260. qANQR1DBwU4DX7jmYZnncmUQB/9KuKBddzQH+tZ1ZywKK0yHKnq57kWq+RFtQdCJ
  261. WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu
  262. IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P
  263. AQhYlRjNacGcslkhXqNjK5Va4tuOAPy2n1Q8UUrHbUd0g+xJ9Bm0G0LZXyvCWyKH
  264. kuNEHFQiLuCY6Iv0myq6iX6tjuHehZlFSh80b5BVV9tNLwNR5Eqz1klxMhoghJOA
  265. </data>
  266. </message>
  267. ]]></example>
  268. </section1>
  269. <section1 topic='Usage Guidelines' anchor='usage'>
  270. <ul>
  271. <li>Generally, in-band bytestreams SHOULD be used only as a last resort. <strong>SOCKS5 Bytestreams</strong> will almost always be preferable.</li>
  272. <li>A server MAY rate limit a connection, depending on the size and frequency of data packets.</li>
  273. <li>A server MAY disconnect a connection that sends overly large packets as defined by its local service policy.</li>
  274. <li>It is RECOMMENDED to use a 'block-size' of 4096.</li>
  275. </ul>
  276. </section1>
  277. <section1 topic='Security Considerations' anchor='sec'>
  278. <p>The In-Band Bytestreams protocol is as secure as the underlying XMPP transport. The application that uses IBB could have its own security layer, but this is outside of the scope of IBB.</p>
  279. <p>An entity MUST verify any Base64 data received. An implementation MUST reject (not ignore) any characters that are not explicitly allowed by the Base64 alphabet; this helps to guard against creation of a covert channel that could be used to "leak" information. An implementation MUST NOT break on invalid input and MUST reject any sequence of Base64 characters containing the pad ('=') character if that character is included as something other than the last character of the data (e.g., "=AAA" or "BBBB=CCC"); this helps to guard against buffer overflow attacks and other attacks on the implementation. Base64 encoding visually hides otherwise easily recognized information, such as passwords, but does not provide any computational confidentiality. Base64 encoding MUST follow the definition in Section 4 of RFC 4648.</p>
  280. </section1>
  281. <section1 topic='IANA Considerations' anchor='iana'>
  282. <p>This document requires no interaction with &IANA;.</p>
  283. </section1>
  284. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  285. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  286. <p>The &REGISTRAR; includes 'http://jabber.org/protocol/ibb' in its registry of XML namespaces at &NAMESPACES;.</p>
  287. </section2>
  288. </section1>
  289. <section1 topic='XML Schema' anchor='schema'>
  290. <code><![CDATA[
  291. <?xml version='1.0' encoding='UTF-8'?>
  292. <xs:schema
  293. xmlns:xs='http://www.w3.org/2001/XMLSchema'
  294. targetNamespace='http://jabber.org/protocol/ibb'
  295. xmlns='http://jabber.org/protocol/ibb'
  296. elementFormDefault='qualified'>
  297. <xs:annotation>
  298. <xs:documentation>
  299. The protocol documented by this schema is defined in
  300. XEP-0047: http://www.xmpp.org/extensions/xep-0047.html
  301. </xs:documentation>
  302. </xs:annotation>
  303. <xs:element name='open'>
  304. <xs:complexType>
  305. <xs:simpleContent>
  306. <xs:extension base='empty'>
  307. <xs:attribute name='block-size' type='xs:unsignedShort' use='required'/>
  308. <xs:attribute name='sid' type='xs:NMTOKEN' use='required'/>
  309. <xs:attribute name='stanza' use='optional' default='iq'>
  310. <xs:simpleType>
  311. <xs:restriction base='xs:NCName'>
  312. <xs:enumeration value='iq'/>
  313. <xs:enumeration value='message'/>
  314. </xs:restriction>
  315. </xs:simpleType>
  316. </xs:attribute>
  317. </xs:extension>
  318. </xs:simpleContent>
  319. </xs:complexType>
  320. </xs:element>
  321. <xs:element name='close'>
  322. <xs:complexType>
  323. <xs:simpleContent>
  324. <xs:extension base='empty'>
  325. <xs:attribute name='sid' type='xs:NMTOKEN' use='required'/>
  326. </xs:extension>
  327. </xs:simpleContent>
  328. </xs:complexType>
  329. </xs:element>
  330. <xs:element name='data'>
  331. <xs:complexType>
  332. <xs:simpleContent>
  333. <xs:extension base='xs:string'>
  334. <xs:attribute name='seq' type='xs:unsignedShort' use='required'/>
  335. <xs:attribute name='sid' type='xs:NMTOKEN' use='required'/>
  336. </xs:extension>
  337. </xs:simpleContent>
  338. </xs:complexType>
  339. </xs:element>
  340. <xs:simpleType name='empty'>
  341. <xs:restriction base='xs:string'>
  342. <xs:enumeration value=''/>
  343. </xs:restriction>
  344. </xs:simpleType>
  345. </xs:schema>
  346. ]]></code>
  347. </section1>
  348. <section1 topic='Acknowledgements' anchor='ack'>
  349. <p>Thanks to Sergey Dobrov, Fabio Forno, Todd Herman, Lance Stout, and Matthew Wild for their feedback.</p>
  350. </section1>
  351. </xep>