<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd'>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc sortrefs="yes"?>
<?rfc strict="yes"?>
<?rfc symrefs="yes"?>
<?rfc toc="yes"?>
<?rfc tocdepth="1"?>
<?rfc rfcedstyle="yes"?>
<rfc submissionType="IETF" category="std" consensus="yes" number="7573" ipr="trust200902">

  <front>
    <title abbrev="SIP-XMPP Interworking: Chat">Interworking between the Session Initiation Protocol (SIP) and the Extensible Messaging and Presence Protocol (XMPP): One&nbhy;to&nbhy;One&nbsp;Text&nbsp;Chat&nbsp;Sessions</title>
    <author initials="P." surname="Saint-Andre" fullname="Peter Saint-Andre">
      <organization>&amp;yet</organization>
      <address>
        <email>peter@andyet.com</email>
        <uri>https://andyet.com/</uri>
      </address>
    </author>
    <author initials="S." surname="Loreto" fullname="Salvatore Loreto">
      <organization>Ericsson</organization>
      <address>
        <postal>
          <street>Hirsalantie 11</street>
          <code>02420</code> 
          <city>Jorvas</city> 
          <country>Finland</country>
         </postal>
        <email>Salvatore.Loreto@ericsson.com</email>
      </address>
    </author>
    <date month="June" year="2015"/>
    <area>RAI</area>

    <keyword>Text Chat</keyword>
    <keyword>Instant Messaging</keyword>
    <keyword>Session Initiation Protocol</keyword>
    <keyword>SIP</keyword>
    <keyword>Message Sessions Relay Protocol</keyword>
    <keyword>MSRP</keyword>
    <keyword>Extensible Messaging and Presence Protocol</keyword>
    <keyword>XMPP</keyword>

    <abstract>
      <t>This document defines a bidirectional protocol mapping for the exchange of instant messages in the context of a one-to-one chat session between a user of the Session Initiation Protocol (SIP) and a user of the Extensible Messaging and Presence Protocol (XMPP).  Specifically for SIP text chat, this document specifies a mapping to the Message Session Relay Protocol (MSRP).</t>
    </abstract>
  </front>

  <middle>

    <section title="Introduction" anchor="intro">
      <t>Both the Session Initiation Protocol (SIP) <xref target="RFC3261"/> and the Extensible Messaging and Presence Protocol (XMPP) <xref target='RFC6120'/> can be used for the purpose of one-to-one text chat over the Internet.  To ensure interworking between these technologies, it is important to define bidirectional protocol mappings.</t>
      <t>The architectural assumptions underlying such protocol mappings are provided in <xref target='RFC7247'/>, including mapping of addresses and error conditions.  This document specifies mappings for one-to-one text chat sessions (sometimes called "session-mode" messaging); in particular, this document specifies mappings between XMPP messages of type "chat" and the Message Session Relay Protocol (MSRP) <xref target='RFC4975'/>, which is commonly used in SIP-based systems for chat functionality (although note that MSRP is not conjoined to SIP, and can be used by non-SIP technologies).  Mappings for single instant messages and groupchat are provided in <xref target="RFC7572" /> and <xref target="GROUPCHAT" />.</t>

<!--[rfced] For the ease of the reader, would you like to specify to which documents you are referring?

Original:
Mappings for single instant messages and
   groupchat are provided in separate documents.

