<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc compact="yes"?>
<?rfc sortrefs="yes"?>
<?rfc linkmailto="no"?>
<?rfc strict="no"?>
<?rfc subcompact="no"?>
<?rfc symrefs="yes"?>


<rfc ipr="trust200811" category="std">

  <front>
    <title abbrev="SIP media with XMPP IM and presence">
      Guidelines and Protocol Extensions for Combining SIP Based
      Real-time Media Sessions With XMPP Based Instant Messaging and
      Presence Service.   
    </title>
    
    <author initials="S" surname="Veikkolainen" fullname="Simo Veikkolainen">
      <organization>Nokia</organization>
      <address>
	<postal>
	  <street>P.O. Box 407</street>
	  <city>NOKIA GROUP</city> 
	  <region>FI</region> 
	  <code>00045</code>
	  <country>Finland</country>
	</postal>
	<phone>+358 50 486 4463 </phone>
	<email>simo.veikkolainen@nokia.com</email>
      </address>
    </author>
    
    <author initials="M" surname="Isomaki" fullname="Markus Isomaki">
      <organization>Nokia</organization>
      <address>
	<postal>
	  <street>P.O. Box 100</street>
	  <city>NOKIA GROUP</city> 
	  <region>FI</region> 
	  <code>00045</code>
	  <country>Finland</country>
	</postal>
	<phone>+358 50 522 5984</phone>
	<email>markus.isomaki@nokia.com</email>
      </address>
    </author>
    
    <date day="4" month="March" year="2009"/>
    <area>RAI</area>
<!--    <workgroup>SIP WG</workgroup> -->
    <keyword>I-D</keyword>
    <keyword>Internet-Draft</keyword>
    <keyword>XMPP</keyword>
    <abstract>
      <t>
	This memo defines guidelines and protocol extensions for
	combining Session Initiation Protocol (SIP)  based real-time
	media sessions with Extensible Messaging and Presence Protocol
	(XMPP) based instant messaging and presence services in a
	seamless manner. This is accomplished by integration and
	protocol extension support in the endpoints, without
	requiring any changes in the SIP or XMPP server
	infrastructure. It is even possible that SIP and XMPP services
	are offered by different service providers. 
      </t>
    </abstract> 
  </front>
  
  <middle>
    <section anchor="intro" title="Introduction">
      
      <t>
	Currently most standards-based Voice over IP (VoIP)
	deployments use Session Initiation Protocol (SIP). In addition
	to providing basic voice service SIP has an extensive support
	for more advanced telephony features including interworking
	with the traditional Public Switched Telephone Network
	(PSTN). SIP is also gaining popularity in the field of video
	communication.
      </t>

      <t>
	At the same time, the Extensible Messaging and Presence
	Protocol (XMPP) is enjoying widespread usage in instant
	messaging and presence services. An interesting scenario
	arises when a SIP based voice and video service is combined
	together with an XMPP based instant messaging and presence
	service.
      </t>
      
      <t>
	This memo describes how SIP based real-tome sessions and XMPP
	based IM and presence can be offered using existing server
	implementations. This memo also presents a set of requirements
	and protocol extensions for SIP User Ageng and XMPP client
	implementations in order to offer a seamless usage experience
	when using SIP based VoIP  with XMPP based instant messaging
	and presence. 
      </t>
      
      <t>
	Combining SIP based real-time services with XMPP based presence
	and IM service can be accomplished for the most part in the
	endpoints; little if anything needs to be done in the service
	infrastructure. It is also possible to achieve seamless
	integration even when SIP and XMPP services are offered by
	different service providers.
      </t>
      
      <t>
	The main issues that need to be addressed when offering such
	combined services are identities and addressing. SIP and XMPP
	both use a similar addressing scheme (based on "user@domain"
	structure) to identify users and endpoints but there are some
	subtle differencies as well. It is not possible to assume any
	algorithmic correlation between SIP and XMPP Universal
	Resource Identifiers (URI), even when they identify the same
	user or endpoint. New protocol mechanisms are needed to tie
	together communication contexts that are based on the two
	protocols. 
      </t>
	  
      <t>
	We do not discuss how protocol translation through a gateway
	could be performed between the protocols; this is the subject
	of other work, see for example <xref
	target="I-D.saintandre-sip-xmpp-core"/>. 
      </t>

      <t>
	We focus on one-to-one communication only. Multiparty use
	cases such as combining SIP voice conference with XMPP IM
	group chat are beyond the scope.
      </t>

      <t>
	The document structure is as follows: <xref
	target="sec-conventions"/> present the document conventions
	and definitions, <xref
	target="sec-deployment-scenarios-and-use-cases"/> presents
	deployment scenarios and use cases, <xref
	target="sec-requirements"/> lists the 
	requirements, <xref target="sec-overview-of-operation"/>
	provides an operview of the protocol operation, <xref
	target="sec-protocol-extensions"/> provides the defintions,
	and examples are presented  in <xref target="sec-examples"/>. 
      </t>
    </section>
    
    <section title="Conventions Used in This Document"
	     anchor="sec-conventions"> 
      
      <t>
	The key words "MUST", "MUST NOT", "REQUIRED", "SHALL",
	"SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED",  "MAY", and
	"OPTIONAL" in this document are to be interpreted as described in
	BCP 14, <xref target="RFC2119">RFC 2119</xref> and indicate
	requirement levels for compliant implementations.
      </t>

     <t>
	The following definitions are used in this memo:
      </t>
      <t>
	<list>
	  <t>Integrated endpoint is an implementation that combines
	  the functionality of SIP User Agent and XMPP client and can
	  offer its user a seamless user experience in the 
	  sense that a single UI and contact information can be user
	  for voice and video communication using the SIP protocol as
	  well as instant messaging and presence sharing using
	  XMPP. We assume an integrated endpoint is able to support
	  SIP and XMPP protocol extensions defined in this memo.</t>
	  
	  <t>Separated endpoint refers to independent SIP User Agent and
	  XMPP client implementations that are not aware of each other
	  if they are used by the same user. The users uses SIP UA for
	  voice and video, while using XMPP client for IM and
	  presence. It is assumed that a separated endpoint does not
	  support any SIP or XMPP protocol extensions defined in this
	  memo.</t> 
	</list>
      </t>

  
    </section>
    
    <section title="Deployment scenarios and use cases"
	     anchor="sec-deployment-scenarios-and-use-cases">
      
      <t>
	This section presents the assumptions we make about SIP and
	XMPP deployments with respect to endpoints and server
	infrastructure. We also enumerate the actual use cases that
	the combined service must accommodate for.
      </t>
      
      <section title="Deployment scenarios"
	       anchor="sec-deployment-scenarios"> 
	
	<t>
	  The assumption is that the server infrastructure for SIP and
	  XMPP are totally separated, thus no exchange of information
	  is expected between them. There is no assumption that SIP
	  and XMPP services are even offered by the same service
	  provider. This means that the user identities can even be
	  from two different domains. However, if the same service
	  provider offers both SIP and XMPP service, it is recommended
	  that the URIs sip:user@domain and xmpp:user@domain
	  correspond to the same user. 
	</t>
	  
	<t>
	  We assume that the user intially only knows the contact
	  address of the other user in one protocol space. The contact
	  address for the other protocol must be learned through this.
	</t>

	<t>
	  We consider only cases where two integrated endpoints
	  interact. When an intergrated endpoint communicates with a
	  separated endpoint, normal SIP and XMPP procedures apply and
	  no extensions defined in this memo are used. 
	</t>
	
      </section>

      <section title="Use cases" anchor="sec-use-cases">
	
	<t>
	  <list style="symbols">
	    <t>
	      Two users who both use an integrated endpoint start an
	      (XMPP) IM conversation. After the exchange of initial
	      messages, their UIs show that the other party is capable
	      of (SIP) voice and/or video in addition to IM. Either
	      user can at any point add voice and/or video component
	      to the conversation in such a way that they end up in
	      the same endpoint and conversation context where the IM
	      exchange is already taking place. (Note that for this
	      use case the conversation initiatior initially only
	      needs to know the other user’s XMPP user id.)
	    </t>

	    <t>
	      Two users who both use an integrated endpoint start a
	      (SIP) voice and/or video call. As the call is
	      established, their UIs show that the other party is
	      capable for (XMPP) IM. Either user can at any point add
	      an IM component to the conversation in such a way that
	      they end up in the same endpoint and conversation
	      context where the voice and/or call is already taking
	      place. (Note that for this use case the caller
	      initially only needs to know the other user’s SIP user
	      id.)    
	      <list style="empty">
		<t>
		  It is possible to vary the two cases above so that
		  one fo the users initiates a "multimedia call" to
		  the other one, i.e. SIP voice and/or video and XMPP
		  IM are all active from the stary. Tehcnically this
		  happens according to the two-phased approach above,
		  and it inivisble from the end-user.
		</t>
	      </list>
	    </t>

