1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-11-22 01:02:17 -05:00
git-svn-id: file:///home/ksmith/gitmigration/svn/xmpp/trunk@2759 4b5297f7-1745-476d-ba37-a9c6900126ab
This commit is contained in:
Peter Saint-Andre 2009-02-20 02:39:18 +00:00
parent db189d4f5b
commit 69f94b5bcd

View File

@ -6,7 +6,7 @@
<?xml-stylesheet type='text/xsl' href='xep.xsl'?> <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep> <xep>
<header> <header>
<title>In-Band Bytestreams (IBB)</title> <title>In-Band Bytestreams</title>
<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> <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>
&LEGALNOTICE; &LEGALNOTICE;
<number>0047</number> <number>0047</number>
@ -26,10 +26,10 @@
&infiniti; &infiniti;
&stpeter; &stpeter;
<revision> <revision>
<version>1.2rc1</version> <version>1.2rc2</version>
<date>in progress, last updated 2009-02-18</date> <date>in progress, last updated 2009-02-19</date>
<initials>psa/jk</initials> <initials>psa/jk</initials>
<remark>Encouraged use of IQ stanzas rather than message stanzas for sending data; clarified bidirectional nature of IBB.</remark> <remark>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.</remark>
</revision> </revision>
<revision> <revision>
<version>1.1</version> <version>1.1</version>
@ -93,55 +93,80 @@
</revision> </revision>
</header> </header>
<section1 topic='Introduction'> <section1 topic='Introduction' anchor='intro'>
<p>This document describes In-Band Bytestreams (or IBB), a reliable bytestream protocol between two Jabber entities over a Jabber XML stream. The basic idea is that binary data is encoded as Base64 and transferred over the Jabber network.</p> <p>This document describes In-Band Bytestreams (IBB), a simple 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, so its usage is open-ended. To date it has been used as a fallback method for sending files 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 communication.</p>
</section1> </section1>
<section1 topic='Uses'> <section1 topic='Protocol' anchor='protocol'>
<p>IBB is a generic bytestream, and so its usage is left open-ended. It is likely to be useful for sending small payloads, such as files that would otherwise be too cumbersome to send as an instant message (such as a text file) or impossible to send (such as a small binary image file). It could also be useful for any kind of low-bandwidth activity, such as a chess game or a shell session. And, while it is mostly intended as a fallback in situations where a &xep0065; is unavailable, IBB could be more desirable for many of the simple bytestream use-cases that do not have high bandwidth requirements.</p> <p>IBB as specified in this document defines two protocol aspects:</p>
</section1> <ol>
<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>
<section1 topic='Protocol'> <li>How to send chunks of IBB data using IQ or message stanzas containing &lt;data/&gt; elements.</li>
<section2 topic='Creating a Bytestream'> </ol>
<example caption='Initiation of interaction'><![CDATA[ <p>Other methods can be used for setup and teardown, such as &xep0166; as specified in &xep0261;.</p>
<iq type='set' <section2 topic='Creating a Bytestream' anchor='create'>
from='romeo@montague.net/orchard' <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 two attributes: 'block-size' defines the maximum size in bytes of each data chunk (which SHOULD NOT be greater than 65535) and 'sid' defines a unique session ID for this IBB session (which SHOULD math the NMTOKEN datatype).</p>
<example caption='Initiator requests session'><![CDATA[
<iq from='romeo@montague.net/orchard'
id='jn3h8g65'
to='juliet@capulet.com/balcony' to='juliet@capulet.com/balcony'
id='inband_1'> type='set'>
<open sid='i781hf64' <open sid='i781hf64'
block-size='4096' block-size='4096'
xmlns='http://jabber.org/protocol/ibb'/> xmlns='http://jabber.org/protocol/ibb'/>
</iq> </iq>
]]></example> ]]></example>
<p>This asks Juliet if she would like to form an In-Band Bytestreams connection, using the session ID 'i781hf64' (generated by the initiator here) to uniquely reference the bytestream. The 'block-size' attribute specifies the maximum amount of data (in bytes) that an IBB packet may contain.</p> <p>If the responder wishes to proceed with the IBB session, it returns an IQ-result to the initiator.</p>
<example caption='Success Response'><![CDATA[ <example caption='Responder accepts session'><![CDATA[
<iq type='result' <iq from='juliet@capulet.com/balcony'
from='juliet@capulet.com/balcony' id='jn3h8g65'
to='romeo@montague.net/orchard' to='romeo@montague.net/orchard'
id='inband_1'/> type='result'/>
]]></example> ]]></example>
<p>This is a success response from juliet@capulet.com/balcony, saying that the bytestream is active.</p> <p>If the responder does not support IBB, it returns a &unavailable; or &feature; error.</p>
<example caption='Error'><![CDATA[ <example caption='Responder does not support IBB'><![CDATA[
<iq type='error' <iq from='juliet@capulet.com/balcony'
from='juliet@capulet.com/balcony' id='jn3h8g65'
to='romeo@montague.net/orchard' to='romeo@montague.net/orchard'
id='inband_1'/> type='error'/>
<error type='cancel'> <error type='cancel'>
<feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> <service-unavailable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
]]></example>
<p>If the responder supports IBB but would prefer a smaller block-size, it returns a &constraint; error.</p>
<example caption='Responder prefers smaller chunks'><![CDATA[
<iq from='juliet@capulet.com/balcony'
id='jn3h8g65'
to='romeo@montague.net/orchard'
type='error'/>
<error type='modify'>
<resource-constraint xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
]]></example>
<p>If the responder supports IBB but does not wish to proceed with the session, it returns a &notacceptable; error.</p>
<example caption='Responder does not wish to proceed'><![CDATA[
<iq from='juliet@capulet.com/balcony'
id='jn3h8g65'
to='romeo@montague.net/orchard'
type='error'/>
<error type='cancel'>
<not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error> </error>
</iq> </iq>
]]></example> ]]></example>
<p>This is an error response from juliet@capulet.com/balcony saying that an In-Band Bytestreams is not possible.</p>
</section2> </section2>
<section2 topic='Sending Data'> <section2 topic='Sending Data' anchor='send'>
<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 MAY be sent in a message stanza (although this is not encouraged). The data to be sent, prior to any encoding or wrapping in the stanza, must be no larger than the 'block-size' determined in the stream negotiation.</p> <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>
<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 MAY be sent in a message stanza. The data to be sent, prior to any wrapping in the &lt;data/&gt; element and IQ or message stanza, MUST NOT be larger than the 'block-size' determined in the bytestream negotiation.</p>
<example caption='Sending data using IQ'><![CDATA[ <example caption='Sending data using IQ'><![CDATA[
<iq from='romeo@montague.net/orchard' <iq from='romeo@montague.net/orchard'
id='kr91n475' id='kr91n475'
to='juliet@capulet.com/balcony' to='juliet@capulet.com/balcony'
type='set'> type='set'>
<data xmlns='http://jabber.org/protocol/ibb' sid='i781hf64' seq='0'> <data xmlns='http://jabber.org/protocol/ibb' seq='0' sid='i781hf64'>
qANQR1DBwU4DX7jmYZnncmUQB/9KuKBddzQH+tZ1ZywKK0yHKnq57kWq+RFtQdCJ qANQR1DBwU4DX7jmYZnncmUQB/9KuKBddzQH+tZ1ZywKK0yHKnq57kWq+RFtQdCJ
WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu
IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P
@ -150,8 +175,10 @@
</data> </data>
</iq> </iq>
]]></example> ]]></example>
<p>The data to send is included as XML character data of the &lt;data/&gt; element after being encoded as Base64 as specified in Section 4 of &rfc4648;. The 'seq' attribute is a 16-bit unsigned integer counter starting at 0, and MUST be incremented for each packet sent. Thus, the next packet sent should have a 'seq' of 1, the one after that with a 'seq' of 2, and so on. The counter loops at maximum, so after value 65535, 'seq' MUST start again at 0.</p> <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;.</p>
<p>In the case of IQ stanzas, the recipient MUST reply to each data packet with an IQ of type 'result'.</p> <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 within this session. The 'seq' value starts at 0 (zero) and MUST be incremented for each packet sent. 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 the 'seq' MUST start again at 0.</p>
<p>The &lt;data/&gt; element MUST also possess a 'sid' attribute that ties the data chunk to this particular IBB session.</p>
<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>
<example caption='Acknowledging data using IQ'><![CDATA[ <example caption='Acknowledging data using IQ'><![CDATA[
<iq from='juliet@capulet.com/balcony' <iq from='juliet@capulet.com/balcony'
id='kr91n475' id='kr91n475'
@ -159,22 +186,13 @@
type='result'/> type='result'/>
]]></example> ]]></example>
<p>The sender need not wait for these acknowledgements before sending further stanzas. However, it is RECOMMENDED that the sender does wait in order to minimize possible rate-limiting penalties.</p> <p>The sender need not wait for these acknowledgements before sending further stanzas. However, it is RECOMMENDED that the sender does wait in order to minimize possible rate-limiting penalties.</p>
<p>It is possible that delivery of the stanza might fail.</p> <p>It is possible that delivery of the stanza might fail, e.g. because the recipient has gone offline or because a server-to-server link has gone down). In this case the entity that detects the error shall return an appropriate XMPP stanza eror, such as &recipient; or &timeout;. Upon receiving notice that delivery of a data packet has failed, the sender MUST consider the bytestream to be closed and invalid.</p>
<example caption='Failed delivery with iq'><![CDATA[ <p>It is also possible that the recipient might detect an error with the data packet, e.g. because the session ID is unknown, because the sequence number has already been used, or because the data is not formatted in accordance with Section 4 of <cite>RFC 4648</cite>. In this case the recipient shall return an appropriate XMPP stanza error, such as &notfound;, &unexpected; or &badrequest;. Upon receiving notice that a data packet is cannot be processed by the recipient, the sender SHOULD consider the bytestream to be closed and invalid but MAY attempt to correct the error and re-send the offending data packet using the same sequence number (the recipient MUST NOT consider a sequence number to have been used until the data packet has been successfully processed).</p>
<iq from='juliet@capulet.com/balcony' <p>Data packets MUST be processed in the order they are received. If an out-of-sequence packet is received for a particular 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 consider the bytestream invalid and SHOULD close the bytestream as described in the next section.</p>
id='hr81gs67'
to='romeo@montague.net/orchard'
type='error'>
<error type='cancel'>
<remote-server-timeout xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
</error>
</iq>
]]></example>
<p>Upon delivery failure, the sender MUST consider the bytestream to be closed and invalid.</p>
</section2> </section2>
<section2 topic='Closing the Bytestream'> <section2 topic='Closing the Bytestream' anchor='close'>
<p>To close the bytestream, either party can send an IQ-set containing a &lt;close/&gt; element.</p> <p>To close the bytestream, either party sends an IQ-set containing a &lt;close/&gt; element.</p>
<example caption='Closing the bytestream'><![CDATA[ <example caption='Closing the bytestream'><![CDATA[
<iq from='romeo@montague.net/orchard' <iq from='romeo@montague.net/orchard'
id='us71g45j' id='us71g45j'
@ -183,15 +201,15 @@
<close xmlns='http://jabber.org/protocol/ibb' sid='i781hf64'/> <close xmlns='http://jabber.org/protocol/ibb' sid='i781hf64'/>
</iq> </iq>
]]></example> ]]></example>
<p>The receiving party then acknowledges that the bytestream has been closed by returning an IQ-result.</p>
<example caption='Success response'><![CDATA[ <example caption='Success response'><![CDATA[
<iq from='juliet@capulet.com/balcony' <iq from='juliet@capulet.com/balcony'
id='us71g45j' id='us71g45j'
to='romeo@montague.net/orchard' to='romeo@montague.net/orchard'
type='result'/> type='result'/>
]]></example> ]]></example>
<p>This is a success response from juliet@capulet.com/balcony, saying that the bytestream is now closed.</p> <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>
<p>It is possible that the recipient of the close notification does not know about the bytestream, in which case it would return an item-not-found error.</p> <example caption='Recipient does not know about the IBB session'><![CDATA[
<example caption='Possible error'><![CDATA[
<iq type='error' <iq type='error'
from='juliet@capulet.com/balcony' from='juliet@capulet.com/balcony'
to='romeo@montague.net/orchard' to='romeo@montague.net/orchard'
@ -201,11 +219,7 @@
</error> </error>
</iq> </iq>
]]></example> ]]></example>
<p>Upon error, the bytestream MUST be considered closed and invalid.</p> <p>In either case, the sender MUST consider the bytestream to be closed and invalid.</p>
</section2>
<section2 topic='Receiving Packets'>
<p>Data packets MUST be processed in the order they are received. If an out-of-sequence packet is received for a particular 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, and at this point MUST consider the bytestream closed and invalid.</p>
</section2> </section2>
</section1> </section1>
@ -214,33 +228,34 @@
<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 SessionID. If enabled by the application that uses IBB, the parties MAY negotiate multiple SessionIDs for the same bytestream, however such methods are out of scope for this specification.</p> <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 SessionID. If enabled by the application that uses IBB, the parties MAY negotiate multiple SessionIDs for the same bytestream, however such methods are out of scope for this specification.</p>
</section1> </section1>
<section1 topic='Usage Guidelines'> <section1 topic='Usage Guidelines' anchor='intro'>
<ul> <ul>
<li>Generally, IBB should be used as a last resort. <strong>SOCKS5 Bytestreams</strong> will almost always be preferable.</li> <li>Generally, in-band bytestreams SHOULD be used only as a last resort. <strong>SOCKS5 Bytestreams</strong> will almost always be preferable.</li>
<li>A server MAY rate limit a connection, depending on the size and frequency of data packets.</li> <li>A server MAY rate limit a connection, depending on the size and frequency of data packets.</li>
<li>A server MAY disconnect a connection that sends overly large packets as defined by server policy.</li> <li>A server MAY disconnect a connection that sends overly large packets as defined by server policy.</li>
<li>&lt;message&gt; delivery SHOULD be used when &xep0079; or other stanza flow-control facilities are available. However, if they are not available, then &lt;iq&gt; SHOULD be used.</li>
<li>It is RECOMMENDED to use a 'block-size' of 4096.</li> <li>It is RECOMMENDED to use a 'block-size' of 4096.</li>
<li>For proper tracking of message delivery errors, the use of the stanza 'id' attribute is RECOMMENDED.</li> <li>For proper tracking of delivery and processing errors related to data packets, the 'id' attribute MUST be used with IQ stanzas and SHOULD be used with message stanzas.</li>
<li>It is RECOMMENDED to use IQ stanzas when sending data packets.</li>
<li>If message stanzas are used when sending data packets, the sender SHOULD also use &xep0079; or some other stanza flow-control method.</li>
</ul> </ul>
</section1> </section1>
<section1 topic='Security Considerations'> <section1 topic='Security Considerations' anchor='intro'>
<p>In-Band Bytestreams is as secure as the underlying Jabber transport. The bytestream application could have its own security layer, but this is outside of the scope of IBB.</p> <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>
<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. Base 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> <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. Base 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>
</section1> </section1>
<section1 topic='IANA Considerations'> <section1 topic='IANA Considerations' anchor='intro'>
<p>This document requires no interaction with &IANA;.</p> <p>This document requires no interaction with &IANA;.</p>
</section1> </section1>
<section1 topic='XMPP Registrar Considerations'> <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
<section2 topic='Protocol Namespaces'> <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
<p>The &REGISTRAR; includes 'http://jabber.org/protocol/ibb' in its registry of XML namespaces &NAMESPACES;.</p> <p>The &REGISTRAR; includes 'http://jabber.org/protocol/ibb' in its registry of XML namespaces at &NAMESPACES;.</p>
</section2> </section2>
</section1> </section1>
<section1 topic='XML Schema'> <section1 topic='XML Schema' anchor='intro'>
<code><![CDATA[ <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
@ -261,8 +276,8 @@
<xs:complexType> <xs:complexType>
<xs:simpleContent> <xs:simpleContent>
<xs:extension base='empty'> <xs:extension base='empty'>
<xs:attribute name='sid' type='xs:string' use='required'/> <xs:attribute name='block-size' type='xs:unsignedShort' use='required'/>
<xs:attribute name='block-size' type='xs:string' use='required'/> <xs:attribute name='sid' type='xs:NMTOKEN' use='required'/>
</xs:extension> </xs:extension>
</xs:simpleContent> </xs:simpleContent>
</xs:complexType> </xs:complexType>
@ -272,7 +287,7 @@
<xs:complexType> <xs:complexType>
<xs:simpleContent> <xs:simpleContent>
<xs:extension base='empty'> <xs:extension base='empty'>
<xs:attribute name='sid' type='xs:string' use='required'/> <xs:attribute name='sid' type='xs:NMTOKEN' use='required'/>
</xs:extension> </xs:extension>
</xs:simpleContent> </xs:simpleContent>
</xs:complexType> </xs:complexType>
@ -282,8 +297,8 @@
<xs:complexType> <xs:complexType>
<xs:simpleContent> <xs:simpleContent>
<xs:extension base='xs:string'> <xs:extension base='xs:string'>
<xs:attribute name='sid' type='xs:string' use='required'/> <xs:attribute name='seq' type='xs:unsignedShort' use='required'/>
<xs:attribute name='seq' type='xs:string' use='required'/> <xs:attribute name='sid' type='xs:NMTOKEN' use='required'/>
</xs:extension> </xs:extension>
</xs:simpleContent> </xs:simpleContent>
</xs:complexType> </xs:complexType>