-->
      <t>The approach taken here is to directly map syntax and semantics from one protocol to another.  The mapping described herein depends on the protocols defined in the following specifications:</t>
      <t>
        <list style='symbols'>
          <t>XMPP chat sessions using message stanzas of type "chat" are specified in <xref target="RFC6121"/>.</t>
          <t>MSRP chat sessions using the SIP INVITE and SEND request types are specified in <xref target='RFC4975'/>.</t>
        </list>
      </t>
      <t>In SIP-based systems that use MSRP, a chat session is formally negotiated (just as any other session type is negotiated when using SIP).  By contrast, a one-to-one chat "session" in XMPP is an informal construct and is not formally negotiated: a user simply sends a message of type "chat" to a contact, the contact then replies to the message, and the sum total of such messages exchanged during a defined period of time is considered to be a chat session (ideally tied together using an XMPP &lt;thread/&gt; element as described in Section 5.1 of <xref target='RFC6121'/>).  To overcome the disparity between these approaches, a gateway that wishes to map between SIP/MSRP and XMPP for one-to-one chat sessions needs to maintain some additional state, as described below.</t>
    </section>

    <section title="Intended Audience" anchor="audience">
      <t>The documents in this series are intended for use by software developers who have an existing system based on one of these technologies (e.g., SIP) and who would like to enable communication from that existing system to systems based on the other technology (e.g., XMPP).  We assume that readers are familiar with the core specifications for both SIP <xref target='RFC3261'/> and XMPP <xref target='RFC6120'/>, with the base document for this series <xref target='RFC7247'/>, and with the following chat-related specifications:</t>
      <t>
        <list style='symbols'>
          <t>"The Message Session Relay Protocol (MSRP)" <xref target='RFC4975'/></t>
          <t>"Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence" <xref target='RFC6121'/></t>
          <t>"Indication of Message Composition for Instant Messaging" <xref target='RFC3994'/></t>
          <t>"Chat State Notifications" <xref target='XEP-0085'/></t>
        </list>
      </t>
      <t>Note well that not all protocol-compliant messages are shown (such as SIP 100 TRYING messages), in order to focus the reader on the essential aspects of the protocol flows.</t>
    </section>

    <section title="Terminology" anchor="terms">
      <t>A number of terms used here are explained in <xref target='RFC3261'/>, <xref target='RFC4975'/>, <xref target='RFC6120'/>, and <xref target='RFC6121'/>.</t>
      <t>In flow diagrams, SIP/MSRP traffic is shown using arrows such as "***&gt;" whereas XMPP traffic is shown using arrows such as "...&gt;".</t>
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in <xref target='RFC2119'/>.</t>
    </section>

    <section title="XMPP to MSRP" anchor="xmpp2msrp">
      <t>In XMPP, the "informal session" approach is to simply send someone a &lt;message/&gt; of type "chat" without starting any session negotiation ahead of time (as described in <xref target="RFC6121"/>).  The XMPP "informal session" approach maps very well into a SIP MESSAGE request, as described in <xref target="RFC7572"/>.  However, the XMPP informal session approach can also be mapped to MSRP if the XMPP-to-SIP gateway maintains additional state.  The order of events is as follows.</t>
      <figure anchor='figure-1' title='XMPP to MSRP Order of Events'>
        <artwork><![CDATA[
XMPP            XMPP        XMPP-to-MSRP        SIP             SIP
User           Server         Gateway          Server          User
 |               |               |               |               |
 | (F1) XMPP     |               |               |               |
 | message       |               |               |               |
 |..............>|               |               |               |
 |               | (F2) XMPP     |               |               |
 |               | message       |               |               |
 |               |..............>|               |               |
 |               |               | (F3) SIP      |               |
 |               |               | INVITE        |               |
 |               |               |**************>|               |
 |               |               |               | (F4) SIP      |
 |               |               |               | INVITE        |
 |               |               |               |**************>|
 |               |               |               | (F5) SIP      |
 |               |               |               | 200 OK        |
 |               |               |               |<**************|
 |               |               | (F6) SIP      |               |
 |               |               | 200 OK        |               |
 |               |               |<**************|               |
 |               |               | (F7) SIP ACK  |               |
 |               |               |**************>|               |
 |               |               |               | (F8) SIP ACK  |
 |               |               |               |**************>|
 |               |               | (F9) MSRP SEND                |
 |               |               |******************************>|
 .               .               .               .               .
 .               .               .               .               .
 |               |               | (F10) MSRP SEND               |
 |               |               |<******************************|
 |               | (F11) XMPP    |               |               |
 |               | message       |               |               |
 |               |<..............|               |               |
 | (F12) XMPP    |               |               |               |
 | message       |               |               |               |
 |<..............|               |               |               |
 .               .               .               .               .
 .               .               .               .               .
 |               |               |               | (F13) SIP BYE |
 |               |               |               |<**************|
 |               |               | (F14) SIP BYE |               |
 |               |               |<**************|               |
 |               |               | (F15) SIP     |               |
 |               |               | 200 OK        |               |
 |               |               |**************>|               |
 |               |               |               | (F16) SIP     |
 |               |               |               | 200 OK        |
 |               |               |               |**************>|
        ]]></artwork>
      </figure>
      <t>The mapping of XMPP syntax to SIP syntax MUST be as specified in <xref target='RFC7572'/>.</t>
      <t>First, the XMPP user would generate an XMPP chat message.</t>
      <figure>
        <preamble>Example 1: Juliet Sends XMPP Message (F1)</preamble>
        <artwork><![CDATA[
| <message from='juliet@example.com/yn0cl4bnw0yr3vym'
|          to='romeo@example.net'
|          id='a786hjs2'
|          type='chat'>
|   <thread>29377446-0CBB-4296-8958-590D79094C50</thread>
|   <body>Art thou not Romeo, and a Montague?</body>
| </message>
        ]]></artwork>
      </figure>
      <t>Upon receiving such a message stanza, the XMPP server needs to determine the identity of the domainpart in the 'to' address, which it does by following the procedures explained in Section 5 of <xref target='RFC7247'/>.  If the domain is a SIP domain, the XMPP server will hand off the message stanza to an XMPP-to-SIP gateway or connection manager that natively communicates with MSRP-aware SIP servers.</t>
      <t>The XMPP-to-SIP gateway at the XMPP server would then initiate an MSRP session with Romeo on Juliet's behalf (since there is no reliable way for the gateway to determine whether Romeo's client supports MSRP, if that is not the case then MSRP session initiation might result in an error).</t>
      <figure>
        <preamble>Example 2: Gateway Starts SIP Session on Behalf of Juliet (F3)</preamble>
        <artwork><![CDATA[
| INVITE sip:romeo@example.net SIP/2.0
| To: <sip:romeo@example.net>
| From: <sip:juliet@example.com>
| Contact: <sip:juliet@example.com>;gr=yn0cl4bnw0yr3vym
| Subject: Open chat with Juliet?
| Call-ID: 29377446-0CBB-4296-8958-590D79094C50
| CSeq: 1 INVITE
| Content-Type: application/sdp
| 
| c=IN IP4 x2s.example.com
| m=message 7654 TCP/MSRP *
| a=accept-types:text/plain
| a=path:msrp://x2s.example.com:7654/jshA7weztas;tcp
        ]]></artwork>
      </figure>
      <t>Here we assume that Romeo's client supports MSRP and that Romeo accepts the MSRP session request.</t>
      <figure>
        <preamble>Example 3: Romeo Accepts Session Request (F5)</preamble>
        <artwork><![CDATA[
| SIP/2.0 200 OK
| From: <sip:juliet@example.com>
| To: <sip:romeo@example.net>
| Contact: <sip:romeo@example.net>;gr=dr4hcr0st3lup4c
| Call-ID: 29377446-0CBB-4296-8958-590D79094C50
| CSeq: 1 INVITE
| Content-Type: application/sdp
| 
| c=IN IP4 s2x.example.net
| m=message 12763 TCP/MSRP *
| a=accept-types:text/plain
| a=path:msrp://s2x.example.net:12763/kjhd37s2s20w2a;tcp
        ]]></artwork>
      </figure>
      <t>The XMPP-to-SIP gateway then acknowledges the session acceptance on behalf of Juliet.</t>
      <figure>
        <preamble>Example 4: Gateway Sends ACK to Romeo (F7)</preamble>
        <artwork><![CDATA[
| ACK sip:juliet@example.com SIP/2.0
| To: <sip:romeo@example.net>;gr=dr4hcr0st3lup4c
| From: <sip:juliet@example.com>
| Contact: <sip:juliet@example.com>;gr=yn0cl4bnw0yr3vym
| Call-ID: 29377446-0CBB-4296-8958-590D79094C50
| CSeq: 2 ACK
        ]]></artwork>
      </figure>
      <t>The XMPP-to-SIP gateway then transforms the original XMPP chat message into MSRP.</t>
      <figure>
        <preamble>Example 5: Gateway Maps XMPP Message to MSRP (F9)</preamble>
        <artwork><![CDATA[
| MSRP a786hjs2 SEND
| From-Path: msrp://x2s.example.com:7654/jshA7weztas;tcp
| To-Path: msrp://s2x.example.net:12763/kjhd37s2s20w2a;tcp
| Message-ID: 54C6F4F1-A39C-47D6-8718-FA65B3D0414A
| Byte-Range: 1-25/25
| Content-Type: text/plain
| 
| Art thou not Romeo, and a Montague?
| -------a786hjs2$
        ]]></artwork>
      </figure>
      <t>Romeo can then send a reply using his MSRP client.</t>
      <figure>
        <preamble>Example 6: Romeo Sends Reply (F10)</preamble>
        <artwork><![CDATA[
| MSRP di2fs53v SEND
| To-Path: msrp://x2s.example.com:7654/jshA7weztas;tcp
| From-Path: msrp://s2x.example.net:12763/kjhd37s2s20w2a;tcp
| Message-ID: 6480C096-937A-46E7-BF9D-1353706B60AA
| Byte-Range: 1-25/25
| Failure-Report: no
| Content-Type: text/plain
| 
| Neither, fair saint, if either thee dislike.
| -------di2fs53v$
        ]]></artwork>
      </figure>
      <t>The SIP-to-XMPP gateway would then transform that message into appropriate XMPP syntax for routing to the intended recipient.</t>
      <figure>
        <preamble>Example 7: Gateway Maps MSRP Message to XMPP (F11)</preamble>
        <artwork><![CDATA[
| <message from='romeo@example.net/dr4hcr0st3lup4c'
|          to='juliet@example.com/yn0cl4bnw0yr3vym'
|          id='di2fs53v'
|          type='chat'>
|   <thread>29377446-0CBB-4296-8958-590D79094C50</thread>
|   <body>Neither, fair saint, if either thee dislike.</body>
| </message>
        ]]></artwork>
      </figure>
      <t>When the MSRP user wishes to end the chat session, the user's MSRP client sends a SIP BYE.</t>
      <figure>
        <preamble>Example 8: Romeo Terminates Chat Session (F13)</preamble>
        <artwork><![CDATA[
| BYE juliet@example.com sip: SIP/2.0
| From: <sip:juliet@example.com>;tag=786
| To: <sip:romeo@example.net>;tag=087js
| Call-ID: 29377446-0CBB-4296-8958-590D79094C50
| CSeq: 3 BYE
| Content-Length: 0
        ]]></artwork>
      </figure>
      <t>The BYE is then acknowledged by the XMPP-to-SIP gateway.</t>
      <figure>
        <preamble>Example 9: Gateway Acknowledges Termination (F15)</preamble>
        <artwork><![CDATA[
| SIP/2.0 200 OK
| From: <sip:juliet@example.com>;tag=786
| To: <sip:romeo@example.net>;tag=087js
| Call-ID: 29377446-0CBB-4296-8958-590D79094C50
| CSeq: 3 BYE
| Content-Length: 0
        ]]></artwork>
      </figure>
      <t>Because there is no formal session on the XMPP side, there is no corresponding communication from the gateway to the XMPP user.  However, it is reasonable for the gateway to send a "gone" chat state notification <xref target='XEP-0085'/>, as described under <xref target='composing-gone'/>.</t>
      <t>In addition, there is no explicit method defined in <xref target='RFC6121'/> for an XMPP user to formally terminate a chat session, so a gateway would need to listen for a "gone" chat state notification from the XMPP user or institute a timer that considers the XMPP informal chat session to be ended after some amount of time has elapsed (<xref target='XEP-0085'/> suggests generating a "gone" chat state if a user has not interacted with the chat session interface, system, or device for a relatively long period of time, e.g., 10 minutes).</t>
    </section>

    <section title="MSRP to XMPP" anchor="msrp2xmpp">
      <t>When an MSRP client sends messages through a gateway to an XMPP client, the order of events is as follows.</t>
      <figure anchor='figure-2' title='MSRP to XMPP Order of Events'>
        <artwork><![CDATA[
SIP             SIP         MSRP-to-XMPP       XMPP            XMPP
User           Server         Gateway         Server           User
 |               |               |               |               |
 | (F17) SIP     |               |               |               |
 | INVITE        |               |               |               |
 |**************>|               |               |               |
 |               | (F18) SIP     |               |               |
 |               | INVITE        |               |               |
 |               |**************>|               |               |
 |               | (F19) SIP     |               |               |
 |               | 200 OK        |               |               |
 |               |<**************|               |               |
 | (F20) SIP     |               |               |               |
 | 200 OK        |               |               |               |
 |<**************|               |               |               |
 | (F21) SIP ACK |               |               |               |
 |**************>|               |               |               |
 |               | (F22) SIP ACK |               |               |
 |               |**************>|               |               |
 | (F23) MSRP SEND               |               |               |
 |******************************>|               |               |
 |               |               | (F24) XMPP    |               |
 |               |               | message       |               |
 |               |               |..............>|               |
 |               |               |               | (F25) XMPP    |
 |               |               |               | message       |
 |               |               |               |..............>|
 .               .               .               .               .
 .               .               .               .               .
 |               |               |               | (F26) XMPP    |
 |               |               |               | message       |
 |               |               |               |<..............|
 |               |               | (F27) XMPP    |               |
 |               |               | message       |               |
 |               |               |<..............|               |
 | (F28) MSRP SEND               |               |               |
 |<******************************|               |               |
 .               .               .               .               .
 .               .               .               .               .
 |               |               |               |               |
 |               |               |               |               |
 | (F29) SIP BYE |               |               |               |
 |**************>|               |               |               |
 |               | (F30) SIP BYE |               |               |
 |               |**************>|               |               |
 |               | (F31) SIP     |               |               |
 |               | 200 OK        |               |               |
 |               |<**************|               |               |
 | (F32) SIP     |               |               |               |
 | 200 OK        |               |               |               |
 |<**************|               |               |               |
        ]]></artwork>
      </figure>
      <t>The mapping of SIP syntax to XMPP syntax MUST be as specified in <xref target='RFC7572'/>.</t>
      <t>The protocol flow begins when Romeo starts a chat session with Juliet.</t>
      <figure>
        <preamble>Example 10: Romeo Starts Chat Session (F17)</preamble>
        <artwork><![CDATA[
| INVITE sip:juliet@example.com SIP/2.0
| From: <sip:romeo@example.net>
| To: <sip:juliet@example.com>
| Contact: <sip:romeo@example.net>;gr=dr4hcr0st3lup4c
| Subject: Open chat with Romeo?
| Call-ID: F6989A8C-DE8A-4E21-8E07-F0898304796F
| CSeq: 1 INVITE
| Content-Type: application/sdp
| 
| c=IN IP4 s2x.example.net
| m=message 7313 TCP/MSRP *
| a=accept-types:text/plain
| a=path:msrp://s2x.example.net:7313/ansp71weztas;tcp
        ]]></artwork>
      </figure>
      <t>Upon receiving the INVITE, the SIP (MSRP) server needs to determine the identity of the domain portion of the Request-URI or To header, which it does by following the procedures explained in Section 5 of <xref target='RFC7247'/>.  If the domain is an XMPP domain, the SIP server will hand off the INVITE to an associated MSRP-to-XMPP gateway or connection manager that natively communicates with XMPP servers.</t>
      <figure>
        <preamble>Example 11: Gateway Accepts Session on Juliet's Behalf (F19)</preamble>
          <artwork><![CDATA[
| SIP/2.0 200 OK
| From: <sip:romeo@example.net>;gr=dr4hcr0st3lup4c
| To: <sip:juliet@example.com>
| Contact: <sip:juliet@example.com>;gr=yn0cl4bnw0yr3vym
| Call-ID: F6989A8C-DE8A-4E21-8E07-F0898304796F
| CSeq: 1 INVITE
| Content-Type: application/sdp
| 
| c=IN IP4 x2s.example.com
| m=message 8763 TCP/MSRP *
| a=accept-types:text/plain
| a=path:msrp://x2s.example.com:8763/lkjh37s2s20w2a;tcp
          ]]></artwork>
        </figure>
        <figure>
          <preamble>Example 12: Romeo Sends ACK (F21)</preamble>
          <artwork><![CDATA[
| ACK sip:juliet@example.com SIP/2.0
| To: <sip:juliet@example.com>;gr=yn0cl4bnw0yr3vym
| From: <sip:romeo@example.net>
| Contact: <sip:romeo@example.net>;gr=dr4hcr0st3lup4c
| Call-ID: F6989A8C-DE8A-4E21-8E07-F0898304796F
| CSeq: 2 ACK
          ]]></artwork>
        </figure>
        <figure>
          <preamble>Example 13: Romeo Sends Message (F23)</preamble>
          <artwork><![CDATA[
| MSRP ad49kswow SEND
| To-Path: msrp://x2s.example.com:8763/lkjh37s2s20w2a;tcp
| From-Path: msrp://s2x.example.net:7313/ansp71weztas;tcp
| Message-ID: 676FDB92-7852-443A-8005-2A1B9FE44F4E
| Byte-Range: 1-32/32
| Failure-Report: no
| Content-Type: text/plain
| 
| I take thee at thy word ...
| -------ad49kswow$
          ]]></artwork>
        </figure>
        <figure>
          <preamble>Example 14: MSRP-to-XMPP Gateway Maps MSRP Message to XMPP (F24)</preamble>
          <artwork><![CDATA[
| <message from='romeo@example.net'
|          to='juliet@example.com'
|          id='ad49kswow'
|          type='chat'>
|   <thread>F6989A8C-DE8A-4E21-8E07-F0898304796F</thread>
|   <body>I take thee at thy word ...</body>
| </message>
          ]]></artwork>
        </figure>
        <figure>
          <preamble>Example 15: Juliet Sends Reply (F26)</preamble>
          <artwork><![CDATA[
| <message from='juliet@example.com'
|          to='romeo@example.net'
|          id='ms53b7z9'
|          type='chat'>
|   <thread>29377446-0CBB-4296-8958-590D79094C50</thread>
|   <body>What man art thou ...?</body>
| </message>
          ]]></artwork>
        </figure>
        <figure>
          <preamble>Example 16: Gateway Maps XMPP Message to MSRP (F28)</preamble>
          <artwork><![CDATA[
| MSRP ms53b7z9 SEND
| To-Path: msrp://s2x.example.net:7313/jshA7weztas;tcp
| From-Path: msrp://x2s.example.com:8763/lkjh37s2s20w2a;tcp
| Message-ID: 17EBA17B-94C0-463B-AD84-DE405C4C9D41
| Byte-Range: 1-25/25
| Failure-Report: no
| Content-Type: text/plain
| 
| What man art thou ...?
| -------ms53b7z9$
          ]]></artwork>
        </figure>
        <figure>
          <preamble>Example 17: Romeo Terminates Chat Session (F29)</preamble>
          <artwork><![CDATA[
| BYE juliet@example.com sip: SIP/2.0
| To: <sip:juliet@example.com>;gr=yn0cl4bnw0yr3vym
| From: <sip:romeo@example.net>
| Contact: <sip:romeo@example.net>;gr=dr4hcr0st3lup4c
| Call-ID: F6989A8C-DE8A-4E21-8E07-F0898304796F
| CSeq: 3 BYE
| Content-Length: 0
          ]]></artwork>
        </figure>
        <figure>
          <preamble>Example 18: Gateway Acknowledges Termination of Session on Behalf of Juliet (F31)</preamble>
          <artwork><![CDATA[
| SIP/2.0 200 OK
| To: <sip:juliet@example.com>;gr=yn0cl4bnw0yr3vym
| From: <sip:romeo@example.net>
| Contact: <sip:romeo@example.net>;gr=dr4hcr0st3lup4c
| Call-ID: F6989A8C-DE8A-4E21-8E07-F0898304796F
| CSeq: 3 BYE
          ]]></artwork>
        </figure>
    </section>

    <section title="Composing Events" anchor="composing">
      <t>Both XMPP and MSRP enable a client to receive notifications when a person's conversation partner is composing an instant message within the context of a chat session.</t>
      <t>For XMPP, the Chat State Notifications specification <xref target='XEP-0085'/> defines five states: active, inactive, gone, composing, and paused. Some of these states are related to the act of message composition (composing, paused), whereas others are related to the sender's involvement with the chat session (active, inactive, gone).  Note that the "gone" chat state is not to be confused with the &lt;gone/&gt; stanza error condition defined in <xref target='RFC6120'/>.</t>
      <t>For MSRP (and, in general, for so-called SIP for Instant Messaging
  and Presence Leveraging Extensions (SIMPLE) systems), the Indication of Message Composition for Instant Messaging specification <xref target='RFC3994'/> defines two states: idle and active.  Here the idle state indicates that the sender is not actively composing a message, and the active state indicates that the sender is indeed actively composing a message (the sending client simply toggles between the two states).</t>
      <t>Because XEP-0085 states can represent information that is not captured in RFC 3994, gateways can either (a) map only the composing-related states or (b) map all the XEP-0085 states.</t>
      <t>The following mappings are suggested.</t>
      <figure>
        <preamble>Table 3: Mapping of SIP/SIMPLE isComposing Events to XMPP Chat states</preamble>
        <artwork><![CDATA[
+-------------------+--------------------+
| isComposing Event |  Chat State        |
+-------------------+--------------------+
| active            |  composing         |
| idle              |  active            |
+-------------------+--------------------+
        ]]></artwork>
      </figure>
      <figure>
        <preamble>Table 4: Mapping of XMPP Chat States to SIP/SIMPLE isComposing Events</preamble>
        <artwork><![CDATA[
+-------------------+--------------------+
| Chat State        | isComposing Event  |
+-------------------+--------------------+
| active            |  idle              |
| inactive          |  idle              |
| gone              |  none (Section 6.1)|
| composing         |  active            |
| paused            |  idle              |
+-------------------+--------------------+
        ]]></artwork>
      </figure>
      <t>The XMPP Chat State Notifications specification <xref target='XEP-0085'/> allows the sending of "standalone notifications" outside the context of a message, theoretically even before any messages are exchanged; although a gateway could thus send an &lt;active/&gt; notification to the XMPP user when the SIP user accepts or initiates a chat session (i.e., after F6 in <xref target="xmpp2msrp" /> or after F22 in <xref target="msrp2xmpp" />), this usage might be unexpected by XMPP clients as a way to signal the beginning of an informal chat session.</t>
      <section title="Use of the Gone Chat State" anchor="composing-gone">
        <t>Although there is no direct mapping for the "gone" chat state to an
  isComposing event, receipt of the "gone" state at an XMPP-to-MSRP
  gateway can serve as a trigger for terminating the formal chat
  session within MSRP, i.e., for sending a SIP BYE for the session from
  the XMPP-to-MSRP gateway to the SIP user.  The following examples
  illustrate this indirect mapping (which would arise if, for example,
  the XMPP user were to send a "gone" chat state notification after
  step F12 in Figure 1 or step F28 in Figure 2; in either of these cases, the
  session would be terminated by the XMPP user instead of by the SIP
  user, as currently shown in Figures 1 and 2).</t>
        <figure>
          <preamble>Example 19: Juliet Sends Gone Chat State</preamble>
          <artwork><![CDATA[
| <message from='juliet@example.com'
|          id='nx62f197'
|          to='romeo@example.net'
|          type='chat'>
|   <thread>29377446-0CBB-4296-8958-590D79094C50</thread>
|   <gone xmlns='http://jabber.org/protocol/chatstates'/>
| </message>
          ]]></artwork>
        </figure>
        <figure>
          <preamble>Example 20: XMPP-to-MSRP Gateway Maps Gone Chat State to SIP BYE</preamble>
          <artwork><![CDATA[
| BYE romeo@example.net sip: SIP/2.0
| From: <sip:juliet@example.com>;tag=786
| To: <sip:romeo@example.net>;tag=087js
| Call-ID: 29377446-0CBB-4296-8958-590D79094C50
| CSeq: 3 BYE
| Content-Length: 0
          ]]></artwork>
        </figure>
        <t>Similarly, receipt of a SIP BYE message at an MSRP-to-XMPP gateway
  can serve as a trigger for sending a "gone" chat state notification
  to the XMPP user.  The following examples illustrate this indirect
  mapping (which would occur after step F14 in Figure 1 or step F30 in
  Figure 2).</t>
        <figure>
          <preamble>Example 21: Romeo Terminates Chat Session</preamble>
          <artwork><![CDATA[
| BYE juliet@example.com sip: SIP/2.0
| To: <sip:juliet@example.com>;gr=yn0cl4bnw0yr3vym
| From: <sip:romeo@example.net>
| Contact: <sip:romeo@example.net>;gr=dr4hcr0st3lup4c
| Call-ID: F6989A8C-DE8A-4E21-8E07-F0898304796F
| CSeq: 3 BYE
| Content-Length: 0
          ]]></artwork>
        </figure>
        <figure>
          <preamble>Example 22: MSRP-to-XMPP Gateway Generates Gone Chat State</preamble>
          <artwork><![CDATA[
| <message from='romeo@example.net'
|          id='hs61v397'
|          to='juliet@example.com'
|          type='chat'>
|   <thread>F6989A8C-DE8A-4E21-8E07-F0898304796F</thread>
|   <gone xmlns='http://jabber.org/protocol/chatstates'/>
| </message>
          ]]></artwork>
        </figure>
        <t>To enable these uses, gateways that support chat state notifications MUST support the "gone" state (which is merely recommended, not required, by <xref target='XEP-0085'/>).</t>
        <t>It is also reasonable for gateways to implement timers that automatically trigger a "gone" chat state if the XMPP user has not sent a message within the "session" for a given amount of time (<xref target='XEP-0085'/> suggests generating a "gone" chat state if a user has not interacted with the chat session interface, system, or device for a relatively long period of time, e.g., 10 minutes).</t>
      </section>
    </section>

    <section title="Delivery Reports" anchor="delivery">
      <t>Both XMPP and MSRP enable a client to receive notifications when a message has been received by the intended recipient.</t>
      <t>For XMPP, the Message Receipts specification <xref target='XEP-0184'/> defines a method and XML namespace for requesting and returning indications that a message has been received by a client controlled by the intended recipient.</t>
      <t>For MSRP, a native reporting feature is included, in the form of REPORT chunks (see Sections 7.1.2 and 7.1.3 of <xref target='RFC4975'/>).</t>
      <t>An XMPP Message Receipts element of &lt;request xmlns='urn:xmpp:receipts'/&gt; is to be mapped to an MSRP Success-Report header field with a value of "yes", and an XMPP Message Receipts element of &lt;received xmlns='urn:xmpp:receipts'/&gt; is to be mapped to an MSRP REPORT request.</t>
      <t>A Success-Report header field with a value of "yes" in an MSRP SEND request is to be mapped to an XMPP Message Receipts element of &lt;request xmlns='urn:xmpp:receipts'/&gt;, and an MSRP REPORT request is to be mapped to an XMPP message containing only a Message Receipts element of &lt;received xmlns='urn:xmpp:receipts'/&gt;.</t>
      <t>Because the XMPP Message Receipts specification does not support failure reports, there is no mapping for the MSRP Failure-Report header field and gateways SHOULD set that header field to "no".</t>
      <t>Examples follow.</t>
      <t>First, the XMPP user sends a message containing a request for delivery notification.</t>
      <figure>
        <preamble>Example 23: Juliet Sends XMPP Message with Receipt Request</preamble>
        <artwork><![CDATA[
| <message from='juliet@example.com'
|          id='bf9m36d5'
|          to='romeo@example.net'
|          type='chat'>
|   <thread>29377446-0CBB-4296-8958-590D79094C50</thread>
|   <body>What man art thou ...?</body>
|   <request xmlns='urn:xmpp:receipts'/>
| </message>
        ]]></artwork>
      </figure>
      <figure>
        <preamble>Example 24: Gateway Maps XMPP Message to MSRP</preamble>
        <artwork><![CDATA[
| MSRP bf9m36d5 SEND
| To-Path: msrp://s2x.example.net:7313/jshA7weztas;tcp
| From-Path: msrp://x2s.example.com:8763/lkjh37s2s20w2a;tcp
| Message-ID: 6187CF9B-317A-41DA-BB6A-5E48A9C794EF
| Byte-Range: 1-25/25
| Success-Report: yes
| Failure-Report: no
| Content-Type: text/plain
| 
| What man art thou ...?
| -------bf9m36d5$
        ]]></artwork>
      </figure>
      <t>Next, the recipient returns a report.</t>
      <figure>
        <preamble>Example 25: Romeo Returns MSRP Receipt</preamble>
        <artwork><![CDATA[
| MSRP hx74g336 REPORT
| To-Path: msrp://x2s.example.com:8763/lkjh37s2s20w2a;tcp
| From-Path: msrp://s2x.example.net:7313/jshA7weztas;tcp
| Message-ID: 6187CF9B-317A-41DA-BB6A-5E48A9C794EF
| Byte-Range: 1-106/106
| Status: 000 200 OK
| -------hx74g336$
        ]]></artwork>
      </figure>
      <figure>
        <preamble>Example 26: MSRP-to-XMPP Gateway Maps Receipt to XMPP</preamble>
        <artwork><![CDATA[
| <message from='romeo@example.net'
|          id='hx74g336'
|          to='juliet@example.com'>
|   <received xmlns='urn:xmpp:receipts' id='87652491'/>
| </message>

        ]]></artwork>
      </figure>
    </section>

    <section title='Message Size' anchor="size">
      <t>Unlike page-mode messaging <xref target='RFC3428'/> (which specifies that the size of a MESSAGE request is not allowed to exceed 1300 bytes), session-mode messaging <xref target='RFC4975'/> can be used to send larger messages.  MSRP includes a chunking mechanism such that larger messages can be broken up into multiple MSRP SEND requests.  Because the MSRP gateway at an XMPP service acts as an MSRP endpoint, it is responsible for receiving chunked messages and reconstructing them into a single message for delivery toward the XMPP recipient.  (Naturally, implementations need to be careful about accepting very large messages; see Section 14.5 of <xref target='RFC4975'/>.)</t>
      <t>Although there is no hard limit on the size of an XMPP stanza, in practice, most XMPP services (at least on the public Internet) are configured with a maximum stanza size in order to help prevent denial-of-service attacks.  As specified in Section 13.12 of <xref target='RFC6120'/>, this maximum is not allowed to be less than 10,000 bytes.</t>
      <t>The administrators of an XMPP service need to ensure that the associated MSRP gateway is configured with the same or smaller maximum MSRP message size as the maximum XMPP stanza size; this enables the gateway to return an appropriate value for the Session Description Protocol (SDP) "max-size" attribute (see Section 8.6 of <xref target='RFC4975'/>) and to properly handle incoming messages larger than the configured limits.</t>
      <t>If an MSRP-to-XMPP gateway implementation receives an MSRP message that exceeds its configured limit as just described, it MUST return an MSRP 413 error (e.g., in response to the first SEND request whose Byte-Range header field indicates a byte total exceeding the limit).</t>
    </section>

    <section title="Internationalization Considerations" anchor="i18n">
      <t>Relevant discussion of internationalized text in messages can be found in <xref target='RFC7572'/>.</t>
    </section>


    <section title="Security Considerations" anchor="security">
      <t>Detailed security considerations are given in the following documents:
