1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-12-21 23:28:51 -05:00

0.4 published

git-svn-id: file:///home/ksmith/gitmigration/svn/xmpp/trunk@3941 4b5297f7-1745-476d-ba37-a9c6900126ab
This commit is contained in:
Peter Saint-Andre 2010-02-18 06:12:38 +00:00
parent 789f15ebe7
commit 6e6134e9e7

View File

@ -25,6 +25,7 @@
&stpeter;
&dmeyer;
&infiniti;
&mlundblad;
<author>
<firstname>Klaus</firstname>
<surname>Hartke</surname>
@ -34,8 +35,8 @@
<revision>
<version>0.4</version>
<date>2010-02-17</date>
<initial>ml</initial>
<remark><p>Added proxy-error action. Added a block-size attribute in the transport-accept action when negotiating a fallback to IBB, analogueous with changes in XEP-0261.</p></remark>
<initials>ml/psa</initials>
<remark><p>Added proxy-error action; added a block-size attribute in the transport-accept action when negotiating a fallback to IBB, analogous to changes in XEP-0261; editorial review.</p></remark>
</revision>
<revision>
<version>0.3</version>
@ -76,13 +77,13 @@
</header>
<section1 topic='Introduction' anchor='intro'>
<p>&xep0166; defines a framework for negotiating and managing data sessions over XMPP. In order to provide a flexible framework, the base Jingle specification defines neither data transport methods nor application formats, leaving that up to separate specifications. The current document defines a transport method for establishing and managing data exchanges between XMPP entities using the existing SOCKS5 Bytestreams (S5B) protocol specified in &xep0065;. This "jingle-s5b" method results in a streaming transport method suitable for use in Jingle application types where packet loss cannot be tolerated (e.g., file transfer). Jingle-S5B reuses the protocol flow from <cite>XEP-0065</cite> for the communication with a SOCKS5 streamhost; the communication between two clients to negotiate the possible candidates differs from <cite>XEP-0065</cite> and share similarities with &xep0176;</p>
<p>&xep0166; defines a framework for negotiating and managing data sessions over XMPP. In order to provide a flexible framework, the base Jingle specification defines neither data transport methods nor application formats, leaving that up to separate specifications. The current document defines a transport method for establishing and managing data exchanges between XMPP entities using the existing SOCKS5 Bytestreams (S5B) protocol specified in &xep0065;. This "jingle-s5b" method results in a streaming transport method suitable for use in Jingle application types where packet loss cannot be tolerated (e.g., file transfer). Jingle-S5B reuses the protocol flow from <cite>XEP-0065</cite> for the communication with a SOCKS5 streamhost; the communication between two clients to negotiate the possible candidates differs from <cite>XEP-0065</cite> and shares similarities with &xep0176;</p>
</section1>
<section1 topic='Protocol' anchor='protocol'>
<para>The basic flow is as follows.</para>
<code><![CDATA[
Romeo Juliet
Initiator Responder
| |
| session-initiate |
| (with S5B candidates) |
@ -111,9 +112,16 @@ Romeo Juliet
| |
]]></code>
<p>This flow is illustrated in the following examples (to simplify the presentation these use a "stub" application instead of a real application type).</p>
<section2 topic='Selecting Candidates' anchor='select'>
<p>It is RECOMMENDED that a client will offer as many &lt;candidate/&gt; elements as possible with itself as the host (i.e., non-proxy candidates). Such candidates might be found using the following methods:</p>
<ul>
<li>Opening the TCP port on all available interfaces the user wants to use (e.g., maybe not an expensive UMTS link), including the IPv4 and IPv6 addresses of that interface (if available).</li>
<li>Using the client's external IP address as discovered through an assisting NAT protocol or other means.</li>
</ul>
<p>If the client knows it is behind a NAT and the router announces UPnP IGD or NAT-PMP support, the client SHOULD map the open port to the external interface of the router and include the public IP address and port information in the &lt;candidate/&gt; offers. To increase the chance of success without using a proxy, this specification allows the responder to also send offers, effectively equivalent to the "fast-mode" for SOCKS5 Bytestreams as previously described at &lt;<link url='http://delta.affinix.com/specs/stream.html'>http://delta.affinix.com/specs/stream.html</link>&gt;.</p>
</section2>
<section2 topic='Exchanging Candidates' anchor='exchange'>
<p>First the initiator sends a Jingle session-initiate request that contains one or more transport candidates which are a mixture of <cite>XEP-0065</cite> streamhosts and ICE candidates used in <cite>XEP-0176</cite>.</p>
<p>It is RECOMMENDED that a client will offer as many &lt;candidate/&gt; elements as possible with itself as the host (i.e., non-proxy candidates). This includes opening the TCP port on all available interfaces the user wants to use (e.g. maybe not an expensive UMTS link), both the IPv4 and IPv6 addresses of that interface (if available), and using an assisting NAT protocol if possible. If the client knows it is behind a NAT and the router announces UPnP IGD or NAT-PMP support, the client SHOULD map the open port to the external interface of the router and include the public IP address and port information in the &lt;candidate/&gt; offers. To increase the chance of success without using a proxy, this specification allows the responder to also send offers, effectively equivalent to the "fast-mode" for SOCKS5 Bytestreams as previously described at &lt;<link url='http://delta.affinix.com/specs/stream.html'>http://delta.affinix.com/specs/stream.html</link>&gt;.</p>
<p>Once the initiator has a set of candidates, it sends a Jingle session-initiate request that contains one or more transport candidates which are a mixture of <cite>XEP-0065</cite> streamhosts and ICE candidates used in <cite>XEP-0176</cite>.</p>
<example caption="Initiator sends session-initiate (stub)"><![CDATA[
<iq from='romeo@montague.lit/orchard'
id='xn28s7gk'
@ -126,8 +134,8 @@ Romeo Juliet
<content creator='initiator' name='stub'>
<description xmlns='urn:xmpp:jingle:apps:stub:0'/>
<transport xmlns='urn:xmpp:jingle:transports:s5b:1'
sid='vj3hs98y'
mode='tcp'>
mode='tcp'
sid='vj3hs98y'>
<candidate cid='hft54dqy'
host='192.168.4.1'
jid='romeo@montague.lit/orchard'
@ -153,7 +161,7 @@ Romeo Juliet
type='result'/>
]]></example>
<p>Depending on the application type, a user agent controlled by a human user might need to wait for the user to affirm a desire to proceed with the session before continuing. When the user agent has received such affirmation (or if the user agent can automatically proceed for any reason, e.g. because no human intervention is expected or because a human user has configured the user agent to automatically accept sessions with a given entity), it returns a Jingle session-accept message. This message MUST contain a &TRANSPORT; element qualified by the 'urn:xmpp:jingle:transports:s5b:1' namespace, which SHOULD in turn contain one &lt;candidate/&gt; element for each SOCKS5 Bytestreams candidate generated by or known to the responder, but MAY instead be empty if the responder does not wish to offer any candidates or wishes to send each candidate as the payload of a transport-info message.</p>
<p>Note: If the responder sends candidates, the chances of a successful connection are increased. For example, the initiator might be behind a NAT or might have no access to a proxy, whereas the responder might have a public IP address, might know about a proxy, or might have NAT penetration support like NAT-PMP in the router. (Whereas this "fast-mode" was a special extension previously, it is the default in Jingle.)</p>
<p>If the responder sends candidates in the session-accept, the chances of a successful connection are increased. For example, the initiator might be behind a NAT or might have no access to a proxy, whereas the responder might have a public IP address, might know about a proxy, or might have NAT penetration support like NAT-PMP in a router. (Whereas this "fast-mode" was a special extension previously, it is the default in jingle-s5b.) However, the responder MUST NOT offer as a candidate any host/port combination that has already been offered by the initiator; this helps to prevent failure of negotiation with the proxy.</p>
<p>In the following example, Juliet's client opens one port. The provided &lt;candidates/&gt; are the (private) IPv4 address of the interface, a (public) IPv6 address, and the public IPv4 address created by mapping the private IP address/port using NAT-PMP.</p>
<example caption="Responder sends session-accept with candidates"><![CDATA[
<iq from='juliet@capulet.lit/balcony'
@ -167,8 +175,8 @@ Romeo Juliet
<content creator='initiator' name='stub'>
<description xmlns='urn:xmpp:jingle:apps:stub:0'/>
<transport xmlns='urn:xmpp:jingle:transports:s5b:1'
sid='vj3hs98y'
mode='tcp'>
mode='tcp'
sid='vj3hs98y'>
<candidate cid='ht567dq'
host='192.169.1.10'
jid='juliet@capulet.lit/balcony'
@ -200,10 +208,10 @@ Romeo Juliet
type='result'/>
]]></example>
<p>A client SHOULD check the offered candidates in order of their priority, starting with the highest value. How the priority is calculated depends on the actual available interfaces. It is RECOMMENDED to use the following formula:</p>
<example caption="Priority Calculation"><![CDATA[
<code>
priority = (2^16)*(type preference) + (local preference)
]]></example>
<p>The type preference is an integer value between 0 and 127. The following types and their suggested preference values are defined here:</p>
</code>
<p>The type preference is an integer value between 0 and 127. The following types and their suggested preference values are defined.</p>
<table caption='Defined Types'>
<tr>
<th>Type</th>
@ -231,16 +239,16 @@ priority = (2^16)*(type preference) + (local preference)
<td>10</td>
</tr>
</table>
<p>The local preference is used to rate different candidates of the same type, e.g. a DSL link might be preferred over a VPN connection. The value of the local preference SHOULD be between 0 and 65535. The proposed values are only guidelines. If a client wants to increase or decrease the value of a specific candidate it is free to do so. For instance, a client might have an expensive UMTS link as last resort and might rate this link lower than all SOCKS5 relays.</p>
<p>The local preference is used to rate different candidates of the same type, e.g. a DSL link might be preferred over a VPN connection. The value of the local preference SHOULD be between 0 and 65535. The proposed values are only guidelines. If a client wants to increase or decrease the value of a specific candidate it is free to do so. For instance, a client might have an expensive UMTS link as a last resort and might rate this link lower than all SOCKS5 relays.</p>
</section2>
<section2 topic='Connecting to Candidates' anchor='connect'>
<p>After receiving its peer's candidates, a client start to connect to them in order of the priority. The protocol is described in <cite>XEP-0065</cite> in detail. Once one client has successfully created a connection, it sends the &lt;candidate-used/&gt; element to the peer inside a transport-info Jingle message. If a client receives a candidate-used information it SHOULD continue trying to connect to candidates of its peer if it has not tried all candidates with a higher priority than the one successfully used by the peer.</p>
<p>After receiving its peer's candidates, a client start to connect to them in order of the priority. The protocol is described in <cite>XEP-0065</cite> in detail. Once one client has successfully created a connection, it sends the &lt;candidate-used/&gt; element to the peer inside a transport-info Jingle message. If a client receives a candidate-used notification it SHOULD continue trying to connect to candidates of its peer if it has not tried all candidates with a higher priority than the one successfully used by the peer.</p>
<example caption="Initiator sends candidate-used in Jingle transport-info"><![CDATA[
<iq from='romeo@montague.lit/orchard'
id='hjdi8'
to='juliet@capulet.lit/balcony'
type='set'>
<jingle xmlns='urn:xmpp:jingle:1'>
<jingle xmlns='urn:xmpp:jingle:1'
action='transport-info'
initiator='romeo@montague.lit/orchard'
sid='a73sjjvkla37jfea'>
@ -293,7 +301,7 @@ priority = (2^16)*(type preference) + (local preference)
<li>If both parties send a candidate-error notification then the SOCKS5 negotiation has failed and the parties need to fall back to some other transport method, typically IBB; see the <link url='#fallback'>Fallback to IBB</link> section of this document for details.</li>
<li>If one of the parties sends a candidate-error notification and the other party sends a candidate-used notification, then the candidate-used shall be considered the nominated candidate.</li>
<li>If both parties send a candidate-used notification but the candidates have a different priority, then the candidate with the lower priority shall be considered the nominated candidate.</li>
<li>If both parties send a candidate-used notification with candidates having the same priority, then the candidate chosen by the initiator shall be considered the nominated candidate (consistent with the rules in <cite>XEP-0166</cite>).</li>
<li>If both parties send a candidate-used notification with candidates having the same priority, then the candidate chosen by the initiator shall be considered the nominated candidate (this is consistent with the rules in <cite>XEP-0166</cite>).</li>
</ol>
<p>The parties shall use the nominated candidate for the data transfer. If the nominated candidate is of the proxy type, then the peer has no way to know when it can send data. Therefore the party that offered the nominated candidate MUST send an activated notification to the peer once it has activated the bytestream (as described in <cite>XEP-0065</cite>); it does so by sending a transport-info message containing an &lt;activated/&gt; element as follows.</p>
<example caption="Responder informs initiator that bytestream has been activated"><![CDATA[
@ -335,6 +343,9 @@ priority = (2^16)*(type preference) + (local preference)
]]></example>
<p>The parties shall then consider the bytestream unsuccessful and fallback to IBB as described in <link url='#fallback'>Fallback to IBB</link>.</p>
</section2>
<section2 topic='Exchanging Data' anchor='data'>
<p>Once the parties have chosen (and if necessary activated) a streamhost, they can exchange data as defined in <cite>XEP-0065</cite>.</p>
</section2>
<section2 topic='Closing the Bytestream' anchor='close'>
<p>Once the parties have finished using the bytestream (e.g., because a complete file has been sent), either party can send a Jingle session-terminate action.</p>
<example caption="Initiator terminates the session"><![CDATA[
@ -387,7 +398,7 @@ Romeo Juliet
|--------------------------------->|
| |
]]></code>
<p>First the initiator sends a Jingle session-initiate, in this case with a transport of SOCKS5 Bytestreams. The protocol flow is exactly the same as described above. If both clients are unable to connect to a candidate provided by the peer, both send candidate-error messages and SOCKS5 as failed. The initiator MUST either terminate the Jingle session with a Jingle reason of &lt;connectivity-error/&gt; or replace the transport with something else using the transport-replace action. Typically the fallback option is IBB. Therefore the initiator sends a transport-replace action including a transport of IBB.</p>
<p>First the initiator sends a Jingle session-initiate, in this case with a transport of SOCKS5 Bytestreams. The protocol flow is exactly the same as described above. If both clients are unable to connect to a candidate provided by the peer, both send candidate-error messages and SOCKS5 as failed. The initiator MUST either terminate the Jingle session with a Jingle reason of &lt;connectivity-error/&gt; or replace the transport with something else using the transport-replace action. Typically the fallback option is IBB (see, for example, &xep0234;). Therefore the initiator sends a transport-replace action including a transport of IBB.</p>
<example caption="Initiator replaces transport with IBB"><![CDATA[
<iq from='romeo@montague.lit/orchard'
id='hs92n57'
@ -437,14 +448,14 @@ Romeo Juliet
to='romeo@montague.lit/orchard'
type='result'/>
]]></example>
<p>Now the initiator sends data using In-Band Bytestreams as defined in <cite>XEP-0047</cite>.</p>
<p>Now the parties can send data using In-Band Bytestreams as defined in <cite>XEP-0047</cite>.</p>
</section1>
<section1 topic='Processing Rules and Usage Guidelines' anchor='rules'>
<p>The same processing rules and usage guidelines defined in XEP-0065 apply to the Jingle S5B Transport Method. Additional implementation suggestions are:</p>
<ol>
<li>A client SHOULD try the offered candidates in the order of their priority.</li>
<li>If more than one &lt;candidate/&gt; element is present a client SHOULD wait 200ms before trying the next one.</li>
<li>If more than one &lt;candidate/&gt; element is present in a session-initiate or session-accept, a client SHOULD wait 200ms before trying the next one.</li>
<li>If the candidate has a JID attribute and that JID is not the one of the peer it indicates the usage of a proxy. If the client had offered direct connection information it MAY want to wait a little bit longer than 200ms before trying the first proxy.</li>
<li>A client SHOULD NOT wait for a TCP timeout on connect. If it is unable to connect to any candidate within 5 seconds it SHOULD send a candidate-error to the other party.</li>
</ol>
@ -498,7 +509,7 @@ Romeo Juliet
<code><![CDATA[
<transport>
<name>s5b</name>
<desc>A method for exchanging data over SOCKS5 Bytestreams.</desc>
<desc>A method for negotiating data exchange over SOCKS5 Bytestreams.</desc>
<type>streaming</type>
<doc>XEP-0260</doc>
</transport>
@ -524,8 +535,8 @@ Romeo Juliet
<xs:element name='candidate-error' minOccurs='0' maxOccurs='1' type='empty'/>
<xs:element ref='activated' minOccurs='0' maxOccurs='1'/>
</xs:choice>
<xs:attribute name='sid' type='xs:string' use='optional'/>
<xs:attribute name='mode' use='optional' default='tcp'>
<xs:attribute name='sid' type='xs:string' use='optional'/>
<xs:simpleType>
<xs:restriction base='xs:NCName'>
<xs:enumeration value='tcp'/>
@ -542,7 +553,7 @@ Romeo Juliet
<xs:extension base='empty'>
<xs:attribute name='cid' type='xs:string' use='required'/>
<xs:attribute name='host' type='xs:string' use='required'/>
<xs:attribute name='jid' type='xs:string' use='optional'/>
<xs:attribute name='jid' type='xs:string' use='required'/>
<xs:attribute name='port' type='xs:positiveInteger' use='optional'/>
<xs:attribute name='priority' type='xs:positiveInteger' use='required'/>
<xs:attribute name='type' use='optional' default='direct'>