idnits 2.17.1 draft-toutain-lpwan-coap-static-context-hc-00.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 : ---------------------------------------------------------------------------- ** The document seems to lack a Security Considerations section. ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) ** There are 80 instances of too long lines in the document, the longest one being 13 characters in excess of 72. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 443 has weird spacing: '... | Tk mappi...' -- The document date (October 28, 2016) is 2729 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- == Unused Reference: 'RFC1332' is defined on line 477, but no explicit reference was found in the text == Unused Reference: 'RFC3095' is defined on line 481, but no explicit reference was found in the text == Unused Reference: 'RFC4944' is defined on line 489, but no explicit reference was found in the text == Unused Reference: 'RFC4997' is defined on line 494, but no explicit reference was found in the text == Unused Reference: 'RFC5225' is defined on line 499, but no explicit reference was found in the text == Unused Reference: 'RFC6282' is defined on line 504, but no explicit reference was found in the text Summary: 3 errors (**), 0 flaws (~~), 8 warnings (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group A. Minaburo 3 Internet-Draft Acklio 4 Intended status: Informational L. Toutain 5 Expires: May 1, 2017 Institut MINES TELECOM ; TELECOM Bretagne 6 October 28, 2016 8 6LPWA Static Context Header Compression (SCHC) for CoAP 9 draft-toutain-lpwan-coap-static-context-hc-00 11 Abstract 13 This draft discusses the way SCHC can be applied to CoAP headers and 14 extend the number of functions (CDF) to optimize compression. 16 Status of This Memo 18 This Internet-Draft is submitted in full conformance with the 19 provisions of BCP 78 and BCP 79. 21 Internet-Drafts are working documents of the Internet Engineering 22 Task Force (IETF). Note that other groups may also distribute 23 working documents as Internet-Drafts. The list of current Internet- 24 Drafts is at http://datatracker.ietf.org/drafts/current/. 26 Internet-Drafts are draft documents valid for a maximum of six months 27 and may be updated, replaced, or obsoleted by other documents at any 28 time. It is inappropriate to use Internet-Drafts as reference 29 material or to cite them other than as "work in progress." 31 This Internet-Draft will expire on May 1, 2017. 33 Copyright Notice 35 Copyright (c) 2016 IETF Trust and the persons identified as the 36 document authors. All rights reserved. 38 This document is subject to BCP 78 and the IETF Trust's Legal 39 Provisions Relating to IETF Documents 40 (http://trustee.ietf.org/license-info) in effect on the date of 41 publication of this document. Please review these documents 42 carefully, as they describe your rights and restrictions with respect 43 to this document. Code Components extracted from this document must 44 include Simplified BSD License text as described in Section 4.e of 45 the Trust Legal Provisions and are provided without warranty as 46 described in the Simplified BSD License. 48 1. Introduction 50 [I-D.toutain-lpwan-ipv6-static-context-hc] defines a compression 51 technique for LPWA network based on static context. This context is 52 said static since the element values composing the context are not 53 learned during packet exchanges but previously installed. The 54 context is known by both ends. A context is composed of a set of 55 rules (referenced by rule ids). A rule describes the header fields 56 with some associated Target Values (TV). A Matching Operator (MO) is 57 associated to each field. The rule is selected if all the MO matches 58 . A Compression Decompression Function is associated to each field to 59 define the link between the compressed and decompressed value for a 60 specific field. 62 This draft discusses the way SCHC can be applied to CoAP headers and 63 extend the number of functions (CDF) to optimize compression. 65 2. Compressing CoAP 67 CoAP [RFC7252] is an implementation of a the REST architecture for 68 contrained devices. Gateway between CoAP and HTTP can be easily 69 build since both protocol uses the same address space (URL), caching 70 mechanisms and methods. 72 Nevertheless, if limited, the size of a CoAP header may be 73 incompatible with LPWAN constraints and some compression may be 74 needed to reduce the header size. CoAP compression is not 75 straightforward. Some differences between IPv6/UDP and CoAP can be 76 enlighten. CoAP differs from IPv6 and UDP protocols: 78 o IPv6 and UDP are symmetrical protocols. The same fields are found 79 in the request and in the answer, only location in the header may 80 change (e.g. source and destination fields). A CoAP request is 81 different from an answer. For instance, the URI-path option is 82 mandatory in the request and may not be found in the response. 84 o CoAP also obeys to the client/server paradigm and the compression 85 rate can be different if the request is issued from a LPWAN node 86 or from an external device. For instance in the former case the 87 token size may be set to one byte. In the latter case, the token 88 size cannot be constraint and be up to 15 byte long. 90 o In IPv6, main header and UDP fields have a fixed size. In CoAP, 91 Token size may vary from 0 to 15 bytes, length is given by a field 92 in the header. More systematically, the options are described 93 using the Type-Length-Value principle. Evenmore regarding the 94 option size value, the coding will be different. 96 o options type in CoAP are not defined with the same value. The 97 Delta TLV coding makes that the type is not independant of 98 previous option and may vary regarding the options contained in 99 the header. 101 2.1. CoAP usages 103 A LPWAN node can either be a client or a server and sometimes both. 104 In the client mode, the LPWAN node sends request to a server and 105 expected answer or acknowledgements. Acknowledgements can be at 2 106 different levels: 108 o transport level, a CON message is acknowledged by an ACK message. 109 NON confirmable messages are not acknowledged. 111 o REST level, a REST request is acknowledged by an "error" code. 112 [RFC7967] defines an option to limit the number of 113 acknowledgements. 115 Note that acknowledgement can be optimized and a REST level 116 acknowledgement can be used as a transport level acknowledgement. 118 2.2. CoAP protocol analysis 120 CoAP defines the following fields: 122 o version (2 bits): this field can be elided during a compresssion 124 o type (2 bits): defines the type of the transport messages, 4 125 values are defined. Regarding the type of exchange, if only NON 126 messages are sent or CON/ACK messages, this field can be reduced 127 to 0 or 1 bit. 129 o token length (4 bytes). The standard allows up to 15 bytes for a 130 token length. If a fix token size is chosen, then this field can 131 be elided. If some variation in length are needed then 1 or 2 132 bits could be enough for most of LPWAN applications. 134 o code (8 bits). This field codes the request and the response 135 values. CoAP represents in a more compact way, coding used in 136 HTTP, but the coding is not optimal. 138 o message id (16 bits). This value is used to acknowledge CON 139 frames. The size of this field is computed to allow the 140 anticipation (how many frames can be sent without 141 acknowledgement). When a value is used, [RFC7252] defines the 142 time before it can be reused without ambiguities. This size may 143 be too large for a LPWAN node sending or receiving few messages a 144 day. 146 o Token (0 to 15 bytes). Token identifies active flows. Regarding 147 the usage (stability of in time and limited number), a short token 148 (1 Byte) can be enough. 150 o options are coded through delta-TLV. The delta-T depends of 151 previous values, length is encoded inside the option. [RFC7252] 152 distinguishes repeatable options that can appear several time in 153 the header. Among them we can distinguish: 155 * list options which appear several time in the header but are 156 exclusive such as the Accept option. 158 * cumulative options which appear several time in the header but 159 are part of a more generic value such as Uri-Path and Uri- 160 Query. 162 For a given flow some value options are stable through time. 163 Observe, ETag, If-Match, If-None-Match and Size varies in each 164 message. Options can be stored in a SCHC context and cumulative 165 options can be stored globally. 167 The CoAP protocol must not be altered by the compression/ 168 decompression phase, but if no semantic is attributed to a value, it 169 may be changed during this phase. For instance the compression phase 170 may reduce the size of a token but must maintain its unicity. The 171 decompressor will not be able to restore the original value but 172 behavior will remain the same. If no special semantic is assigned to 173 the token, this will be transparent. If a special semantic is 174 assigned to the token, its compression may not be possible. 176 This implies that the compressor/decompressor must be aware of the 177 protocol state machine and do not processes request and response the 178 same way. 180 A conservative compression leaves the field value unchanged. Non 181 conservative compression can be used when a CoAP implementation has 182 not been defined to work specifically with LPWAN network and uses 183 large values for fields. 185 2.2.1. CoAP Compression Decompression Function 187 To compress more efficiently CoAP message, several Compression/ 188 Decompression Function (CDF) must be defined. 190 2.2.1.1. Static-mapping 192 The goal of static-mapping is to reduce the size of a field by 193 allocating shorter value. The mapping is known by both ends and 194 stored in a table in both end context. The Static-mapping is 195 conservative. 197 Static-mapping may be applied to several fields. For instance the 198 type field may be reduced from 2 bits to 1 bit if only CON/ACK type 199 is used, but the main benefit is compressing the code field. 201 The CoAP code field defines a tricky way to ensure compatibility with 202 HTTP values. Nevertheless only 21 values are defined by [RFC7252] 203 compared to the 255 possible values. So it could efficiently be 204 coded on 5 bits. To allow flexibility and evolution if new codes are 205 introduced, a static mapping table is associated to each instance of 206 this function. 208 Figure 1 gives a possible mapping, it can be changed to add new codes 209 or reduced if some values are never used by both ends. 211 +------+------------------------------+-----------+ 212 | Code | Description | Mapping | 213 +------+------------------------------+-----------+ 214 | 0.00 | | 0x00 | 215 | 0.01 | GET | 0x01 | 216 | 0.02 | POST | 0x02 | 217 | 0.03 | PUT | 0x03 | 218 | 0.04 | DELETE | 0x04 | 219 | 0.05 | FETCH | 0x05 | 220 | 0.06 | PATCH | 0x06 | 221 | 0.07 | iPATCH | 0x07 | 222 | 2.01 | Created | 0x08 | 223 | 2.02 | Deleted | 0x09 | 224 | 2.03 | Valid | 0x0A | 225 | 2.04 | Changed | 0x0B | 226 | 2.05 | Content | 0x0C | 227 | 4.00 | Bad Request | 0x0D | 228 | 4.01 | Unauthorized | 0x0E | 229 | 4.02 | Bad Option | 0x0F | 230 | 4.03 | Forbidden | 0x10 | 231 | 4.04 | Not Found | 0x11 | 232 | 4.05 | Method Not Allowed | 0x12 | 233 | 4.06 | Not Acceptable | 0x13 | 234 | 4.12 | Precondition Failed | 0x14 | 235 | 4.13 | Request Entity Too Large | 0x15 | 236 | 4.15 | Unsupported Content-Format | 0x16 | 237 | 5.00 | Internal Server Error | 0x17 | 238 | 5.01 | Not Implemented | 0x18 | 239 | 5.02 | Bad Gateway | 0x19 | 240 | 5.03 | Service Unavailable | 0x1A | 241 | 5.04 | Gateway Timeout | 0x1B | 242 | 5.05 | Proxying Not Supported | 0x1C | 243 +------+------------------------------+-----------+ 245 Figure 1: CoAP code mapping 247 This CDF can also be applied to path to send a reference instead of 248 the path value. 250 2.2.1.2. Remapping 252 With dynamic mapping, the mapping is done dynamically, which means 253 that the other end has no way to the learn the original value. This 254 function is not conservative. The mapping context must be stored in 255 a reliable way on the compressor, if lost the session with LPWAN node 256 will be lost, which can generate a traffic increase on the LPWA 257 network. 259 This function converts a large number to a smaller one and maintain 260 bi-directional mapping. If the field has no semantic, such as a CoAP 261 token or a message ID, this will reduce the size of the information 262 sent on the link. This mapping only applies for request compression, 263 answers must keep the value original value. 265 For instance a compression receives a CoAP request with a large 266 token. The compressor reduces the token size by allocating a unused 267 value in a smaller space. When the response come back, the 268 compressor exchange the smallest token with the original one. 270 This mean that the compressor must be aware of the CoAP state 271 machine, to identify a request and its associated response, but also 272 determine when a token value can be reused. 274 2.2.1.3. Reduce-entropy 276 Reduce-entropy is a non-conservative function. the goal is to 277 minimize the increase in a field value. It may be used for the 278 observe option, all increase in the original sequence number will 279 lead to an increase of 1 in the compressed value. 281 For instance a LPWAN node is a CoAP server and receives Observe 282 responses coming from an outside client. The client uses a clock to 283 generate Observe sequence number. If that value has non particular 284 meaning for the CoAP server, increase of 1 will not change the 285 protocol behavior. Reordering works the same way as for original 286 Observe. 288 2.2.2. CoAP mandatory header 290 Figure 2 proposes some function assignments to the CoAP header 291 fields. 293 /--------------------+---------------------+----------------------------------------\ 294 | Field |Function | Behavior | 295 +--------------------+---------------------+----------------------------------------+ 296 |version |not-sent |version is always the same | 297 +--------------------+---------------------+----------------------------------------+ 298 |type |value-sent |if all the types are used | 299 | |static-mapping |to reduce to one bit if 2 type are used | 300 | |not-sent |if only one type is used (e.g. NON) | 301 +--------------------+---------------------+----------------------------------------+ 302 |token length |not-sent |no tokens or fixed size | 303 | |compute-token-length |if token size is reduced | 304 | |value-sent |token is sent integrally | 305 +--------------------+---------------------+----------------------------------------+ 306 |code |value-sent |no modification | 307 | |static-mapping |code size reduction | 308 +--------------------+---------------------+----------------------------------------+ 309 |message id |value-sent |no modification | 310 |token |remapping |reduces message id size | 311 +====================+=====================+========================================+ 312 |Content-Format |value-sent |no modification | 313 |Accept |not-sent |defined in the rule | 314 |Max-Age |static-mapping |map the possible value | 315 +--------------------+---------------------+----------------------------------------+ 316 |Path: |value-sent |no modification | 317 |Uri-Host+Uri-Port+ |not-sent |defined in the rule | 318 |Uri-Path*+Uri-Query*|static-mapping |a value to define a path | 319 | | | | 320 |Proxy-Uri | |Note: only the full path is stored in | 321 |Proxy-Scheme | |context | 322 +--------------------+---------------------+----------------------------------------+ 323 |ETag |value-sent |Always sent | 324 |Location-Path | | | 325 |Location-Query | | | 326 |If-Match | | | 327 |If-None-Match | | | 328 |Size1 | | | 329 +--------------------+---------------------+----------------------------------------+ 331 Figure 2: SCHC functions' example assignment for CoAP 333 2.2.3. Examples of CoAP header compression 335 2.2.3.1. Mandatory header with CON message 337 In this first scenario, the LPWAN compressor receives from outside 338 client a POST message, which is immediately acknowledged by the ES. 339 For this simple scenario, the rules are described Figure 3 340 rule id 1 341 +-------------+-------+-----+---------------+----------------+ 342 | Field |TV |MO |CDF | Sent | 343 +=============+=======+=====+===============+================+ 344 |CoAP version | 01 |= |not-sent | | 345 |CoAP Type | | |value-sent |TT | 346 |CoAP TKL | 0000 |= |not-sent | | 347 |CoAP Code | | |static-map | CC CCC | 348 |CoAP MID | | |dynamic-map | M-ID | 349 |CoAP Path |/path | |not-sent | | 350 +-------------+-------+-----+---------------+----------------+ 352 Figure 3: CoAP Context to compress header without token 354 Figure 3 gives a simple compression rule for CoAP headers without 355 tokens. 357 The version fields and Token Length are elided. Code has shrunk to 5 358 bits using the static-mapping function. Message-ID has shrunk to 9 359 bits to preserve alignment on byte boundary. 361 Figure 4 shows the time diagram of the exchange. A LPWAN Application 362 Server sends a CON message. Compression reduces the header sending 363 only the Type, a mapped code and the Message ID is change to a value 364 on 9 bits. The receiver decompress the header. The message ID value 365 is changed. 367 The CON message is a request, therefore the LC process to a dynamic 368 mapping. When the ES receives the ACK message, this will not 369 initiate locally a the message ID mapping since it is a response. 370 The LC receives the ACK and uncompress it to restore the original 371 value. Dynamic Mapping context lifetime follows the same rules as 372 message ID duration. 374 End System LPWA LC 375 | | 376 | rule id=1 |<---------------------- 377 |<---------------------------| +-+-+--+----+--------+ 378 <-------------------- | TTCC CCCM MMMM MMMM | |1|0| 4|0.01| 0x1234 | 379 +-+-+--+----+--------+ | 0000 0010 0000 0001 | | 0xb4 p a t | 380 |1|0| 1|0.01| 0x0001 | | | | h | 381 | 0xb4 p a t | | | +------+ 382 | h | | | dynamic mapping 383 +------+ | | +--------+--------+ 384 | | |0x1234 | 0x01 | 385 | | +--------+--------+ 386 ----------------------->| rule id=1 | 387 +-+-+--+----+--------+ |--------------------------->| 388 |1|2| 0|2.05| 0x0001 | | TTCC CCCM MMMM MMMM |------------------------> 389 +-+-+--+----+--------+ | 1000 0000 0000 0001 | +-+-+--+----+--------+ 390 | | |1|2| 0|2.05| 0x1234 | 391 v v +-+-+--+----+--------+ 393 Figure 4: Compression with global addresses 395 Note that the compressor and decompressor must understand the CoAP 396 protocol: 398 o The LC compressor detects a new transport request and allocate a 399 new dynamic mapping value. 401 o When receiving a response the ES compressor ES detects that this 402 is a response (type=2) therefore the message ID value in 403 unchanged. 405 o The upstream compressor detects that is an REST answer (code 2.05) 406 therefore the path option is not inserted in the uncompress header 408 2.2.3.2. Exchange with token 410 The following scenario introduces tokens. The LC manages two 411 remapping contexts. One for Message ID and the other for token. ES 412 manages one context for Message ID. Mapping is trigged by the 413 reception of CON messages to compress or CoAP requests to compress. 414 Note that the compressed message ID size has been reduced to 7 bits, 415 compared to the previous example, to maintain byte boundary 416 alignment. 418 +----------------+------------------------+----------------+-----------------+ 419 | Field | Function | Ctxt Value | Sent compressed | 420 +----------------+------------------------+----------------+-----------------+ 421 |CoAP version | not-sent | | | 422 |CoAP Type | value-sent | |TT | 423 |CoAP TKL | compute-token-length | | LL | 424 |CoAP Code | map-code | mapping table | CCCC C | 425 |CoAP MID | remapping | 7 bits | M-ID | 426 |CoAP Token | remapping | 8 bits | token| 427 |CoAP Path | not-sent |/data/humidity | 428 +----------------+------------------------+----------------+-----------------+ 430 Figure 5: CoAP Context to compress header with token 431 End System LPWA LC 432 | | 433 | SHIM=1 |<---------------------- 434 |<---------------------------| +-+-+--+----+--------+ 435 <-------------------- | TT LL CCCC C MMMMMMM | |1|0| 4|0.01| 0x1234 | 436 +-+-+--+----+--------+ | 00 01 0000 1 0000001 | | DEADBEEF | 437 |1|0| 1|0.01| 0x0001 | | 0000 0001 | | 0xb4 d a t | 438 | 01 0xb4 d a | | Token | | a 0x08 h u | 439 | t a 0x08 h | | | | m i d i | 440 | u m i d | | | | t y | 441 | i t y | | | +------------+ 442 +-----------------+ | | Mid mapping: 1234 -> 1 443 | | Tk mapping: DEADBEEF -> 1 444 ----------------------->| SHIM=1 | 445 +-+-+--+----+--------+ |--------------------------->| 446 |1|2| 0|0.00| 0x0001 | | TT LL CCCC C MMMMMMMM |------------------------> 447 +-+-+--+----+--------+ | 10 01 0000 0 00000001 | +-+-+--+----+--------+ 448 | | |1|2| 0|0.00| 0x1234 | 449 | | +-+-+--+----+--------+ 450 ----------------------->| | 451 +-+-+--+----+--------+ |--------------------------->| 452 |1|0| 0|2.05| 0xCAFE | | TT LL CCCC C MMMMMMMM |------------------------> 453 | 0x01 2 5 | | 00 01 1100 0 00000002 | +-+-+--+----+--------+ 454 +--------------------+ | 0000 0001 | |1|0| 4|2.05| 0x0001 | 455 | 2 5 | | DEADBEEF | 456 | | | 2 5 | 457 Mid mapping: CAFE -> 1 | | +-----------+ 458 | | 459 | |<------------------------ 460 |<---------------------------| +-+-+--+----+--------+ 461 <-----------------------| TT LL CCCC C MMMMMMMM | |1|2| 0|0.00|0x0001 | 462 +-+-+--+----+--------+ | 10 00 0000 0 00000002 | +-+-+--+----+--------+ 463 |1|2| 0|0.00| 0xCAFE | | | 464 +-+-+--+----+--------+ | | 465 v v 467 Figure 6: Compression with token 469 3. Normative References 471 [I-D.toutain-lpwan-ipv6-static-context-hc] 472 Minaburo, A. and L. Toutain, "LPWAN Static Context Header 473 Compression (SCHC) for IPv6 and UDP", draft-toutain-lpwan- 474 ipv6-static-context-hc-00 (work in progress), September 475 2016. 477 [RFC1332] McGregor, G., "The PPP Internet Protocol Control Protocol 478 (IPCP)", RFC 1332, DOI 10.17487/RFC1332, May 1992, 479 . 481 [RFC3095] Bormann, C., Burmeister, C., Degermark, M., Fukushima, H., 482 Hannu, H., Jonsson, L-E., Hakenberg, R., Koren, T., Le, 483 K., Liu, Z., Martensson, A., Miyazaki, A., Svanbro, K., 484 Wiebke, T., Yoshimura, T., and H. Zheng, "RObust Header 485 Compression (ROHC): Framework and four profiles: RTP, UDP, 486 ESP, and uncompressed", RFC 3095, DOI 10.17487/RFC3095, 487 July 2001, . 489 [RFC4944] Montenegro, G., Kushalnagar, N., Hui, J., and D. Culler, 490 "Transmission of IPv6 Packets over IEEE 802.15.4 491 Networks", RFC 4944, DOI 10.17487/RFC4944, September 2007, 492 . 494 [RFC4997] Finking, R. and G. Pelletier, "Formal Notation for RObust 495 Header Compression (ROHC-FN)", RFC 4997, 496 DOI 10.17487/RFC4997, July 2007, 497 . 499 [RFC5225] Pelletier, G. and K. Sandlund, "RObust Header Compression 500 Version 2 (ROHCv2): Profiles for RTP, UDP, IP, ESP and 501 UDP-Lite", RFC 5225, DOI 10.17487/RFC5225, April 2008, 502 . 504 [RFC6282] Hui, J., Ed. and P. Thubert, "Compression Format for IPv6 505 Datagrams over IEEE 802.15.4-Based Networks", RFC 6282, 506 DOI 10.17487/RFC6282, September 2011, 507 . 509 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 510 Application Protocol (CoAP)", RFC 7252, 511 DOI 10.17487/RFC7252, June 2014, 512 . 514 [RFC7967] Bhattacharyya, A., Bandyopadhyay, S., Pal, A., and T. 515 Bose, "Constrained Application Protocol (CoAP) Option for 516 No Server Response", RFC 7967, DOI 10.17487/RFC7967, 517 August 2016, . 519 Authors' Addresses 520 Ana Minaburo 521 Acklio 522 2bis rue de la Chataigneraie 523 35510 Cesson-Sevigne Cedex 524 France 526 Email: ana@ackl.io 528 Laurent Toutain 529 Institut MINES TELECOM ; TELECOM Bretagne 530 2 rue de la Chataigneraie 531 CS 17607 532 35576 Cesson-Sevigne Cedex 533 France 535 Email: Laurent.Toutain@telecom-bretagne.eu