<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
  <!ENTITY % ents SYSTEM "xep.ent">
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
  <title>Reliable Entity Link</title>
  <abstract>Protocol for linking a bytestream between two Jabber entities.</abstract>
  &LEGALNOTICE;
  <number>0041</number>
  <status>Retracted</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <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@affinix.com</email>
    <jid>justin@andbit.net</jid>
  </author>
  <revision>
    <version>0.2</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>&xep0047;</td>
  </tr>
  <tr>
    <td>s5b</td>
    <td>&xep0065;</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 &xep0030;:</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 &xep0020; 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 &IANA;.</p>
</section1>

<section1 topic='XMPP Registrar Considerations'>
  <p>The &REGISTRAR; 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>
