<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc='no'?>
<?rfc tocdepth='4'?>
<?rfc compact="yes"?>
<rfc category="std" ipr="trust200902" docName='draft-chenxin-behave-turn-websocket-00'>
<front>
   <title abbrev="TURN over websocket">
      Traversal Using Relays around NAT (TURN) Extensions for Websocket Allocations
   </title>
   <author initials="Xin" surname="Chen" fullname="Xin Chen">
      <organization>Huawei</organization>
      <address>
         <email>hangzhou.chenxin@huawei.com</email>
      </address>
   </author>
   <date year="2013" />
   <area>Transport Area</area>
   <workgroup>Behavior Engineering for Hindrance Avoidance</workgroup>
   <abstract>
      <t>

This document defines an extension to TURN that allows it to run over a Websocket 
<xref target="RFC6455"/> channel. 
This will allow a client in a restrictive network to exchange and relay media or data over the websocket.

      </t>
   </abstract>
</front>
<middle>
   <section title="Introduction">
      <t>

Traversal Using Relays around NAT (TURN)<xref target="RFC5766"/>, which assigns a transport address allocation for 
clients and relays data between the address and the clients, is an extension to the Session Traversal 
Utilities for NAT <xref target="RFC5389"/> protocol. TURN is used for NAT traversal in some complicated types of 
NAT network by UDP-based media sessions <xref target="RFC5766"/> or TCP-based media sessions <xref target="RFC6062"/>.  
It is also used with Interactive Connectivity Establishment (ICE) <xref target="RFC5245"/>. 

      </t>
      <t>

In some particularly restrictive networks, e.g. a web proxy or firewall that only allows HTTP traffic 
to pass through, TURN UDP-based media sessions and TURN TCP-based media sessions do not work. 
These types of network often appear in the prison, the hotel, the airport and other places that need 
limit the access of network. RTCWeb provides direct interactive rich communication between two 
peers' web-browser, which has the similar requirement to allow two peers to use fallback communication 
in the http-only network 
<xref target="I-D.ietf-rtcweb-use-cases-and-requirements"/>(F37).
      </t>
      <t>
Another use case of Turn over websocket is that the turn server could be a generic relay for some protocols over websocket, such as BFCP<xref target="RFC4975"/> and MSRP<xref target="I-D.ietf-bfcpbis-rfc4582bis"/>. There are drafts to support BFCP <xref target="I-D.pascual-dispatch-bfcp-websocket"/>and MSRP<xref target="I-D.pd-msrp-websocket"/> transported in the websocket, however in these drafts a special server is needed as the intermediary to receive the protocol data from the client. In the Peer to Peer scene, BFCP and MSRP message is required be exchange by two peers, and additional server is a little complicated to deploy in such scene. The turn over websocket could be used as generic relay server, which could relay these protocol data between two peers.
      </t>
      <t>

This document defines an extension to TURN that allows it to run over a Websocket <xref target="RFC6455"/> channel. 
This will allow a client in a restrictive network to exchange media over a websocket. This is useful 
to solve the http fallback problem and is easy to be implemented in the existing rtcweb framework. 
The connection between the server and the peer is still UDP as <xref target="RFC5766"/> or TCP , TLS over TCP as <xref target="RFC6062"/>.

      </t>

      <figure><artwork><![CDATA[
          +----------------------------+---------------------+
          | TURN client to TURN server | TURN server to peer |
          +----------------------------+---------------------+
          |                            |         UDP         |
          |    Websocket over TCP      |         TCP         |
          |                            |      TLS over TCP   |
          +----------------------------+---------------------+
      ]]></artwork></figure>

   </section>


   <section title="Terminology">
      <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="Deployment Topology">
      <t>

As mentioned in <xref target="I-D.miniero-rtcweb-http-fallback"/>, within the context of real-time multimedia 
communications and considering a scenario that involves two peers,an HTTP fallback mechanism may 
fall in basically three different network topologies:

      </t>

      <section title="A topology whereas only one of the involved peers needs HTTP fallback for communication">

         <figure anchor="websocket-to-udp-tcp"><artwork><![CDATA[
                            +-----------+
                            | TURN &    |
             +--------------+ websocket +----------------+
             |  websocket   | server    |                 \ UDP/TCP
             |              +-----------+                  \
             |                                              \
             |                                               |
         +---+---+                                       +---+---+
         | Alice |                                       |  Bob  |
         +-------+                                       +---+---+
         ]]></artwork></figure>

         <t>

In <xref target="websocket-to-udp-tcp"/>,  only one involved peer(Alice) is in the restrained network, 
so Alice need use websocket connection to traverse the firewall and proxy. 
The situation for Bob is better, he could connect to TURN server by UDP or TCP using existing mechanism.

         </t>
         <t>

When Alice wants to communicate with Bob, she need request a UDP or TCP allocation in websocket server 
for Bob, which is transferred in the websocket channel. The websocket server will receive the request 
and handle it like a TURN server. The procedure of TURN message is the same as TURN UDP and TURN TCP, 
and the websocket server will also allocate a UDP or TCP relay address for Bob. The application data 
from Alice and Bob will be packaged and relayed to each other by the websocket server.

         </t>
      </section>
      <section title="A topology whereas both the involved peers need HTTP fallback for communication, 
