idnits 2.17.1 draft-ietf-core-http-mapping-10.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document seems to lack the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. (The document does seem to have the reference to RFC 2119 which the ID-Checklist requires). -- The document date (May 13, 2016) is 2905 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Informational ---------------------------------------------------------------------------- == Missing Reference: 'C-T' is mentioned on line 816, but not defined == Missing Reference: 'C-E' is mentioned on line 802, but not defined == Outdated reference: A later version (-21) exists of draft-ietf-core-block-20 ** Obsolete normative reference: RFC 7230 (Obsoleted by RFC 9110, RFC 9112) ** Obsolete normative reference: RFC 7231 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 7232 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 7235 (Obsoleted by RFC 9110) == Outdated reference: A later version (-10) exists of draft-ietf-core-links-json-05 == Outdated reference: A later version (-28) exists of draft-ietf-core-resource-directory-07 -- Obsolete informational reference (is this intentional?): RFC 2616 (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) -- Obsolete informational reference (is this intentional?): RFC 7049 (Obsoleted by RFC 8949) Summary: 4 errors (**), 0 flaws (~~), 7 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 CoRE Working Group A. Castellani 3 Internet-Draft University of Padova 4 Intended status: Informational S. Loreto 5 Expires: November 14, 2016 Ericsson 6 A. Rahman 7 InterDigital Communications, LLC 8 T. Fossati 9 Alcatel-Lucent 10 E. Dijk 11 Philips Research 12 May 13, 2016 14 Guidelines for HTTP-to-CoAP Mapping Implementations 15 draft-ietf-core-http-mapping-10 17 Abstract 19 This document provides reference information for implementing a 20 cross-protocol network proxy that performs translation from the HTTP 21 protocol to the CoAP protocol. This will enable a HTTP client to 22 access resources on a CoAP server through the proxy. This document 23 describes how a HTTP request is mapped to a CoAP request, and then 24 how a CoAP response is mapped back to a HTTP response. This includes 25 guidelines for URI mapping, media type mapping and additional proxy 26 implementation issues. This document covers the Reverse, Forward and 27 Interception cross-protocol proxy cases. 29 Status of This Memo 31 This Internet-Draft is submitted in full conformance with the 32 provisions of BCP 78 and BCP 79. 34 Internet-Drafts are working documents of the Internet Engineering 35 Task Force (IETF). Note that other groups may also distribute 36 working documents as Internet-Drafts. The list of current Internet- 37 Drafts is at http://datatracker.ietf.org/drafts/current/. 39 Internet-Drafts are draft documents valid for a maximum of six months 40 and may be updated, replaced, or obsoleted by other documents at any 41 time. It is inappropriate to use Internet-Drafts as reference 42 material or to cite them other than as "work in progress." 44 This Internet-Draft will expire on November 14, 2016. 46 Copyright Notice 48 Copyright (c) 2016 IETF Trust and the persons identified as the 49 document authors. All rights reserved. 51 This document is subject to BCP 78 and the IETF Trust's Legal 52 Provisions Relating to IETF Documents 53 (http://trustee.ietf.org/license-info) in effect on the date of 54 publication of this document. Please review these documents 55 carefully, as they describe your rights and restrictions with respect 56 to this document. Code Components extracted from this document must 57 include Simplified BSD License text as described in Section 4.e of 58 the Trust Legal Provisions and are provided without warranty as 59 described in the Simplified BSD License. 61 Table of Contents 63 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 64 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 65 3. HTTP-to-CoAP Proxy . . . . . . . . . . . . . . . . . . . . . 5 66 4. Use Cases . . . . . . . . . . . . . . . . . . . . . . . . . . 6 67 5. URI Mapping . . . . . . . . . . . . . . . . . . . . . . . . . 6 68 5.1. URI Terminology . . . . . . . . . . . . . . . . . . . . . 7 69 5.2. Null Mapping . . . . . . . . . . . . . . . . . . . . . . 8 70 5.3. Default Mapping . . . . . . . . . . . . . . . . . . . . . 8 71 5.3.1. Optional Scheme Omission . . . . . . . . . . . . . . 8 72 5.3.2. Encoding Caveats . . . . . . . . . . . . . . . . . . 9 73 5.4. URI Mapping Template . . . . . . . . . . . . . . . . . . 9 74 5.4.1. Simple Form . . . . . . . . . . . . . . . . . . . . . 9 75 5.4.2. Enhanced Form . . . . . . . . . . . . . . . . . . . . 11 76 5.5. Discovery . . . . . . . . . . . . . . . . . . . . . . . . 12 77 5.5.1. Examples . . . . . . . . . . . . . . . . . . . . . . 13 78 6. Media Type Mapping . . . . . . . . . . . . . . . . . . . . . 15 79 6.1. Overview . . . . . . . . . . . . . . . . . . . . . . . . 15 80 6.2. 'application/coap-payload' Media Type . . . . . . . . . . 16 81 6.3. Loose Media Type Mapping . . . . . . . . . . . . . . . . 17 82 6.4. Media Type to Content Format Mapping Algorithm . . . . . 18 83 6.5. Content Transcoding . . . . . . . . . . . . . . . . . . . 19 84 6.5.1. General . . . . . . . . . . . . . . . . . . . . . . . 19 85 6.5.2. CoRE Link Format . . . . . . . . . . . . . . . . . . 19 86 6.5.3. Diagnostic Messages . . . . . . . . . . . . . . . . . 20 87 7. Response Code Mapping . . . . . . . . . . . . . . . . . . . . 20 88 8. Additional Mapping Guidelines . . . . . . . . . . . . . . . . 23 89 8.1. Caching and Congestion Control . . . . . . . . . . . . . 23 90 8.2. Cache Refresh via Observe . . . . . . . . . . . . . . . . 23 91 8.3. Use of CoAP Blockwise Transfer . . . . . . . . . . . . . 24 92 8.4. CoAP Multicast . . . . . . . . . . . . . . . . . . . . . 25 93 8.5. Timeouts . . . . . . . . . . . . . . . . . . . . . . . . 25 95 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 25 96 9.1. New 'core.hc' Resource Type . . . . . . . . . . . . . . . 25 97 9.2. New 'coap-payload' Internet Media Type . . . . . . . . . 26 98 10. Security Considerations . . . . . . . . . . . . . . . . . . . 27 99 10.1. Multicast . . . . . . . . . . . . . . . . . . . . . . . 27 100 10.2. Traffic Overflow . . . . . . . . . . . . . . . . . . . . 28 101 10.3. Handling Secured Exchanges . . . . . . . . . . . . . . . 28 102 10.4. URI Mapping . . . . . . . . . . . . . . . . . . . . . . 29 103 11. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 29 104 12. References . . . . . . . . . . . . . . . . . . . . . . . . . 30 105 12.1. Normative References . . . . . . . . . . . . . . . . . . 30 106 12.2. Informative References . . . . . . . . . . . . . . . . . 31 107 Appendix A. Change Log . . . . . . . . . . . . . . . . . . . . . 32 108 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 35 110 1. Introduction 112 CoAP [RFC7252] has been designed with the twofold aim to be an 113 application protocol specialized for constrained environments and to 114 be easily used in Representational State Transfer (REST) based 115 architectures such as the Web. The latter goal has led to defining 116 CoAP to easily interoperate with HTTP [RFC7230] through an 117 intermediary proxy which performs cross-protocol conversion. 119 Section 10 of [RFC7252] describes the fundamentals of the CoAP-to- 120 HTTP and the HTTP-to-CoAP cross-protocol mapping process. However, 121 [RFC7252] focuses on the basic mapping of request methods and simple 122 response code mapping between HTTP and CoAP, and it leaves many 123 details of the cross-protocol proxy for future definition. 124 Therefore, a primary goal of this informational document is to define 125 a consistent set of guidelines that an HTTP-to-CoAP proxy 126 implementation should adhere to. The key benefit to adhering to such 127 guidelines is to reduce variation between proxy implementations, 128 thereby increasing interoperability between an HTTP client and a CoAP 129 server independent of the proxy that implements the cross-protocol 130 mapping. (For example, a proxy conforming to these guidelines made 131 by vendor A can be easily replaced by a proxy from vendor B that also 132 conforms to the guidelines.) 134 This document is organized as follows: 136 o Section 2 defines proxy terminology; 138 o Section 3 introduces the HTTP-to-CoAP proxy; 140 o Section 4 lists use cases in which HTTP clients need to contact 141 CoAP servers; 143 o Section 5 introduces a null, default and advanced HTTP-to-CoAP URI 144 mapping syntax; 146 o Section 6 describes how to map HTTP media types to CoAP content 147 formats and vice versa; 149 o Section 7 describes how to map CoAP responses to HTTP responses; 151 o Section 8 describes additional mapping guidelines related to 152 caching, congestion, timeouts, etc.; 154 o Section 10 discusses possible security impact of HTTP-to-CoAP 155 protocol mapping. 157 2. Terminology 159 The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 160 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 161 "OPTIONAL" in this document are to be interpreted as described in 162 [RFC2119]. 164 HC Proxy: a proxy performing a cross-protocol mapping, in the context 165 of this document an HTTP-to-CoAP (HC) mapping. Specifically, the HC 166 proxy acts as an HTTP server and a CoAP client. The HC Proxy can 167 take on the role of a Forward, Reverse or Interception Proxy. 169 Forward Proxy (or Forward HC Proxy): a message forwarding agent that 170 is selected by the HTTP client, usually via local configuration 171 rules, to receive requests for some type(s) of absolute URI and to 172 attempt to satisfy those requests via translation to the protocol 173 indicated by the absolute URI. The user decides (is willing) to use 174 the proxy as the forwarding/de-referencing agent for a predefined 175 subset of the URI space. In [RFC7230] this is called a Proxy. 176 [RFC7252] defines Forward-Proxy similarly. 178 Reverse Proxy (or Reverse HC Proxy): as in [RFC7230], a receiving 179 agent that acts as a layer above some other server(s) and translates 180 the received requests to the underlying server's protocol. A Reverse 181 HC Proxy behaves as an origin (HTTP) server on its connection from 182 the HTTP client. The HTTP client uses the "origin-form" 183 (Section 5.3.1 of [RFC7230]) as a request-target URI. 185 Interception Proxy (or Interception HC Proxy) [RFC3040]: a proxy that 186 receives inbound HTTP traffic flows through the process of traffic 187 redirection; transparent to the HTTP client. 189 Note that a Reverse Proxy appears to an HTTP client as an origin 190 server while a Forward Proxy does not. So, when communicating with a 191 Reverse Proxy a client may be unaware it is communicating with a 192 proxy at all. 194 3. HTTP-to-CoAP Proxy 196 A HC proxy is accessed by an HTTP client which wants to access a 197 resource on a CoAP server. The HC proxy handles the HTTP request by 198 mapping it to the equivalent CoAP request, which is then forwarded to 199 the appropriate CoAP server. The received CoAP response is then 200 mapped to an appropriate HTTP response and finally sent back to the 201 originating HTTP client. 203 See Figure 1 for an example deployment scenario. Here a HC proxy is 204 located at the boundary of the Constrained Network domain, to avoid 205 sending any HTTP traffic into the Constrained Network and to avoid 206 any (unsecured) CoAP multicast traffic outside the Constrained 207 Network. A DNS server (not shown) is used by the HTTP Client to 208 resolve the IP address of the HC proxy and optionally also used by 209 the HC proxy to resolve IP addresses of CoAP servers. 211 Constrained Network 212 .-------------------. 213 / .------. \ 214 / | CoAP | \ 215 / |server| \ 216 || '------' || 217 || || 218 .--------. HTTP Request .------------. CoAP Req .------. || 219 | HTTP |---------------->|HTTP-to-CoAP|----------->| CoAP | || 220 | Client |<----------------| Proxy |<-----------|Server| || 221 '--------' HTTP Response '------------' CoAP Resp '------' || 222 || || 223 || .------. || 224 || | CoAP | || 225 \ |server| .------. / 226 \ '------' | CoAP | / 227 \ |server| / 228 \ '------' / 229 '-----------------' 231 Figure 1: HTTP-To-CoAP Proxy Deployment Scenario 233 Normative requirements on the translation of HTTP requests to CoAP 234 requests and of the CoAP responses back to HTTP responses are defined 235 in Section 10.2 of [RFC7252]. However, [RFC7252] focuses on the 236 basic mapping of request methods and simple response code mapping 237 between HTTP and CoAP, and leaves many details of the cross-protocol 238 HC proxy for future definition. This document provides additional 239 guidelines and more details for the implementation of a HC Proxy, 240 which should be followed in addition to the normative requirements. 241 Note that the guidelines apply to all forms of an HC proxy (i.e. 242 Reverse, Forward, Intercepting) unless explicitly otherwise noted. 244 4. Use Cases 246 To illustrate the situations HTTP to CoAP protocol translation may be 247 used, three use cases are described below. 249 1. Legacy building control application without CoAP: A building 250 control application that uses HTTP but not CoAP can check the status 251 of CoAP sensors and/or control actuators via a HC proxy. 253 2. Making sensor data available to 3rd parties on the Web: For 254 demonstration or public interest purposes, a HC proxy may be 255 configured to expose the contents of a CoAP sensor to the world via 256 the web (HTTP and/or HTTPS). Some sensors may only accept secure 257 'coaps' requests, therefore the proxy is configured to translate 258 request to those devices accordingly. The HC proxy is furthermore 259 configured to only pass through GET requests in order to protect the 260 constrained network. 262 3. Smartphone and home sensor: A smartphone can access directly a 263 CoAP home sensor using a mutually authenticated 'https' request, 264 provided its home router runs a HC proxy and is configured with the 265 appropriate certificate. An HTML5 application on the smartphone can 266 provide a friendly UI using the standard (HTTP) networking functions 267 of HTML5. 269 A key point in the above use cases is the expected nature of the URI 270 to be used by the HTTP client initiating the HTTP request to the HC 271 proxy. Specifically, in use case #1, there will be no "coap" or 272 "coaps" related information embedded in the HTTP URI as it is a 273 legacy HTTP client sending the request. Use case #2 is also expected 274 to be similar. In contrast, in use case #3, it is expected that the 275 HTTP client will specifically embed "coap" or "coaps" related 276 information in the HTTP URI of the HTTP request to the HC proxy. 278 5. URI Mapping 280 Though, in principle, a CoAP URI could be directly used by a HTTP 281 client to de-reference a CoAP resource through a HC proxy, the 282 reality is that all major web browsers, networking libraries and 283 command line tools do not allow making HTTP requests using URIs with 284 a scheme "coap" or "coaps". 286 Thus, there is a need for web applications to embed or "pack" a CoAP 287 URI into a HTTP URI so that it can be (non-destructively) transported 288 from the HTTP client to the HC proxy. The HC proxy can then "unpack" 289 the CoAP URI and finally de-reference it via a CoAP request to the 290 target Server. 292 URI Mapping is the term used in the document to describe the process 293 through which the URI of a CoAP resource is transformed into an HTTP 294 URI so that: 296 o the requesting HTTP client can handle it; 298 o the receiving HC proxy can extract the intended CoAP URI 299 unambiguously. 301 To this end, the remainder of this section will identify: 303 o the default mechanism to map a CoAP URI into a HTTP URI; 305 o the URI template format to express a class of CoAP-HTTP URI 306 mapping functions; 308 o the discovery mechanism based on CoRE Link Format [RFC6690] 309 through which clients of a HC proxy can dynamically discover 310 information about the supported URI Mapping Template(s), as well 311 as the URI where the HC proxy function is anchored. 313 5.1. URI Terminology 315 In the remainder of this section, the following terms will be used 316 with a distinctive meaning: 318 HC Proxy URI: 319 URI which refers to the HC proxy function. It conforms to 320 syntax defined in Section 2.7 of [RFC7230]. 322 Target CoAP URI: 323 URI which refers to the (final) CoAP resource that has to be 324 de-referenced. It conforms to syntax defined in Section 6 of 325 [RFC7252]. Specifically, its scheme is either "coap" or 326 "coaps". 328 Hosting HTTP URI: 329 URI that conforms to syntax in Section 2.7 of [RFC7230]. Its 330 authority component refers to a HC proxy, whereas path (and 331 query) component(s) embed the information used by a HC proxy 332 to extract the Target CoAP URI. 334 5.2. Null Mapping 336 The null mapping is the case where there is no Target CoAP URI 337 appended to the HC Proxy URI. In other words, it is a "pure" HTTP 338 URI that is sent to the HC Proxy. This would typically occur in 339 situations like Use Case #1 described in Section 4, and the Proxy 340 would typically be a Reverse Proxy. In this scenario, the HC Proxy 341 will determine through its own proprietary algorithms what the Target 342 CoAP URI should be. 344 5.3. Default Mapping 346 The default mapping is for the Target CoAP URI to be appended as-is 347 to the HC Proxy URI, to form the Hosting HTTP URI. This is the URI 348 that will then be sent by the HTTP client in the HTTP request to the 349 HC proxy. 351 For example: given a HC Proxy URI http://p.example.com/hc and a 352 Target CoAP URI coap://s.example.com/light, the resulting Hosting 353 HTTP URI would be http://p.example.com/hc/coap://s.example.com/light. 355 Provided a correct Target CoAP URI, the Hosting HTTP URI resulting 356 from the default mapping is always syntactically correct. 357 Furthermore, the Target CoAP URI can always be extracted 358 unambiguously from the Hosting HTTP URI. Also, it is worth noting 359 that, using the default mapping, a query component in the target CoAP 360 resource URI is naturally encoded into the query component of the 361 Hosting URI, e.g.: coap://s.example.com/light?dim=5 becomes 362 http://p.example.com/hc/coap://s.example.com/light?dim=5. 364 There is no default for the HC Proxy URI. Therefore, it is either 365 known in advance, e.g. as a configuration preset, or dynamically 366 discovered using the mechanism described in Section 5.5. 368 The default URI mapping function SHOULD be implemented and activated 369 by default in a HC proxy, unless there are valid reasons, e.g. 370 application specific, to use a different mapping function. 372 5.3.1. Optional Scheme Omission 374 When found in a Hosting HTTP URI, the scheme (i.e., "coap" or 375 "coaps"), the scheme component delimiter (":"), and the double slash 376 ("//") preceding the authority MAY be omitted. In such case, a local 377 default - not defined by this document - applies. 379 So, http://p.example.com/hc/s.coap.example.com/foo could either 380 represent the target coap://s.coap.example.com/foo or 381 coaps://s.coap.example.com/foo depending on application specific 382 presets. 384 5.3.2. Encoding Caveats 386 When the authority of the Target CoAP URI is given as an IPv6address, 387 then the surrounding square brackets must be percent-encoded in the 388 Hosting HTTP URI, in order to comply with the syntax defined in 389 Section 3.3. of [RFC3986] for a URI path segment. E.g.: 390 coap://[2001:db8::1]/light?on becomes 391 http://p.example.com/hc/coap://%5B2001:db8::1%5D/light?on. 393 Everything else can be safely copied verbatim from the Target CoAP 394 URI to the Hosting HTTP URI. 396 5.4. URI Mapping Template 398 This section defines a format for the URI template [RFC6570] used by 399 a HC proxy to inform its clients about the expected syntax for the 400 Hosting HTTP URI. This will then be used by the HTTP client to 401 construct the URI to be sent in the HTTP request to the HC proxy. 403 When instantiated, an URI Mapping Template is always concatenated to 404 a HC Proxy URI provided by the HC proxy via discovery (see 405 Section 5.5), or by other means. 407 A simple form (Section 5.4.1) and an enhanced form (Section 5.4.2) 408 are provided to fit different users' requirements. 410 Both forms are expressed as level 2 URI templates [RFC6570] to take 411 care of the expansion of values that are allowed to include reserved 412 URI characters. The syntax of all URI formats is specified in this 413 section in Augmented Backus-Naur Form (ABNF) [RFC5234]. 415 5.4.1. Simple Form 417 The simple form MUST be used for mappings where the Target CoAP URI 418 is going to be copied (using rules of Section 5.3.2) at some fixed 419 position into the Hosting HTTP URI. 421 The following template variables MUST be used in mutual exclusion in 422 a template definition: 424 cu = coap-URI ; from [RFC7252], Section 6.1 425 su = coaps-URI ; from [RFC7252], Section 6.2 426 tu = cu / su 428 The same considerations as in Section 5.3.1 apply, in that the CoAP 429 scheme may be omitted from the Hosting HTTP URI. 431 5.4.1.1. Examples 433 All the following examples (given as a specific URI mapping template, 434 a Target CoAP URI, and the produced Hosting HTTP URI) use 435 http://p.example.com/hc as the HC Proxy URI. Note that these 436 examples all define mapping templates that deviate from the default 437 template of Section 5.3 to be able to illustrate the use of the above 438 template variables. 440 1. "coap" URI is a query argument of the Hosting HTTP URI: 442 ?coap_target_uri={+cu} 444 coap://s.example.com/light 446 http://p.example.com/hc?coap_target_uri=coap://s.example.com/light 448 2. "coaps" URI is a query argument of the Hosting HTTP URI: 450 ?coaps_target_uri={+su} 452 coaps://s.example.com/light 454 http://p.example.com/hc?coaps_target_uri=coaps://s.example.com/light 456 3. Target CoAP URI as a query argument of the Hosting HTTP URI: 458 ?target_uri={+tu} 460 coap://s.example.com/light 462 http://p.example.com/hc?target_uri=coap://s.example.com/light 464 or 466 coaps://s.example.com/light 468 http://p.example.com/hc?target_uri=coaps://s.example.com/light 470 4. Target CoAP URI in the path component of the Hosting HTTP URI 471 (i.e., the default URI Mapping template): 473 /{+tu} 475 coap://s.example.com/light 477 http://p.example.com/hc/coap://s.example.com/light 479 or 481 coaps://s.example.com/light 483 http://p.example.com/hc/coaps://s.example.com/light 485 5. "coap" URI is a query argument of the Hosting HTTP URI; client 486 decides to omit scheme because a default scheme is agreed 487 beforehand between client and proxy: 489 ?coap_uri={+cu} 491 coap://s.example.com/light 493 http://p.example.com/hc?coap_uri=s.example.com/light 495 5.4.2. Enhanced Form 497 The enhanced form can be used to express more sophisticated mappings, 498 i.e., those that do not fit into the simple form. 500 There MUST be at most one instance of each of the following template 501 variables in a template definition: 503 s = "coap" / "coaps" ; from [RFC7252], Sections 6.1 and 6.2 504 hp = host [":" port] ; from [RFC3986] Sections 3.2.2 and 3.2.3 505 p = path-abempty ; from [RFC3986] Section 3.3 506 q = query ; from [RFC3986] Section 3.4 507 qq = [ "?" query ] ; qq is empty iff 'query' is empty 509 5.4.2.1. Examples 511 All the following examples (given as a specific URI mapping template, 512 a Target CoAP URI, and the produced Hosting HTTP URI) use 513 http://p.example.com/hc as the HC Proxy URI. 515 1. Target CoAP URI components in path segments, and optional query 516 in query component: 518 {+s}{+hp}{+p}{+qq} 520 coap://s.example.com/light 522 http://p.example.com/hc/coap/s.example.com/light 524 or 526 coap://s.example.com/light?on 528 http://p.example.com/hc/coap/s.example.com/light?on 530 2. Target CoAP URI components split in individual query arguments: 532 ?s={+s}&hp={+hp}&p={+p}&q={+q} 534 coap://s.example.com/light 536 http://p.example.com/hc?s=coap&hp=s.example.com&p=/light&q= 538 or 540 coaps://s.example.com/light?on 542 http://p.example.com/hc?s=coaps&hp=s.example.com&p=/light&q=on 544 5.5. Discovery 546 In order to accommodate site specific needs while allowing third 547 parties to discover the proxy function, the HC proxy SHOULD publish 548 information related to the location and syntax of the HC proxy 549 function using the CoRE Link Format [RFC6690] interface. 551 To this aim a new Resource Type, "core.hc", is defined in this 552 document. It can be used as the value for the "rt" attribute in a 553 query to the /.well-known/core in order to locate the URI where the 554 HC proxy function is anchored, i.e. the HC Proxy URI. 556 Along with it, the new target attribute "hct" is defined in this 557 document. This attribute MAY be returned in a "core.hc" link to 558 provide the URI Mapping Template associated to the mapping resource. 560 The default template given in Section 5.3, i.e., {+tu}, MUST be 561 assumed if no "hct" attribute is found in the returned link. If a 562 "hct" attribute is present in the returned link, then a client MUST 563 use it to create the Hosting HTTP URI. 565 The URI mapping SHOULD be discoverable (as specified in [RFC6690]) on 566 both the HTTP and the CoAP side of the HC proxy, with one important 567 difference: on the CoAP side the link associated to the "core.hc" 568 resource needs an explicit anchor referring to the HTTP origin, while 569 on the HTTP interface the link context is already the HTTP origin 570 carried in the request's Host header, and doesn't have to be made 571 explicit. 573 5.5.1. Examples 575 o The first example exercises the CoAP interface, and assumes that 576 the default template, {+tu}, is used. For example, in use case #3 577 in section Section 4, the smartphone may discover the public HC 578 proxy before leaving the home network. Then when outside the home 579 network, the smartphone will be able to query the appropriate home 580 sensor. 582 Req: GET coap://[ff02::1]/.well-known/core?rt=core.hc 584 Res: 2.05 Content 585 ;anchor="http://p.example.com";rt="core.hc" 587 o The second example - also on the CoAP side of the HC proxy - uses 588 a custom template, i.e., one where the CoAP URI is carried inside 589 the query component, thus the returned link carries the URI 590 template to be used in an explicit "hct" attribute: 592 Req: GET coap://[ff02::1]/.well-known/core?rt=core.hc 594 Res: 2.05 Content 595 ;anchor="http://p.example.com"; 596 rt="core.hc";hct="?uri={+tu}" 598 On the HTTP side, link information can be serialized in more than one 599 way: 601 o using the 'application/link-format' content type: 603 Req: GET /.well-known/core?rt=core.hc HTTP/1.1 604 Host: p.example.com 606 Res: HTTP/1.1 200 OK 607 Content-Type: application/link-format 608 Content-Length: 18 610 ;rt="core.hc" 612 o using the 'application/link-format+json' content type as defined 613 in [I-D.ietf-core-links-json]: 615 Req: GET /.well-known/core?rt=core.hc HTTP/1.1 616 Host: p.example.com 618 Res: HTTP/1.1 200 OK 619 Content-Type: application/link-format+json 620 Content-Length: 31 622 [{"href":"/hc","rt":"core.hc"}] 624 o using the Link header: 626 Req: GET /.well-known/core?rt=core.hc HTTP/1.1 627 Host: p.example.com 629 Res: HTTP/1.1 200 OK 630 Link: ;rt="core.hc" 632 o A HC proxy may expose two different HC Proxy URIs to differentiate 633 between Target CoAP resources in the "coap" and "coaps" scheme: 635 Req: GET /.well-known/core?rt=core.hc 636 Host: p.example.com 638 Res: HTTP/1.1 200 OK 639 Content-Type: application/link-format+json 640 Content-Length: 111 642 [ 643 {"href":"/hc/plaintext","rt":"core.hc","hct":"{+cu}"}, 644 {"href":"/hc/secure","rt":"core.hc","hct":"{+su}"} 645 ] 647 6. Media Type Mapping 649 6.1. Overview 651 A HC proxy needs to translate HTTP media types (Section 3.1.1.1 of 652 [RFC7231]) and content encodings (Section 3.1.2.2 of [RFC7231]) into 653 CoAP content formats (Section 12.3 of [RFC7252]) and vice versa. 655 Media type translation can happen in GET, PUT or POST requests going 656 from HTTP to CoAP, and in 2.xx (i.e., successful) responses going 657 from CoAP to HTTP. Specifically, PUT and POST need to map both the 658 Content-Type and Content-Encoding HTTP headers into a single CoAP 659 Content-Format option, whereas GET needs to map Accept and Accept- 660 Encoding HTTP headers into a single CoAP Accept option. To generate 661 the HTTP response, the CoAP Content-Format option is mapped back to a 662 suitable HTTP Content-Type and Content-Encoding combination. 664 An HTTP request carrying a Content-Type and Content-Encoding 665 combination which the HC proxy is unable to map to an equivalent CoAP 666 Content-Format, SHALL elicit a 415 (Unsupported Media Type) response 667 by the HC proxy. 669 On the content negotiation side, failure to map Accept and Accept-* 670 headers SHOULD be silently ignored: the HC proxy SHOULD therefore 671 forward as a CoAP request with no Accept option. The HC proxy thus 672 disregards the Accept/Accept-* header fields by treating the response 673 as if it is not subject to content negotiation, as mentioned in 674 Sections 5.3.* of [RFC7231]. However, a HC proxy implementation is 675 free to attempt mapping a single Accept header in a GET request to 676 multiple CoAP GET requests, each with a single Accept option, which 677 are then tried in sequence until one succeeds. Note that an HTTP 678 Accept */* MUST be mapped to a CoAP request without Accept option. 680 While the CoAP to HTTP direction has always a well defined mapping 681 (with the exception examined in Section 6.2), the HTTP to CoAP 682 direction is more problematic because the source set, i.e., 683 potentially 1000+ IANA registered media types, is much bigger than 684 the destination set, i.e., the mere 6 values initially defined in 685 Section 12.3 of [RFC7252]. 687 Depending on the tight/loose coupling with the application(s) for 688 which it proxies, the HC proxy could implement different media type 689 mappings. 691 When tightly coupled, the HC proxy knows exactly which content 692 formats are supported by the applications, and can be strict when 693 enforcing its forwarding policies in general, and the media type 694 mapping in particular. 696 On the other side, when the HC proxy is a general purpose application 697 layer gateway, being too strict could significantly reduce the amount 698 of traffic that it'd be able to successfully forward. In this case, 699 the "loose" media type mapping detailed in Section 6.3 MAY be 700 implemented. 702 The latter grants more evolution of the surrounding ecosystem, at the 703 cost of allowing more attack surface. In fact, as a result of such 704 strategy, payloads would be forwarded more liberally across the 705 unconstrained/constrained network boundary of the communication path. 706 Therefore, when applied, other forms of access control must be set in 707 place to avoid unauthorized users to deplete or abuse systems and 708 network resources. 710 6.2. 'application/coap-payload' Media Type 712 If the HC proxy receives a CoAP response with a Content-Format that 713 it does not recognize (e.g. because the value has been registered 714 after the proxy has been deployed, or the CoAP server uses an 715 experimental value which is not registered), then the HC proxy SHALL 716 return a generic "application/coap-payload" media type with numeric 717 parameter "cf" as defined in Section 9.2. 719 For example, the CoAP content format '60' ("application/cbor") would 720 be represented by "application/coap-payload;cf=60", if the HC Proxy 721 doesn't recognize the content format '60'. 723 A HTTP client may use the media type "application/coap-payload" as a 724 means to send a specific content format to a CoAP server via a HC 725 Proxy if the client has determined that the HC Proxy does not 726 directly support the type mapping it needs. This case may happen 727 when dealing for example with newly registered, yet to be registered, 728 or experimental CoAP content formats. 730 6.3. Loose Media Type Mapping 732 By structuring the type information in a super-class (e.g. "text") 733 followed by a finer grained sub-class (e.g. "html"), and optional 734 parameters (e.g. "charset=utf-8"), Internet media types provide a 735 rich and scalable framework for encoding the type of any given 736 entity. 738 This approach is not applicable to CoAP, where Content Formats 739 conflate an Internet media type (potentially with specific 740 parameters) and a content encoding into one small integer value. 742 To remedy this loss of flexibility, we introduce the concept of a 743 "loose" media type mapping, where media types that are 744 specializations of a more generic media type can be aliased to their 745 super-class and then mapped (if possible) to one of the CoAP content 746 formats. For example, "application/soap+xml" can be aliased to 747 "application/xml", which has a known conversion to CoAP. In the 748 context of this "loose" media type mapping, "application/octet- 749 stream" can be used as a fallback when no better alias is found for a 750 specific media type. 752 Table 1 defines the default lookup table for the "loose" media type 753 mapping. Given an input media type, the table returns its best 754 generalized media type using the most specific match i.e. the table 755 entries are compared to the input in top to bottom order until an 756 entry matches. 758 +---------------------+--------------------------+ 759 | Internet media type | Generalized media type | 760 +---------------------+--------------------------+ 761 | application/*+xml | application/xml | 762 | application/*+json | application/json | 763 | text/xml | application/xml | 764 | text/* | text/plain | 765 | */* | application/octet-stream | 766 +---------------------+--------------------------+ 768 Table 1: Media type generalization lookup table 770 The "loose" media type mapping is an OPTIONAL feature. 771 Implementations supporting this kind of mapping should provide a 772 flexible way to define the set of media type generalizations allowed. 774 6.4. Media Type to Content Format Mapping Algorithm 776 This section defines the algorithm used to map an HTTP Internet media 777 type to its correspondent CoAP content format. 779 The algorithm uses the mapping table defined in Section 12.3 of 780 [RFC7252] plus, possibly, any locally defined extension of it. 781 Optionally, the table and lookup mechanism described in Section 6.3 782 can be used if the implementation chooses so. 784 Note that the algorithm may have side effects on the associated 785 representation (see also Section 6.5). 787 In the following: 789 o C-T, C-E, and C-F stand for the values of the Content-Type (or 790 Accept) HTTP header, Content-Encoding (or Accept-Encoding) HTTP 791 header, and Content-Format CoAP option respectively. 793 o If C-E is not given it is assumed to be "identity". 795 o MAP is the mandatory lookup table, GMAP is the optional 796 generalized table. 798 INPUT: C-T and C-E 799 OUTPUT: C-F or Fail 801 1. if no C-T: return Fail 802 2. C-F = MAP[C-T, C-E] 803 3. if C-F is not None: return C-F 804 4. if C-E is not "identity": 805 5. if C-E is supported (e.g. gzip): 806 6. decode the representation accordingly 807 7. set C-E to "identity" 808 8. else: 809 9. return Fail 810 10. repeat steps 2. and 3. 811 11. if C-T allows a non-lossy transformation into \ 812 12. one of the supported C-F: 813 13. transcode the representation accordingly 814 14. return C-F 815 15. if GMAP is defined: 816 16. C-F = GMAP[C-T] 817 17. if C-F is not None: return C-F 818 18. return Fail 820 Figure 2 822 6.5. Content Transcoding 824 6.5.1. General 826 Payload content transcoding (e.g. see steps 11-14 of Figure 2) is an 827 OPTIONAL feature. Implementations supporting this feature should 828 provide a flexible way to define the set of transcodings allowed. 830 As noted in Section 6.4, the process of mapping the media type can 831 have side effects on the forwarded entity body. This may be caused 832 by the removal or addition of a specific content encoding, or because 833 the HC proxy decides to transcode the representation to a different 834 (compatible) format. The latter proves useful when an optimized 835 version of a specific format exists. For example an XML-encoded 836 resource could be transcoded to Efficient XML Interchange (EXI) 837 format, or a JSON-encoded resource into CBOR [RFC7049], effectively 838 achieving compression without losing any information. 840 However, it should be noted that in certain cases, transcoding can 841 lose information in a non-obvious manner. For example, encoding an 842 XML document using schema-informed EXI encoding leads to a loss of 843 information when the destination does not know the exact schema 844 version used by the encoder, which means that whenever the HC proxy 845 transcodes an application/XML to application/EXI in-band metadata 846 could be lost. Therefore, the implementer should always carefully 847 verify such lossy payload transformations before triggering the 848 transcoding. 850 6.5.2. CoRE Link Format 852 The CoRE Link Format [RFC6690] is a set of links (i.e., URIs and 853 their formal relationships) which is carried as content payload in a 854 CoAP response. These links usually include CoAP URIs that might be 855 translated by the HC proxy to the correspondent HTTP URIs using the 856 implemented URI mapping function (see Section 5). Such a process 857 would inspect the forwarded traffic and attempt to re-write the body 858 of resources with an application/link-format media type, mapping the 859 embedded CoAP URIs to their HTTP counterparts. Some potential issues 860 with this approach are: 862 1. The client may be interested to retrieve original (unaltered) 863 CoAP payloads through the HC proxy, not modified versions. 865 2. Tampering with payloads is incompatible with resources that are 866 integrity protected (although this is a problem with transcoding 867 in general). 869 3. The HC proxy needs to fully understand [RFC6690] syntax and 870 semantics, otherwise there is an inherent risk to corrupt the 871 payloads. 873 Therefore, CoRE Link Format payload should only be transcoded at the 874 risk and discretion of the proxy implementer. 876 6.5.3. Diagnostic Messages 878 CoAP responses may, in certain error cases, contain a diagnostic 879 message in the payload explaining the error situation, as described 880 in Section 5.5.2 of [RFC7252]. If present, the CoAP response 881 diagnostic payload SHOULD be copied in the HTTP response body. The 882 CoAP diagnostic message MUST NOT be copied into the HTTP reason- 883 phrase, since it potentially contains CR-LF characters which are 884 incompatible with HTTP reason-phrase syntax. 886 7. Response Code Mapping 888 Table 2 defines the HTTP response status codes to which each CoAP 889 response code SHOULD be mapped. Multiple appearances of a HTTP 890 status code in the second column indicates multiple equivalent HTTP 891 responses are possible based on the same CoAP response code, 892 depending on the conditions cited in the Notes (third column and text 893 below table). 895 +-----------------------------+-----------------------------+-------+ 896 | CoAP Response Code | HTTP Status Code | Notes | 897 +-----------------------------+-----------------------------+-------+ 898 | 2.01 Created | 201 Created | 1 | 899 | 2.02 Deleted | 200 OK | 2 | 900 | | 204 No Content | 2 | 901 | 2.03 Valid | 304 Not Modified | 3 | 902 | | 200 OK | 4 | 903 | 2.04 Changed | 200 OK | 2 | 904 | | 204 No Content | 2 | 905 | 2.05 Content | 200 OK | | 906 | 4.00 Bad Request | 400 Bad Request | | 907 | 4.01 Unauthorized | 403 Forbidden | 5 | 908 | 4.02 Bad Option | 400 Bad Request | 6 | 909 | 4.02 Bad Option | 500 Internal Server Error | 6 | 910 | 4.03 Forbidden | 403 Forbidden | | 911 | 4.04 Not Found | 404 Not Found | | 912 | 4.05 Method Not Allowed | 400 Bad Request | 7 | 913 | 4.06 Not Acceptable | 406 Not Acceptable | | 914 | 4.12 Precondition Failed | 412 Precondition Failed | | 915 | 4.13 Request Ent. Too Large | 413 Request Repr. Too Large | | 916 | 4.15 Unsupported Media Type | 415 Unsupported Media Type | | 917 | 5.00 Internal Server Error | 500 Internal Server Error | | 918 | 5.01 Not Implemented | 501 Not Implemented | | 919 | 5.02 Bad Gateway | 502 Bad Gateway | | 920 | 5.03 Service Unavailable | 503 Service Unavailable | 8 | 921 | 5.04 Gateway Timeout | 504 Gateway Timeout | | 922 | 5.05 Proxying Not Supported | 502 Bad Gateway | 9 | 923 +-----------------------------+-----------------------------+-------+ 925 Table 2: CoAP-HTTP Response Code Mappings 927 Notes: 929 1. A CoAP server may return an arbitrary format payload along with 930 this response. If present, this payload MUST be returned as 931 entity in the HTTP 201 response. Section 7.3.2 of [RFC7231] does 932 not put any requirement on the format of the entity. (In the 933 past, [RFC2616] did.) 935 2. The HTTP code is 200 or 204 respectively for the case that a CoAP 936 server returns a payload or not. [RFC7231] Section 5.3 requires 937 code 200 in case a representation of the action result is 938 returned for DELETE/POST/PUT, and code 204 if not. Hence, a 939 proxy MUST transfer any CoAP payload contained in a CoAP 2.02 940 response to the HTTP client using a 200 OK response. 942 3. HTTP code 304 (Not Modified) is sent if the HTTP client performed 943 a conditional HTTP request and the CoAP server responded with 944 2.03 (Valid) to the corresponding CoAP validation request. Note 945 that Section 4.1 of [RFC7232] puts some requirements on header 946 fields that must be present in the HTTP 304 response. 948 4. A 200 response to a CoAP 2.03 occurs only when the HC proxy, for 949 efficiency reasons, is running a local cache. An unconditional 950 HTTP GET which produces a cache-hit, could trigger a re- 951 validation (i.e. a conditional GET) on the CoAP side. The proxy 952 receiving 2.03 updates the freshness of its cached representation 953 and returns it to the HTTP client. 955 5. A HTTP 401 Unauthorized (Section 3.1 of [RFC7235]) response is 956 not applicable because there is no equivalent in CoAP of WWW- 957 Authenticate which is mandatory in a HTTP 401 response. 959 6. If the proxy has a way to determine that the Bad Option is due to 960 the straightforward mapping of a client request header into a 961 CoAP option, then returning HTTP 400 (Bad Request) is 962 appropriate. In all other cases, the proxy MUST return HTTP 500 963 (Internal Server Error) stating its inability to provide a 964 suitable translation to the client's request. 966 7. A CoAP 4.05 (Method Not Allowed) response SHOULD normally be 967 mapped to a HTTP 400 (Bad Request) code, because the HTTP 405 968 response would require specifying the supported methods - which 969 are generally unknown. In this case the HC Proxy SHOULD also 970 return a HTTP reason-phrase in the HTTP status line that starts 971 with the string "CoAP server returned 4.05" in order to 972 facilitate troubleshooting. However, if the HC proxy has more 973 granular information about the supported methods for the 974 requested resource (e.g. via a Resource Directory 975 ([I-D.ietf-core-resource-directory])) then it MAY send back a 976 HTTP 405 (Method Not Allowed) with a properly filled in "Allow" 977 response-header field (Section 7.4.1 of [RFC7231]). 979 8. The value of the HTTP "Retry-After" response-header field is 980 taken from the value of the CoAP Max-Age Option, if present. 982 9. This CoAP response can only happen if the proxy itself is 983 configured to use a CoAP forward-proxy (Section 5.7 of [RFC7252]) 984 to execute some, or all, of its CoAP requests. 986 8. Additional Mapping Guidelines 988 8.1. Caching and Congestion Control 990 A HC proxy should cache CoAP responses, and reply whenever applicable 991 with a cached representation of the requested resource. 993 If the HTTP client drops the connection after the HTTP request was 994 made, a HC proxy should wait for the associated CoAP response and 995 cache it if possible. Subsequent requests to the HC proxy for the 996 same resource can use the result present in cache, or, if a response 997 has still to come, the HTTP requests will wait on the open CoAP 998 request. 1000 According to [RFC7252], a proxy must limit the number of outstanding 1001 requests to a given CoAP server to NSTART. To limit the amount of 1002 aggregate traffic to a constrained network, the HC proxy should also 1003 put a limit on the number of concurrent CoAP requests pending on the 1004 same constrained network; further incoming requests may either be 1005 queued or dropped (returning 503 Service Unavailable). This limit 1006 and the proxy queueing/dropping behavior should be configurable. 1008 Highly volatile resources that are being frequently requested may be 1009 observed [RFC7641] by the HC proxy to keep their cached 1010 representation fresh while minimizing the amount of CoAP traffic in 1011 the constrained network. See Section 8.2. 1013 8.2. Cache Refresh via Observe 1015 There are cases where using the CoAP observe protocol [RFC7641] to 1016 handle proxy cache refresh is preferable to the validation mechanism 1017 based on ETag as defined in [RFC7252]. Such scenarios include, but 1018 are not limited to, sleepy CoAP nodes -- with possibly high variance 1019 in requests' distribution -- which would greatly benefit from a 1020 server driven cache update mechanism. Ideal candidates for CoAP 1021 observe are also crowded or very low throughput networks, where 1022 reduction of the total number of exchanged messages is an important 1023 requirement. 1025 This subsection aims at providing a practical evaluation method to 1026 decide whether refreshing a cached resource R is more efficiently 1027 handled via ETag validation or by establishing an observation on R. 1029 Let T_R be the mean time between two client requests to resource R, 1030 let T_C be the mean time between two representation changes of R, and 1031 let M_R be the mean number of CoAP messages per second exchanged to 1032 and from resource R. If we assume that the initial cost for 1033 establishing the observation is negligible, an observation on R 1034 reduces M_R iff T_R < 2*T_C with respect to using ETag validation, 1035 that is iff the mean arrival rate of requests for resource R is 1036 greater than half the change rate of R. 1038 When observing the resource R, M_R is always upper bounded by 2/T_C. 1040 8.3. Use of CoAP Blockwise Transfer 1042 A HC proxy SHOULD support CoAP blockwise transfers 1043 [I-D.ietf-core-block] to allow transport of large CoAP payloads while 1044 avoiding excessive link-layer fragmentation in constrained networks, 1045 and to cope with small datagram buffers in CoAP end-points as 1046 described in [RFC7252] Section 4.6. 1048 A HC proxy SHOULD attempt to retry a payload-carrying CoAP PUT or 1049 POST request with blockwise transfer if the destination CoAP server 1050 responded with 4.13 (Request Entity Too Large) to the original 1051 request. A HC proxy SHOULD attempt to use blockwise transfer when 1052 sending a CoAP PUT or POST request message that is larger than 1053 BLOCKWISE_THRESHOLD bytes. The value of BLOCKWISE_THRESHOLD is 1054 implementation-specific, for example it can be: 1056 o calculated based on a known or typical UDP datagram buffer size 1057 for CoAP end-points, or 1059 o set to N times the known size of a link-layer frame in a 1060 constrained network where e.g. N=5, or 1062 o preset to a known IP MTU value, or 1064 o set to a known Path MTU value. 1066 The value BLOCKWISE_THRESHOLD, or the parameters from which it is 1067 calculated, should be configurable in a proxy implementation. The 1068 maximum block size the proxy will attempt to use in CoAP requests 1069 should also be configurable. 1071 The HC proxy SHOULD detect CoAP end-points not supporting blockwise 1072 transfers. This can be done by checking for a 4.02 (Bad Option) 1073 response returned by an end-point in response to a CoAP request with 1074 a Block* Option, and subsequent absence of the 4.02 in response to 1075 the same request without Block* Options. This allows the HC proxy to 1076 be more efficient, not attempting repeated blockwise transfers to 1077 CoAP servers that do not support it. 1079 8.4. CoAP Multicast 1081 A HC proxy MAY support CoAP multicast. If it does, the HC proxy 1082 sends out a multicast CoAP request if the Target CoAP URI's authority 1083 is a multicast IP literal or resolves to a multicast IP address. If 1084 the HC proxy does not support CoAP multicast, it SHOULD respond 403 1085 (Forbidden) to any valid HTTP request that maps to a CoAP multicast 1086 request. 1088 Details related to supporting CoAP multicast are currently out of 1089 scope of this document since in a proxy scenario a HTTP client 1090 typically expects to receive a single response, not multiple. 1091 However, a HC proxy that implements CoAP multicast may include 1092 application-specific functions to aggregate multiple CoAP responses 1093 into a single HTTP response. We suggest using the "application/http" 1094 internet media type (Section 8.3.2 of [RFC7230]) to enclose a set of 1095 one or more HTTP response messages, each representing the mapping of 1096 one CoAP response. 1098 For further considerations related to the handling of multicast 1099 requests, see Section 10.1. 1101 8.5. Timeouts 1103 If the CoAP server takes a long time in responding, the HTTP client 1104 or any other proxy in between may timeout. Further discussion of 1105 timeouts in HTTP is available in Section 6.2.4 of [RFC7230]. 1107 A HC proxy MUST define an internal timeout for each pending CoAP 1108 request, because the CoAP server may silently die before completing 1109 the request. Assuming the Proxy uses confirmable CoAP requests, such 1110 timeout value T SHOULD be at least 1112 T = MAX_RTT + MAX_SERVER_RESPONSE_DELAY 1114 where MAX_RTT is defined in [RFC7252] and MAX_SERVER_RESPONSE_DELAY 1115 is defined in [RFC7390]. 1117 9. IANA Considerations 1119 9.1. New 'core.hc' Resource Type 1121 This document registers a new Resource Type (rt=) Link Target 1122 Attribute, 'core.hc', in the "Resource Type (rt=) Link Target 1123 Attribute Values" subregistry under the "Constrained RESTful 1124 Environments (CoRE) Parameters" registry. 1126 Attribute Value: core.hc 1127 Description: HTTP to CoAP mapping base resource. 1129 Reference: See Section 5.5. 1131 9.2. New 'coap-payload' Internet Media Type 1133 This document defines the "application/coap-payload" media type with 1134 a single parameter "cf". This media type represents any payload that 1135 a CoAP message can carry, having a content format that can be 1136 identified by a CoAP Content-Format parameter (an integer in range 1137 0-65535). The parameter "cf" is the integer defining the CoAP 1138 content format. 1140 Type name: application 1142 Subtype name: coap-payload 1144 Required parameters: 1146 cf - CoAP Content-Format integer in range 0-65535 denoting the 1147 content format of the CoAP payload carried. 1149 Optional parameters: None 1151 Encoding considerations: 1153 The specific CoAP content format encoding considerations for the 1154 selected Content-Format (cf parameter) apply. 1156 Security considerations: 1158 The specific CoAP content format security considerations for the 1159 selected Content-Format (cf parameter) apply. 1161 Interoperability considerations: 1163 Published specification: (this I-D - TBD) 1165 Applications that use this media type: 1167 HTTP-to-CoAP Proxies. 1169 Fragment identifier considerations: N/A 1171 Additional information: 1173 Deprecated alias names for this type: N/A 1174 Magic number(s): N/A 1176 File extension(s): N/A 1178 Macintosh file type code(s): N/A 1180 Person and email address to contact for further information: 1182 Esko Dijk ("esko@ieee.org") 1184 Intended usage: COMMON 1186 Restrictions on usage: 1188 An application (or user) can only use this media type if it has to 1189 represent a CoAP payload of which the specified CoAP Content-Format 1190 is an unrecognized number; such that a proper translation directly to 1191 the equivalent HTTP media type is not possible. 1193 Author: CoRE WG 1195 Change controller: IETF 1197 Provisional registration? (standards tree only): N/A 1199 10. Security Considerations 1201 The security concerns raised in Section 9.2 of [RFC7230] also apply 1202 to the HC proxy scenario. 1204 A HC proxy deployed at the boundary of a constrained network is an 1205 easy single point of failure for reducing availability. As such, 1206 special care should be taken in designing, developing and operating 1207 it, keeping in mind that, in most cases, it has fewer limitations 1208 than the constrained devices it is serving. 1210 The following sub paragraphs categorize and discuss a set of specific 1211 security issues related to the translation, caching and forwarding 1212 functionality exposed by a HC proxy. 1214 10.1. Multicast 1216 Multicast requests impose a non trivial cost on the constrained 1217 network and endpoints, and might be exploited as a DoS attack vector. 1218 From a privacy perspective, they can be used to gather detailed 1219 information about the resources hosted in the constrained network. 1220 For these reasons, it is RECOMMENDED that requests to multicast 1221 resources are access controlled with a default-deny policy. It is 1222 RECOMMENDED that the requestor of a multicast resource is strongly 1223 authenticated. If privacy is a concern, for example whenever the 1224 HTTP request transits through the public Internet, the request SHOULD 1225 be transported over a mutually authenticated and encrypted TLS 1226 connection. 1228 10.2. Traffic Overflow 1230 Due to the typically constrained nature of CoAP nodes, particular 1231 attention should be given to the implementation of traffic reduction 1232 mechanisms (see Section 8.1), because inefficient proxy 1233 implementations can be targeted by unconstrained Internet attackers. 1234 Bandwidth or complexity involved in such attacks is very low. 1236 An amplification attack to the constrained network may be triggered 1237 by a multicast request generated by a single HTTP request which is 1238 mapped to a CoAP multicast resource, as discussed in Section 11.3 of 1239 [RFC7252]. 1241 The risk likelihood of this amplification technique is higher than an 1242 amplification attack carried out by a malicious constrained device 1243 (e.g. ICMPv6 flooding, like Packet Too Big, or Parameter Problem on 1244 a multicast destination [RFC4732]), since it does not require direct 1245 access to the constrained network. 1247 The feasibility of this attack which disrupts availability of the 1248 targeted CoAP server can be limited by access controlling the exposed 1249 multicast resources, so that only known/authorized users can access 1250 such URIs. 1252 10.3. Handling Secured Exchanges 1254 An HTTP request can be sent to the HC proxy over a secured 1255 connection. However, there may not always exist a secure connection 1256 mapping to CoAP. For example, a secure distribution method for 1257 multicast traffic is complex and may not be implemented (see 1258 [RFC7390]). 1260 A HC proxy should implement rules for security context translations. 1261 For example all "https" unicast requests are translated to "coaps" 1262 requests, or "https" requests are translated to unsecured "coap" 1263 requests. Another rule could specify the security policy and 1264 parameters used for DTLS connections. Such rules will largely depend 1265 on the application and network context in which the HC proxy 1266 operates. These rules should be configurable. 1268 It is RECOMMENDED that, by default, accessing a "coaps" URI is only 1269 allowed from a corresponding "https" URI. 1271 By default, a HC proxy SHOULD reject any secured client request if 1272 there is no configured security policy mapping. This recommendation 1273 may be relaxed in case the destination network is believed to be 1274 secured by other means. Assuming that CoAP nodes are isolated behind 1275 a firewall as in the HC proxy deployment shown in Figure 1, the HC 1276 proxy may be configured to translate the incoming HTTPS request using 1277 plain CoAP (NoSec mode). 1279 10.4. URI Mapping 1281 The following risks related to the URI mapping described in Section 5 1282 and its use by HC proxies have been identified: 1284 DoS attack on the constrained/CoAP network. 1285 Mitigation: by default deny any Target CoAP URI whose authority is 1286 (or maps to) a multicast address. Then explicitly white-list 1287 multicast resources/authorities that are allowed to be de- 1288 referenced. See also Section 8.4. 1290 Leaking information on the constrained/CoAP network resources and 1291 topology. 1292 Mitigation: by default deny any Target CoAP URI (especially 1293 /.well-known/core is a resource to be protected), and then 1294 explicitly white-list resources that are allowed to be seen from 1295 outside. 1297 The internal CoAP Target resource is totally transparent from 1298 outside. 1299 Mitigation: implement a HTTPS-only interface, which makes the 1300 Target CoAP URI totally opaque to a passive attacker. 1302 11. Acknowledgements 1304 An initial version of Table 2 in Section 7 has been provided in 1305 revision -05 of the CoRE CoAP I-D. Special thanks to Peter van der 1306 Stok for countless comments and discussions on this document, that 1307 contributed to its current structure and text. 1309 Thanks to Carsten Bormann, Zach Shelby, Michele Rossi, Nicola Bui, 1310 Michele Zorzi, Klaus Hartke, Cullen Jennings, Kepeng Li, Brian Frank, 1311 Peter Saint-Andre, Kerry Lynn, Linyi Tian, Dorothy Gellert, Francesco 1312 Corazza and Hannes Tschofenig for helpful comments and discussions 1313 that have shaped the document. 1315 The research leading to these results has received funding from the 1316 European Community's Seventh Framework Programme [FP7/2007-2013] 1317 under grant agreement n.251557. 1319 12. References 1321 12.1. Normative References 1323 [I-D.ietf-core-block] 1324 Bormann, C. and Z. Shelby, "Block-wise transfers in CoAP", 1325 draft-ietf-core-block-20 (work in progress), April 2016. 1327 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1328 Requirement Levels", BCP 14, RFC 2119, 1329 DOI 10.17487/RFC2119, March 1997, 1330 . 1332 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1333 Resource Identifier (URI): Generic Syntax", STD 66, 1334 RFC 3986, DOI 10.17487/RFC3986, January 2005, 1335 . 1337 [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax 1338 Specifications: ABNF", STD 68, RFC 5234, 1339 DOI 10.17487/RFC5234, January 2008, 1340 . 1342 [RFC6570] Gregorio, J., Fielding, R., Hadley, M., Nottingham, M., 1343 and D. Orchard, "URI Template", RFC 6570, 1344 DOI 10.17487/RFC6570, March 2012, 1345 . 1347 [RFC6690] Shelby, Z., "Constrained RESTful Environments (CoRE) Link 1348 Format", RFC 6690, DOI 10.17487/RFC6690, August 2012, 1349 . 1351 [RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 1352 Protocol (HTTP/1.1): Message Syntax and Routing", 1353 RFC 7230, DOI 10.17487/RFC7230, June 2014, 1354 . 1356 [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 1357 Protocol (HTTP/1.1): Semantics and Content", RFC 7231, 1358 DOI 10.17487/RFC7231, June 2014, 1359 . 1361 [RFC7232] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 1362 Protocol (HTTP/1.1): Conditional Requests", RFC 7232, 1363 DOI 10.17487/RFC7232, June 2014, 1364 . 1366 [RFC7235] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 1367 Protocol (HTTP/1.1): Authentication", RFC 7235, 1368 DOI 10.17487/RFC7235, June 2014, 1369 . 1371 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 1372 Application Protocol (CoAP)", RFC 7252, 1373 DOI 10.17487/RFC7252, June 2014, 1374 . 1376 [RFC7641] Hartke, K., "Observing Resources in the Constrained 1377 Application Protocol (CoAP)", RFC 7641, 1378 DOI 10.17487/RFC7641, September 2015, 1379 . 1381 12.2. Informative References 1383 [I-D.ietf-core-links-json] 1384 Li, K., Rahman, A., and C. Bormann, "Representing CoRE 1385 Formats in JSON and CBOR", draft-ietf-core-links-json-05 1386 (work in progress), April 2016. 1388 [I-D.ietf-core-resource-directory] 1389 Shelby, Z., Koster, M., Bormann, C., and P. Stok, "CoRE 1390 Resource Directory", draft-ietf-core-resource-directory-07 1391 (work in progress), March 2016. 1393 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 1394 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 1395 Transfer Protocol -- HTTP/1.1", RFC 2616, 1396 DOI 10.17487/RFC2616, June 1999, 1397 . 1399 [RFC3040] Cooper, I., Melve, I., and G. Tomlinson, "Internet Web 1400 Replication and Caching Taxonomy", RFC 3040, 1401 DOI 10.17487/RFC3040, January 2001, 1402 . 1404 [RFC4732] Handley, M., Ed., Rescorla, E., Ed., and IAB, "Internet 1405 Denial-of-Service Considerations", RFC 4732, 1406 DOI 10.17487/RFC4732, December 2006, 1407 . 1409 [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object 1410 Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, 1411 October 2013, . 1413 [RFC7390] Rahman, A., Ed. and E. Dijk, Ed., "Group Communication for 1414 the Constrained Application Protocol (CoAP)", RFC 7390, 1415 DOI 10.17487/RFC7390, October 2014, 1416 . 1418 Appendix A. Change Log 1420 [Note to RFC Editor: Please remove this section before publication.] 1422 Changes from ietf-09 to ietf-10: 1424 o Addressed Ticket #401 - Clarified that draft covers not only 1425 Reverse HC Proxy but that many parts also apply to Forward and 1426 Interception Proxies. 1428 o Clarified that draft concentrates on the HTTP-to-CoAP mapping 1429 direction (i.e. the HC proxy is a HTTP server and a CoAP client). 1431 o Clarified the "null mapping" case where no CoAP URI information is 1432 embedded in the HTTP request URI. 1434 o Moved multicast related security text to the "Security 1435 Considerations" to consolidate all security information in one 1436 location. 1438 o Removed references to "placement" of proxy (e.g. server-side vs 1439 client-side) as is confusing and provides little added value. 1441 o Fixed version numbers on references that were corrupted in last 1442 revision due to outdated xml2rfc conversion tool local cache. 1444 o Various editorial improvements. 1446 Changes from ietf-08 to ietf-09: 1448 o Clean up requirements language as per Klaus' comment. 1450 Changes from ietf-07 to ietf-08: 1452 o Addressed WGLC review comments from Klaus Hartke as per the 1453 correspondence of March 9, 2016 on the CORE WG mailing list. 1455 Changes from ietf-06 to ietf-07: 1457 o Addressed Ticket #384 - Section 5.4.1 describes briefly 1458 (informative) how to discover CoAP resources from an HTTP client. 1460 o Addressed Ticket #378 - For HTTP media type to CoAP content format 1461 mapping and vice versa: a new draft (TBD) may be proposed in CoRE 1462 which describes an approach for automatic updating of the media 1463 type mapping. This was noted in Section 6.1 but is otherwise 1464 outside the scope of this draft. 1466 o Addressed Ticket #377 - Added IANA section that defines a new HTTP 1467 media type "application/coap-payload" and created new Section 6.2 1468 on how to use it. 1470 o Addressed Ticket #376 - Updated Table 2 (and corresponding note 7) 1471 to indicate that a CoAP 4.05 (Method Not Allowed) Response Code 1472 should be mapped to a HTTP 400 (Bad Request). 1474 o Added note to comply to ABNF when translating CoAP diagnostic 1475 payload to reason-phrase in Section 6.5.3. 1477 Changes from ietf-05 to ietf-06: 1479 o Fully restructured the draft, bringing introductory text more to 1480 the front and allocating main sections to each of the key topics; 1481 addressing Ticket #379; 1483 o Addressed Ticket #382, fix of enhanced form URI template 1484 definition of q in Section 5.3.2; 1486 o Addressed Ticket #381, found a mapping 4.01 to 401 Unauthorized in 1487 Section 7; 1489 o Addressed Ticket #380 (Add IANA registration for "core.hc" 1490 Resource Type) in Section 9; 1492 o Addressed Ticket #376 (CoAP 4.05 response can't be translated to 1493 HTTP 405 by HC proxy) in Section 7 by use of empty 'Allow' header; 1495 o Removed details on the pros and cons of HC proxy placement 1496 options; 1498 o Addressed review comments of Carsten Bormann; 1500 o Clarified failure in mapping of HTTP Accept headers (Section 6.3); 1502 o Clarified detection of CoAP servers not supporting blockwise 1503 (Section 8.3); 1505 o Changed CoAP request timeout min value to MAX_RTT + 1506 MAX_SERVER_RESPONSE_DELAY (Section 8.6); 1508 o Added security section item (Section 10.3) related to use of CoAP 1509 blockwise transfers; 1511 o Many editorial improvements. 1513 Changes from ietf-04 to ietf-05: 1515 o Addressed Ticket #366 (Mapping of CoRE Link Format payloads to be 1516 valid in HTTP Domain?) in Section 6.3.3.2 (Content Transcoding - 1517 CORE Link Format); 1519 o Addressed Ticket #375 (Add requirement on mapping of CoAP 1520 diagnostic payload) in Section 6.3.3.3 (Content Transcoding - 1521 Diagnostic Messages); 1523 o Addressed comment from Yusuke (http://www.ietf.org/mail- 1524 archive/web/core/current/msg05491.html) in Section 6.3.3.1 1525 (Content Transcoding - General); 1527 o Various editorial improvements. 1529 Changes from ietf-03 to ietf-04: 1531 o Expanded use case descriptions in Section 4; 1533 o Fixed/enhanced discovery examples in Section 5.4.1; 1535 o Addressed Ticket #365 (Add text on media type conversion by HTTP- 1536 CoAP proxy) in new Section 6.3.1 (Generalized media type mapping) 1537 and new Section 6.3.2 (Content translation); 1539 o Updated HTTPBis WG draft references to recently published RFC 1540 numbers. 1542 o Various editorial improvements. 1544 Changes from ietf-02 to ietf-03: 1546 o Closed Ticket #351 "Add security implications of proposed default 1547 HTTP-CoAP URI mapping"; 1549 o Closed Ticket #363 "Remove CoAP scheme in default HTTP-CoAP URI 1550 mapping"; 1552 o Closed Ticket #364 "Add discovery of HTTP-CoAP mapping 1553 resource(s)". 1555 Changes from ietf-01 to ietf-02: 1557 o Selection of single default URI mapping proposal as proposed to WG 1558 mailing list 2013-10-09. 1560 Changes from ietf-00 to ietf-01: 1562 o Added URI mapping proposals to Section 4 as per the Email 1563 proposals to WG mailing list from Esko. 1565 Authors' Addresses 1567 Angelo P. Castellani 1568 University of Padova 1569 Via Gradenigo 6/B 1570 Padova 35131 1571 Italy 1573 Email: angelo@castellani.net 1575 Salvatore Loreto 1576 Ericsson 1577 Hirsalantie 11 1578 Jorvas 02420 1579 Finland 1581 Email: salvatore.loreto@ericsson.com 1583 Akbar Rahman 1584 InterDigital Communications, LLC 1585 1000 Sherbrooke Street West 1586 Montreal H3A 3G4 1587 Canada 1589 Phone: +1 514 585 0761 1590 Email: Akbar.Rahman@InterDigital.com 1592 Thomas Fossati 1593 Alcatel-Lucent 1594 3 Ely Road 1595 Milton, Cambridge CB24 6DD 1596 UK 1598 Email: thomas.fossati@alcatel-lucent.com 1599 Esko Dijk 1600 Philips Research 1601 High Tech Campus 34 1602 Eindhoven 5656 AE 1603 The Netherlands 1605 Email: esko.dijk@philips.com