<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Reliable Entity Link</title>
  <abstract>Protocol for linking a bytestream between two Jabber entities.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0041</number>
  <status>Retracted</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0020</spec>
    <spec>XEP-0030</spec>
  </dependencies>
  <supersedes/>
  <supersededby><spec>XEP-0065</spec></supersededby>
  <shortname>rel</shortname>
  
  <author>
    <firstname>Justin</firstname>
    <surname>Karneges</surname>
    <email>justin@karneges.com</email>
    <jid>justin@andbit.net</jid>
  </author>

  <revision>
    <version>0.9</version>
    <date>2003-09-30</date>
    <initials>psa</initials>
    <remark>At the request of the author, the status of this specification has been changed to Retracted since it has been superseded by XEP-0065.</remark>
  </revision>
  <revision>
    <version>0.8</version>
    <date>2003-06-26</date>
    <initials>jk</initials>
    <remark>Refactored to old jidlink roots</remark>
  </revision>
  <revision>
    <version>0.7</version>
    <date>2003-04-29</date>
    <initials>jk</initials>
    <remark>Overhaul and rename</remark>
  </revision>
  <revision>
    <version>0.6</version>
    <date>2002-11-23</date>
    <initials>jk</initials>
    <remark>Reflect changes to DTCP</remark>
  </revision>
  <revision>
    <version>0.5</version>
    <date>2002-10-10</date>
    <initials>jk</initials>
    <remark>Table of stream transports</remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2002-10-10</date>
    <initials>jk</initials>
    <remark>New name, cleaned up the text, added test mode.</remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2002-09-12</date>
    <initials>jk</initials>
    <remark>Changed the implementation.</remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2002-08-16</date>
    <initials>jk</initials>
    <remark>Fixed spelling errors, simplified the document.</remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2002-08-15</date>
    <initials>jk</initials>
    <remark>Initial version.</remark>
  </revision>
</header>
<section1 topic="Overview">
<section2 topic="Introduction">
<p>Reliable Entity Link (or simply 'REL'), is a system for coordinating reliable bytestreams between two Jabber entities for the purpose of keeping applications (and application specifications) simple.  However, this proposal does not define any specific bytestream protocol.  It is expected that there will be multiple ways to obtain a bytestream between Jabber entities (thru-server and peer-to-peer are two methods that come to mind), but applications can refer to REL instead of some particular stream transport.</p>
</section2>

<section2 topic="Stream transport properties">
<p>A REL-compatible stream transport must have the following properties:</p>
<ul>
  <li>Provides a reliable bytestream between two Jabber entities, which means that the bytestream transport handles all data delivery issues, such that the application need not worry about them.</li>
  <li>Has link states from the following table.
  </li>
  <li>Defines a stream identifier, which MUST have a unique ASCII representation. The stream protocol MUST be able to use any ASCII identifier chosen during REL negotiation, as long as the sending party doesn't use the same identifier more than once.</li>
</ul>
<table caption="Link states">
  <tr>
    <th>Code</th>
    <th>Description</th>
  </tr>
  <tr>
    <td><tt>INIT</tt></td>
    <td>Initiation</td>
  </tr>
  <tr>
    <td><tt>GOOD</tt></td>
    <td>Successful initiation (connected)</td>
  </tr>
  <tr>
    <td><tt>BAD</tt></td>
    <td>Unsuccessful initiation (stream is closed, no further state)</td>
  </tr>
  <tr>
    <td><tt>CLOS</tt></td>
    <td>Successful closure after establishment (stream is closed, no further state)</td>
  </tr>
  <tr>
    <td><tt>ERR</tt></td>
    <td>Link failure after establishment (stream is closed, no further state)</td>
  </tr>
</table>
<p>The following stream transports that meet these guidelines are:</p>
<table caption="Supported streams">
  <tr>
    <th>Short name</th>
    <th>Protocol</th>
  </tr>
  <tr>
    <td>ibb</td>
    <td><span class="ref"><link url="https://xmpp.org/extensions/xep-0047.html">In-Band Bytestreams (XEP-0047)</link></span> <note>XEP-0047: In-Band Bytestreams &lt;<link url="https://xmpp.org/extensions/xep-0047.html">https://xmpp.org/extensions/xep-0047.html</link>&gt;.</note></td>
  </tr>
  <tr>
    <td>s5b</td>
    <td><span class="ref"><link url="https://xmpp.org/extensions/xep-0065.html">SOCKS5 Bytestreams (XEP-0065)</link></span> <note>XEP-0065: SOCKS5 Bytestreams &lt;<link url="https://xmpp.org/extensions/xep-0065.html">https://xmpp.org/extensions/xep-0065.html</link>&gt;.</note></td>
  </tr>
</table>

</section2>
</section1>

<section1 topic="Usage">
<section2 topic="Service discovery">
<p>Before using REL, ensure it is a supported service of the remote entity by using <span class="ref"><link url="https://xmpp.org/extensions/xep-0030.html">Service Discovery (XEP-0030)</link></span> <note>XEP-0030: Service Discovery &lt;<link url="https://xmpp.org/extensions/xep-0030.html">https://xmpp.org/extensions/xep-0030.html</link>&gt;.</note>:</p>