<!--	    <t>
	      It is possible to vary the two use cases above so that
	      one of the users initiates a “multimedia call” to the
	      other one, i.e. SIP voice and/or video and XMPP IM are
	      all active from the start. (Technically this may happen
	      according to the two-phased approach above, but
	      invisibly to the end-user.) It is possible that the
	      callee does not support all necessary protocol or media
	      capabilities, so the call may end up being reduced to
	      just voice and/or video or IM conversation. 
	    </t>
-->

	    <t>
	      A user of an integrated endpoint is able to publish her
	      SIP voice and video related presence status as part of
	      her XMPP presence. The status includes information such
	      as user’s SIP contact address (for the integrated
	      endpoint), media capability and availability and whether
	      the user is currently “on the phone”. Another user of an
	      integrated endpoint can see the presence status
	      (assuming she is authorized for that) and based on that
	      initiate calls. For instance watcher’s UI can now for
	      certainty show that the user on her roster is capable
	      of receiving “multimedia calls” (Note that the watcher
	      initially only needs to know the other user’s XMPP user id.)    
	    </t>
	  </list>

	  <t>
	    <list>
	      <t>OPEN ISSUE: Is there a use case for discovering
	      other user’s XMPP identity based on her SIP identity
	      without needing to establish a media session. SIP
	      OPTIONS would be one possibility for that (as we do
	      not assume SIP presence support).</t> 
	    </list>
	  </t>
	  
	</t>

