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
1 changed files with 87 additions and 72 deletions

View File

@ -6,7 +6,7 @@
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<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>
&LEGALNOTICE;
<number>0047</number>
@ -26,10 +26,10 @@
&infiniti;
&stpeter;
<revision>
<version>1.2rc1</version>
<date>in progress, last updated 2009-02-18</date>
<version>1.2rc2</version>
<date>in progress, last updated 2009-02-19</date>
<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>
<version>1.1</version>
@ -93,55 +93,80 @@
</revision>
</header>
<section1 topic='Introduction'>
<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>
<section1 topic='Introduction' anchor='intro'>
<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 topic='Uses'>
<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>
</section1>
<section1 topic='Protocol'>
<section2 topic='Creating a Bytestream'>
<example caption='Initiation of interaction'><![CDATA[
<iq type='set'
from='romeo@montague.net/orchard'
<section1 topic='Protocol' anchor='protocol'>
<p>IBB as specified in this document defines two protocol aspects:</p>
<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>
<li>How to send chunks of IBB data using IQ or message stanzas containing &lt;data/&gt; elements.</li>
</ol>
<p>Other methods can be used for setup and teardown, such as &xep0166; as specified in &xep0261;.</p>
<section2 topic='Creating a Bytestream' anchor='create'>
<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'
id='inband_1'>
type='set'>
<open sid='i781hf64'
block-size='4096'
xmlns='http://jabber.org/protocol/ibb'/>
</iq>
]]></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>
<example caption='Success Response'><![CDATA[
<iq type='result'
from='juliet@capulet.com/balcony'
<p>If the responder wishes to proceed with the IBB session, it returns an IQ-result to the initiator.</p>
<example caption='Responder accepts session'><![CDATA[
<iq from='juliet@capulet.com/balcony'
id='jn3h8g65'
to='romeo@montague.net/orchard'
id='inband_1'/>
type='result'/>
]]></example>
<p>This is a success response from juliet@capulet.com/balcony, saying that the bytestream is active.</p>
<example caption='Error'><![CDATA[
<iq type='error'
from='juliet@capulet.com/balcony'
<p>If the responder does not support IBB, it returns a &unavailable; or &feature; error.</p>
<example caption='Responder does not support IBB'><![CDATA[
<iq from='juliet@capulet.com/balcony'
id='jn3h8g65'
to='romeo@montague.net/orchard'
id='inband_1'/>
type='error'/>
<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>
</iq>
]]></example>
<p>This is an error response from juliet@capulet.com/balcony saying that an In-Band Bytestreams is not possible.</p>
</section2>
<section2 topic='Sending Data'>
<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>
<section2 topic='Sending Data' anchor='send'>
<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[
<iq from='romeo@montague.net/orchard'
id='kr91n475'
to='juliet@capulet.com/balcony'
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
WpdWpR0uQsuJe7+vh3NWn59/gTc5MDlX8dS9p0ovStmNcyLhxVgmqS8ZKhsblVeu
IpQ0JgavABqibJolc3BKrVtVV1igKiX/N7Pi8RtY1K18toaMDhdEfhBRzO/XB0+P
@ -150,8 +175,10 @@
</data>
</iq>
]]></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>In the case of IQ stanzas, the recipient MUST reply to each data packet with an IQ of type 'result'.</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>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[
<iq from='juliet@capulet.com/balcony'
id='kr91n475'
@ -159,22 +186,13 @@
type='result'/>
]]></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>It is possible that delivery of the stanza might fail.</p>
<example caption='Failed delivery with iq'><![CDATA[
<iq from='juliet@capulet.com/balcony'
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>
<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>
<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>
<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>
</section2>
<section2 topic='Closing the Bytestream'>
<p>To close the bytestream, either party can send an IQ-set containing a &lt;close/&gt; element.</p>
<section2 topic='Closing the Bytestream' anchor='close'>
<p>To close the bytestream, either party sends an IQ-set containing a &lt;close/&gt; element.</p>
<example caption='Closing the bytestream'><![CDATA[
<iq from='romeo@montague.net/orchard'
id='us71g45j'
@ -183,15 +201,15 @@
<close xmlns='http://jabber.org/protocol/ibb' sid='i781hf64'/>
</iq>
]]></example>
<p>The receiving party then acknowledges that the bytestream has been closed by returning an IQ-result.</p>
<example caption='Success response'><![CDATA[
<iq from='juliet@capulet.com/balcony'
id='us71g45j'
to='romeo@montague.net/orchard'
type='result'/>
]]></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 item-not-found error.</p>
<example caption='Possible error'><![CDATA[
<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>
<example caption='Recipient does not know about the IBB session'><![CDATA[
<iq type='error'
from='juliet@capulet.com/balcony'
to='romeo@montague.net/orchard'
@ -201,11 +219,7 @@
</error>
</iq>
]]></example>
<p>Upon error, the bytestream MUST be considered 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>
<p>In either case, the sender MUST consider the bytestream to be closed and invalid.</p>
</section2>
</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>
</section1>
<section1 topic='Usage Guidelines'>
<section1 topic='Usage Guidelines' anchor='intro'>
<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 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>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>
</section1>
<section1 topic='Security Considerations'>
<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>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 topic='Security Considerations' anchor='intro'>
<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>
</section1>
<section1 topic='IANA Considerations'>
<section1 topic='IANA Considerations' anchor='intro'>
<p>This document requires no interaction with &IANA;.</p>
</section1>
<section1 topic='XMPP Registrar Considerations'>
<section2 topic='Protocol Namespaces'>
<p>The &REGISTRAR; includes 'http://jabber.org/protocol/ibb' in its registry of XML namespaces &NAMESPACES;.</p>
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
<section2 topic='Protocol Namespaces' anchor='registrar-ns'>
<p>The &REGISTRAR; includes 'http://jabber.org/protocol/ibb' in its registry of XML namespaces at &NAMESPACES;.</p>
</section2>
</section1>
<section1 topic='XML Schema'>
<section1 topic='XML Schema' anchor='intro'>
<code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>
@ -261,8 +276,8 @@
<xs:complexType>
<xs:simpleContent>
<xs:extension base='empty'>
<xs:attribute name='sid' type='xs:string' use='required'/>
<xs:attribute name='block-size' type='xs:string' use='required'/>
<xs:attribute name='block-size' type='xs:unsignedShort' use='required'/>
<xs:attribute name='sid' type='xs:NMTOKEN' use='required'/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
@ -272,7 +287,7 @@
<xs:complexType>
<xs:simpleContent>
<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:simpleContent>
</xs:complexType>
@ -282,8 +297,8 @@
<xs:complexType>
<xs:simpleContent>
<xs:extension base='xs:string'>
<xs:attribute name='sid' type='xs:string' use='required'/>
<xs:attribute name='seq' type='xs:string' use='required'/>
<xs:attribute name='seq' type='xs:unsignedShort' use='required'/>
<xs:attribute name='sid' type='xs:NMTOKEN' use='required'/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>