<example caption="Requesting disco information"><![CDATA[
<iq type="get" to="joe@blow.com/Home" id="sd_1">
  <query xmlns="http://jabber.org/protocol/disco#info"/>
</iq>
]]></example>

<p>The remote entity will advertise the "http://jabber.org/protocol/rel" namespace as a feature to represent they implement this protocol.</p>

<example caption="Response"><![CDATA[
<iq type="result" from="joe@blow.com/Home" id="sd_1">
  <query xmlns="http://jabber.org/protocol/disco#info">
    <feature var="http://jabber.org/protocol/rel"/>
  </query>
</iq>
]]></example>

</section2>

<section2 topic="Obtaining a REL context">
<p>To use REL, the entities must obtain a REL Context ID (or <em>cid</em>) through some action.  A <em>cid</em> is simply an opaque alphanumeric string.  For example, perhaps the link is needed for a file transfer:</p>

<example caption="Possible File Transfer"><![CDATA[
<iq type="set" id="ft_1" to="joe@blow.com/Home">
  <query xmlns="filexfer" filename="coolfile.txt"/>
</iq>
]]></example>

<example caption="Possible response"><![CDATA[
<iq type="result" id="ft_1" from="joe@blow.com/Home">
  <query xmlns="filexfer">
    <cid xmlns="http://jabber.org/protocol/rel" value="myCID"/>
  </query>
</iq>
]]></example>

<p>All high-level protocols that use Reliable Entity Link MUST have a way of providing such a cid.  The cid must be unique among all other REL cids between the two entities.</p>
</section2>

<section2 topic="Selecting a Stream">
<p>The next step is to ask the remote entity which stream method it would like to use.  We will use <span class="ref"><link url="https://xmpp.org/extensions/xep-0020.html">Feature Negotiation (XEP-0020)</link></span> <note>XEP-0020: Feature Negotiation &lt;<link url="https://xmpp.org/extensions/xep-0020.html">https://xmpp.org/extensions/xep-0020.html</link>&gt;.</note> for this.  The streams are listed using the short names from the table of supported streams.</p>

<example caption="Selecting a stream"><![CDATA[
<iq type="get" id="rel_1" to="joe@blow.com/Home">
  <query xmlns="http://jabber.org/protocol/rel" cid="myCID" keepAlive='true'>
    <feature xmlns="http://jabber.org/protocol/feature-neg">
      <x xmlns="jabber:x:data">
        <field var="method" type="list-single">
          <option><value>s5b</value></option>
          <option><value>ibb</value></option>
        </field>
      </x>
    </feature>
  </query>
</iq>
]]></example>

<p>The keepAlive attribute indicates that the initiator is planning on trying another method if the one selected here is to fail.  An entity SHOULD use keepAlive for all attempts but the last for a given application.  If keepAlive is omitted, then it is considered false.</p>

<p>The remote entity will then agree on a method:</p>
<example caption="Possible response"><![CDATA[
<iq type="result" id="rel_1" from="joe@blow.com/Home">
  <query xmlns="http://jabber.org/protocol/rel" cid="myCID">
    <feature xmlns="http://jabber.org/protocol/feature-neg">
      <x xmlns="jabber:x:data" type="submit">
        <field var="method">
          <value>s5b</value>
        </field>
      </x>
    </feature>
  </query>
</iq>
]]></example>

<p>Or maybe an error:</p>
<example caption="Error"><![CDATA[
<iq type="error" id="rel_1" from="joe@blow.com/Home">
  <error code="501">No supported protocols.</error>
</iq>
]]></example>

<p>If the entity returns error, then the REL cid is invalidated and the application fails.  If a stream method has been chosen successfully, then now it must be initiated using the REL cid as the stream's identifier (the stream goes into <strong><tt>INIT</tt></strong> state).</p>

<p>On <strong><tt>GOOD</tt></strong>: This indicates the stream is ready for use within the original context, and data exchanged over the stream is to be left up to the application.</p>

<p>On <strong><tt>BAD</tt></strong>: If the keepAlive="true" attribute was specified, then the initiator MUST repeat this section over again to attempt with a different method.  If keepAlive was not specified, then the REL cid is invalidated and the application fails.</p>

<p>On <strong><tt>CLOS</tt></strong> or <strong><tt>ERR</tt></strong>, the REL cid is invalidated.</p>
</section2>
</section1>

<section1 topic="Security Considerations">
  <p>There are no security considerations.</p>
</section1>

<section1 topic="IANA Considerations">
  <p>This document requires no interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>
</section1>

<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <p>The <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note> shall register the 'http://jabber.org/protocol/rel' namespace as a result of this document.</p>
</section1>

<section1 topic="XML Schema">
  <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://jabber.org/protocol/rel'
    xmlns='http://jabber.org/protocol/rel'
    elementFormDefault='qualified'>

   <xs:element name='query'>
     <xs:complexType>
      <xs:attribute name='cid' type='xs:string' use='required'/>
      <xs:attribute name='keepAlive' type='xs:boolean' use='optional'/>
     </xs:complexType>
   </xs:element>

</xs:schema>
]]></code>
</section1>

</xep>