<list style="symbols">

<t>For instant messaging protocols in general, see <xref target='RFC2779'/></t>
<t>For MSRP chat, see <xref target="RFC4975"/>; for when SIP is used to negotiate MSRP sessions, see <xref
target='RFC3261'/></t>
<t>For XMPP-based instant messaging, see <xref target="RFC6121"/> and also <xref target="RFC6120"/></t>  
<t>For SIP-XMPP interworking in general, see <xref target='RFC7247'/></t>
<t>For end-to-end encryption of instant messages, see <xref target='RFC7572'/>
</t>
</list>
</t>
    </section>

  </middle>
  <back>
    <references title="Normative References">
<!--I-D.ietf-stox-im; Companion Document -->

<reference anchor='RFC7572' target='http://www.rfc-editor.org/info/rfc7572'>
<front>
<title>Interworking between the Session Initiation Protocol (SIP) and the Extensible Messaging and Presence Protocol (XMPP): Instant Messaging</title>
<author initials='P' surname='Saint-Andre' fullname='Peter Saint-Andre'>
    <organization />
</author>
<author initials='A' surname='Houri' fullname='Avshalom Houri'>
    <organization />
</author>
<author initials='J' surname='Hildebrand' fullname='Joe Hildebrand'>
    <organization />
</author>
<date month='June' year='2015' />
<abstract><t>This document defines a bidirectional protocol mapping for the exchange of single instant messages between the Session Initiation Protocol (SIP) and the Extensible Messaging and Presence Protocol (XMPP).</t></abstract>
</front>
<seriesInfo name='RFC' value='7572' />
<seriesInfo name='DOI' value='10.17487/RFC7572'/>
</reference>

