idnits 2.17.1 draft-ietf-lpwan-coap-static-context-hc-02.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 2 instances of too long lines in the document, the longest one being 14 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 219 has weird spacing: '...mapping mappi...' == Line 240 has weird spacing: '... bi val...' == Line 332 has weird spacing: '...mapping mappi...' == Line 409 has weird spacing: '... up val...' == Line 415 has weird spacing: '...mapping mappi...' == (8 more instances...) -- The document date (September 06, 2017) is 2396 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- No issues found here. Summary: 3 errors (**), 0 flaws (~~), 7 warnings (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 lpwan Working Group A. Minaburo 3 Internet-Draft Acklio 4 Intended status: Informational L. Toutain 5 Expires: March 10, 2018 Institut MINES TELECOM ; IMT Atlantique 6 September 06, 2017 8 LPWAN Static Context Header Compression (SCHC) for CoAP 9 draft-ietf-lpwan-coap-static-context-hc-02 11 Abstract 13 This draft defines the way SCHC header compression can be applied to 14 CoAP headers. CoAP header structure differs from IPv6 and UDP 15 protocols since the CoAP Header is flexible header with a variable 16 number of options themself of a variable length. Another important 17 difference is the asymmetry in the header information used for 18 request and response messages. This draft takes into account the 19 fact that a thing can play the role of a CoAP client, a CoAP client 20 or both roles. 22 Status of This Memo 24 This Internet-Draft is submitted in full conformance with the 25 provisions of BCP 78 and BCP 79. 27 Internet-Drafts are working documents of the Internet Engineering 28 Task Force (IETF). Note that other groups may also distribute 29 working documents as Internet-Drafts. The list of current Internet- 30 Drafts is at https://datatracker.ietf.org/drafts/current/. 32 Internet-Drafts are draft documents valid for a maximum of six months 33 and may be updated, replaced, or obsoleted by other documents at any 34 time. It is inappropriate to use Internet-Drafts as reference 35 material or to cite them other than as "work in progress." 37 This Internet-Draft will expire on March 10, 2018. 39 Copyright Notice 41 Copyright (c) 2017 IETF Trust and the persons identified as the 42 document authors. All rights reserved. 44 This document is subject to BCP 78 and the IETF Trust's Legal 45 Provisions Relating to IETF Documents 46 (https://trustee.ietf.org/license-info) in effect on the date of 47 publication of this document. Please review these documents 48 carefully, as they describe your rights and restrictions with respect 49 to this document. Code Components extracted from this document must 50 include Simplified BSD License text as described in Section 4.e of 51 the Trust Legal Provisions and are provided without warranty as 52 described in the Simplified BSD License. 54 Table of Contents 56 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 57 2. CoAP Compressing . . . . . . . . . . . . . . . . . . . . . . 3 58 3. Compression of CoAP header fields . . . . . . . . . . . . . . 4 59 3.1. CoAP version field (2 bits) . . . . . . . . . . . . . . . 4 60 3.2. CoAP type field . . . . . . . . . . . . . . . . . . . . . 5 61 3.3. CoAP token length field . . . . . . . . . . . . . . . . . 5 62 3.4. CoAP code field . . . . . . . . . . . . . . . . . . . . . 6 63 3.5. CoAP Message ID field . . . . . . . . . . . . . . . . . . 8 64 3.6. CoAP Token field . . . . . . . . . . . . . . . . . . . . 9 65 4. CoAP options . . . . . . . . . . . . . . . . . . . . . . . . 9 66 4.1. CoAP option Content-format field. . . . . . . . . . . . . 9 67 4.2. CoAP option Accept field . . . . . . . . . . . . . . . . 10 68 4.3. CoAP option Max-Age field, CoAP option Uri-Host and Uri- 69 Port fields . . . . . . . . . . . . . . . . . . . . . . . 11 70 5. CoAP option Uri-Path and Uri-Query fields . . . . . . . . . . 11 71 5.1. CoAP option Proxy-URI and Proxy-Scheme fields . . . . . . 12 72 5.2. CoAP option ETag, If-Match, If-None-Match, Location-Path 73 and Location-Query fields . . . . . . . . . . . . . . . . 13 74 6. Other RFCs . . . . . . . . . . . . . . . . . . . . . . . . . 13 75 6.1. Block . . . . . . . . . . . . . . . . . . . . . . . . . . 13 76 6.2. Observe . . . . . . . . . . . . . . . . . . . . . . . . . 13 77 6.3. No-Response . . . . . . . . . . . . . . . . . . . . . . . 13 78 7. Protocol analysis . . . . . . . . . . . . . . . . . . . . . . 13 79 8. Examples of CoAP header compression . . . . . . . . . . . . . 14 80 8.1. Mandatory header with CON message . . . . . . . . . . . . 14 81 8.2. Complete exchange . . . . . . . . . . . . . . . . . . . . 16 82 9. Normative References . . . . . . . . . . . . . . . . . . . . 17 83 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 18 85 1. Introduction 87 CoAP [rfc7252] is an implementation of the REST architecture for 88 constrained devices. Gateway between CoAP and HTTP can be easily 89 built since both protocols uses the same address space (URL), caching 90 mechanisms and methods. 92 Nevertheless, if limited, the size of a CoAP header may be too large 93 for LPWAN constraints and some compression may be needed to reduce 94 the header size. 96 [I-D.toutain-lpwan-ipv6-static-context-hc] defines a header 97 compression mechanism for LPWAN network based on a static context. 98 The context is said static since the element values composing the 99 context are not learned during the packet exchanges but are 100 previously defined. The context(s) is(are) known by both ends before 101 transmission. 103 A context is composed of a set of rules (contexts) that are 104 referenced by Rule IDs (identifiers). A rule contains an ordered 105 list of the header fields containing a field ID (FID) and its 106 position when repeated, a direction indicator (DI) (upstream, 107 downstream and bidirectional) and some associated Target Values (TV) 108 which are expected in the message header. A Matching Operator (MO) 109 is associated to each header field description. The rule is selected 110 if all the MOs fit the TVs. In that case, a Compression 111 Decompression Function (CDF) associated to each field defines the 112 link between the compressed and decompressed value for each of the 113 header fields. 115 This document describes how the rules can be applied to CoAP flows. Compression of the 116 CoAP header may be done in conjunction with the above layers or independantly. 118 2. CoAP Compressing 120 CoAP differs from IPv6 and UDP protocols on the following 121 aspects: 123 o IPv6 and UDP are symmetrical protocols. The same fields are found 124 in the request and in the response, only location in the header 125 may vary (e.g. source and destination fields). A CoAP request is 126 different from an response. For example, the URI-path option is 127 mandatory in the request and is not found in the response, request 128 may contain an Accept option and the response a Content-format 129 option. 131 Even when a field is "symmetric" (i.e. found in both directions) 132 the values carried are different. For instance the Type field 133 will contain a CON value in the request and a ACK or RST value in 134 the response. Exploiting the asymmetry in compression will allow 135 to send no bit in the compressed request and a single bit in the 136 answer. Same behavior can be applied to the CoAP Code field (O.OX 137 code are present in the request and Y.ZZ in the answer). 139 o CoAP also obeys to the client/server paradigm and the compression 140 rate can be different if the request is issued from a LPWAN node 141 or from an non LPWAN device. For instance a Thing (ES) aware of 142 LPWAN constraints can generate a 1 byte token, but a regular CoAP 143 client will certainly send a larger token to the Thing. SCHC 144 compression will not modify the values to offer a better 145 compression rate. Nevertheless a proxy placed before the 146 compressor may change some field values to offer a better 147 compression rate and maintain the necessary context for 148 interoperability with existing CoAP implementations. 150 o In IPv6 and UDP header fields have a fixed size. In CoAP, Token 151 size may vary from 0 to 8 bytes, length is given by a field in the 152 header. More systematically, the CoAP options are described using 153 the Type-Length-Value. When applying SCHC header compression. 155 By sending compressed field information following the rule order, 156 SCHC offers a serialization/deserialization mechanism. Since a 157 field exists to indicate the token length there is no ambiguity. 158 For options, the rule indicates also the expected options found 159 the int CoAP header. Therefore only the length is needed to 160 recognise an option. The length will be send using the same CoAP 161 encoding (size less than 12 are directly sent, higher values uses 162 the escape mechanisms defined by [rfc7252]). Delta Type is 163 omitted, the value will be recovered by the decompressor. This 164 reduce the option length of 4, 12 or 20 bits regarding the 165 orignial size of the delta type encoding in the option. 167 o In CoAP headers a field can be duplicated several times, for 168 instances, elements of an URI (path or queries) or accepted 169 formats. The position defined in a rule, associated to a Field 170 ID, can be used to identify the proper element. 172 3. Compression of CoAP header fields 174 This section discusses of the compression of the different CoAP 175 header fields. These are just examples. The compression should take 176 into account the nature of the traffic and not only the field values. 177 Next chapter will define some compression rules for some common 178 exchanges. 180 3.1. CoAP version field (2 bits) 182 This field is bidirectional and can be elided during the SCHC 183 compression, since it always contains the same value. It appears 184 only in first position. 186 FID Pos DI TV MO CDF 187 ver 1 bi 1 equal not-sent 189 3.2. CoAP type field 191 This field can be managed bidirectionally or unidirectionally.Several 192 strategies can be applied to this field regarding the values used: 194 o If the ES is a client or a Server and non confirmable message are 195 used, the transmission of the Type field can be avoided: 197 * Pos is always 1, 199 * DI can either be "uplink" if the ES is a CoAP client or 200 "downlink" if the ES is a CoAP server, or "bidirectional" 202 * TV is set to the value, 204 * MO is set to "equal" 206 * CDF is set to "not-sent". 208 FID Pos DI TV MO CDF 209 type 1 bi NON equal not-sent 211 o If the ES is either a client or a Server and confirmable message 212 are used, the DI can be used to elide the type on the request and 213 compress it to 1 bit on the response. The example above shows the 214 rule for a ES acting as a client, directions need to be reversed 215 for a ES acting as a server. 217 FID Pos DI TV MO CDF 218 type 1 up CON equal not-sent 219 type 1 dw {0:ACK, 1:RST} match-mapping mapping-sent 221 o Otherwise if the ES is acting simultaneously as a client and a 222 server and the rule handle these two traffics, Type field must be 223 sent uncompressed. 225 FID Pos DI TV MO CDF 226 type 1 bi ignore send-value 228 3.3. CoAP token length field 230 This field is bi-directional. 232 Several strategies can be applied to this field regarding the values: 234 o no token or a wellknown length, the transmission can be avoided. 235 A special care must be taken, if CON messages are acknowledged 236 with an empty ACK message. In that case the token is not always 237 present. 239 FID Pos DI TV MO CDF 240 TKL 1 bi value ignore send-value 242 o If the length is changing from one message to an other, the Token 243 Length field must be sent. If the Token length can be limited, 244 then only the least significant bits have to be sent. The example 245 below allows values between 0 and 3. 247 FID Pos DI TV MO CDF 248 TKL 1 bi 0x0 MSB(2) LSB(2) 250 o otherwise the field value has to be sent. 252 FID Pos DI TV MO CDF 253 TKL 1 bi ignore value-sent 255 3.4. CoAP code field 257 This field is bidirectional, but compression can be enhanced using 258 DI. 260 The CoAP Code field defines a tricky way to ensure compatibility with 261 HTTP values. Nevertheless only 21 values are defined by [rfc7252] 262 compared to the 255 possible values. 264 +------+------------------------------+-----------+ 265 | Code | Description | Mapping | 266 +------+------------------------------+-----------+ 267 | 0.00 | | 0x00 | 268 | 0.01 | GET | 0x01 | 269 | 0.02 | POST | 0x02 | 270 | 0.03 | PUT | 0x03 | 271 | 0.04 | DELETE | 0x04 | 272 | 0.05 | FETCH | 0x05 | 273 | 0.06 | PATCH | 0x06 | 274 | 0.07 | iPATCH | 0x07 | 275 | 2.01 | Created | 0x08 | 276 | 2.02 | Deleted | 0x09 | 277 | 2.03 | Valid | 0x0A | 278 | 2.04 | Changed | 0x0B | 279 | 2.05 | Content | 0x0C | 280 | 4.00 | Bad Request | 0x0D | 281 | 4.01 | Unauthorized | 0x0E | 282 | 4.02 | Bad Option | 0x0F | 283 | 4.03 | Forbidden | 0x10 | 284 | 4.04 | Not Found | 0x11 | 285 | 4.05 | Method Not Allowed | 0x12 | 286 | 4.06 | Not Acceptable | 0x13 | 287 | 4.12 | Precondition Failed | 0x14 | 288 | 4.13 | Request Entity Too Large | 0x15 | 289 | 4.15 | Unsupported Content-Format | 0x16 | 290 | 5.00 | Internal Server Error | 0x17 | 291 | 5.01 | Not Implemented | 0x18 | 292 | 5.02 | Bad Gateway | 0x19 | 293 | 5.03 | Service Unavailable | 0x1A | 294 | 5.04 | Gateway Timeout | 0x1B | 295 | 5.05 | Proxying Not Supported | 0x1C | 296 +------+------------------------------+-----------+ 298 Figure 1: Example of CoAP code mapping 300 Figure 1 gives a possible mapping, it can be changed to add new codes 301 or reduced if some values are never used by both ends. It could 302 efficiently be coded on 5 bits. 304 Even if the number of code can be increase with other RFC, 305 implementations may use a limited number of values, which can help to 306 reduce the number of bits sent on the LPWAN. 308 The number of code may vary over time, some new codes may be 309 introduced or some applications use a limited number of values. 311 The client and the server do not use the same values. This asymmetry 312 can be exploited to reduce the size sent on the LPWAN. 314 The field can be treated differently in upstream than in downstream. 315 If the Thing is a client an entry can be set on the uplink message 316 with a code matching for 0.0X values and another for downlink values 317 for Y.ZZ codes. It is the opposite if the thing is a server. 319 If the ES always sends or receives requests with the same method, the 320 Code field can be elided. The entry below shows a rule for a client 321 sending only GET request. 323 FID Pos DI TV MO CDF 324 code 1 up GET equal not-sent 326 If the client may send different methods, a matching-list can be 327 applied. For table Figure 1, 3 bits are necessary, but it could be 328 less if fewer methods are used. Example below gives an example where 329 the ES is a server and receives only GET and POST requests. 331 FID Pos DI TV MO CDF 332 code 1 dw {0:0.01, 1:0.02}match-mapping mapping-sent 334 The same approach can be applied to responses. 336 3.5. CoAP Message ID field 338 This field is bidirectional. 340 Message ID is used for two purposes: 342 o To acknowledge a CON message with an ACK. 344 o To avoid duplicate messages. 346 In LPWAN, since a message can be received by several radio gateway, 347 some LPWAN technologies include a sequence number in L2 to avoid 348 duplicate frames. Therefore if the message does not need to be 349 acknowledged (NON or RST message), the Message ID field can be 350 avoided. 352 FID Pos DI TV MO CDF 353 Mid 1 bi ignore not-sent 355 The decompressor must generate a value. 357 [[Note; check id this field is not used by OSCOAP .]] 358 To optimize information sent on the LPWAN, shorter values may be used 359 during the exchange, but Message ID values generated a common CoAP 360 implementation will not take into account this limitation. Before 361 the compression, a proxy may be needed to reduce the size. 363 FID Pos DI TV MO CDF 364 Mid 1 bi 0x0000 MSB(12) LSB(4) 366 Otherwise if no compression is possible, the field has to be sent 368 FID Pos DI TV MO CDF 369 Mid 1 bi ignore value-sent 371 3.6. CoAP Token field 373 This field is bi-directional. 375 Token is used to identify transactions and varies from one 376 transaction to another. Therefore, it is usually necessary to send 377 the value of the token field on the LPWAN network. The optimization 378 will occur by using small values. 380 Common CoAP implementations may generate large tokens, even if 381 shorter tokens could be used regarding the LPWAN characteristics. A 382 proxy may be needed to reduce the size of the token before 383 compression. 385 The size of the compress token sent is known by a combination of the 386 Token Length field and the rule entry. For instance, with the entry 387 below: 389 FID Pos DI TV MO CDF 390 tkl 1 bi 2 equal not-sent 391 token 1 bi 0x00 MSB(12) LSB(4) 393 The uncompressed token is 2 bytes long, but the compressed size will 394 be 4 bits. 396 4. CoAP options 398 4.1. CoAP option Content-format field. 400 This field is unidirectional and must not be set to bidirectional in 401 a rule entry. It is used only by the server to inform the client 402 about of the payload type and is never found in client requests. 404 If single value is expected by the client, the TV contains that value 405 and MO is set to "equal" and the CDF is set to "not-sent". The 406 examples below describe the rules for an ES acting as a server. 408 FID Pos DI TV MO CDF 409 content 1 up value equal not-sent 411 If several possible value are expected by the client, a matching-list 412 can be used. 414 FID Pos DI TV MO CDF 415 content 1 up {0:50,1:41} match-mapping mapping-sent 417 Otherwise the value can be sent.The value-sent CDF in the compressor 418 do not send the option type and the decompressor reconstruct it 419 regarding the position in the rule. 421 FID Pos DI TV MO CDF 422 content 1 up ignore value-sent 424 4.2. CoAP option Accept field 426 This field is unidirectional and must not be set to bidirectional in 427 a rule entry. It is used only by the client to inform of the 428 possible payload type and is never found in server response. 430 The number of accept options is not limited and can vary regarding 431 the usage. To be selected a rule must contain the exact number about 432 accept options with their positions. Since the order in which the 433 Accept value are sent, the position order can be modified. The rule 434 below 436 FID Pos DI TV MO CDF 437 accept 1 up 41 egal not-sent 438 accept 2 up 50 egal not-sent 440 will be selected only if two accept options are in the CoAP header if 441 this order. 443 The rule below: 445 FID Pos DI TV MO CDF 446 accept 0 up 41 egal not-sent 447 accept 0 up 50 egal not-sent 449 will accept a-only CoAP messages with 2 accept options, but the order 450 will not influence the rule selection. The decompression will 451 reconstruct the header regarding the rule order. 453 Otherwise a matching-list can be applied to the different values, in 454 that case the order is important to recover the appropriate value and 455 the position must be clearly indicate. 457 FID Pos DI TV MO CDF 458 accept 1 up {0:50,1:41} match-mapping mapping-sent 459 accept 2 up {0:50,1:61} match-mapping mapping-sent 460 accept 3 up {0:61,1:71} match-mapping mapping-sent 462 Finally, the option can be explicitly sent. 464 FID Pos DI TV MO CDF 465 accept 1 up ignore value-sent 467 4.3. CoAP option Max-Age field, CoAP option Uri-Host and Uri-Port 468 fields 470 This field is unidirectional and must not be set to bidirectional in 471 a rule entry. It is used only by the server to inform of the caching 472 duration and is never found in client requests. 474 If the duration is known by both ends, value can be elided on the 475 LPWAN. 477 A matching list can be used if some wellknown values are defined. 479 Otherwise the option length and value can be sent on the LPWAN. 481 [[note: we can reduce (or create a new option) the unit to minute, 482 second is small for LPWAN ]] 484 5. CoAP option Uri-Path and Uri-Query fields 486 This fields are unidirectional and must not be set to bidirectional 487 in a rule entry. They are used only by the client to access to a 488 specific resource and are never found in server response. 490 The Matching Operator behavior has not changed, but the value must 491 take a position value, if the entry is repeated : 493 FID Pos DI TV MO CDF 494 URI-Path 1 up foo equal not-sent 495 URI-Path 2 up bar equal not-sent 497 Figure 2: Position entry. 499 For instance, the rule Figure 2 matches with /foo/bar, but not /bar/ 500 foo. 502 When the length is not clearly indicated in the rule, the value 503 length must be sent with the field data, which means for CoAP to send 504 directly the CoAP option with length and value. 506 For instance for a CoMi path /c/X6?k="eth0" the rule can be set to: 508 FID Pos DI TV MO CDF 509 URI-Path 1 up c equal not-sent 510 URI-Path 2 up ignore value-sent 511 URI-Query 1 up k= MSB (16) LSB 513 Figure 3: CoMi URI compression 515 Figure 3 shows the parsing and the compression of the URI. where c is 516 not sent. The second element is sent with the length (i.e. 0x2 X 6) 517 followed by the query option (i.e. 0x05 "eth0"). 519 A Mapping list can be used to reduce size of variable Paths or 520 Queries. In that case, to optimize the compression, several elements 521 can be regrouped into a single entry. Numbering of elements do not 522 change, MO comparison is set with the first element of the matching. 524 FID Pos DI TV MO CDF 525 URI-Path 1 up {0:"/c/c", equal not-sent 526 1:"/c/d" 527 URI-Path 3 up ignore value-sent 528 URI-Query 1 up k= MSB (16) LSB 530 Figure 4: complex path example 532 For instance, the following Path /foo/bar/variable/stable can leads 533 to the rule defined Figure 4. 535 5.1. CoAP option Proxy-URI and Proxy-Scheme fields 537 These fields are unidirectional and must not be set to bidirectional 538 in a rule entry. They are used only by the client to access to a 539 specific resource and are never found in server response. 541 If the field value must be sent, TV is not set, MO is set to "ignore" 542 and CDF is set to "value-sent. A mapping can also be used. 544 Otherwise the TV is set to the value, MO is set to "equal" and CDF is 545 set to "not-sent" 547 5.2. CoAP option ETag, If-Match, If-None-Match, Location-Path and 548 Location-Query fields 550 These fields are unidirectional. 552 These fields values cannot be stored in a rule entry. They must 553 always be sent with the request. 555 [[Can include OSCOAP Object security in that category ]] 557 6. Other RFCs 559 6.1. Block 561 Block option should be avoided in LPWAN. The minimum size of 16 562 bytes can be incompatible with some LPWAN technologies. 564 [[Note: do we recommand LPWAN fragmentation since the smallest value 565 of 16 is too big?]] 567 6.2. Observe 569 [rfc7641] defines the Observe option. The TV is not set, MO is set 570 to "ignore" and the CDF is set to "value-sent". SCHC does not limit 571 the maximum size for this option (3 bytes). To reduce the 572 transmission size either the Thing implementation should limit the 573 value increase or a proxy can be used limit the increase. 575 Since RST message may be sent to inform a server that the client do 576 not require Observe response, a rule must allow the transmission of 577 this message. 579 6.3. No-Response 581 [rfc7967] defines an No-Response option limiting the responses made 582 by a server to a request. If the value is not by both ends, then TV 583 is set to this value, MO is set to "equal" and CDF is set to "not- 584 sent". 586 Otherwise, if the value is changing over time, TV is not set, MO is 587 set to "ignore" and CDF to "value-sent". A matching list can also be 588 used to reduce the size. 590 7. Protocol analysis 591 8. Examples of CoAP header compression 593 8.1. Mandatory header with CON message 595 In this first scenario, the LPWAN compressor receives from outside 596 client a POST message, which is immediately acknowledged by the 597 Thing. For this simple scenario, the rules are described Figure 5. 599 rule id 1 600 +-------------+------+---------+-------------+-----+----------------+ 601 | Field |TV |MO |CDF |dir | Sent | 602 +=============+======+=========+=============+=====+================+ 603 |CoAP version | 01 |equal |not-sent |bi | | 604 |CoAP Type | |ignore |value-sent |bi |TT | 605 |CoAP TKL | 0 |equal |not-sent |bi | | 606 |CoAP Code | ML1 |match-map|matching-sent|bi | CC CCC | 607 |CoAP MID | 0000 |MSB(7 ) |LSB(9) |bi | M-ID | 608 |CoAP Uri-Path| path |equal 1 |not-sent |down | | 609 +-------------+------+---------+-------------+-----+----------------+ 611 Figure 5: CoAP Context to compress header without token 613 The version and Token Length fields are elided. Code has shrunk to 5 614 bits using the matching list (as the one given Figure 1: 0.01 is 615 value 0x01 and 2.05 is value 0x0c) Message-ID has shrunk to 9 bits to 616 preserve alignment on byte boundary. The most significant bit must 617 be set to 0 through a CoAP proxy. Uri-Path contains a single element 618 indicated in the matching operator. 620 Figure 6 shows the time diagram of the exchange. A LPWAN Application 621 Server sends a CON message. Compression reduces the header sending 622 only the Type, a mapped code and the least 9 significant bits of 623 Message ID. The receiver decompresses the header. . 625 The CON message is a request, therefore the LC process to a dynamic 626 mapping. When the ES receives the ACK message, this will not 627 initiate locally a message ID mapping since it is a response. The LC 628 receives the ACK and uncompressed it to restore the original value. 629 Dynamic Mapping context lifetime follows the same rules as message ID 630 duration. 632 End System LPWA LC 633 | | 634 | rule id=1 |<---------------------- 635 |<--------------------| +-+-+--+----+--------+ 636 <-------------------- | TTCC CCCM MMMM MMMM| |1|0| 4|0.01| 0x0034 | 637 +-+-+--+----+--------+ | 0000 0010 0011 0100| | 0xb4 p a t | 638 |1|0| 1|0.01| 0x0034 | | | | h | 639 | 0xb4 p a t | | | +------+ 640 | h | | | 641 +------+ | | 642 | | 643 | | 644 ----------------------->| rule id=1 | 645 +-+-+--+----+--------+ |-------------------->| 646 |1|2| 0|2.05| 0x0034 | | TTCC CCCM MMMM MMMM|------------------------> 647 +-+-+--+----+--------+ | 1001 1000 0011 0100| +-+-+--+----+--------+ 648 | | |1|2| 0|2.05| 0x0034 | 649 v v +-+-+--+----+--------+ 651 Figure 6: Compression with global addresses 653 The message can be further optimized by setting some fields 654 unidirectional, as described in Figure 7. Note that Type is no more 655 sent in the compressed format, Compressed Code size in not changed in 656 that example (8 values are needed to code all the requests and 21 to 657 code all the responses in the matching list Figure 1) 659 rule id 1 660 +-------------+------+---------+-------------+---+----------------+ 661 | Field |TV |MO |CDF |dir| Sent | 662 +=============+======+=========+=============+===+================+ 663 |CoAP version | 01 |equal |not-sent |bi | | 664 |CoAP Type | CON |equal |not-sent |dw | | 665 |CoAP Type | ACK |equal |not-sent |up | | 666 |CoAP TKL | 0 |equal |not-sent |bi | | 667 |CoAP Code | ML2 |match-map|mapping-sent |dw |CCCC C | 668 |CoAP Code | ML3 |match-map|mapping-sent |up |CCCC C | 669 |CoAP MID | 0000 |MSB(5) |LSB(11) |bi | M-ID | 670 |CoAP Uri-Path| path |equal 1 |not-sent |dw | | 671 +-------------+------+---------+-------------+---+----------------+ 673 ML1 = {CON : 0, ACK:1} ML2 = {POST:0, 2.04:1, 0.00:3} 675 Figure 7: CoAP Context to compress header without token 677 8.2. Complete exchange 679 In that example, the Thing is using CoMi and sends queries for 2 SID. 681 CON 682 MID=0x0012 | | 683 POST | | 684 Accept X | | 685 /c/k=AS |------------------------>| 686 | | 687 | | 688 |<------------------------| ACK MID=0x0012 689 | | 0.00 690 | | 691 | | 692 |<------------------------| CON 693 | | MID=0X0034 694 | | Content-Format X 695 ACK MID=0x0034 |------------------------>| 696 0.00 698 rule id 3 699 +-------------+------+---------+-------------+---+----------------+ 700 | Field |TV |MO |CDF |dir| Sent | 701 +=============+======+=========+=============+===+================+ 702 |CoAP version | 01 |equal |not-sent |bi | | 703 |CoAP Type | CON |equal |not-sent |up | | 704 |CoAP Type | ACK |equal |not-sent |dw | | 705 |CoAP TKL | 1 |equal |not-sent |bi | | 706 |CoAP Code | POST |equal |not-sent |up | | 707 |CoAP Code | 0.00 |equal |not-sent |dw | | 708 |CoAP MID | 0000 |MSB(8) |LSB |bi |MMMMMMMM | 709 |CoAP Token | |ignore |send-value |up |TTTTTTTT | 710 |CoAP Uri-Path| /c |equal 1 |not-sent |dw | | 711 |CoAP Uri-query ML4 |equal 1 |not-sent |dw |P | 712 |CoAP Content | X |equal |not-sent |up | | 713 +-------------+------+---------+-------------+---+----------------+ 715 rule id 4 716 +-------------+------+---------+-------------+---+----------------+ 717 | Field |TV |MO |CDF |dir| Sent | 718 +=============+======+=========+=============+===+================+ 719 |CoAP version | 01 |equal |not-sent |bi | | 720 |CoAP Type | CON |equal |not-sent |dw | | 721 |CoAP Type | ACK |equal |not-sent |up | | 722 |CoAP TKL | 1 |equal |not-sent |bi | | 723 |CoAP Code | 2.05 |equal |not-sent |dw | | 724 |CoAP Code | 0.00 |equal |not-sent |up | | 725 |CoAP MID | 0000 |MSB(8) |LSB |bi |MMMMMMMM | 726 |CoAP Token | |ignore |send-value |dw |TTTTTTTT | 727 |COAP Accept | X |equal |not-sent |dw | | 728 +-------------+------+---------+-------------+---+----------------+ 730 alternative rule: 732 rule id 4 733 +-------------+------+---------+-------------+---+----------------+ 734 | Field |TV |MO |CDF |dir| Sent | 735 +=============+======+=========+=============+===+================+ 736 |CoAP version | 01 |equal |not-sent |bi | | 737 |CoAP Type | ML1 |match-map|match-sent |bi |t | 738 |CoAP TKL | 1 |equal |not-sent |bi | | 739 |CoAP Code | ML2 |match-map|match-sent |up | cc | 740 |CoAP Code | ML3 |match-map|match-sent |dw | cc | 741 |CoAP MID | 0000 |MSB(8) |LSB |bi |MMMMMMMM | 742 |CoAP Token | |ignore |send-value |dw |TTTTTTTT | 743 |CoAP Uri-Path| /c |equal 1 |not-sent |dw | | 744 |CoAP Uri-query ML4 |equal 1 |not-sent |dw |P | 745 |CoAP Content | X |equal |not-sent |up | | 746 |COAP Accept | x |equal |not-sent |dw | | 747 +-------------+------+---------+-------------+---+----------------+ 749 ML1 {CON:0, ACK:1} ML2 {POST:0, 0.00: 1} ML3 {2.05:0, 0.00:1} 750 ML4 {NULL:0, k=AS:1, K=AZE:2} 752 9. Normative References 754 [I-D.toutain-lpwan-ipv6-static-context-hc] 755 Minaburo, A. and L. Toutain, "LPWAN Static Context Header 756 Compression (SCHC) for IPv6 and UDP", draft-toutain-lpwan- 757 ipv6-static-context-hc-00 (work in progress), September 758 2016. 760 [rfc7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 761 Application Protocol (CoAP)", RFC 7252, 762 DOI 10.17487/RFC7252, June 2014, 763 . 765 [rfc7641] Hartke, K., "Observing Resources in the Constrained 766 Application Protocol (CoAP)", RFC 7641, 767 DOI 10.17487/RFC7641, September 2015, 768 . 770 [rfc7967] Bhattacharyya, A., Bandyopadhyay, S., Pal, A., and T. 771 Bose, "Constrained Application Protocol (CoAP) Option for 772 No Server Response", RFC 7967, DOI 10.17487/RFC7967, 773 August 2016, . 775 Authors' Addresses 777 Ana Minaburo 778 Acklio 779 2bis rue de la Chataigneraie 780 35510 Cesson-Sevigne Cedex 781 France 783 Email: ana@ackl.io 785 Laurent Toutain 786 Institut MINES TELECOM ; IMT Atlantique 787 2 rue de la Chataigneraie 788 CS 17607 789 35576 Cesson-Sevigne Cedex 790 France 792 Email: Laurent.Toutain@imt-atlantique.fr