<!--	<t>
	  A user wishing to establish a connection with another user
	  selects a contact from the phonebook and establishes the
	  session or connection as per normal procedures defined for
	  the protocol in question.
	</t>
	
	<t>
	  If a user wants to add a voice component to an ongoing
	  instant messaging session, or vice versa, the new connection
	  is also established using the normal procedures defined the
	  the protocol. 
	</t>

	<t>
	  In oder to find out that the incoming connection request is
	  related to an ongoing communication with the same user, the
	  terminating client needs to compare the originating
	  identities of the sessions.
	</t>

	<t>
	  Often, the identity of the originating user in the other
	  domain is not known by the terminating client. Therefore, a
	  mechanism should be available to carry the identifiers from
	  another protocol domain.
	</t>

	<t>
	  The presence information is managed by XMPP. Normally, XMPP
	  presence clients allow the user to manually set the presence
	  status (available, busy, away, etc.). One useful feature
	  when offering VoIP services is to set the presence status
	  automatically to busy when the user is engaged in a call, or
	  set the presence status to do-not-disturb when the user
	  has set DnD on from the VoIP client. Similarly, setting
	  presence to DnD should result in the voice calls to be
	  treated as if the user set the DnD feature on.
	</t>

	<t>
	  We assume that an integrated client has an ability to
	  monitor the status of the communication in the other
	  protocol domain. For example, an application, when
	  establishing or receiving a voice call also at the same time
	  instructs the client to set the presence status to
	  busy. This is quite straightforward requiremnt for an
	  integarted client. 
	</t>
