<?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>Jingle IAX Transport Method</title>
  <abstract>This document defines a Jingle transport method that results in using the Inter-Asterisk eXchange protocol (IAX) for the final communication.</abstract>
  <number>0179</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0166</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>jingle-iax</shortname>
  <author>
    <firstname>Antonio F.</firstname>
    <surname>Cano</surname>
    <email>antoniofcano@grupoikusnet.com</email>
    <jid>antoniofcano@jabber.org</jid>
  </author>
  &stpeter;
  <revision>
    <version>0.2</version>
    <date>2006-03-23</date>
    <initials>psa</initials>
    <remark><p>Recommended use of IAX-native methods for DTMF.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2006-03-09</date>
    <initials>psa</initials>
    <remark><p>Initial version.</p></remark>
  </revision>
  <revision>
    <version>0.0.4</version>
    <date>2006-03-02</date>
    <initials>afc</initials>
    <remark><p>Synced with last revision of Jingle and Raw UDP transport. Review some descriptions and modify some names like location for candidate</p></remark>
  </revision>
  <revision>
    <version>0.0.3</version>
    <date>2006-02-26</date>
    <initials>afc</initials>
    <remark><p>Modify the initiate proccess, Rome tell to Juliet the transport to use and she answer with the transport information needed to be contacted. Added to transport the remoteTransport an localTransport data.</p></remark>
  </revision>
  <revision>
    <version>0.0.2</version>
    <date>2006-02-24</date>
    <initials>afc</initials>
    <remark><p>Some fixes and take care of Asterisk PBX entity.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2006-02-23</date>
    <initials>afc</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>
<section1 topic='Introduction' anchor='intro'>
  <p>&xep0166;  defines a framework for negotiating and managing out-of-band multimedia sessions over XMPP. In order to provide a flexible framework, the base Jingle specification defines neither data transport methods nor media (session) types, leaving that up to separate specifications. The current document defines a transport method for establishing and managing &iax; sessions between XMPP entities.</p>
  <p>IAX is a peer-to-peer media and signaling protocol, where the endpoints maintain state machines. With respect to media, sequencing and timing information is included into IAX frames, without the use of Real-Time Transport Protocol (RTP) for the media. <note>IAX is a binary protocol; this design choice was made for bandwidth efficiency.</note> The IAX protocol handles the signaling and, when the call is accepted by both peers, the media passes between the two hosts. With this approach, IAX doesn't suffer from NAT traversal problems associated with others protocols like SIP or other related protocols.</p>
</section1>
<section1 topic='Requirements' anchor='reqs'>
  <p>The Jingle transport description defined herein is designed to meet the following requirements:</p>
  <ol>
    <li>Enable negotiation of parameters necessary for take in contact both IAX peers.</li>
    <li>Make it relatively easy to implement support in standard Jabber/XMPP clients.</li>
    <li>Where communication with non-XMPP entities is needed, push as much complexity as possible onto server-side gateways between the XMPP network and the non-XMPP network.</li>
  </ol>
</section1>
<section1 topic='Protocol Description' anchor='protocol'>
  <section2 topic='Transport Initiation' anchor='protocol-initiate'>
    <p>In order for the initiating entity in a Jingle exchange to start the negotiation, it MUST send a Jingle "session-initiate" stanza as described in <cite>XEP-0166</cite>. This stanza MUST include at least one transport method. If the initiating entity wishes to negotiate the IAX transport, it MUST include an empty &TRANSPORT; child element qualified by the 'http://jabber.org/protocol/jingle/transport/iax' namespace.</p>

   <example caption="Initiation Example, sended by Romeo"><![CDATA[
    <iq to='juliet@capulet.com/balcony'
      from='romeo@montague.net/orchard'
      id='jingle1'
      type='set'>
      <jingle xmlns='http://jabber.org/protocol/jingle'
            action='session-initiate'
            initiator='romeo@montague.net/orchard'
            sid='a73sjjvkla37jfea'>
        <description ...> 
        <transport xmlns='http://jabber.org/protocol/jingle/transport/iax' version='2'/>
    </jingle>
    </iq>
  ]]></example>

 </section2>

  <section2 topic='Target Entity Response' anchor='protocol-response'>
    <p>As described in <cite>XEP-0166</cite>, to provisionally accept the session initiation request, the target entity returns an IQ-result:</p>
    <example caption="Target Entity Provisionally Accepts the Session Request"><![CDATA[
<iq type='result' from='juliet@capulet.com/balcony' to='romeo@montague.net/orchard' id='jingle1'/>
    ]]></example>
    <p>To accept the IAX  transport method, the target entity MUST send a &JINGLE; element with an action of 'transport-accept', specifying the transport method desired.</p>
    <p>This &TRANSPORT; element MUST include two  &CANDIDATE; element per channel, whose 'ip' and 'port' attributes specify the IP address and port number of the candidate that the initiator has reason to believe will be most likely to succeed for that channel. The two candidates are the local and remote one. NAT type doesn't matter because the IAX protocol by itself addresses the problem of NAT traversal. We differentiate the two candidates with name attribute.</p>
    <p>The transport attributes are:</p>
    <ol>
      <li>Version -- this is the protocol version we want to use by (currently 1 or 2, perhaps other versions in the future). This information is provided as an attribute of the transport.</li>
      <li>User -- the user needed to log into the Asterisk PBX. This is OPTIONAL.</li>
      <li>Password -- the password needed to log the User into the Asterisk PBX. This is OPTIONAL.</li>
      <li>Secure -- describes the encryption method, this is OPTIONAL because at the moment there is one implementation of AES128 in Asterisk but not in the protocol, this could change in the future.</li>
    </ol>
    <p>User and Password are OPTIONAL and needed in the case we want to call an extension that is behind an Asterisk PBX. The Asterisk PBX has to be properly configured to accept this kind of call.</p>
    <p>When we get the answer, it is time to see if the media that we want to start is supported by both peers. If so the IAX session is initialized by the protocol stack.</p>
    <p>The candidate attributes are:</p>
    <ol>
      <li>Name -- the name of the candidate MUST be local, public or vpn.</li>
      <li>IP -- the IP where the candidate is located.</li>
      <li>Port -- the port where the candidate is listening.</li>
    </ol>
    <p>To discover this public IP address we need a third party and SHOULD make discovery via &rfc3489;, which will be an address on the outside of the firewall or NAT.</p>
    <example caption="Target Entity Accepts the IAX Transport Method"><![CDATA[
    <iq to='romeo@montague.net/orchard'
        from='juliet@capulet.com/balcony'
        id='jingle1'
        type='set'>
      <jingle xmlns='http://jabber.org/protocol/jingle'
            action='transport-accept'
            initiator='juliet@capulet.com/balcony'
            sid='a73sjjvkla37jfea'>
        <transport xmlns='http://jabber.org/protocol/jingle/transport/iax' 
                   version='2' 
                   secure='aes128' 
                   user='some-Asterisk-Username' 
                   password='some-Asterisk-Password'>
          <candidate name='local' ip='some-Local-IP-address-here' port='some-Local-Port-here'/>
          <candidate name='public' ip='some-Remote-IP-address-here' port='some-Remote-Port-here'/>
        </transport>
    </jingle>
    </iq>
  ]]></example>
  </section2>
  <section2 topic='Informational Messages' anchor='protocol-info'>
     <p>The syntax and semantics informational message payloads specific to the IAX  transport method will be defined in a future version of this specification.</p>
  </section2> 