using two different intermediaries">

         <figure anchor="websocket-to-udp-tcp-to-websocket"><artwork><![CDATA[
                      +-----------+         +-----------+
                      | TURN &    |         | TURN &    |
         +------------+ websocket +---------+ websocket +--------- +
         | websocket  | server    | UDP/TCP | server    |websocket |
         |            +-----------+         +-----------+          |
         |                                                         |
         |                                                         |
     +---+---+                                                 +---+---+
     | Alice |                                                 |  Bob  |
     +-------+                                                 +---+---+
         ]]></artwork></figure>
         <t>

In <xref target="websocket-to-udp-tcp-to-websocket"/>, both Alice and Bob are i restrictive 
networks, so both need a fallback mechanism. One complex scenario is that Alice and Bob each have their own 
websocket server. In this scenario, Alice and Bob need to request the Turn allocation in their own 
websocket server using a websocket connection. The procedure of TURN message is the same as TURN UDP 
and TURN TCP. The websocket server should relay the application data to each other by UDP ,TCP or 
other existing ways. It is better that Alice and Bob allocate the same type of transport address, 
so their own websocket server could connect to each other by this address directly.

         </t>

      </section>
      <section title="A topology whereas both the involved peers need HTTP fallback for RTP, using the same intermediary">

         <figure anchor="websocket-to-websocket"><artwork><![CDATA[
                                +-----------+
                                | TURN &    |
         +----------------------+ websocket +--------------------+
         |  websocket           | server    |         websocket  |
         |                      +-----------+                    |
         |                                                       |
         |                                                       |
     +---+---+                                               +---+---+
     | Alice |                                               |  Bob  |
     +-------+                                               +---+---+
         ]]></artwork></figure>
         <t>

In <xref target="websocket-to-websocket"/>, Alice and Bob are both also in the restrictive network as 
<xref target="websocket-to-udp-tcp-to-websocket"/> with a slight difference that Alice and Bob share 
the same websocket server. In this scenario, Alice and Bob need exchange TURN messages as TURN UDP and TCP 
using websocket connection. The websocket will assign the allocation for both sides and decide how to 
bind the two allocations together and bridge the TURN application data, which is entirely implementation specific.

         </t>

      </section>
   </section>
   <section title="Allocation">
      <t>

Because the UDP and TCP allocation for the peer can satisfy the different scenarios, 
we just need to extend the connection between the client and the server - websocket connection. 
Considering websocket connection is based on TCP transport connection, we should add a flag in server's 
allocation to distinguish these two connections: 'app-connection'.

      </t>
      <t>

In the application of TURN UDP and TURN TCP, the 5-tuple (client's IP address, client's port, 
server IP address, server port, transport protocol) is used for stating the connection between 
the client and the server. However the 5-tuple is hard to state the websocket connection which 
is an application-level connection. The app-connection is used for stating the application level 
connection, whose value is 'ws' or'wss' when the client uses websocket or secure websocket to connect TURN server.

      </t>
   </section>
   <section title="Operation">
      <t>

The operation of the client, server and peer is the same as TURN UDP and TURN TCP with a difference 
of the new connection channel - websocket. 

      </t>
   </section>


   <section title="Multiplexing">
      <t>

In restrictive networks, the port resource is limited, so multiplexing the TURN connections on a single 
port is necessary. A method for websocket multiplexing is proposed in <xref target="I-D.ietf-hybi-websocket-multiplexing"/>, 
which describes a multiplexing extension for the WebSocket Protocol.  
With this extension, one TCP connection can provide multiple virtual WebSocket connections by 
encapsulating frames tagged with a channel ID.

            </t>
            <t>

This method could be used in conveying TURN data. One control websocket channel is needed to convey 
the TURN control message. When allocation request is successful, a new websocket connection should 
be established for transferring TURN application data. The channel ID for the new websocket connection 
should be saved in the allocation in server, so that all data in this channel will be bound to this 
specific allocation.
  
         </t>
		 </section>
	
   <section title="IANA Considerations">
      <t>
TBS
      </t>
   </section>
   <section title="Security Considerations">
      <t>
TBS
      </t>
   </section>
   <section title="Acknowledgements">
      <t>

Paul Kyzivat helped with the formatting of this draft.

      </t>
   </section>
</middle>

<back>
   <references title="Normative References">
      <?rfc include="reference.RFC.5766.xml"?>
      <?rfc include="reference.RFC.6062.xml"?>
   </references>
   <references title="Informative References">
      <?rfc include="reference.RFC.2119.xml"?>
      <?rfc include="reference.RFC.5245.xml"?>
      <?rfc include="reference.RFC.5389.xml"?>
      <?rfc include="reference.RFC.6455.xml"?>
	  <?rfc include="reference.RFC.4975.xml"?>
	  <?rfc include="reference.I-D.ietf-bfcpbis-rfc4582bis.xml"?>
	  <?rfc include="reference.I-D.pascual-dispatch-bfcp-websocket.xml"?>
	  <?rfc include="reference.I-D.pd-msrp-websocket.xml"?>
      <?rfc include="reference.I-D.ietf-rtcweb-use-cases-and-requirements.xml"?>
      <?rfc include="reference.I-D.miniero-rtcweb-http-fallback.xml"?>
      <?rfc include="reference.I-D.ietf-hybi-websocket-multiplexing.xml"?> 
   </references>


</back>
</rfc>