-->

      </section>
    </section>
    
    <section title="Requirements" anchor="sec-requirements">
      <t>
	This section presents the protocol requirements.
      </t>
      
      <t>
	<list style="format REQ-%d:">
	  
	  <t>
	    It must be possible for the sender of an XMPP message to
	    include its SIP contact information within the
	    message. The contact information must allow the recipient
	    to establish the SIP session such that the session is
	    routed to the same endpoint which is hosting the XMPP
	    conversation. As including the same information
	    in every message would create some overhead, it is
	    desirable to be able to convey the contact only once per
	    IM conversation/thread.  
	  </t>

	  <t>
	    It must be possible for the caller to convey in the SIP
	    session initiation information which allows the callee to
	    correlate the session with an ongoing XMPP conversation. 
	  </t>

	  <t>
	    It must be possible for the SIP User Agent Client and User
	    Agent Server that establish a real-time media session to
	    exchange their XMPP contact information so that either
	    endpoint can at any time send XMPP messages to the other
	    endpoint. 
	  </t>

	  <t>
	    It must be possible for the sender to convey in the XMPP
	    message information which allows the recipient to
	    correlate the message with an ongoing SIP session.
	  </t>
	  
	  <t>
	    It must be possible to include SIP real-time media related
	    contact and status in XMPP presence information. The
	    information must contain at least SIP contact address to
	    identify a user or a user agent instance, media
	    capabilities and general availability status
	  </t>
	  
	</list>
	
      </t>

      
      <t>
	<list>
	  <t>OPEN ISSUE: Should we define requirements related to
	  “error” or “corner” cases here. For instance what happens to
	  communication attempts after the other party has closed the
	  conversation context, e.g. a correlated XMPP message that is
	  sent after the related SIP session is terminated. Or a SIP
	  INVITE that appears two days after the XMPP IM conversation
	  was ended.</t> 
                

	  <t>NOTE: There is also an implicit requirement that we must
	  take Session Border Controllers into account when defining
	  how SIP User Agents are able to identify an existing session
	  between them in a common manner.</t> 
	</list>
      </t>

    </section>


    <section title="Overview of operation"
	     anchor="sec-overview-of-operation"> 
      
      <t>
	Both SIP and XMPP allow registration of multiple endpoints 
	using the same identifier, either a SIP AOR or XMPP
	Jabber ID (JID). When two endpoints are enganged in an IM
	conversation, for example, and wish to add a voice component
	to the communication, it has be ensured that the resulting SIP 
	dialog is targeted to the same endoint that is
	running the IM conversation. Fortunately, both XMPP and SIP
	provide a mechanism for this.
      </t>
      
      <t>
	<xref target="I-D.ietf-sip-gruu"/> defines mechanisms for
	a SIP UA to obtain and use a Globally Routable User Agent
	(UA) URI. A GRUU will route a call to a specific UA
	instance. Unfortunately, not all SIP registrars support the
	optional GRUU mechanism. In that case the SIP UA has not other
	option but to use its AOR in place of GRUU.
      </t>
      
      <t>
	In XMPP, a "full JID" consists of a name,
	domain and a resource identifier in the form of
	&lt;name@domain/resource&gt;. The resource identifier can be
	used to identify a specific endpoint.
      </t>


      <section title="Endpoints engaged in XMPP conversation adding a
		      SIP session" anchor="sec-adding-sip-session">
	
      <t>
	<figure align="center"><artwork><![CDATA[

Bob                    Alice
 |                       |
 |    IM session         |
 |<=====================>|
 |                       |
 | (F1) INVITE           |
 |---------------------->|
 |                       |
 | (F2) 200OK            |
 |<----------------------|
 |                       |
 | (F3) ACK              |
 |---------------------->|
 |                       |
 |  RTP media            |
 |<=====================>|
 |                       |

]]>	</artwork></figure>
      </t>

      <t>
	This case starts by one endpoint (Bob) sending a message
	stanza to another (Alice). Bob includes &lt;thread&gt; element in
	the message and chooses a unique value for it. In his first
	message Bob also includes his SIP URI in &lt;sip-contact&gt;
	element, defined in <xref
	target="sec-extension-message-stanza"/>. If Bob has been able to
	obtain a GRUU from his registrar, he populates the
	&lt;sip-contact&gt; with that. Otherwise a mere AOR is used. When
	Alice receives Bob’s SIP URI Alice stores it associated with
	the current &lt;thread&gt;. When responding to Bob’s messages
	Alice also includes &lt;thread&gt; and her SIP URI (GRUU or
	AOR) in &lt;sip-contact&gt;. Upon receiving Alice’s first message
	Bob stores Alice’s SIP URI associated with the current
	&lt;thread&gt;. In addition to containing a SIP URI,
	&lt;sip-contact&gt; also conveys the information whether an
	endpoint supports audio or video or both medias. So, based on
	exchanged &lt;sip-contact&gt; elements, both endpoints now know
	each others SIP URIs and media capabilities.  
      </t>

      <t>
	The same &lt;thread&gt; value is used in all further messages by
	both endpoints to keep track of the conversation. As long as
	the &lt;thread&gt; value is unchanged, the &lt;sip-contact&gt;
	element need not be repeated, unless either endpoint’s SIP
	GRUU changes for some reason.    
      </t>

      <t>
	When either party wants to extend the IM conversation by
	adding SIP voice or video session, they address a SIP INVITE
	to the SIP URI learned in &lt;sip-contact&gt;. If &lt;contact&gt;
	contained a GRUU, it ensures that the INVITE will be routed to
	the correct endpoint. The caller populates XMPP-Thread header,
	defined in <xref target="sec-xmpp-thread-header"/>, 
	in the INVITE with the value of &lt;thread&gt;. The callee is
	thus able to correlate the SIP session to the IM
	conversation. The callee replays XMPP-Thread in responses to
	INVITE to indicate that the correlation was successful.  
      </t> 

      
    </section>
      
  
    <section title="Endpoints engaged in a SIP session adding an
		    XMPP IM conversation"
	     anchor="sec-adding-xmpp-conversation"> 

      <t>
	In this case two endpoints first have a SIP voice or video
	session. They exchange their full JIDs within the session
	establishment. The caller (Bob) adds XMPP-Contact header,
	defined in <xref target="sec-xmpp-contact-header"/>, in
	INVITE populating it with his full JID. XMPP-Contact also
	includes an opaque end-to-end identifier for the session
	common to both endpoints. The callee (Alice) stores this
	information as part of the session state. In 200 OK response
	to INVITE Alice includes similar XMPP-Contact header with
	her full JID, and replays the end-to-end session
	identifier. Bob stores this information as part of his
	session state. Both endpoints now know each others full JIDs
	and have a common reference to the session. 
      </t> 
      
      <t>	
	<list>	  
	  <t>OPEN ISSUE: Instead of defining XMPP-specific session
	  identifier we could use SIP call-id as is. However, there
	  is a concern that call-id may be changed by SBCs en route
	  is thus might not be a useful as a common reference for
	  both User Agents. <xref target="I-D.kaplan-sip-session-id"/>
	  defines a Session-ID header that potentially could also be
	  used.</t>   
	</list>      
      </t> 
      
      <t>
	When either endpoint wants to send XMPP messages to each
	other, they address them to the full JID learned from
	XMPP-Contact header. This ensures that the messages reach
	the correct endpoint. In the very first message the sender
	also includes &lt;sip-correlation&gt; element, defined in
	<xref target="sec-extension-message-stanza"/>, with the session
	identifier value learned from XMPP-Contact. The recipient
	uses the value to correlate the message with the SIP session
	and echoes it back the first message it sends to indicate
	that the correlation was succesful.  
      </t>
      
    </section>
    

      <section title="Using XMPP presence for publishing and obtaining
	SIP contact address, media capabilities and availability"
	       anchor="sec-using-xmpp-presence"> 

	<t>
	  SIP related presence information is encoded in XMPP presence
	  schema as an extension. It includes endpoints SIP URI
	  (preferably GRUU but can be also AOR), media capabilities
	  (audio, video), and availability (open, closed, busy). Based
	  on this information XMPP Presence watcher is able to
	  initiate SIP voice and video sessions. 
	</t>

    </section>

  </section>
    
  <section title="Protocol extensions" anchor="sec-protocol-extensions">
      
      <t>
	In this section we define protocol extensions to meet the
	requirements stated in the previous section. 
      </t>
      
      <section title="Extensions to XMPP message stanza"
	       anchor="sec-extension-message-stanza"> 
	
	<t>
	  The child elements of the message stanza can be extended
	  with elements from other namespaces. For the purposes of
	  carrying a SIP identifier in the message stanza, we define
	  two new elements, the &lt;sip-contact&gt; element and
	  &lt;sip-correlation&gt; element.
	</t>

	<section title="The &lt;sip-contact&gt; element"
		 anchor="sip-contact-element"> 
	<t>
	  The &lt;sip-contact&gt; element, qualified by
	  "http://jabber.org/protocol/sip-contact" namespace, has one
	  mandatory attribute, "target", which defines the target's
	  SIP URI. The format of the "target" attribute is an
	  absoluteURI defined in <xref target="RFC3261"/>.
	</t>
	
	<t>
	  When an endpoint initiates an XMPP IM conversation, and
	  wants to offer a possibility to later add a SIP real-time
	  media session, it MUST include a &lt;sip-contact&gt; element
	  as a child element in the first the &lt;message&gt; stanza
	  it sends, and MUST add a &lt;thread&gt; element and populate
	  its value according to <xref target="RFC3921"/>. The
	  endpoint MUST include in the “target” attribute of the
	  &lt;sip-contact&gt; element the SIP URI it wishes to be
	  contacted at. If the endpoint is aware of its GRUU, it
	  SHOULD use that as the value in the “target” attribute;
	  otherwise it MAY use its AOR.  
	</t>

	<t>
	  The endpoint receiving an XMPP &lt;message&gt; stanza that
	  includes &lt;thread&gt; and &lt;sip-contact&gt; elements
	  MUST copy the &lt;thread&gt; element value to the first
	  &lt;message&gt; stanza it sends back, as defined in <xref
	  target="RFC3921"/>, and MUST include a &lt;sip-contact&gt;
	  element and set the “target” attribute value to the SIP URI
	  it wishes to be contacted at.  
	</t>

	<t>
	  An endpoint MUST add its audio and video capabilities
	  defined in <xref target="RFC3840"/> to the contact address
	  in the “target” attribute, and MUST understand those
	  capabilities if received from the other endpoint. An
	  endpoint MAY add other media capabilities.  
	</t>

	<t>
	  When an endpoint receives a &lt;sip-contact&gt; element in a
	  &lt;message&gt; stanza, it MUST store the value of the target
	  attribute, and use it as the SIP URI in an INVITE request if
	  the user of the endpoint would like to add a SIP session to
	  the IM conversation context 
	</t>

	<t>
	  For example, a &lt;sip-contact&gt; element carrying a SIP
	  Globally Routable Unique URI (GRUU) would be
	</t>
	<figure><artwork><![CDATA[
  <sip-contact target="<sip:alice@example.com">;gr=urn:
     uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6;
     audio;video">
]]>	</artwork></figure>

	</section>

	<section title="The &lt;sip-correlation&gt; element"
		 anchor="sip-correlation-element"> 
	  <t>
	    In order to indicate that an XMPP IM conversation is
	    related to an existing SIP session, we define a new
	    element in the message stanza called &lt;sip-correlation&gt;. The
	    &lt;sip-correlation&gt;, qualified by the
	    "http://jabber.org/protocol/sip-correlation" namespace,
	    has one mandatory attribute, "value".
	  </t>
	  <t>
	    The endpoint sending the &lt;message&gt; stanza MUST set
	    the "value" attribute to the value of the
	    correlation-value parameter of the SIP XMPP-Contact
	    header. The XMPP-Contact header is exhanged during the
	    setup of the SIP session. The endpoint MUST also include
	    a &lt;thread&gt; element in the message.
	  </t>

	  <t>
	    An endpoint receiving a &lt;message&gt; stanza which
	    includes a &lt;sip-correlation&gt; element MUST first
	    compare the "from" attribute value of the &lt;message&gt;
	    stanza to the XMPP JID in the contact-value of the
	    XMPP-Contact header of its active SIP sessions. If a
	    matching SIP session is found, the endpoint MUST compare
	    the "value" attribute to the correlation-value of the
	    XMPP-Contact header of that SIP session. If the "value"
	    attribute matches to correlation-value of an XMPP-Contact
	    header, the &lt;message&gt; stanza is correlated to that
	    SIP session. If the user replies to the message, the
	    values of the &lt;thread&gt; element and the "value"
	    attribute of the &lt;sip-correlation&gt; element in the
	    first reply MUST be the same as in the original
	    message. This indicates that the correlation was
	    successful. The correlation is valid as long as the
	    messages are exchanged with the same &lt;thread&gt;
	    value. 
	  </t>

	  <t>
	    As an example, a &lt;sip-correlation&gt; element carrying
	    the XMPP-Contact header correlation-value parameter of an
	    existing SIP session would be

	    <list>
	      <t>&lt;sip-correlation value="xyz123"/&gt;</t>
	    </list>
	  </t>
	  
	</section>

	<t>
	  <list><t>OPEN ISSUE: XML Schemas to be provided</t></list>
	</t>
      </section>

      <section title="Extensions to XMPP presence stanza"
	       anchor="sec-extensions-to-xmpp-presence-stanza"> 
	
	<t>
	  The XMPP presence stanza defined in <xref target="RFC3921"/> can
	  be extended with any properly-namespaced child element. We
	  define a new optional element called &lt;contact&gt; which,
	  qualified by the http://jabber.org/protocol/contact namespace,
	  MAY appear as a child element in the presence stanza.
	</t>
	
	<t>
	  The contact element SHOULD be set to the SIP address (GRUU or
	  AOR) the endpoint wishes to be contacted at for further
	  communication.
	</t>

	<t>
	  Exact syntax and XML Schema of the correlation element is TBD.
	</t>
	
      </section>

      <section title="Extensions to SIP headers"
	       anchor="sec-extensions-to-sip-headers"> 
	
	<section title="SIP XMPP-Thread header"
	       anchor="sec-xmpp-thread-header"> 
	
	<t>
	  In order to indicate that the SIP dialog is related to
	  an existing XMPP messaging session, we define a new SIP
	  header, called XMPP-Thread. The XMPP-Thread contains information
	  that can be used by the terminating endpoint to correlate
	  the SIP session establishment to an existing XMPP
	  conversation.
	</t>

	<t>
	  The endpoint sending a SIP INVITE request MUST include an
	  XMPP-Thread header, and set its value to the value of the
	  &lt;thread&gt; element used in the XMPP IM conversation.
	</t>

	<t>
	  The endpoint receiving a SIP INVITE which inludes an
	  XMPP-Thread header act as follows:</t>

	  <t>
	    <list style="symbols">
	      <t> it first compares the Contact header value with all
	      SIP GRUUs from &lt;sip-contact&gt;
	      elements in active XMPP IM conversations, and unless a
	      match is found,</t>
	      <t> compares P-Asserted-Identity header value with 
	      all other SIP URIs from 
	      &lt;sip-contact&gt; elements in active XMPP IM
	      conversations</t>
	      <t>if a single match is found, the receiving endpoint
	      MUST  the value of the XMPP-Thread element to the
	      &lt;thread&gt; element values of existing XMPP IM
	      conversations the endpoint has active, and 
	      </t>
	      <t>if the value matches, the SIP INVITE is correlated to
	      the IM conversation. The endpoint MUST copy the
	      XMPP-Thread header to any of the 2xx series responses.</t>
	    </list>
	</t>

	<t>
	  <xref target="fig-xmpp-thread-header-support"/>
	  defines support of XMPP-Contact header in SIP requests and
	  responses, and extends Table 2 of <xref
	  target="RFC3261"/>. MESSAGE, SUBCRIBE and NOTIFY, REFER,
	  INFO, UPDATE, PRACK, and PUBLISH are defined in <xref
	  target="RFC3428"/>, <xref target="RFC3265"/>, <xref
	  target="RFC3515"/>, <xref target="RFC2976"/>, <xref
	  target="RFC3311"/>, <xref target="RFC3262"/>, and <xref
	  target="RFC3903"/>, respectively.
	</t>


	<figure title="XMPP-Thread header support"
		anchor="fig-xmpp-thread-header-support"><artwork> 
      Header field    where   proxy   ACK  BYE  CAN  INV  OPT  REG  MSG
      ------------    -----   -----   ---  ---  ---  ---  ---  ---  ---
      XMPP-Thread       R              -    -    -    o    -    -    -
      XMPP-Thread      2xx             -    -    -    o    -    -    -

                                      SUB  NOT  REF  INF  UPD  PRA  PUB
                                      ---  ---  ---  ---  ---  ---  ---
      XMPP-Thread       R              -    -    -    -    -    -    -
      XMPP-Thread      2xx             -    -    -    -    -    -    -
    </artwork></figure>

	<t>
	  The syntax of the XMPP-Thread using augmented Backur-Naur
	  Form (ABNF) <xref target="RFC5234"/> is defined as follows:
	</t>

	<figure><artwork>