</section1>
<section1 topic='Implementation Notes' anchor='impl'>
    <section2 topic='Ports' anchor='impl-ports'>
      <p>The port is returned by the IAX library stack initialization process. <note>Among IAX library implementations, <link url='http://iaxclient.sourceforge.net/'>IAXclient</link> is recommended since it is easy to use, stable, multiplatform, and used in most IAX implementations.</note> By default the port is 4569 UDP but if there is more than one IAX entity in the same box this port could be different.</p>
    </section2>
    <section2 topic='Caller Identification' anchor='impl-id'>
       <p>Once the Jingle negotiation has been completed and the IAX stack has control, the initiating entity has to set his callerID information (cidname to Jingle and cidnum to JabberID) before dialing to a contact. If the initator's client has to show the contact's information, this comes from the initiator attribute of the returned IQ.</p>
    </section2>
    <section2 topic='Asterisk PBX' anchor='impl-pbx'>
       <p>IAX is a native protocol of the Asterisk PBX. When using the IAX protocol we could easily connect with an Asterisk PBX. There are two scenarios:</p>
       <ol>
         <li><p>We want to reach an internal extension directly (or go to PSTN line through Asterisk). in that case we need a user and password with rights into the PBX and setup into the Jabber client (the Jabber client will act like a softphone). This information has to be given for the final user to the entity. The idea in this scenario isn't so clear because if the jabber client acts like a softphone and we need to call an extension, we coudl just dial the extension without using Jingle.</p></li>
         <li><p>The Asterisk PBX accept incoming calls from IAX. In that case just call the Asterisk like other peer and the Asterisk MUST be properly configured for accepting the 'anonymous' (not an internal user of the PBX) incoming call.</p></li> 
      </ol>
      <p>In both cases, the Asterisk PBX has to be logged into the Jabber network and implement the Jingle extension like a channel (Asterisk terminology).</p>
    </section2>
    <section2 topic='DTMF' anchor='impl-DTMF'>
      <p>If it is necessary to send Dual Tone Multi-Frequency (DTMF) tones, it is RECOMMENDED to use the IAX-native methods specified in <cite>draft-ietf-guy-iax</cite>. The XML format specified &xep0181; MAY be used only as a fallback.</p>
    </section2>
</section1>
<section1 topic='Security Considerations' anchor='security'>
  <p>To follow.</p>
</section1>
<section1 topic='IANA Considerations' anchor='iana'>
  <p>This document requires no interaction with &IANA;.</p>
</section1>
<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
    <p>The &REGISTRAR; shall include 'http://jabber.org/protocol/jingle/transport/iax' and 'http://jabber.org/protocol/jingle/info/iax' in its registry of protocol namespaces.</p>
  </section2>
  <section2 topic='Jingle IAX Transport Description' anchor='registrar-transport'>
    <p>The XMPP Registrar shall include the name "iax" in its registry of Jingle transport descriptions. The registration is as follows:</p>
    <code><![CDATA[
<transport>
  <name>iax</name>
  <desc>Jingle IAX sessions.</desc>
  <doc>XEP-0179</doc>
</transport>
    ]]></code>
  </section2>
</section1>
</xep>
