<?xml version="1.0" encoding="UTF-8"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
     which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "rfc2629xslt/rfc2629.dtd" [
<!-- One method to get references from the online citation libraries.
     There has to be one entity for each item to be referenced.
     An alternate method (rfc include) is described in the references. -->

 <!-- Normative References -->
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!-- Informative References -->
<!ENTITY RFC3261 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3261.xml"> <!-- SIP -->
<!ENTITY RFC2616 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2616.xml"> <!-- HTTP -->
<!ENTITY RFC6120 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6120.xml"> <!-- XMPP -->
<!ENTITY I-D.jennings-rtcweb-signaling SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-jennings-rtcweb-signaling-00.xml">
<!ENTITY I-D.ietf-hybi-thewebsocketprotocol SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ietf-hybi-thewebsocketprotocol-17.xml">
<!ENTITY I-D.ibc-rtcweb-sip-websocket SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ibc-rtcweb-sip-websocket-00.xml">
<!ENTITY I-D.moffitt-xmpp-over-websocket SYSTEM "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-moffitt-xmpp-over-websocket-00.xml">
]>

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs),
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
     (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="no" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->

<rfc category="info" docName="draft-sipdoc-rtcweb-open-wire-protocol-00" ipr="trust200902">
<!-- category values: std, bcp, info, exp, and historic
     ipr values: full3667, noModification3667, noDerivatives3667
     you can add the attributes updates="NNNN" and obsoletes="NNNN"
     they will automatically be output with "(if approved)" -->

  <!-- ***** FRONT MATTER ***** -->

  <front>

    <!-- The abbreviated title is used in the page header - it is only necessary if the
         full title is longer than 39 characters -->
    <title abbrev="RTC-Web Open Wire Protocol">Open In-The-Wire Protocol for RTC-Web</title>

    <!-- add 'role="editor"' below for the editors if appropriate -->

    <!-- Another author who claims to be an editor -->

    <author fullname="Inaki Baz Castillo" initials="I.B.C." surname="Baz Castillo">
      <organization>XtraTelecom S.A.</organization>
      <address>
        <postal>
          <street></street>
          <city>Barakaldo</city>
          <region>Basque Country</region>
          <code></code>
          <country>Spain</country>
        </postal>
        <email>ibc@aliax.net</email>
      </address>
    </author>

    <author fullname="Saul Ibarra Corretge" initials="S.I.C." surname="Ibarra Corretge">
      <organization>AG Projects</organization>
      <address>
        <postal>
          <street></street>
          <city>Amsterdam</city>
          <region></region>
          <code></code>
          <country>Netherlands</country>
        </postal>
        <email>saul@ag-projects.com</email>
      </address>
    </author>
 
    <author fullname="Jose Luis Millan Villegas" initials="J.L.M.V." surname="Millan Villegas">
      <organization>XtraTelecom S.A.</organization>
      <address>
        <postal>
        <street>
        </street>
        <city>Bilbao</city>
        <region>Basque Country</region>
        <code>
        </code>
        <country>Spain</country>
        </postal>
        <email>jmillan@aliax.net</email>
      </address>
    </author>


    <date month="October" year="2011" />
    <!-- If the month and year are both specified and are the current ones, xml2rfc will fill
         in the current day for you. If only the current year is specified, xml2rfc will fill
         in the current day and month for you. If the year is not the current one, it is
         necessary to specify at least a month (xml2rfc assumes day="1" if not specified for the
         purpose of calculating the expiry date).  With drafts it is normally sufficient to
         specify just the year. -->

    <!-- Meta-data Declarations -->

    <area></area>
    <!--<workgroup></workgroup>-->
    <!-- WG name at the upperleft corner of the doc,
         IETF is fine for individual submissions.
         If this element is not present, the default is "Network Working Group",
         which is used by the RFC Editor as a nod to the history of the IETF. -->

    <keyword>RTCweb</keyword>
    <keyword>RTC-Web</keyword>
    <keyword>WebRTC</keyword>
    <keyword>Signaling</keyword>
    <!-- Keywords will be incorporated into HTML output
         files in a meta tag but they have no effect on text or nroff
         output. If you submit your draft to the RFC Editor, the
         keywords will be used for the search engine. -->

    <abstract>
      <t>RTC-Web clients communicate with a server in order to request or manage realtime communications with other users. This document exposes four hypothetical and different RTC-Web scenarios and analyzes the requirements of the in-the-wire protocol in each of them.</t>

      <t>The aim of this document is to make RTC-Web properly fit in the nature of the Web.</t>
    </abstract>
 

  </front>



  <middle>


    <section title="Conventions" anchor="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 <xref target="RFC2119"/>.</t>
    </section>
    

    <section title="Introduction" anchor="introduction">
        <t>In contrast to protocols such as <xref target="RFC3261">SIP</xref> or <xref target="RFC6120">XMPP</xref>, <xref target="RTC-Web">RTC-Web</xref> does not define a protocol for establishing media sessions between peers. Instead RTC-Web defines the media protocols (RTP/SRTP/ICE) to be used by web browsers. It also states how the web browser natively handles media streams (including media security and validation concerns), defines the requirements for the communication between the RTC-Web stack in the browser and the web application (via a JavaScript API to be defined by W3C) and MAY suggest some kind of media negotiation protocol to be carried in-the-wire between RTC-Web clients and servers.</t>

      <t>That said, RTC-Web does not mandate any user identifier syntax (in the way SIP defines the SIP URI), nor an authentication mechanism, in-the-wire messages format or the way messages are exchanged between RTC-Web clients and servers. There are many different ways by which those targets can be achieved nowadays on the Web.</t>

      <t>All this flexibility makes the whole picture of an RTC-Web scenario and the scope in which RTC-Web is involved hard to understand. This document tries to identify each component in the RTC-Web architecture and clarify which components can be left up to web developers and which others should be mandated by RTC-Web specifications.</t>
    </section>

    
    <section title="Definitions" anchor="definitions">
      <t>The following terms have special significance in the context of RTC-Web.

        <list style="hanging" hangIndent="6">
          <t hangText="JavaScript WebRTC API:">This is the communication layer between the native RTC-Web stack in the browser and JavaScript. It includes JavaScript functions to manage media sessions along with JavaScript callbacks which will be called by the RTC-Web stack when some media related event takes place. This API MUST be exposed by every RTC-Web compliant browser. It's being defined by W3C.</t>

          <t hangText="RTC-Web Server:">The server that RTC-Web clients communicate with for initiating and managing media sessions with remote peers. This is usually an <xref target="RFC2616">HTTP</xref> server or a <xref target="I-D.ietf-hybi-thewebsocketprotocol">WebSocket</xref> server behaving as a centralized point for signaling messages exchanged between peers (and MAY accomplish other tasks such as authentication, authorization, peer lookup procedures and protocol conversion). A given RTC-Web server will implement the In-The-Wire Protocol (defined below) chosen by the website developer.</t>

          <t hangText="In-The-Wire Protocol:">This is the communication layer between users' web browser and the RTC-Web Server. It involves a signaling protocol to be carried over HTTP or WebSocket (the protocols JavaScript can interact with). The messages exchanged over this protocol contain call control information and media negotiation information (both Call Control Protocol and Media Negotiation Protocol explained next).</t>

          <t hangText="Call Control Protocol:">This involves the format and semantics of the messages exchanged between the RTC-Web client (web browser) and the RTC-Web Server for routing and other purposes such as authorization, authentication, registration and others. Examples of a Call Control Protocol could be SIP or XMPP carried over HTTP or WebSocket, whose messages contain information about the originator and recipient of the message, credentials, type of message, etc. However any other custom protocol (such as HTTP POST or some JSON-based protocol over WebSocket) can accomplish this task. Call Control Protocol messages MAY carry media negotiation information (in the same way a SIP INVITE request contains an SDP body).</t>

          <t hangText="Media Negotiation Protocol:">When a RTC-Web client wants to establish a media session with a remote peer, it sends a Call Control Protocol request over the wire to the RTC-Web Server indicating the destination of the request (along with other fields). Such a request also carries media information exposed by the originator. In the SIP protocol example, the Media Negotiation Protocol is represented by the SDP offer/answer body conveyed by INVITE and 200 OK messages (simplified). In the case of RTC-Web, such media negotiation MAY be carried as <xref target="I-D.jennings-rtcweb-signaling">ROAP</xref> Offer/Answer JSON objects.
          </t>

          <t hangText="JavaScript RTC-Web Library:">This is a website-agnostic JavaScript library. Web developers (end-users) can include it within their websites. The library defines a custom In-The-Wire Protocol by providing an API with functions for generating requests and responses (to be sent in-the-wire) along with callbacks for processing incoming request/responses and state change notifications. This JavaScript library is coded by an RTC-Web expert and is supposed to hide the complexity of the JavaScript WebRTC API and the management of the In-The-Wire Signaling to the end-user. This is the API the end-user should use and care about (and here is where the famous term "20 lines of code" applies).</t>

          <t hangText="JavaScript WebSite Library:">This is the custom JavaScript library that a web developer (the end-user) provides in his website. In the context of RTC-Web, this custom library is supposed to make usage of functions and features present in a JavaScript RTC-Web Library (defined above). This is the library in which the end-user writes "20 lines of code" for integrating RTC-Web capabilities within his website.</t>
        </list>
      </t>
    </section>


    <section title="Overview of an RTC-Web Communication" anchor="overvier_of_an_rtcweb_communication">

      <t>Here a hypothetical and very simple RTC-Web scenario is described:
        <list style="symbols">
          <t>A user visits a web page "mysite.com" using his browser and logs-in the web by introducing his username (Bob) and password. The authentication is achieved by sending an HTTP POST request with the user's credentials. The web server validates the credentials and replies with a HTTP 200 response containing a Cookie "kj87kjsdhf" to be used within the same session. The user is redirected to a new page from which the browser retrieves two JavaScript libraries:
            <list style="hanging" hangIndent="6">
              <t hangText="rtcquery.js (a JavaScript RTC-Web Library):">This is a GPL JavaScript library implementing a custom In-The-Wire Protocol for RTC-Web based on JSON and WebSocket. This library is becoming the most successful and extended RTC-Web library and there are O'Reilly books about it.</t>
              <t hangText="mysite.js (a JavaScript WebSite Library):">This is the JavaScript code created by the web developer of "mysite.com". It includes website specific functions and makes use of the "rtcquery.js" library to incorporate RTC-Web capabilities to the web page (by adding "20 lines of code").</t>
            </list>
          </t>

          <t>Once all the JavaScript code (both "rtcquery.js" and "mysite.js") is loaded by the browser, it opens a WebSocket connection with the web server, which is also a WebSocket server listening on the same port (it could be a different server though).</t>

          <t>The web developer of "mysite.com" has implemented the In-The-Wire Protocol defined in "rtcquery.js" into his WebSocket server using PHP. For this task, the developer has studied the documentation available in the website of the rtcQuery.js project.</t>

          <t>The custom In-The-Wire Protocol states that each request sent over the WebSocket connection is a JSON object containing:
            <list style="hanging" hangIndent="6">
              <t hangText="A mandatory Call Control Protocol section:">This includes fields such as "call-id" (a common string for all the requests/responses within the same call), "transaction-id" (an integer for correlating a request and its associated responses), "request-type" (for example "call"), "source-user" (current user), "destination-user" (the remote peer), "subject" (some description of the call) and "cookie" (the Cookie sent by web server, which is used by the client to identify itself and get authorization by the WebSocket server).</t>
              <t hangText="An optional Media Negotiation Protocol section:">This is conveyed by attaching a <xref target="I-D.jennings-rtcweb-signaling">ROAP</xref> Offer or OK JSON object.</t>
            </list>
          </t>

          <t>In-The-Wire Protocol responses are similar to the requests, but instead of "request-type" and "subject", they contain a "status" field indicating the nature of the response (which can be "accepted", "rejected" or "not-online") and instead of a ROAP Offer they MAY contain a ROAP Answer.</t>

          <t>The new page rendered by the browser includes a big section with "online" users (those that are available for audio/video sessions). The user wants to make an audio call with Alice (who is online) and clicks a "Call" button next to Alice's buddy.</t>

          <t>Then the JavaScript code makes a call (using the JavaScript WebRTC API) to the browser RTC-Web stack in order to ask for a ROAP Offer object with just "audio" capability (note: PeerConnection stuff ommited for brevity). The RTC-Web stack performs some internal operations to discover the browser IP, gets some available UDP port for sending RTP, chooses an audio codec from the list of available codecs in the browser, and returns the ROAP Offer JSON object.</t>

          <t>After that, the JavaScript code constructs an In-The-Wire Protocol request (a JSON object) as follows:<figure><artwork><![CDATA[
  {
    "request": {
      "call-id": "0skilqwp",
      "transaction-id": 1001,
      "request-type": "call",
      "source-user": "Bob",
      "destination-user": "Alice",
      "subject": null,
      "cookie": "kj87kjsdhf",
      "media": _ROAP_OFFER_OBJECT_
    }
  }
]]></artwork></figure>
          </t>

          <t>The JavaScript code sends the request to the web server via the existing WebSocket connection.</t>

          <t>The server inspects the "cookie" and the "source-user" fields, and authorizes the request since such Cookie value is associated to an existing web session owned by Bob.</t>

          <t>Then the server checks for Alice's status. Alice is online and connected via WebSocket to the server, so using such connection the server delivers the request to Alice (previously removing the "cookie" field).</t>

          <t>Alice's browser receives the request and some JavaScript callback (defined by the JavaScript code when a WebSocket messsage is received) is called. Alice is prompted to accept or reject the incoming call request from Bob. Alice presses "Accept".</t>

          <t>The JavaScript code in Alice's browser makes a call (using the JavaScript WebRTC API) to the browser RTC-Web stack and gets a ROAP Answer object with just "audio" capability. Then it constructs an In-The-Wire Protocol response as follows (note that it includes her Cookie) and sends it to the server via the WebSocket connection:<figure><artwork><![CDATA[
  {
    "response": {
      "call-id": "0skilqwp",
      "transaction-id": 1001,
      "status": "accepted",
      "source-user": "Alice",
      "destination-user": "Bob",
      "cookie": "t112mnkszz",
      "media": _ROAP_ANSWER_OBJECT_
    }
  }
]]></artwork></figure>
          </t>

          <t>The server inspects the "cookie" and "source-user" and validates the response. Then it inspects the "destination-user" and routes the response object to Bob.</t>

          <t>Upon receipt of the response, the JavaScript code in Bob's browser automatically sends a request acknowledging the response to the server:<figure><artwork><![CDATA[
  {
    "request": {
      "call-id": "0skilqwp",
      "transaction-id": 1001,
      "request-type": "ack",
      "source-user": "Bob",
      "destination-user": "Alice",
      "cookie": "kj87kjsdhf",
      "media": _ROAP_OK_MESSAGE_
    }
  }
]]></artwork></figure>
          </t>

          <t>The request is routed to Alice's browser and its ROAP OK message automatically delivered to the RTC-Web stack by the JavaScript code.</t>

          <t>At this point, both Bob and Alice's browsers perform ICE connectivity checks and finally establish a RTP audio session. The success of the media session establishment is notified to the users via some JavaScript pop-up.</t>

          <t>After a while Alice decides to terminate the call by pressing a "Hangup" button. The JavaScript code asks the RTC-Web stack in the browser to finish sending RTP and sends a JSON request to Bob via the WebSocket connection:<figure><artwork><![CDATA[
  {
    "request": {
      "call-id": "0skilqwp",
      "transaction-id": 1002,
      "request-type": "hangup",
      "source-user": "Alice",
      "destination-user": "Bob",
      "cookie": "t112mnkszz"
    }
  }
]]></artwork></figure>
          </t>

          <t>Bob receives the request. His JavaScript code calls the RTC-Web stack to finish the media session (by passing it some "session-id" identifier retrieved from the initial ROAP Offer).</t>

          <t>Session is now terminated. Bob did not get a date with Alice, but has been enjoying a RTC experience so he is satisfied.</t>
        </list>
      </t>

      <t>Lets inspect the RTC-Web components as defined by this document in the given scenario:
        <list style="hanging" hangIndent="6">
          <t hangText="RTC-Web Server:">A WebSocket server running in the same port as the web server.</t>
          <t hangText="In-The-Wire Protocol:">Custom JSON messages over WebSocket transport.</t>
          <t hangText="Call Control Protocol:">All the fields in the JSON message (but the "media" field).</t>
          <t hangText="Media Negotiation Protocol:">The media information is located in the "media" parameter of the JSON message. It's carried as ROAP Offer/Answer JSON object.</t>
          <t hangText="JavaScript RTC-Web Library:">"rtcquery.js" library made GPL by the rtcQuery.js project.</t>
          <t hangText="JavaScript WebSite Library:">"mysite.js" custom library (makes use of "rtcquery.js").</t>
        </list>
      </t>
    </section>


    <section title="More Use Cases" anchor="more_use_cases">

      <section title="RTC-Web in Facebook" anchor="rtcweb_in_facebook">

        <t>Facebook integrates IM (instant messaging) into its web application. For that the JavaScript code performs HTTP long polling for retrieving incoming IM messages in realtime, and sends an HTTP POST request when a user sends a message to another user. Such HTTP POST requests look as follows:<figure><artwork><![CDATA[
  POST /ajax/chat/send.php?__a=1 HTTP/1.1
  Host: www.facebook.com
  Connection: keep-alive
  X-SVN-Rev: 460802
  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  Referer: http://www.facebook.com/?sfrm=1
  Content-Length: XXX
  Cookie: datr=ZjyfTjurvmsqvYVBDcXF8u; c_user=104442654509775; L=2;
    lu=RgQytVtJJBoSvWUNOYzs0oQg; sct=1319153603;
    xs=60%3A1c179a7dfb7f08278477b20e778bd391; p=112;
    presence=631L212REp_5f1B08654409875F4EriF0CEstateFDutF131910363 \
    96EvisF1HsndF1ODiFA21B02609687525A2C_5dEfFA21B02602687525A2Euct \
    319103618FD55F1G318103604PEuoFD1B02602687525FDexpF1319103680370 \
    lF_5b1_5dEolF0CCEalFD1B02602687525FDiF0umF0CCCC;
    wd=1366x675
  Pragma: no-cache
  Cache-Control: no-cache

  msg_id=1319103647568%3A3629978310&client_time=1319103646048&
  to=100002772687525&num_tabs=1&pvs_time&msg_text=hello&
  to_offline=false&to_idle=false&window_id=2877189837&
  sidebar_launched=true&sidebar_enabled=true&sidebar_capable=true&
  sidebar_should_show=false&sidebar_visible=false&
  post_form_id=449eb730c851e127f21d8a88b6a00667&fb_dtsg=AQC3StlW&lsd&
  post_form_id_source=AsyncRequest&__user=100002624409995
]]></artwork></figure>
        </t>

        <t>The above request contains some parameters in both the Cookie header and the body. The Cookie header seems to contain information about the identity of the user sending the IM message. The Cookie value is probably also used for authentication in the server. The "msg_text" parameter in the body contains the IM text message itself while the "to" parameter in the body seems to contain the destination user (a long integer probably representing the user ID). The meaning of other parameters in both the Cookie and the body are up to Facebook, this is, they are specific to the application. It seems obvious that it's not possible to standarize all these parameters.</t>

        <t>Assuming that Facebook is willing to integrate RTC-Web within the web application, it makes sense that Facebook would be interested in reusing the same protocol and message format it's already using for IM (which is also realtime communication). So when a user clicks some "Call" button within his Facebook contact list, it is expected that the JavaScript code could generate an HTTP POST as follows:<figure><artwork><![CDATA[
  POST /ajax/call/call.php?__a=1 HTTP/1.1
  Host: www.facebook.com
  Connection: keep-alive
  X-SVN-Rev: 460802
  Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  Referer: http://www.facebook.com/?sfrm=1
  Content-Length: XXX
  Cookie: datr=ZjyfTjurvmsqvYVBDcXF8u; c_user=104442654509775; L=2;
    lu=RgQytVtJJBoSvWUNOYzs0oQg; sct=1319153603;
    xs=60%3A1c179a7dfb7f08278477b20e778bd391; p=112;
    presence=631L212REp_5f1B08654409875F4EriF0CEstateFDutF131910363 \
    96EvisF1HsndF1ODiFA21B02609687525A2C_5dEfFA21B02602687525A2Euct \
    319103618FD55F1G318103604PEuoFD1B02602687525FDexpF1319103680370 \
    lF_5b1_5dEolF0CCEalFD1B02602687525FDiF0umF0CCCC;
    wd=1366x675
  Pragma: no-cache
  Cache-Control: no-cache

  call_id=1319103647568%3A3629978310&client_time=1319103646048&
  to=100002772687525&num_tabs=1&pvs_time&to_offline=false&
  to_idle=false&window_id=2877189837&sidebar_launched=true&
  sidebar_enabled=true&sidebar_capable=true&
  sidebar_should_show=false&sidebar_visible=false&
  post_form_id=449eb730c851e127f21d8a88b6a00667&fb_dtsg=AQC3StlW&
  lsd&post_form_id_source=AsyncRequest&__user=100002624409995&
  media=_ROAP_OFFER_OBJECT_
]]></artwork></figure>
        </t>

        <t>The new HTTP POST request differs in the request URI (which now points to "/ajax/call/call.php"). The body includes a "media" parameter whose value is a ROAP Offer JSON object (properly encoded if necessary).</t>

        <t>Given this HTTP POST request, lets inspect the RTC-Web components as defined by this document:
          <list style="hanging" hangIndent="6">
            <t hangText="RTC-Web Server:">Facebook uses their HTTP servers as RTC-Web servers.</t>
            <t hangText="In-The-Wire Protocol:">Facebook uses HTTP protocol and a common HTTP POST request.</t>
            <t hangText="Call Control Protocol:">The information about the call originator is mainly included in the Cookie header, while other topics as the destination user of the call are located in the body (the "to" parameter).</t>
            <t hangText="Media Negotiation Protocol:">The media information is located in the "media" parameter of the body. In this case Facebook uses a ROAP Offer JSON object for carrying such media information.</t>
            <t hangText="JavaScript RTC-Web Library:">It is expected to be an advanced JavaScript library designed by Facebook which also includes other functions unrelated to RTC-Web.</t>
            <t hangText="JavaScript WebSite Library:">Merged with the JavaScript RTC-Web Library into a single JavaScript file.</t>
          </list>
        </t>

        <t>If Facebook would desire to interoperate (federate) with a SIP network it is clear that it would need a signaling protocol gateway which converts the HTTP POST information into a SIP request, and the ROAP Offer into a SDP body.</t>
      </section>


      <section title="SIP over WebSocket" anchor="sip_over_websocket">

        <t>This is an optimal solution for interoperating with SIP without requiring a protocol gateway. In this scenario the web user downloads a JavaScript code from the website and the JavaScript code establishes a WebSocket connection with a SIP proxy (the RTC-Web server) implementing the <xref target="I-D.ibc-rtcweb-sip-websocket">WebSocket transport</xref> (along with other common SIP transports as UDP and TCP). The messages exchanged between the RTC-Web client and server over the WebSocket connection are pure SIP requests and responses, with no modifications (others than the new "WS" transport identificator in the Via header).</t>

        <t>When the user makes a call from the web it generates a SIP INVITE to be sent over the WebSocket connection, which looks as follows:<figure><artwork><![CDATA[
  INVITE sip:bob@example.org SIP/2.0
  Via: SIP/2.0/WS invalid.domain;branch=z9hG4bK56sdasks
  From: sip:alice@example.org;tag=asdyka899
  To: sip:bob@example.org
  Call-ID: asidkj3ss
  CSeq: 1 INVITE
  Max-Forwards: 70
  Contact: <sip:alice@invalid.domain;transport=ws>
  Supported: path, outbound
  Content-Type: application/sdp

  _SDP_
]]></artwork></figure>
        </t>

        <t>For this to work, the JavaScript code must map the ROAP Offer retrieved via the JavaScript WebRTC API into a normal SDP (it's not the aim of this documment to discuss about the complexity such mapping could involve).</t>

        <t>When the INVITE arrives to the RTC-Web Server (which behaves as a pure SIP proxy) it just performs standard SIP routing procedures (the same as if the request would have arrived via UDP or TCP transports), so there is no need for a protocol gateway when interoperating with a pure SIP network out there.</t>

        <t>Given this INVITE request, lets inspect the RTC-Web components as defined by this document:
          <list style="hanging" hangIndent="6">
            <t hangText="RTC-Web Server:">A SIP proxy that also implements the WebSocket transport.</t>
            <t hangText="In-The-Wire Protocol:">Pure SIP protocol.</t>
            <t hangText="Call Control Protocol:">Contained in the headers of the SIP request (From, request URI, Contact, Authorization...).</t>
            <t hangText="Media Negotiation Protocol:">The session description (SDP) carried in the SIP request body.</t>
            <t hangText="JavaScript RTC-Web Library:">It could be a GPL "jssip.js" library implementing SIP over WebSocket and a SIP stack in JavaScript.</t>
            <t hangText="JavaScript WebSite Library:">Website specific. It would make use of the "jssip.js" library for adding RTC-Web capabilities "in 20 lines of code".</t>
          </list>
        </t>

      </section>


      <section title="Poker Game" anchor="poker_game">

        <t>A website "www.poker-game.info" makes use of HTTP Comet technology for carrying realtime information about the game to each participant. The messages exchanged via HTTP Comet between participants and the web server are XML documents conveying updates and actions happening during the game.</t>

        <t>Now that website wants to integrate RTC-Web capabilities and enter each participant into an audio multiconference in which every user listens to all the participants and can speak to them.</t>

        <t>To accomplish this architecture and still reuse the existing design, once the user logs-in the web his browser receives an incoming audio call from the conference server. Such call request is carried over the HTTP connection (HTTP Comet) as a new XML document which looks as follows:<figure><artwork><![CDATA[
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <game-multiconf>
    <action>call</action>
    <media>_ROAP_OFFER_XML_</media>
  </game-multiconf>
]]></artwork></figure>
        </t>

        <t>The ROAP Offer is generated by the conference server, which satisfies all the media requirements of RTC-Web (ICE, SRTP).</t>

        <t>The JavaScript code in the client side answers the call (once the user accepted it) and sends a similar XML containing a ROAP Answer via the existing HTTP connection.</t>

        <t>Given the above XML document, lets inspect the RTC-Web components as defined by this document:
          <list style="hanging" hangIndent="6">
            <t hangText="RTC-Web Server:">The web server of "www.poker-game.info".</t>
            <t hangText="In-The-Wire Protocol:">Custom XML document through HTTP Comet.</t>
            <t hangText="Call Control Protocol:">It's minimal. There is no information about the originator or recipient of the call (not needed in this scenario). The XML contains an "action" field whose value "call" means "incoming call request from the website".</t>
            <t hangText="Media Negotiation Protocol:">A ROAP Offer/Answer in XML format.</t>
            <t hangText="JavaScript RTC-Web Library:">A library created by the developer of "www.poker-game.info". It implements the In-The-Wire Protocol as stated above.</t>
            <t hangText="JavaScript WebSite Library:">It is merged with the JavaScript RTC-Web Library, so there is a single JavaScript file.</t>
          </list>
        </t>

      </section>

    </section>


    <section title="Conclusions" anchor="conclusion">
      <t>This document has shown four hypothetical scenarios of RTC-Web. Each scenario uses its own In-The-Wire Protocol (JSON over WebSocket, HTTP POST, SIP over WebSocket and XML over HTTP Comet) and it's hard to expect that all these scenarios could be constrained to use the same protocol and message format in-the-wire. The needs of each scenario are not the same, neither the custom fields carried in-the-wire (see for example the ammount of custom parameters Facebook includes within the HTTP POST request).</t>

      <t>In the Web each website decides how to accomplish the features and capabilities it wants to provide to its users. Mandating the message format in-the-wire seems not to be an option given the nature of the Web. Mandating it would also make RTC-Web integration very hard into existing websites which already implement their custom signaling protocol and message format for realtime communications (as instant messaging), their authentication mechanisms, etc.</t>

      <t>RTC-Web will bridge the gap between realtime communication services such as VoIP and the Web, so it must play by the rules present on the Web. These rules include the freedom by which the web developer chooses his preferred option to innovate and offer new services to users. That is the key to success of the Web and should be respected.</t>
    </section>


    <section title="New Requirements for RTC-Web" anchor="new_requirements_for_rtcweb">
      <t>Given the conclusions in the previous section, this document states some new requirements for RTC-Web:
        <list style="numbers">
          <t>It MUST be possible for a website developer to design his own In-The-Wire Protocol (including the messages format and transport used for carrying such messages).</t>

          <t>It MUST be possible for a website developer to choose his favourite JavaScript RTC-Web Library and adapt his web application to make use of it.</t>

          <t>It MUST be possible for a website developer to design a Media Negotiation Protocol in which the media information is not carried as ROAP Offer/Answer objects (by letting the developer implement the ROAP mapping in JavaScript).
            <list style="empty">
              <t>NOTE: This text is written assuming that <xref target="I-D.jennings-rtcweb-signaling">ROAP</xref> becomes a standard in RTC-Web.</t>
            </list>
          </t>

          <t>It MUST be possible for a website developer to make his RTC-Web scenario to interoperate with a pure SIP or XMPP/Jingle network without requiring a signaling protocol gateway (by using <xref target="I-D.ibc-rtcweb-sip-websocket">SIP over WebSocket</xref> or <xref target="I-D.moffitt-xmpp-over-websocket">XMPP over WebSocket</xref>).
            <list style="empty">
              <t>This would be indeed feasible if previous bullets are satisfied.</t>
            </list>
          </t>
        </list>
      </t>
    </section>


    <section title="Security Considerations" anchor="security_considerations">
      <t>Not applicable.</t>
    </section>


    <section title="IANA Considerations" anchor="iana_considerations">
      <t>Not applicable.</t>
    </section>


  </middle>

  <!--  *****BACK MATTER ***** -->

  <back>
    <!-- References split into informative and normative -->

    <!-- There are 2 ways to insert reference entries from the citation libraries:
     1. define an ENTITY at the top, and use "ampersand character"RFC2629; here (as shown)
     2. simply use a PI "less than character"?rfc include="reference.RFC.2119.xml"?> here
        (for I-Ds: include="reference.I-D.narten-iana-considerations-rfc2434bis.xml")

     Both are cited textually in the same manner: by using xref elements.
     If you use the PI option, xml2rfc will, by default, try to find included files in the same
     directory as the including file. You can also define the XML_LIBRARY environment variable
     with a value containing a set of directories to search.  These can be either in the local
     filing system or remote ones accessed by http (http://domain/dir/... ).-->

    <references title="Normative References">
      &RFC2119;
    </references>

    <references title="Informative References">
      &RFC3261;
      &RFC2616;
      &RFC6120;
      &I-D.jennings-rtcweb-signaling;
      &I-D.ietf-hybi-thewebsocketprotocol;
      &I-D.ibc-rtcweb-sip-websocket;
      &I-D.moffitt-xmpp-over-websocket;

      <reference anchor="RTC-Web">
        <front>
          <title>Real Time Collaboration on the World Wide Web</title>
          <author>
            <organization>IETF</organization>
          </author>
          <author>
            <organization>W3C</organization>
          </author>
          <date month="October" year="2010" />
        </front>
      </reference>
    </references>


  </back>

</rfc>