<?rfc include="reference.RFC.2119.xml"?>
<?rfc include="reference.RFC.3261.xml"?>
<?rfc include="reference.RFC.3994.xml"?>
<?rfc include="reference.RFC.4975.xml"?>
<?rfc include="reference.RFC.6120.xml"?>
<?rfc include="reference.RFC.6121.xml"?>
<?rfc include="reference.RFC.7247.xml"?>

<reference anchor="XEP-0085">
  <front>
    <title>Chat State Notifications</title>
    <author initials="P." surname="Saint-Andre" fullname="Peter Saint-Andre">
      <organization/>
      <address>
        <email>stpeter@jabber.org</email>
      </address>
    </author>
    <author initials="D." surname="Smith" fullname="Dave Smith">
      <organization/>
      <address>
        <email>dizzyd@jabber.org</email>
      </address>
    </author>
    <date day="23" month="September" year="2009"/>
  </front>
  <seriesInfo name="XSF XEP" value="0085"/>
  <format type="HTML" target="http://xmpp.org/extensions/xep-0085.html"/>
</reference>

<reference anchor="XEP-0184">
  <front>
    <title>Message Delivery Receipts</title>
    <author initials="P." surname="Saint-Andre" fullname="Peter Saint-Andre">
      <organization/>
      <address>
        <email>stpeter@jabber.org</email>
      </address>
    </author>
    <author initials="J." surname="Hildebrand" fullname="Joe Hildebrand">
      <organization/>
      <address>
        <email>jhildebr@cisco.com</email>
      </address>
    </author>
    <date day="01" month="March" year="2011"/>
  </front>
  <seriesInfo name="XSF XEP" value="0184"/>
  <format type="HTML" target="http://xmpp.org/extensions/xep-0184.html"/>