XMPP-Thread         = "XMPP-Thread" HCOLON thread-value
thread-value        = token 
                      ;defined in RFC3261
	</artwork></figure>

      </section>

      <section title="SIP XMPP-Contact header"
	       anchor="sec-xmpp-contact-header"> 
	
	<t>
	  The XMPP-Contact header is used to carry the XMPP JID and an
	  opaque token that can be used for correlation purposes. 
	</t>

	<t>
	  When an endpoint initiates a SIP session, and wants to offer
	  the possibility to later add an XMPP IM conversation, it
	  MUST include an XMPP-Contact header in the intitial SIP 
	  request. The contact-value of the XMPP-Contact header MUST
	  be set to the full XMPP JID the endpoint wishes to be contacted
	  at, and the correlation-value SHOULD be set to the value of
	  the Call-ID of the SIP session. If the Call-ID cannot be
	  used, the endpoint MUST select the correlation-value such
	  that it fulfills the same uniqueness requirements defined
	  for Call-ID in Section 8.1.1.4 of <xref target="RFC3261"/>.  
	  
	</t>

	<t>
	  An endpoint sending a 2xx series response to an INVITE that
	  contains XMPP-Contact header MUST include a XMPP-Contact
	  header in the response, MUST set the contact-value of the
	  header to the full XMPP JID the endpoint wishes to be
	  contacted at, and MUST copy the correlation-value from the
	  INVITE to the 2xx response.  
	</t>

	<t>
	  The endpoint receiving a SIP request or response with an
	  XMPP-Contact header, MUST store the value of the
	  correlation-value in order to be able to later correlate an
	  XMPP IM conversation with the SIP session. 
	</t>

	<t>
	  An endpoint initiating a correlated XMPP IM conversation
	  MUST use the correlation-value in the
	  &lt;sip-correlation&gt; element as specified in <xref
	  target="sip-correlation-element"/>. 
	</t>

	<t>
	  <xref target="fig-xmpp-contact-header-support"/>
	  defines support of XMPP-Contact header in SIP requests and
	  responses, and extends Table 2 of <xref
	  target="RFC3261"/>. MESSAGE, SUBCRIBE and NOTIFY, REFER,
	  INFO, UPDATE, PRACK, and PUBLISH are defined in <xref
	  target="RFC3428"/>, <xref target="RFC3265"/>, <xref
	  target="RFC3515"/>, <xref target="RFC2976"/>, <xref
	  target="RFC3311"/>, <xref target="RFC3262"/>, and <xref
	  target="RFC3903"/>, respectively.
	</t>

	<figure title="XMPP-Contact header field support"
		anchor="fig-xmpp-contact-header-support"><artwork> 
      Header field    where   proxy   ACK  BYE  CAN  INV  OPT  REG  MSG
      ------------    -----   -----   ---  ---  ---  ---  ---  ---  ---
      XMPP-Contact      R              -    -    -    o    -    -    -
      XMPP-Contact     2xx             -    -    -    o    -    -    -

                                      SUB  NOT  REF  INF  UPD  PRA  PUB
                                      ---  ---  ---  ---  ---  ---  ---
      XMPP-Contact      R              -    -    -    -    -    -    -
      XMPP-Contact     2xx             -    -    -    o    -    -    -
    </artwork></figure>

	<t>
	  The syntax of the XMPP-Contact using augmented Backur-Naur
	  Form (ABNF) <xref target="RFC5234"/> is defined as follows:
	</t>

	<figure><artwork>
