<abstract>This specification defines a Jingle application type for establishing direct or mediated XML streams between two entities over any reliable transport. This technology thus enables two entities to establish a trusted connection for end-to-end encryption or for bypassing server limits on large volumes of XMPP traffic.</abstract>
<remark><p>Initial published version.</p></remark>
</revision>
<revision>
<version>0.0.1</version>
<date>2008-06-13</date>
<initials>psa/jk/dm</initials>
<remark>First draft.</remark>
</revision>
</header>
<section1topic='Introduction'anchor='intro'>
<p>The standard client-server architecture for XMPP communication provides a stable infrastructure for real-time communication. However, there are certain situations in which it is desirable to bypass the standard client-server architecture, including:</p>
<ul>
<li>Two endpoints cannot access an XMPP server</li>
<li>Two endpoints want to enforce end-to-end encryption</li>
<li>Two endpoints want to send a high volume of XMPP traffic but the intermediate servers enforce rate limits</li>
<p>The first situation is addressed by &xep0174;. However, if the endpoints already have client-to-server connections but wish to bypass those connections or leverage those streams for a higher-level application such as end-to-end encryption, it is desirable for the two endpoints to negotiate an end-to-end XML stream. This specification defines methods for doing so, where the application format is an XML stream and the transport method is any direct or mediated reliable transport, such as &xep0261; (mediated), &xep0260; (direct or mediated), or a future ice-tcp Jingle transport (direct or mediated) based on &ice-tcp;.</p>
<p>First, the party that wishes to initiate the stream determines the responder's capabilities (via &xep0030; or &xep0115;). Here we assume that the responder supports a service discovery feature of 'urn:xmpp:tmp:jingle:apps:xmlstream:0' &NSNOTE; corresponding to the Jingle XML stream functionalited defined herein, as well as the 'urn:xmpp:jingle:transports:s5b:0' and 'urn:xmpp:jingle:transports:ibb:0' features.</p>
<p>The initiator then sends a Jingle session-initiation request to the responder. The content-type of the request specifies three things:</p>
<li><p>An application type of "urn:xmpp:tmp:jingle:apps:xmlstream:0" &NSNOTE;, where the <description/> element specifies parameters for the XML stream and the parameters map to those provided in &xep0155; in a way that is consistent with &xep0116;.</p></li>
<li><p>Options for the reliable transport method, such as In-Band Bytestreams ("IBB") as defined in <cite>XEP-0261</cite> or SOCKS5 Bytestreams ("S5B") as defined in <cite>XEP-0260</cite>.</p></li>
<li><p>A security element as defined by <cite>Jingle-XTLS</cite>.</p></li>
<p>In this example, the initiator is <romeo@montague.lit>, the responder is <juliet@capulet.lit>, and the initiation request specifies Alice's desired stream parameters along with a transport method of "s5b" (i.e., <cite>XEP-0260</cite>).</p>
<p>The clients MUST attempt to open a standard TCP socket on the network address of the StreamHost communicated by the peer. If more than one StreamHost was provided, the client SHOULD try to connect to them in the order they occur.</p>
<p>If the client is able to open a TCP socket on a StreamHost, it MUST utilize the SOCKS5 protocol specified in &rfc1928; to establish the connection with the StreamHost.</p>
<p>After one client has authenticated with the StreamHost, it MUST send a Jingle transport-info to the initiator indicating which StreamHost was used.</p>
<examplecaption="Initiator sends streamhost-used in Jingle transport-info"><![CDATA[
<p>After the transport stream is ready and the initiator received the acknowledment from the security-info it starts the four-way TLS handshake on the transport stream.</p>
</section1>
<section1topic='Initiating an e2e Stream'anchor='initiate'>
<p>If the TLS handshake is complete both clients send an initial <stream/> element to open a client-to-client stream</p>
<examplecaption="Opening a Stream"><![CDATA[
<stream:stream
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'
from='romeo@montague.lit/orchard'
to='juliet@capulet.lit/balcony'
version='1.0'>
]]></example>
<p>In accordance with &rfc3921bis;, the initial stream header SHOULD include the 'to' and 'from' attributes. This should be the full JID of the clients. If the initiator supports stream features and the other stream-related aspects of XMPP 1.0 as specified in <cite>RFC 3920</cite>, then it SHOULD include the version='1.0' flag as shown in the previous example.</p>
<p>Once the streams are established, either entity then can send XMPP message, presence, and IQ stanzas, with or without 'to' and 'from' addresses.</p>
<section2topic='Mandatory to Implement Technologies'anchor='impl-mti'>
<p>All implementations MUST support the In-Band Bytestreams transport method as a reliable method of last resort. An implementation SHOULD support other transport methods as well.</p>
</section2>
<section2topic='Preference Order of Transport Methods'anchor='impl-pref'>
<p>An application MAY present transport methods in any order, except that the In-Band Bytestreams method MUST be the lowest preference.</p>
<p>Until this specification advances to a status of Draft, its associated namespaces shall be 'urn:xmpp:tmp:jingle:apps:xmlstream:0'. Upon advancement of this specification, the ®ISTRAR; shall issue a permanent namespace in accordance with the process defined in Section 4 of &xep0053;. The namespace 'urn:xmpp:jingle:apps:xmlstream' is requested and is thought to be unique per the XMPP Registrar's requirements.</p>