</reference>

    </references>

    <references title='Informative References'>

<?rfc include="reference.RFC.2779.xml"?>
<?rfc include="reference.RFC.3428.xml"?>

<!--I-D.ietf-stox-groupchat; In MISSREF as of 5/28/15 -->
<reference anchor='GROUPCHAT'>
<front>
<title>Interworking between the Session Initiation Protocol (SIP) and the Extensible Messaging and Presence Protocol (XMPP): Groupchat</title>
<author initials='P' surname='Saint-Andre' fullname='Peter Saint-Andre'>
    <organization />
</author>
<author initials='S' surname='Corretge' fullname='Saul Corretge'>
    <organization />
</author>
<author initials='S' surname='Loreto' fullname='Salvatore Loreto'>
    <organization />
</author>
<date month='March' year='2015' />
<abstract><t>This document defines a bidirectional protocol mapping for the exchange of instant messages in the context of a multiparty chat session among users of the Session Initiation Protocol (SIP) and users of the Extensible Messaging and Presence Protocol (XMPP). Specifically, this document defines a mapping between the SIP-based Message Session Relay Protocol (MSRP) and the XMPP Multi-User Chat (MUC) extension.</t></abstract>
</front>
<seriesInfo name='Work in Progress,' value='draft-ietf-stox-groupchat-11' />

</reference>


    </references>

    <section title="Acknowledgements" anchor="acks" numbered="no">
      <t>Special thanks to Eddy Gavita and Nazin Hossain for coauthoring an early draft version of this document.</t>
      <t>Thanks to Mary Barnes, Ben Campbell, Dave Crocker, Adrian Georgescu, Philipp Hancke, Saul Ibarra Corretge, Tory Patnoe, and Matt Ryan for their feedback.</t>
      <t>Stephen Farrell, Brian Haberman, Joel Jaeggli, Barry Leiba, Kathleen Moriarty, and Pete Resnick provided helpful input during IESG review.</t>
      <t>The authors gratefully acknowledge the assistance of Markus Isomaki and Yana Stamcheva as the working group chairs and Gonzalo Camarillo and Alissa Cooper as the sponsoring Area Directors.</t>
      <t>Peter Saint-Andre wishes to acknowledge Cisco Systems, Inc., for employing him during his work on earlier draft versions of this document.</t>
    </section>

  </back>
</rfc>