XMPP-Contact        = "XMPP-Contact" HCOLON contact-value SEMI correlation-value
contact-value       = token 
                      ;defined in RFC3261
correlation-value   =token
	</artwork></figure>

      </section>
    </section>
  </section>
    


  <section title="Examples" anchor="sec-examples">
    
    <section title="Endpoint engaged in an IM session adds a
		    voice/video component to the conversation"
	     anchor="sec-example-add-voice-component"> 
      <t>
	<figure title="SIP voice session added to XMPP IM conversation"
		align="center"><artwork><![CDATA[  

Bob                    Alice
 |                       |
 | (F1) <message>        |
 |---------------------->|
 |                       |
 | (F2) <message>        |
 |<----------------------|
 |                       |
 | (F3) INVITE           |
 |---------------------->|
 |                       |
 | (F4) 200OK            |
 |<----------------------|
 |                       |
 | (F5) ACK              |
 |---------------------->|
 |                       |
 |  RTP media            |
 |<=====================>|
 |                       |

]]>	</artwork></figure>
      </t>

      <t>
	Bob and Alice are engaged in an XMPP IM session, when Bob
	would like to add voice/video component to the discussion. 
      </t>

      <t>
	When Bob and Alice exhange message stanzas, they also include
	the SIP address they would like to be contacted at. In this
	example, Bob is aware of its GRUU, while Alice is merely aware
	of her SIP AOR. Both include the SIP identifier in a contact
	element in the message stanza.
      </t>

      <figure title="(F1) Bob sends a message stanza to
		     Alice"><artwork><![CDATA[ 
   <message
       to='alice@example.net'
       from='bob@domain.com/Home'
       type='chat'
       xml:lang='en'>
     <body>Hi!</body>
     <thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread>

     <sip-contact target="<sip:bob@domain.com">;gr=urn:
              uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6;
              audio;video"
              xmlns="http//jabber.org/protocol/contact"/> 
   </message>

]]></artwork></figure>

      <t>
	In the above message, Bob includes his GRUU, and also the
	media capabilities Bob is capable of handling (audio and
	video). 
      </t>

      <t>
	Alice sends back a message stanza containing her SIP contact
	information. 
      </t>

      <figure title="(F2) Alice sends a message stanza to
		    Bob "><artwork><![CDATA[ 
   <message
       to='bob@domain.com/Home'
       from='alice@example.net/4FIL45729'
       type='chat'
       xml:lang='en'>
     <body>Hello there!</body>
     <thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread>

     <sip-contact target="<sip:alice@example.net">;audio;video"
              xmlns="http//jabber.org/protocol/contact"/> 
   </message>

]]></artwork></figure>

      <t>
	Bob then decides to add SIP voice call to the existing XMPP
	conversation. He picks up Alice's contact information that
	Alice sent to him in a message stanza, and issues a SIP INVITE
	request to that URI. The XMPP-Thread carries the value of the
	&lt;thread&gt; element.
      </t>

      <figure title="(F3) Bob sends a SIP INVITE to
		     Alice"><artwork><![CDATA[   

      INVITE sip:alice@example.net SIP/2.0
      Via: SIP/2.0/UDP ua-991.domain.com;branch=apo92hgb2k100
      Max-Forwards: 70
      To: Alice <sip:alice@example.com>
      From: Bob <sip:bob@domain.com>;tag=18593756298
      Call-ID: a84b4c76e66710@ua-991.domain.com
      CSeq: 314159 INVITE
      XMPP-Thread:e0ffe42b28561960c6b12b944a092794b9683a38
      Contact: "<sip:bob@domain.com">;gr=urn:
              uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6;
              audio;video"
      Content-Type: application/sdp
      Content-Length: 142
      
      (SDP not shown)

]]></artwork></figure>

      <t>
	Alice responds with 200OK accepting the session invitiation
	request. Alice also includes the XMPP-Thread element to
	indicate that she has received the thread and successfully
	correlated the session invitation to the XMPP conversation. 
      </t>

      <figure title="(F4) Alice accepts the session and sends a 200OK
		     to Bob"><artwork><![CDATA[   

      SIP/2.0 200 OK
      Via: SIP/2.0/UDP p1.example.com
         ;branch=z9hG4bKnashds8;received=192.0.2.3
      Via: SIP/2.0/UDP p1.domain.com
         ;branch=z9hG4bKnashds8;received=192.0.2.2
      Via: SIP/2.0/UDP ua-991.domain.com
         ;branch=apo92hgb2k100;received=192.0.2.1
      Max-Forwards: 70
      To: Alice <sip:alice@example.com>;tag=c09hh1lsn
      From: Bob <sip:bob@domain.com>;tag=18593756298
      Call-ID: a84b4c76e66710@ua-991.domain.com
      CSeq: 314159 INVITE
      XMPP-Thread:e0ffe42b28561960c6b12b944a092794b9683a38
      Contact: <sip:alice@192.0.2.4>
      Content-Type: application/sdp
      Content-Length: 131
      
      (SDP not shown)

]]></artwork></figure>

      <t>
	Bob then sends a ACK as per normal SIP procedures.
      </t>
    </section>

    <section title="Endpoint engaged in a SIP session adds an XMPP IM
		    conversation" 
	     anchor="sec-example-add-im-component"> 
      <t>
	<figure title="XMPP IM conversation added to SIP voice
		       session" 
		align="center"><artwork><![CDATA[  

Bob                    Alice
 |                       |
 |                       |
 | (F1) INVITE           |
 |---------------------->|
 |                       |
 | (F2) 200OK            |
 |<----------------------|
 |                       |
 | (F3) ACK              |
 |---------------------->|
 |                       |
 |  RTP media            |
 |<=====================>|
 |                       |
 | (F4) <message>        |
 |---------------------->|
 |                       |
 | (F5) <message>        |
 |<----------------------|

]]>	</artwork></figure>
      </t>

      <t>
	Bob invites Alice to a SIP session. In the INVITE request, Bob
	includes the XMPP-Contact header including his XMPP JID. 
      </t>

      <figure title="(F1) Bob sends a SIP INVITE to
		     Alice"><artwork><![CDATA[   

      INVITE sip:alice@example.net SIP/2.0
      Via: SIP/2.0/UDP ua-991.domain.com;branch=apo92hgb2k100
      Max-Forwards: 70
      To: Alice <sip:alice@example.com>
      From: Bob <sip:bob@domain.com>;tag=18593756298
      Call-ID: a84b4c76e66710@ua-991.domain.com
      CSeq: 314159 INVITE
      XMPP-contact:<xmpp:bob@domain.com/home>
                   ;a84b4c76e66710@ua-991.domain.com
      Contact: "<sip:bob@domain.com">;gr=urn:
              uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6;
              audio;video"
      Content-Type: application/sdp
      Content-Length: 142
      
      (SDP not shown)

]]></artwork></figure>


      <figure title="(F2) Alice accepts the session and sends a 200OK
		     to Bob"><artwork><![CDATA[   

      SIP/2.0 200 OK
      Via: SIP/2.0/UDP p1.example.com
         ;branch=z9hG4bKnashds8;received=192.0.2.3
      Via: SIP/2.0/UDP p1.domain.com
         ;branch=z9hG4bKnashds8;received=192.0.2.2
      Via: SIP/2.0/UDP ua-991.domain.com
         ;branch=apo92hgb2k100;received=192.0.2.1
      Max-Forwards: 70
      To: Alice <sip:alice@example.com>;tag=c09hh1lsn
      From: Bob <sip:bob@domain.com>;tag=18593756298
      Call-ID: a84b4c76e66710@ua-991.domain.com
      CSeq: 314159 INVITE
      XMPP-Contact:<xmpp:alice@example.com/4FIL45729>
                  ;a84b4c76e66710@ua-991.domain.com
      Contact: <sip:alice@192.0.2.4>
      Content-Type: application/sdp
      Content-Length: 131
      
      (SDP not shown)

]]></artwork></figure>

      <figure title="(F4) Bob sends a message to
		     Alice"><artwork><![CDATA[   
   <message
       to='alice@example.net'
       from='bob@domain.com/Home'
       type='chat'
       xml:lang='en'>
     <body>Hi!</body>
     <thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread>
     <sip-correlation value="a84b4c76e66710@ua-991.domain.com">
    </message>

]]></artwork></figure>


      <t>
	Alice sends back a message stanza copying the sip-correlation
	value indicating the the correlation was successful. 
      </t>

      <figure title="(F5) Alice sends a message stanza to
		    Bob "><artwork><![CDATA[ 
   <message
       to='bob@domain.com/Home'
       from='alice@example.net'
       type='chat'
       xml:lang='en'>
     <body>Hello there!</body>
     <thread>e0ffe42b28561960c6b12b944a092794b9683a38</thread>
     <sip-correlation value="a84b4c76e66710@ua-991.domain.com">
   </message>

]]></artwork></figure>

    </section>

  </section>
    
  
  <section title="IANA Considerations" anchor="sec-iana">
    <t>TBD</t>
  </section>
  
  
  
  <section title="Security Considerations" anchor="sec-security">

    <t>
      The contact and correlation iformation is
      sensitive and we need to prevent connection hijacking and
      impersonation. If the contact information that is sent over
      one protocol is forged, the identity verification mechanism
      in the other no longer help as an attacker is able to assert
      the false identity.
    </t> 
  </section>
  
  <section title="Acknowledgments" anchor="sec-acks">
    <t>
      TBD
    </t>
  </section>
  
  
</middle>

<back>
  <references title="Normative References">
    <?rfc include="reference.RFC.2119" ?>
    <?rfc include="reference.RFC.3261" ?>
    <?rfc include="reference.RFC.3921" ?>
    <?rfc include="reference.RFC.3920" ?>
    <?rfc include="reference.RFC.3840" ?>
    <?rfc include="reference.RFC.5234" ?>
    <?rfc include="reference.RFC.3428" ?>
    <?rfc include="reference.RFC.3265" ?>
    <?rfc include="reference.RFC.3515" ?>
    <?rfc include="reference.RFC.2976" ?>
    <?rfc include="reference.RFC.3311" ?>
    <?rfc include="reference.RFC.3262" ?>
    <?rfc include="reference.RFC.3903" ?>

  </references>
  
  
  
  
  <references title="Informative References">
    <?rfc include="reference.I-D.saintandre-sip-xmpp-core" ?>
    <?rfc include="reference.I-D.ietf-sip-gruu" ?>      
    <?rfc include="reference.I-D.kaplan-sip-session-id" ?>      
    </references>
    
    
  </back>
  
</rfc>
