<?xml version="1.0" encoding="US-ASCII"?>
<!-- This template is for creating an Internet Draft using xml2rfc,
    which is available here: http://xml.resource.org. -->
<!DOCTYPE rfc SYSTEM "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. -->

<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC2506 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2506.xml">
<!ENTITY RFC3264 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3264.xml">
<!ENTITY RFC3311 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3311.xml">
<!ENTITY RFC3758 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3758.xml">
<!ENTITY RFC3840 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3840.xml">
<!ENTITY RFC4566 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4566.xml">
<!ENTITY RFC4960 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4960.xml">
<!ENTITY RFC5245 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5245.xml">
<!ENTITY RFC5630 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5630.xml">
<!ENTITY RFC6347 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6347.xml">
<!ENTITY RFC6455 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6455.xml"><!ENTITY RFC6525 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6525.xml">
<!ENTITY RFC6690 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6690.xml">
<!ENTITY RFC7228 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7228.xml">
<!ENTITY RFC7252 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7252.xml">
<!ENTITY RFC7595 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7595.xml">
<!ENTITY RFC7675 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7675.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="yes" ?>
<!-- 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-groves-coap-webrtcdc-00" ipr="trust200902">
 <!-- category values: std, bcp, info, exp, and historic
    ipr values: trust200902, noModificationTrust200902, noDerivativesTrust200902,
       or pre5378Trust200902
    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="CoAP over WebRTC DC">A WebRTC Data Channel Transport for the Constrained Application Protocol (CoAP)</title>

   <!-- add 'role="editor"' below for the editors if appropriate -->

   <!-- Another author who claims to be an editor -->

 <author fullname="Christian Groves" initials="C" role="editor"
           surname="Groves">
     <organization>Huawei</organization>

     <address>
       <postal>
         <street></street>

         <!-- Reorder these if your country does things differently -->

         <city>Melbourne</city>

         <region></region>

         <code></code>

         <country>Australia</country>
       </postal>

       <email>Christian.Groves@nteczone.com</email>

       <!-- uri and facsimile elements may also be added -->
     </address>
   </author>
      <author fullname="Weiwei Yang" initials="W" 
           surname="Yang">
     <organization>Huawei</organization>

     <address>
       <postal>
         <street></street>

         <!-- Reorder these if your country does things differently -->

         <city></city>

         <region></region>

         <code></code>

         <country>P.R.China</country>
       </postal>

       <email>tommy@huawei.com</email>

       <!-- uri and facsimile elements may also be added -->
     </address>
	 </author>

   <date year="2016" />

   <!-- 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>Applications and Real-Time Area</area>

   <workgroup>CORE</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>template</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>The WebRTC framework defines a generic transport service allowing WEB-browsers and other endpoints to exchange generic data from peer to peer utilizing a Stream Control Transmission Protocol (SCTP) transport. This service is known as Web Real Time Communication WebRTC data channels (WebRTC DC). The use of WebRTC DCs for the Constrained Application Protocol (CoAP) allows WebRTC enabled devices to exchange CoAP data between peers in a secure reliable manner.</t>
   </abstract>
 </front>

 <middle>
   <section title="Introduction">
	 <t>Whilst the Constrained Application Protocol (CoAP) <xref target="RFC7252" /> was designed for Internet of Things (IoT) deployments in constrained network environments its ready adoption has seen the use of it in a multitude of different network environments. <xref target="I-D.silverajan-core-coap-alternative-transports" /> provides use cases for alternate CoAP transports.</t>
	
	<t><xref target="I-D.ietf-core-coap-tcp-tls" /> highlights a number of issues using the native User Datagram Transport (UDP) and envisages deployments more closely integrated with a Web environment. In a similar manner <xref target="I-D.savolainen-core-coap-websockets" /> proposes the use of the WebSocket protocol <xref target="RFC6455" />. The use of CoAP over WebRTC DCs has not yet been discussed.</t>
	
	<t>WebRTC is a framework <xref target="I-D.ietf-rtcweb-overview" /> that defines real time protocols for browser-based applications. It allows communications between peer WebRTC endpoints (e.g. browsers) without the need to communicate through a web server.</t>
	
	<t>In addition to protocols for the realtime transport of audio and video, the transport of generic peer-to-peer non-media data has been defined using WebRTC DCs. The non-media data is transported using the Stream Control Transmission Protocol (SCTP) <xref target="RFC4960" /> encapsulated in the Datagram Transport Layer Security (DTLS) <xref target="RFC6347" />. It allows both reliable and partially reliable transport and provides confidentiality, source authenticated and integrity protected transfers. The use of Interactive Connectivity Establishment (ICE) <xref target="RFC5245" /> allows network address translator (NAT) traversal. The SCTP/DTLS association may be shared with existing audio and video streams enabling multiplexing of several data streams over a single port further facilitating NAT traversal.</t>
	
	<t> Use cases for WebRTC DCs (section 3.1/<xref target="I-D.ietf-rtcweb-data-channel" /> envisage scenarios where the real-time gaming experience is enhanced by additional object state information. Additional scenarios are considered where information such as heart rate sensor or oxygen saturation sensors could augment audio and video in remote medicine scenarios. The transport of such sensor information is what CoAP has been designed for.</t>
	<t>	This is illustrated in <xref target="fig1" /> showing the WebRTC Trapeziod with added sensor/CoAP information. The left hand side WebRTC endpoint acts as a CoAP to CoAP proxy.</t>

     <figure align="center" anchor="fig1" title="CoAP and WebRTC Trapeziod">
       <preamble></preamble>

       <artwork align="left"><![CDATA[
                +-----------+             +-----------+
                |   Web     |             |   Web     |
                |           |  Signaling  |           |
                |           |-------------|           |
                |  Server   |   path      |  Server   |
                |           |             |           |
                +-----------+             +-----------+
                     /                           \
                    /                             \ Application-
                   /                               \ defined over
                  /                                 \ HTTP/Websockets
                 /  Application-defined over         \
                /   HTTP/Websockets                   \
               /                                       \
         +-----------+                           +-----------+
         |JS/HTML/CSS|                           |JS/HTML/CSS|
         +-----------+                           +-----------+
         +-----------+                           +-----------+
SensorA  |           |                           |           | 
CoAP/UDP |           |                           |           | 
  +------+  Browser  | ------------------------- |  Browser  +
         |           |          Media path       |           |
         |           |       (CoAP/WebRTC DC)    |           |
         +-----------+                           +-----------+

           ]]></artwork>

       <postamble></postamble>
     </figure>
	
	<t>By utilizing the WebRTC DC (SCTP over DTLS over ICE/UDP (or ICE/TCP)) transport for CoAP a number of important features are inherited including: congestion control, order and unordered messages delivery, large message transmission by providing segmentation and reassembly and multiple unidirectional streams. A more detailed analysis of the benefits of WebRTC DCs can be found in section 5/<xref target="I-D.ietf-rtcweb-data-channel" />. <xref target="I-D.ietf-tsvwg-sctp-dtls-encaps" /> describes the usage of SCTP over DTLS.</t>
	
	<t>WebRTC defines in-band and out-of-band methods for establishing a data channel and indicating its characteristics. The Data Channel Establishment Protocol (DCEP) <xref target="I-D.ietf-rtcweb-data-protocol" /> provides an in band means of establishing individual data channels. <xref target="I-D.ietf-mmusic-data-channel-sdpneg" /> uses the Session Description Protocol (SDP) <xref target="RFC4566" /> to provide an out-of-band means to establish data channels.</t>
	
	<t>By defining the use of CoAP over WebRTC DC it negates the need for the WebRTC endpoint to interwork between any CoAP messages received from local devices to a proprietary WebRTC DC format when signalling a remote WebRTC endpoint.</t>
	
	<t>The SCTP Payload Protocol Identifier (PPID) allows the identification of whether a UTF-8 or Binary encoding is being used and thus facilitates the use of text or binary CoAP protocol serializations.</t>
	
	<t>Note: The draft does not yet consider <xref target="I-D.bormann-core-coap-sig"/>. The intention has been to provide a draft that parallels the current CoAP over TCP and CoAP over Web Sockets drafts. It is likely that there will be impacts due to the <xref target="I-D.bormann-core-coap-sig"/>.</t>
	
</section>


   <section title="Requirements Language">
       <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">RFC 2119</xref>.</t>
   </section>
	 
   <section title="Constrained Application Protocol">
   <t>This section describes the use of CoAP over WebRTC DC as a delta to the information contained in section 2/<xref target="RFC7252" />.</t>
   <figure align="center" anchor="fig2" title="WebRTC protocol layers including CoAP">
       <preamble><xref target="fig2" /> shows the CoAP abstract layering as applied to the WebRTC framework.</preamble>

       <artwork align="left"><![CDATA[
                       +---------------------------+
                       |        Application        |                  
                       +------+------+-------------+ \
                       | DCEP | Requests/Responses | |
                       |      +--------------------| | CoAP
                       |      | Messages           | |
                       +------+--------------------+ /
                       |        SCTP               |
         +-----------------------------------------+
         | STUN | SRTP |        DTLS               |
         +-----------------------------------------+
         |                ICE                      |
         +-----------------------------------------+
         | UDP1 | UDP2 | UDP3 | ...                |
         +-----------------------------------------+

           ]]></artwork>

       <postamble></postamble>
     </figure>
	 <t>WebRTC DC mandates the use of SCTP over DTLS. Whilst the above diagram indicates the use of ICE over UDP the use of TCP is also possible in fall back scenarios.</t>
   <section title="Message Model">
	   <t>WebRTC DC allows application protocol messages to be exchanged by peers. WebRTC supports both a reliable and partially reliable methods of transmitting user messages.</t>
	   <t>CoAP <xref target="RFC7252" /> supports four message types "Confirmable, Non-Confirmable, Acknowledge and Reset". As SCTP provides the reliability mechanism the CoAP message types are not strictly needed for CoAP over WebRTC DC. However the message type is still included in the modified CoAP header for usage over WebRTC DC to facilitate interworking. See section 5 for more information.</t>
	   <t>WebRTC DC does not support multicast usage.</t>
	   </section>
   
    <section title="Request Response Model">
<t>WebRTC DCs are realized as a pair of one incoming and one outgoing SCTP stream (with the same identifier) allowing bi-directional communication. Each channel has properties (see section 6.4/<xref target="I-D.ietf-rtcweb-data-channel" /> as discussed below:<list hangIndent="4" style="symbols">
		<t>reliable or unreliable message transmission: WebRTC DCs support the per message indication whether user messages are reliable or partially reliable. Partial reliability indicates that message retransmission is limited to a certain number of retransmissions or lifetime. This loosely parallels to the CoAP usage of Confirmable (CON) or Non-confirmable (NON) messages.</t>
		<t>in-order or out-of-order message delivery: WebRTC DCs support the per message indication whether user messages are delivered in or out of order. CoAP has been designed for unreliable transports and therefore assumes that messages may arrive out-of-order. CoAP implements a lightweight reliability mechanism to deal with this issue.</t>
		<t>priority: WebRTC DCs allows a priority to specified for stream scheduling. The usage of this is application specific. Usage of CoAP has no impact on this parameter. It's up to the application using CoAP to set this indication.</t>
		<t>an optional label: This is an application/implementation specific label. Uniqueness is not guaranteed. Usage of CoAP has no impact on this parameter.</t>
		<t>an optional protocol: This is used to indicate the application protocol in use. A value is required to identify the usage of CoAP.</t>
		</list>
		</t>
		<t>As discussed above WebRTC DC supports an unreliable / un-ordered delivery of messages. Implementations utilizing these data channel characteristics may use CoAP messages and request/response model largely unchanged. In this case the CoAP reliability mechanisms would be used.  However as WebRTC DC's usage of SCTP is reliable or partially reliable there is some redundancy between the functionality that WebRTC DCs and CoAP provides. </t>
		<t>The redundancies are identified and discussed in section 3/<xref target="I-D.ietf-core-coap-tcp-tls" />. Namely: <list counter="reqs" hangIndent="4" style="format %d">
			<t>There is no need to carry acknowledgement semantics at a CoAP level.</t>
			<t>There is no need for duplicate delivery detection. This is part of the SCTP layer.</t>
		</list>
		</t>
</section>


    <section title="Intermediaries and Caching">
<t>As discussed whilst the CoAP message type is not required for reliability of CoAP over WebRTC DC the use of message type is to facilitate interworking to other transports in intermediaries. No other impacts are foreseen.</t>
</section>

    <section title="Resource Discovery">
<t>The usage of CoAP over WebRTC DC has no foreseeable impacts on resource discovery.</t>
</section>
</section>

<section title="Message Format">
<t>As discussed in <xref target="I-D.ietf-core-coap-tcp-tls" /> the use of a reliable underlying transport allows the use of a modified CoAP header format. The modified format removes the "Type (T)" and "Message ID" fields and introduces a "length" as illustrated below in <xref target="fig3" />.</t>
  <figure align="center" anchor="fig3" title="CoAP Header with TCP with 8-bit Length in Header">
       <preamble></preamble>

       <artwork align="left"><![CDATA[
   0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |Len=13 |  TKL  | Length (8-bit)|      Code     | TKL bytes ...
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Options (if any) ...
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |1 1 1 1 1 1 1 1|    Payload (if any) ...
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
           ]]></artwork>
		   
       <postamble></postamble>
     </figure>

<t>The length field was introduced to introduce message delimitation to keep messages separate in TCP. WebRTC DC uses the message orientation of SCTP to preserve message boundaries thus the use of single application message per SCTP user message is mandated by the WebRTC framework. Therefore a further simplified form of header is defined for CoAP over WebRTC datachannel usage:</t>

<figure align="center" anchor="fig4" title="CoAP Header with SCTP with 8-bit Length in Header">
       <preamble></preamble>

       <artwork align="left"><![CDATA[
   0                   1                   2                   3
    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |Ver| T |  TKL  |      Code     | TKL bytes ...
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |  Options (if any) ...
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |1 1 1 1 1 1 1 1|    Payload (if any)...
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
           ]]></artwork>
		   
       <postamble></postamble>
     </figure>

<t>The "Version (Ver)" and "Type (T)" fields are re-introduced as compared to <xref target="I-D.ietf-core-coap-tcp-tls" /> to maintain compatibility with CoAP <xref target="RFC7252" />. Thus the above header is only different from the CoAP header in that 2 bytes are saved due to the removal of the "Message ID".</t>

<t>Version (Ver) is effectively redundant due to the negotiation of the sub-protocol "coap.v1" at data channel establishment. This field MUST match the version indicated in the protocol field.</t>

<t>The use of the message type (T) is used as an indication to the CoAP receiver as to the characteristics of the message. The receiver MUST NOT use this information to implement a CoAP level reliability mechanism. Sections 5.2 and 5.3 detail the usage of message types.</t>

<t>Author's Note 1: The 4 bits required for "Version" and "Type" could be removed however this would mean that octet aligned boundaries would no longer be reserved. <xref target="I-D.savolainen-core-coap-websockets" /> instead indicates that the four most significant bits (i.e. those for Ver and T) be set to zero and are reserved.</t>

<t>Author's Note 2: A further alternative option is to use the CoAP header as defined in <xref target="RFC7252" /> and to indicate that for CoAP over WebRTC DC the "T" and "Message ID" are populated with "0-bits" when sending and ignored when receiving messages. </t>

	<t>CoAP <xref target="RFC7252" /> supports the use of different content-formats. WebRTC DC defines the use of PPIDs per SCTP user message as follows:<list hangIndent="4" style="symbols">
	<t>WebRTC String: to identify a non-empty JavaScript string encoded in UTF-8.</t>
	<t>WebRTC Binary: to identify a non-empty JavaScript binary data (ArrayBuffer, ArrayBufferView or Blob).</t>
	</list>
	</t>
	<t>Depending on the content-format (see section 12.3/<xref target="RFC7252" />) an appropriate PPID to the encoding type SHOULD be used to minimise the need for translating between encodings. For example content type of "text/plain" would result in the use of PPID "WebRTC String".</t>
	<t>Author's note: Specific mappings for each content-format could be provided however given that the formats may change in the future it may be sufficient to offer broad guidance instead.</t>

		<section title="Option Format and Value">
		<t>There are no impacts to option formats or values due to the use of CoAP over WebRTC DCs.</t>
		<t>Author's note: Given that the host is determined by the usage of WebRTC are the Uri-Host and Uri-Port relevant? It would seem that this may be valuable to establish a resource tree independent of WebRTC.</t>
		</section>

</section>

<section title="Message Transmission">
	<t>In order to use a WebRTC DC, a SCTP over DTLS over ICE/UDP (or ICE/TCP) association must be established. A DTLS connection is established followed by an SCTP association. The out-of-band establishment method through the use of SDP-based Data Channel Negotiation <xref target="I-D.ietf-mmusic-data-channel-sdpneg" /> allows the negotiation of SCTP over DTLS over ICE/UDP as well as the negotiation and establishment of the characteristics of an individual WebRTC DC.</t>
	<t>The in-band establishment method through the use of the Data Channel Establishment Protocol (DCEP) <xref target="I-D.ietf-rtcweb-data-protocol" /> only allows for the establishment of a WebRTC DC once the SCTP over DTLS is established. It relies on DATA_CHANNEL_OPEN and DATA_CHANNEL_ACK messages on the relevant SCTP stream to negotiate the properties of the channel. A separate SCTP PPID (50) indicates that the SCTP user message is a WebRTC DCEP message to allow de-multiplexing by the endpoint.</t>
	<t>WebRTC DCs are realized as a pair of one incoming and one outgoing SCTP stream (with the same identifier). Requests are sent on an outgoing SCTP stream and received on the peer incoming stream. The SCTP stream identifier is bound to the WebRTC DC instance at the establishment of the data channel. The establishment protocol provides rules for determining the SCTP stream IDs.</t>
	<t>WebRTC DC closure (Stream Reset) is supported through the use of the SCTP stream reconfiguration extension defined in <xref target="RFC6525" />. The SCTP Stream Reconfiguration reset has the effect of setting the numbering sequence of the SCTP stream back to zero. This is separate function to the CoAP "Reset" message. There is no mapping between the SCTP Stream Reset and the CoAP "Reset" message.</t>

		<section title="Messages and Endpoints">
		<t>As per section 5/<xref target="I-D.ietf-core-coap-tcp-tls" /> requests can be sent from both the connecting host and the endpoint that accepted the connection.  Who initiated the SCTP/DTLS connection has no bearing on the meaning of the CoAP terms client and server.</t>
		<t>WebRTC DC mandates the use of DTLS thus the endpoint is identified depending on the security mode.</t>
		<t>WebRTC DCs allows the indication of whether a SCTP user message is empty through the use of PPIDs (WebRTC String Empty and WebRTC Binary Empty). CoAP defines the use of empty messages. However from the perspective of SCTP these CoAP messages would still contain header information thus PPIDs for empty data MUST not be used.</t>
		<t>CoAP uses an Empty Confirmable message to provoke a Reset message to check the liveness of an endpoint (so called "CoAP" ping).  In WebRTC liveness and the ability to send data is determined through the usage of Session Traversal Utilities for NAT (STUN) Usage for Consent Freshness <xref target="RFC7675" />. Therefore endpoints utilising CoAP over WebRTC DC MUST not use CoAP "reset" messages.</t>
		<t>CoAP also uses Empty messages to acknowledge a request. This is not required due to the SCTP level acknowledgement. Therefore Empty messages MUST not be used with CoAP over WebRTC.</t>
		</section>

		<section title="Messages Transmitted Reliably">
		<t>For CoAP messages marked as confirmable the sender SHALL use a reliable SCTP user message.</t>
		<t>A CoAP endpoint MUST use the ordered delivery SCTP service, as described in <xref target="RFC4960" />, for the CoAP protocol.</t>
		<t>CoAP receivers MUST NOT generate CoAP "ACK" or "reset" messages. SCTP level acknowledgement mechanisms are used.</t>
		</section>
		
		<section title="Messages Transmitted without Reliability">
		<t>WebRTC DC makes use of the SCTP Partial Reliability (SCTP-PR) Extension <xref target="RFC3758" />. This extension allows a user to indicate on a per message basis how persistent the transport service should be in attempting to send the message to the receiver.  One of the benefits of using this extension identified by <xref target="RFC3758" /> is:<list hangIndent="4" style="hanging">
			<t>1. Some application layer protocols may benefit from being able to use a single SCTP association to carry both reliable content, -- such as text pages, billing and accounting information, setup signaling -- and unreliable content, e.g., state that is highly sensitive to timeliness, where generating a new packet is more advantageous than transmitting an old one [3].</t>
		</list>
		</t>
		<t>This benefit is also one of the reasons the CoAP "Non-Confirmable" message was introduced. However the SCTP-PR and the CoAP "Non-Confirmable" message mechanisms differs in their approach. The SCTP-PR mechanism focuses on sender side behaviour (e.g. when to abandon retransmission). The CoAP "Non-Confirmable" message focuses on receiver side behaviour (e.g. must not send a CoAP ACK). Even with the use of SCTP-PR an SCTP receiver will send an SCTP level ACK for a successfully received SCTP CHUNK. The CoAP "Non-Confirmable" message has no effect on the SCTP level function.</t>
		<t>Therefore the use of a CoAP "Non-Confirmable" message type is redundant as the CoAP receiver will never send a CoAP ACK message in response. However to facilitate potential interworking at the receiver the sender SHALL still indicate a "Non-confirmable" message type in a CoAP request/response when required.</t>
		<t>SCTP-PR provides a complimentary function and thus CoAP senders who send Non-confirmable messages SHALL also use SCTP-PR for that message.</t>
		</section>

		<section title="Message Correlation">
		<t>Due to reliability being handled at the SCTP layers the CoAP "Message ID" is not required.</t>
		</section>
		
		<section title="Message Duplication">
		<t>The SCTP layer provides message duplication protection. The CoAP application level procedure is not required.</t>
		</section>
		
		<section title="Message Size">
		<t>The considerations in section 4.1/<xref target="I-D.ietf-core-coap-tcp-tls" /> regarding message size limitations also apply to the use of WebRTC DCs. However <xref target="I-D.ietf-rtcweb-data-channel" /> indicates that senders SHOULD limit the maximum message size to 16KB to avoid monopolization of the SCTP association. Section 5/<xref target=" I-D.ietf-tsvwg-sctp-dtls-encaps" /> provides further details regarding segmentation and  reassembly and  path maximum transmission unit (MTU) discovery.</t>
		<t>Interleaving of large user messages is supported by an SCTP protocol extension defined in <xref target="I-D.ietf-tsvwg-sctp-ndata" />.</t>
		</section>
		
		<section title="Congestion Control">
		<t>SCTP provides congestion control on a per-association basis (see section 5/<xref target="I-D.ietf-rtcweb-data-channel" />.</t>
		</section>
		
		<section title="Transmission Parameters">
		<t>The application level parameters defined in section 4.8/<xref target="RFC7252" /> are not relevant to SCTP.</t>
		</section>
</section>

	<section title="Request/Response Semantics">
	<t>Request and response semantics for CoAP over WebRTC DC is as per section 5/<xref target="RFC7252" /> with the following exceptions:<list hangIndent="4" style="symbols">
		<t>section 5.2/<xref target="RFC7252" />: separate responses MUST be used. Given that WebRTC DC provides an SCTP level acknowledgement it is not possible to piggy back CoAP responses.</t>
		<t>section 5.3.1/<xref target="RFC7252" />: due to the use of DTLS the advice regarding token use without using TLS is invalid.</t>
		<t>section 5.3.2/<xref target="RFC7252" />: In addition CoAP request/response matching is unique to a particular WebRTC DC (SCTP StreamID pair).</t>
		<t>section 5.8/<xref target="RFC7252" />: It is not possible to use a 4.05 piggybacked response.</t>
		</list>
		</t>
	</section>

	<section title="CoAP URI">
	<t>CoAP <xref target="RFC7252" /> defines the "coap" and "coaps" URI schemes for identifying CoAP resources and providing a means of locating the resource. <xref target="RFC7252" /> defines these resources for use with CoAP over UDP.</t>
	<t>Section 8/<xref target="RFC7252" /> (Multicast CoAP), does not apply to the URI schemes defined in the present specification.</t>
	<t>Resources made available via the "coaps+wr" schemes have no shared identity with the other scheme or with the "coap" or "coaps" scheme, even if their resource identifiers indicate the same authority (the same host listening to the same port).  The schemes constitute distinct namespaces and, in combination with the authority, are considered to be distinct origin servers.</t>
	
		<section title="coaps+wr URI scheme">
		<figure>
	    <preamble></preamble>
		 <artwork><![CDATA[
coaps-wr-URI = "coaps+wr:" "//" host [ ":" port ] path-abempty
                  [ "?" query ]
           ]]></artwork>
     </figure>
	 
	 <t>The semantics defined in section 6.3/<xref target="RFC7252" />, apply to this URI scheme, with the following changes:<list hangIndent="4" style="symbols">
	 <t>The port SHALL be omitted. The underlying UDP or TCP port and SCTP port is negotiated prior to the establishment of the CoAP over WebRTC DC.</t>
	 </list>
	 </t>
		</section>
	</section>
	
	<section title="Discovery">
		<section title="Service Discovery">
		<t>WebRTC does not define peer discovery mechanisms. Peers discover each other through the use of the ICE protocol. ICE candidates need to be sent from peer to peer via signalling. The Javascript Session Establishment Protocol (JSEP) <xref target="I-D.ietf-rtcweb-jsep" /> details the generic SDP media descriptions for peer endpoints to determine the characteristics of a session. The actual signalling protocol between application servers is unspecified.  WebRTC endpoints MUST implement the network functions detailed by JSEP including ICE functionality.</t>
		<t>Whilst the inter-application server signalling protocol is unspecified, the Session Initiation Protocol (SIP) is able to carry SDP for the purposes of establishing a CoAP over WebRTC DC session.  SIP allows the use of media feature tags to indicate user agent capabilities <xref target="RFC3840" />. In order to indicate that a SIP user agent supports the use of CoAP a new "sip.coap" media feature tag is proposed. A CoAP-capable endpoint SHOULD include this media feature tag in its REGISTER requests and OPTION responses.  It SHOULD also include the media feature tag in INVITE and UPDATE <xref target="RFC3311" /> requests and responses. Presence of the media feature tag in the contact field of a requestor response can be used to determine that the far end supports CLUE.</t>
		<t>The exchange of SDP results in: the underlying transport address (e.g. IPv4 or IPv6), the underlying transport port (e.g. UDP port) the SCTP port and the SCTP StreamID used for the CoAP WebRTC DC being exchanged between the peer endpoints.</t>
		</section>
		<section title="Resource Discovery">
		<t>On establishment of a CoAP WebRTC DC endpoints are able to use the resource discovery mechanism defined in <xref target="RFC6690" /> for CoAP resources.</t>
		</section>
	</section>

	<section title="Multicast CoAP">
	<t>WebRTC DCs do not support multicast.</t>
	</section>
	
	<section title="Securing CoAP">
	<t>This document defines how to convey CoAP over WebRTC DCs. The WebRTC security architecture <xref target="I-D.ietf-rtcweb-security-arch" /> mandates the use of DTLS for data channels. The use of DTLS 1.2 is compatible with CoAP <xref target="RFC7252" /> which allows makes use of DTLS 1.2. </t>
	<t>The use of DTLS for WebRTC is detailed in <xref target="I-D.ietf-rtcweb-security-arch" />.</t>
	</section>
	
	
	<section title="Interworking">
	<t>An WebRTC endpoint supporting CoAP may in affect act as a gateway between local sensor devices and a remote peer endpoint. The local sensors may utilise CoAP over an alternate signalling transport such as UDP to the local WebRTC endpoint. The WebRTC endpoint may then utilise CoAP over WebRTC to signal to the remote peer.</t>
	<t>A CoAP gateway when converting to and from a WebRTC transport will in general perform the following functions:<list hangIndent="4" style="symbols">
		<t>Map received Empty CoAP message to SCTP level operations and discard the empty message.</t>
		<t>Map received ACK message to SCTP level operations and discard the ACK message.</t>
		<t>Separate piggy-backed messages.</t>
		<t>Provide a mapping between received and sent Tokens in order to match requests and responses.</t>
		</list>
		</t>
	<t>Other behaviour depends on the type of proxy behaviour the gateway is performing. See section 5.7/<xref target="RFC7252" /> for more details.</t>
	</section>
	
   <section anchor="Security" title="Security Considerations">
   <t>Security considerations for WebRTC are discussed in [ID. ietf-rtcweb-security].</t>
   <t>The use of CoAP over WebRTC can potentially negate the risks mentioned in:<list hangIndent="4" style="symbols">
   		<t>section 11.3/<xref target="RFC7252" /> on insecure UDP and multicast being used to aid an amplification attack.</t>
		<t>section 11.4/<xref target="RFC7252" /> on IP address spoofing and section 11.5/<xref target="RFC7252" /> on Cross-Protocol attacks.</t>
		<t>section 11.6/<xref target="RFC7252" /> may also not be relevant as WebRTC endpoints are not expected to be severely constrained.</t>
		</list>
		</t>
	<t>Of particular relevance to the support of CoAP over WebRTC DC is access to local devices. Devices generating CoAP data are essentially the same as cameras and microphones in that they may expose sensitive data about the user or the location of the device. Thus the guidance of section 4.1/<xref target="I-D.ietf-rtcweb-security" /> applies to devices generating CoAP data. Whilst CoAP has been designed for constrained devices where there is no user interface to inform/request consent, it is assumed that device utilising WebRTC DC for CoAP is more likely at minimum a Class 2 <xref target="RFC7228" /> device that could facilitate consent.</t>
	<t>The CoAP media feature tag defined by this document tag may be present in sessions not utilising CoAP, which increases the metadata available about the sending device, which can help an attacker differentiate between multiple devices and help them identify otherwise anonymised users via the fingerprint of features their device supports.  To prevent this, SIP signalling SHOULD always be encrypted using TLS <xref target="RFC5630" />.</t>
	</section>

	
   <section anchor="IANA" title="IANA Considerations">
   
	   <section title="New WebRTC DC Protocol Value">
	   <t>NOTE: This registration is exactly the same as the registration in <xref target="I-D.savolainen-core-coap-websockets" />.</t>
	   <t>This document requests the registration of the subprotocol name "coap.v1" in the WebSocket Subprotocol Name Registry.<list hangIndent="4" style="hanging">
			<t>Subprotocol Identifier:  coap.v1</t>
			<t>Subprotocol Common Name: Constrained Application Protocol (CoAP)</t>
			<t>Subprotocol Definition: [This document]</t>
			</list>
			</t>
		</section>
	
		 <section title="Secure Service Name and Port Number Registration">
		<t>No need has been identified to register a new service name and port number for CoAP over WebRTC. Port number allocation is dynamic.  The use of the SCTP over DTLS over UDP/TCP results in a layering of services.</t>
		</section>
		
		<section title="ALPN Protocol ID">
		<t><xref target="I-D.ietf-core-coap-tcp-tls" /> defines a new "coap" application protocol negotiation protocol identity. However as the DTLS connection is used to establish a WebRTC application the protocol identifiers defined in <xref target="I-D.ietf-rtcweb-alpn" /> MUST be used. Note: that confidentiality protection does not extend to WebRTC DCs.</t>
		</section>
		
		<section title="URI Schemes">
		<t>This document registers a new URI scheme "coaps+wr" for the use of CoAP over WebRTC DCs.  The "coaps+wr" URI schemes can be compared to the "https" URI scheme.</t>
		<t>The IANA is requested to add this new URI schemes to the registry established with <xref target="RFC7595" />.</t>
		</section>
		
		<section title="New SIP Media Feature Tag">
		<t>This specification registers a new media feature tag in the SIP <xref target="RFC3264" /> tree per the procedures defined in <xref target="RFC2506" /> and <xref target="RFC3840" />.</t>
		<t>Media feature tag name: sip.coap</t>
		<t>ASN.1 Identifier: 1.3.6.1.8.4.30</t>
		<t>Summary of the media feature indicated by this tag: This feature tag indicates that the device supports the Constrained Application Protocol (CoAP).</t>
		<t>Values appropriate for use with this feature tag: Boolean.</t>
		<t>The feature tag is intended primarily for use in the following applications, protocols, services, or negotiation mechanisms: This feature tag is useful to indicate the support of CoAP.</t>
		<t>Related standards or documents: [this draft]</t>
		<t>Security Considerations: Security considerations for this media feature tag are discussed in <xref target="Security" />.</t>
		<t>Name(s) and email address(es) of person(s) to contact for further information:<list hangIndent="4" style="hanging">
			<t>CORE workgroup: core@ietf.org</t>
			<t>CORE chairs: core-chairs@ietf.org</t>
			</list>
			</t>
		<t>Intended usage: COMMON</t>
		</section>
   </section>	
   
   <section anchor="Examples" title="Examples">
   <t>The example SDP Offer shows a CoAP over WebRTC DC utilising out-of-band negotiation <xref target="I-D.ietf-mmusic-data-channel-sdpneg" />. It is based on the example in section 7.2/<xref target="I-D.ietf-rtcweb-jsep" />. Modified lines are indicated with ">>>" at the start of the line. These indicators are NOT part of the SDP syntax. Note: some lines have been broken into two lines for formatting reasons.</t>
   <figure>
	    <preamble></preamble>
		 <artwork><![CDATA[
v=0
   o=- 4962303333179871723 1 IN IP4 0.0.0.0
   s=-
   t=0 0
   a=group:BUNDLE a1 d1
   a=ice-options:trickle
   m=audio 9 UDP/TLS/RTP/SAVPF 96 0 8 97 98
   c=IN IP4 0.0.0.0
   a=rtcp:9 IN IP4 0.0.0.0
   a=mid:a1
   a=msid:57017fee-b6c1-4162-929c-a25110252400
          e83006c5-a0ff-4e0a-9ed9-d3e6747be7d9
   a=sendrecv
   a=rtpmap:96 opus/48000/2
   a=rtpmap:0 PCMU/8000
   a=rtpmap:8 PCMA/8000
   a=rtpmap:97 telephone-event/8000
   a=rtpmap:98 telephone-event/48000
   a=maxptime:120
   a=ice-ufrag:ATEn1v9DoTMB9J4r
   a=ice-pwd:AtSK0WpNtpUjkY4+86js7ZQl
   a=fingerprint:sha-256
                 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04
                :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2
   a=setup:actpass
   a=rtcp-mux
   a=rtcp-rsize
   a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
   a=extmap:2 urn:ietf:params:rtp-hdrext:sdes:mid
   a=ssrc:1732846380 cname:FocUG1f0fcg/yvY7

   m=application 0 UDP/DTLS/SCTP webrtc-datachannel
   c=IN IP4 0.0.0.0
   a=bundle-only
   a=mid:d1
   a=fmtp:webrtc-datachannel max-message-size=65536
   a=sctp-port 5000
   a=fingerprint:sha-256 
                 19:E2:1C:3B:4B:9F:81:E6:B8:5C:F4:A5:A8:D8:73:04
                 :BB:05:2F:70:9F:04:A9:0E:05:E9:26:33:E8:70:88:A2
   a=setup:actpass
>>>a=dcmap:0 subprotocol="coap.v1";"label="coap"
           ]]></artwork>
     </figure>
	</section>
		
   <section anchor="Acknowledgements" title="Acknowledgements">
     <t>We would like to thank the authors of <xref target="I-D.ietf-core-coap-tcp-tls" /> and <xref target="I-D.savolainen-core-coap-websockets" /> for providing a framework for this document.</t>
	 <t>This template was derived from an initial version written by Pekka
     Savola and contributed by him to the xml2rfc project.</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">
     <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?-->
    &RFC2119;
	&RFC2506;
	&RFC3264;
	&RFC3311;
	&RFC3758;
	&RFC3840;
	&RFC4566;
	&RFC4960;
	&RFC5245;
	&RFC5630;
	&RFC6347;
	&RFC6525;
	&RFC6690;
	&RFC7228;
	&RFC7252;
	&RFC7595;
	&RFC7675;
    <?rfc include="reference.I-D.ietf-mmusic-data-channel-sdpneg.xml"?>
	<?rfc include="reference.I-D.ietf-rtcweb-alpn.xml"?>
	<?rfc include="reference.I-D.ietf-rtcweb-data-channel.xml"?>
	<?rfc include="reference.I-D.ietf-rtcweb-data-protocol.xml"?>
	<?rfc include="reference.I-D.ietf-rtcweb-jsep.xml"?>
	<?rfc include="reference.I-D.ietf-rtcweb-overview.xml"?>
	<?rfc include="reference.I-D.ietf-rtcweb-security.xml"?>
	<?rfc include="reference.I-D.ietf-rtcweb-security-arch.xml"?>
	<?rfc include="reference.I-D.ietf-tsvwg-sctp-ndata.xml"?>
	<?rfc include="reference.I-D.ietf-tsvwg-sctp-dtls-encaps.xml"?>
  
   </references>

   <references title="Informative References">
     <!-- Here we use entities that we defined at the beginning. -->

		&RFC6455;
    <?rfc include="reference.I-D.bormann-core-coap-sig.xml"?>
	<?rfc include="reference.I-D.silverajan-core-coap-alternative-transports.xml"?>
	<?rfc include="reference.I-D.savolainen-core-coap-websockets.xml"?>
  	<?rfc include="reference.I-D.ietf-core-coap-tcp-tls.xml"?>

   </references>

   <section anchor="app-additional" title="Additional Stuff">
     <t>This becomes an Appendix.</t>
   </section>

  
 </back>
</rfc>
