idnits 2.17.00 (12 Aug 2021) /tmp/idnits17490/draft-ietf-lpwan-coap-static-context-hc-03.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.) Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 186 has weird spacing: '... equal not-s...' == Line 225 has weird spacing: '... 1 bi ign...' == Line 252 has weird spacing: '... 1 bi ign...' == Line 352 has weird spacing: '... 1 bi ign...' == Line 368 has weird spacing: '... 1 bi ign...' == (12 more instances...) -- The document date (March 04, 2018) is 1539 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- == Missing Reference: 'ACK' is mentioned on line 218, but not defined == Missing Reference: 'RST' is mentioned on line 218, but not defined -- Looks like a reference, but probably isn't: '1' on line 459 -- Looks like a reference, but probably isn't: '2' on line 247 -- Looks like a reference, but probably isn't: '4' on line 390 -- Looks like a reference, but probably isn't: '8' on line 368 -- Looks like a reference, but probably isn't: '50' on line 458 -- Looks like a reference, but probably isn't: '41' on line 457 == Missing Reference: '0-16' is mentioned on line 421, but not defined -- Looks like a reference, but probably isn't: '61' on line 459 -- Looks like a reference, but probably isn't: '71' on line 459 Summary: 2 errors (**), 0 flaws (~~), 10 warnings (==), 9 comments (--). 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: September 5, 2018 Institut MINES TELECOM; IMT Atlantique 6 March 04, 2018 8 LPWAN Static Context Header Compression (SCHC) for CoAP 9 draft-ietf-lpwan-coap-static-context-hc-03 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 September 5, 2018. 39 Copyright Notice 41 Copyright (c) 2018 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. A 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 field description composing the 99 Rules and the context are not learned during the packet exchanges but 100 are previously defined. The context(s) is(are) known by both ends 101 before transmission. 103 A context is composed of a set of rules that are referenced by Rule 104 IDs (identifiers). A rule contains an ordered list of the fields 105 descriptions containing a field ID (FID) and its position when 106 repeated, a direction indicator (DI) (upstream, downstream and 107 bidirectional) and some associated Target Values (TV) which are 108 expected in the message header. A Matching Operator (MO) is 109 associated to each header field description. The rule is selected if 110 all the MOs fit the TVs. In that case, a Compression/Decompression 111 Action (CDA) associated to each field defines the link between the 112 compressed and decompressed value for each of the header fields. 114 This document describes how the rules can be applied to CoAP flows. 115 Compression of the CoAP header may be done in conjunction with the 116 above layers or independantly. 118 2. CoAP Compressing 120 CoAP differs from IPv6 and UDP protocols on the following aspects: 122 o IPv6 and UDP are symmetrical protocols. The same fields are found 123 in the request and in the response, only the location in the 124 header may vary (e.g. source and destination fields). A CoAP 125 request is different from a response. For example, the URI-path 126 option is mandatory in the request and is not found in the 127 response, a request may contain an Accept option and the response 128 a Content-format option. 130 Even when a field is "symmetric" (i.e. found in both directions) 131 the values carried are different. For instance the Type field 132 will contain a CON value in the request and a ACK or RST value in 133 the response. Exploiting the asymmetry in compression will allow 134 to send no bit in the compressed request and a single bit in the 135 answer. Same behavior can be applied to the CoAP Code field (O.OX 136 code are present in the request and Y.ZZ in the answer). 138 o CoAP also obeys to the client/server paradigm and the compression 139 rate can be different if the request is issued from an LPWAN node 140 or from an non LPWAN device. For instance a Thing (ES) aware of 141 LPWAN constraints can generate a 1 byte token, but a regular CoAP 142 client will certainly send a larger token to the Thing. SCHC 143 compression will not modify the values to offer a better 144 compression rate. Nevertheless a proxy placed before the 145 compressor may change some field values to offer a better 146 compression rate and maintain the necessary context for 147 interoperability with existing CoAP implementations. 149 o In IPv6 and UDP header fields have a fixed size. In CoAP, Token 150 size may vary from 0 to 8 bytes, length is given by a field in the 151 header. More systematically, the CoAP options are described using 152 the Type-Length-Value. When applying SCHC header compression. 154 By sending compressed field information following the rule order, 155 SCHC offers a serialization/deserialization mechanism. Since a 156 field exists to indicate the token length there is no ambiguity. 157 For options, the rule indicates also the expected options found 158 the int CoAP header. Therefore only the length is needed to 159 recognize an option. The length will be sent using the same CoAP 160 encoding (size less than 12 are directly sent, higher values use 161 the escape mechanisms defined by [rfc7252]). Delta Type is 162 omitted, the value will be recovered by the decompressor. This 163 reduces the option length of 4, 12 or 20 bits regarding the 164 original size of the delta type encoding in the option. 166 o In CoAP headers a field can be duplicated several times, for 167 instances, elements of an URI (path or queries) or accepted 168 formats. The position defined in a rule, associated to a Field 169 ID, can be used to identify the proper element. 171 3. Compression of CoAP header fields 173 This section discusses of the compression of the different CoAP 174 header fields. These are just examples. The compression should take 175 into account the nature of the traffic and not only the field values. 176 Next chapter will define some compression rules for some common 177 exchanges. 179 3.1. CoAP version field (2 bits) 181 This field is bidirectional and can be elided during the SCHC 182 compression, since it always contains the same value. It appears 183 only in first position. 185 FID FL FP DI Value MO CDA Sent 186 ver 2 1 bi 1 equal not-sent 188 3.2. CoAP type field 190 This field can be managed bidirectionally or unidirectionally.Several 191 strategies can be applied to this field regarding the values used: 193 o If the ES is a client or a Server and non confirmable message are 194 used, the transmission of the Type field can be avoided: 196 * Pos is always 1, 198 * DI can either be "uplink" if the ES is a CoAP client or 199 "downlink" if the ES is a CoAP server, or "bidirectional" 201 * TV is set to the value, 203 * MO is set to "equal" 205 * CDA is set to "not-sent". 207 FID FL FP DI Target Value MO CDA Sent 208 type 2 1 bi NON equal not-sent 210 o If the ES is either a client or a Server and confirmable message 211 are used, the DI can be used to elide the type on the request and 212 compress it to 1 bit on the response. The example above shows the 213 rule for a ES acting as a client, directions need to be reversed 214 for a ES acting as a server. 216 FID FL FP DI TV MO CDA Sent 217 type 2 1 up CON equal not-sent 218 type 2 1 dw [ACK,RST] match-mapping mapping-sent [1] 220 o Otherwise if the ES is acting simultaneously as a client and a 221 server and the rule handle these two traffics, Type field must be 222 sent uncompressed. 224 FID FL FP DI TV MO CDA Sent 225 type 2 1 bi ignore send-value [2] 227 3.3. CoAP token length field 229 This field is bi-directional. 231 Several strategies can be applied to this field regarding the values: 233 o no token or a wellknown length, the transmission can be avoided. 234 A special care must be taken, if CON messages are acknowledged 235 with an empty ACK message. In that case the token is not always 236 present. 238 FID FL FP DI TV MO CDA Sent 239 TKL 4 1 bi value ignore send-value [4] 241 o If the length is changing from one message to an other, the Token 242 Length field must be sent. If the Token length can be limited, 243 then only the least significant bits have to be sent. The example 244 below allows values between 0 and 3. 246 FID FL FP DI TV MO CDA Sent 247 TKL 4 1 bi 0x0 MSB(2) LSB(2) [2] 249 o otherwise the field value has to be sent. 251 FID FL FP DI TV MO CDA Sent 252 TKL 4 1 bi ignore value-sent [4] 254 3.4. CoAP code field 256 This field is bidirectional, but compression can be enhanced using 257 DI. 259 The CoAP Code field defines a tricky way to ensure compatibility with 260 HTTP values. Nevertheless only 21 values are defined by [rfc7252] 261 compared to the 255 possible values. 263 +------+------------------------------+-----------+ 264 | Code | Description | Mapping | 265 +------+------------------------------+-----------+ 266 | 0.00 | | 0x00 | 267 | 0.01 | GET | 0x01 | 268 | 0.02 | POST | 0x02 | 269 | 0.03 | PUT | 0x03 | 270 | 0.04 | DELETE | 0x04 | 271 | 0.05 | FETCH | 0x05 | 272 | 0.06 | PATCH | 0x06 | 273 | 0.07 | iPATCH | 0x07 | 274 | 2.01 | Created | 0x08 | 275 | 2.02 | Deleted | 0x09 | 276 | 2.03 | Valid | 0x0A | 277 | 2.04 | Changed | 0x0B | 278 | 2.05 | Content | 0x0C | 279 | 4.00 | Bad Request | 0x0D | 280 | 4.01 | Unauthorized | 0x0E | 281 | 4.02 | Bad Option | 0x0F | 282 | 4.03 | Forbidden | 0x10 | 283 | 4.04 | Not Found | 0x11 | 284 | 4.05 | Method Not Allowed | 0x12 | 285 | 4.06 | Not Acceptable | 0x13 | 286 | 4.12 | Precondition Failed | 0x14 | 287 | 4.13 | Request Entity Too Large | 0x15 | 288 | 4.15 | Unsupported Content-Format | 0x16 | 289 | 5.00 | Internal Server Error | 0x17 | 290 | 5.01 | Not Implemented | 0x18 | 291 | 5.02 | Bad Gateway | 0x19 | 292 | 5.03 | Service Unavailable | 0x1A | 293 | 5.04 | Gateway Timeout | 0x1B | 294 | 5.05 | Proxying Not Supported | 0x1C | 295 +------+------------------------------+-----------+ 297 Figure 1: Example of CoAP code mapping 299 Figure 1 gives a possible mapping, it can be changed to add new codes 300 or reduced if some values are never used by both ends. It could 301 efficiently be coded on 5 bits. 303 Even if the number of code can be increase with other RFC, 304 implementations may use a limited number of values, which can help to 305 reduce the number of bits sent on the LPWAN. 307 The number of code may vary over time, some new codes may be 308 introduced or some applications use a limited number of values. 310 The client and the server do not use the same values. This asymmetry 311 can be exploited to reduce the size sent on the LPWAN. 313 The field can be treated differently in upstream than in downstream. 314 If the Thing is a client an entry can be set on the uplink message 315 with a code matching for 0.0X values and another for downlink values 316 for Y.ZZ codes. It is the opposite if the thing is a server. 318 If the ES always sends or receives requests with the same method, the 319 Code field can be elided. The entry below shows a rule for a client 320 sending only GET request. 322 FID FL FP DI TV MO CDA Sent 323 code 8 1 up GET equal not-sent 325 If the client may send different methods, a matching-list can be 326 applied. For table Figure 1, 3 bits are necessary, but it could be 327 less if fewer methods are used. Example below gives an example where 328 the ES is a server and receives only GET and POST requests. 330 FID FL FP DI Target Value MO CDA Sent 331 code 8 1 dw [0.01, 0.02] match-mapping mapping-sent [1] 333 The same approach can be applied to responses. 335 3.5. CoAP Message ID field 337 This field is bidirectional. 339 Message ID is used for two purposes: 341 o To acknowledge a CON message with an ACK. 343 o To avoid duplicate messages. 345 In LPWAN, since a message can be received by several radio gateway, 346 some LPWAN technologies include a sequence number in L2 to avoid 347 duplicate frames. Therefore if the message does not need to be 348 acknowledged (NON or RST message), the Message ID field can be 349 avoided. 351 FID FL FP DI TV MO CDA Sent 352 Mid 8 1 bi ignore not-sent 354 The decompressor must generate a value. 356 [[Note; check id this field is not used by OSCOAP .]] 357 To optimize information sent on the LPWAN, shorter values may be used 358 during the exchange, but Message ID values generated a common CoAP 359 implementation will not take into account this limitation. Before 360 the compression, a proxy may be needed to reduce the size. 362 FID FL FP DI TV MO CDA Sent 363 Mid 8 1 bi 0x0000 MSB(12) LSB(4) [4] 365 Otherwise if no compression is possible, the field has to be sent 367 FID FL FP DI TV MO CDA Sent 368 Mid 8 1 bi ignore value-sent [8] 370 3.6. CoAP Token field 372 This field is bi-directional. 374 Token is used to identify transactions and varies from one 375 transaction to another. Therefore, it is usually necessary to send 376 the value of the token field on the LPWAN network. The optimization 377 will occur by using small values. 379 Common CoAP implementations may generate large tokens, even if 380 shorter tokens could be used regarding the LPWAN characteristics. A 381 proxy may be needed to reduce the size of the token before 382 compression. 384 The size of the compress token sent is known by a combination of the 385 Token Length field and the rule entry. For instance, with the entry 386 below: 388 FID FL FP DI TV MO CDA Sent 389 tkl 4 1 bi 2 equal not-sent 390 token 8 1 bi 0x00 MSB(12) LSB(4) [4] 392 The uncompressed token is 2 bytes long, but the compressed size will 393 be 4 bits. 395 4. CoAP options 397 4.1. CoAP option Content-format field. 399 This field is unidirectional and must not be set to bidirectional in 400 a rule entry. It is used only by the server to inform the client 401 about of the payload type and is never found in client requests. 403 If single value is expected by the client, the TV contains that value 404 and MO is set to "equal" and the CDF is set to "not-sent". The 405 examples below describe the rules for an ES acting as a server. 407 FID FL FP DI TV MO CDA Sent 408 content 16 1 up value equal not-sent 410 If several possible value are expected by the client, a matching-list 411 can be used. 413 FID FL FP DI TV MO CDA Sent 414 content 16 1 up [50, 41] match-mapping mapping-sent [1] 416 Otherwise the value can be sent.The value-sent CDF in the compressor 417 do not send the option type and the decompressor reconstruct it 418 regarding the position in the rule. 420 FID FL FP DI TV MO CDA Sent 421 content 16 1 up ignore value-sent [0-16] 423 4.2. CoAP option Accept field 425 This field is unidirectional and must not be set to bidirectional in 426 a rule entry. It is used only by the client to inform of the 427 possible payload type and is never found in server response. 429 The number of accept options is not limited and can vary regarding 430 the usage. To be selected a rule must contain the exact number about 431 accept options with their positions. Since the order in which the 432 Accept value are sent, the position order can be modified. The rule 433 below 435 FID FL FP DI TV MO CDA Sent 436 accept 16 1 up 41 egal not-sent 437 accept 16 2 up 50 egal not-sent 439 will be selected only if two accept options are in the CoAP header if 440 this order. 442 The rule below: 444 FID FL FP DI TV MO CDA Sent 445 accept 16 0 up 41 egal not-sent 446 accept 16 0 up 50 egal not-sent 448 will accept a-only CoAP messages with 2 accept options, but the order 449 will not influence the rule selection. The decompression will 450 reconstruct the header regarding the rule order. 452 Otherwise a matching-list can be applied to the different values, in 453 that case the order is important to recover the appropriate value and 454 the position must be clearly indicate. 456 FID FL FP DI TV MO CDA Sent 457 accept 16 1 up [50,41] match-mapping mapping-sent [1] 458 accept 16 2 up [50,61] match-mapping mapping-sent [1] 459 accept 16 3 up [61,71] match-mapping mapping-sent [1] 461 Finally, the option can be explicitly sent. 463 FID FL FP DI TV MO CDA Sent 464 accept 1 up ignore value-sent 466 4.3. CoAP option Max-Age field, CoAP option Uri-Host and Uri-Port 467 fields 469 This field is unidirectional and must not be set to bidirectional in 470 a rule entry. It is used only by the server to inform of the caching 471 duration and is never found in client requests. 473 If the duration is known by both ends, value can be elided on the 474 LPWAN. 476 A matching list can be used if some wellknown values are defined. 478 Otherwise the option length and value can be sent on the LPWAN. 480 [[note: we can reduce (or create a new option) the unit to minute, 481 second is small for LPWAN ]] 483 5. CoAP option Uri-Path and Uri-Query fields 485 This fields are unidirectional and must not be set to bidirectional 486 in a rule entry. They are used only by the client to access to a 487 specific resource and are never found in server response. 489 The Matching Operator behavior has not changed, but the value must 490 take a position value, if the entry is repeated : 492 FID FL FP DI TV MO CDA Sent 493 URI-Path 1 up foo equal not-sent 494 URI-Path 2 up bar equal not-sent 496 Figure 2: Position entry. 498 For instance, the rule Figure 2 matches with /foo/bar, but not /bar/ 499 foo. 501 When the length is not clearly indicated in the rule, the value 502 length must be sent with the field data, which means for CoAP to send 503 directly the CoAP option with length and value. 505 For instance for a CoMi path /c/X6?k="eth0" the rule can be set to: 507 FID FL FP DI TV MO CDA Sent 508 URI-Path 1 up c equal not-sent 509 URI-Path 2 up ignore value-sent 510 URI-Query 1 up k= MSB (16) LSB 512 Figure 3: CoMi URI compression 514 Figure 3 shows the parsing and the compression of the URI. where c is 515 not sent. The second element is sent with the length (i.e. 0x2 X 6) 516 followed by the query option (i.e. 0x05 "eth0"). 518 A Mapping list can be used to reduce size of variable Paths or 519 Queries. In that case, to optimize the compression, several elements 520 can be regrouped into a single entry. Numbering of elements do not 521 change, MO comparison is set with the first element of the matching. 523 FID FL FP DI TV MO CDA Sent 524 URI-Path 1 up {0:"/c/c", equal not-sent 525 1:"/c/d" 526 URI-Path 3 up ignore value-sent 527 URI-Query 1 up k= MSB (16) LSB 529 Figure 4: complex path example 531 For instance, the following Path /foo/bar/variable/stable can leads 532 to the rule defined Figure 4. 534 5.1. CoAP option Proxy-URI and Proxy-Scheme fields 536 These fields are unidirectional and must not be set to bidirectional 537 in a rule entry. They are used only by the client to access to a 538 specific resource and are never found in server response. 540 If the field value must be sent, TV is not set, MO is set to "ignore" 541 and CDF is set to "value-sent. A mapping can also be used. 543 Otherwise the TV is set to the value, MO is set to "equal" and CDF is 544 set to "not-sent" 546 5.2. CoAP option ETag, If-Match, If-None-Match, Location-Path and 547 Location-Query fields 549 These fields are unidirectional. 551 These fields values cannot be stored in a rule entry. They must 552 always be sent with the request. 554 [[Can include OSCOAP Object security in that category ]] 556 6. Other RFCs 558 6.1. Block 560 Block option should be avoided in LPWAN. The minimum size of 16 561 bytes can be incompatible with some LPWAN technologies. 563 [[Note: do we recommand LPWAN fragmentation since the smallest value 564 of 16 is too big?]] 566 6.2. Observe 568 [rfc7641] defines the Observe option. The TV is not set, MO is set 569 to "ignore" and the CDF is set to "value-sent". SCHC does not limit 570 the maximum size for this option (3 bytes). To reduce the 571 transmission size either the Thing implementation should limit the 572 value increase or a proxy can be used limit the increase. 574 Since RST message may be sent to inform a server that the client do 575 not require Observe response, a rule must allow the transmission of 576 this message. 578 6.3. No-Response 580 [rfc7967] defines an No-Response option limiting the responses made 581 by a server to a request. If the value is not by both ends, then TV 582 is set to this value, MO is set to "equal" and CDF is set to "not- 583 sent". 585 Otherwise, if the value is changing over time, TV is not set, MO is 586 set to "ignore" and CDF to "value-sent". A matching list can also be 587 used to reduce the size. 589 7. Protocol analysis 590 8. Examples of CoAP header compression 592 8.1. Mandatory header with CON message 594 In this first scenario, the LPWAN compressor receives from outside 595 client a POST message, which is immediately acknowledged by the 596 Thing. For this simple scenario, the rules are described Figure 5. 598 Rule ID 1 599 +-------------+--+--+--+------+---------+-------------++------------+ 600 | Field |FL|FP|DI|Target| Match | CDA || Sent | 601 | | | | |Value | Opera. | || [bits] | 602 +-------------+--+--+--+------+---------+-------------++------------+ 603 |CoAP version | | |bi| 01 |equal |not-sent || | 604 |CoAP version | | |bi| 01 |equal |not-sent || | 605 |CoAP Type | | |bi| |ignore |value-sent ||TT | 606 |CoAP TKL | | |bi| 0 |equal |not-sent || | 607 |CoAP Code | | |bi| ML1 |match-map|matching-sent|| CC CCC | 608 |CoAP MID | | |bi| 0000 |MSB(7 ) |LSB(9) || M-ID| 609 |CoAP Uri-Path| | |dw| path |equal 1 |not-sent || | 610 +-------------+--+--+--+------+---------+-------------++------------+ 612 Figure 5: CoAP Context to compress header without token 614 The version and Token Length fields are elided. Code has shrunk to 5 615 bits using the matching list (as the one given Figure 1: 0.01 is 616 value 0x01 and 2.05 is value 0x0c) Message-ID has shrunk to 9 bits to 617 preserve alignment on byte boundary. The most significant bit must 618 be set to 0 through a CoAP proxy. Uri-Path contains a single element 619 indicated in the matching operator. 621 Figure 6 shows the time diagram of the exchange. A LPWAN Application 622 Server sends a CON message. Compression reduces the header sending 623 only the Type, a mapped code and the least 9 significant bits of 624 Message ID. The receiver decompresses the header. . 626 The CON message is a request, therefore the LC process to a dynamic 627 mapping. When the ES receives the ACK message, this will not 628 initiate locally a message ID mapping since it is a response. The LC 629 receives the ACK and uncompressed it to restore the original value. 630 Dynamic Mapping context lifetime follows the same rules as message ID 631 duration. 633 End System LPWA LC 634 | | 635 | rule id=1 |<-------------------- 636 |<-------------------| +-+-+--+----+------+ 637 <------------------- | TTCC CCCM MMMM MMMM| |1|0| 4|0.01|0x0034| 638 +-+-+--+----+-------+ | 0000 0010 0011 0100| | 0xb4 p a t| 639 |1|0| 1|0.01|0x0034 | | | | h | 640 | 0xb4 p a t | | | +------+ 641 | h | | | 642 +------+ | | 643 | | 644 | | 645 ---------------------->| rule id=1 | 646 +-+-+--+----+--------+ |------------------->| 647 |1|2| 0|2.05| 0x0034 | | TTCC CCCM MMMM MMMM|---------------------> 648 +-+-+--+----+--------+ | 1001 1000 0011 0100| +-+-+--+----+------+ 649 | | |1|2| 0|2.05|0x0034| 650 v v +-+-+--+----+------+ 652 Figure 6: Compression with global addresses 654 The message can be further optimized by setting some fields 655 unidirectional, as described in Figure 7. Note that Type is no more 656 sent in the compressed format, Compressed Code size in not changed in 657 that example (8 values are needed to code all the requests and 21 to 658 code all the responses in the matching list Figure 1) 660 Rule ID 2 661 +-------------+--+--+--+------+---------+------------++------------+ 662 | Field |FL|FP|DI|Target| MO | CDA || Sent | 663 | | | | |Value | | || [bits] | 664 +-------------+--+--+--+------+---------+------------++------------+ 665 |CoAP version | | |bi|01 |equal |not-sent || | 666 |CoAP Type | | |dw|CON |equal |not-sent || | 667 |CoAP Type | | |up| ACK |equal |not-sent || | 668 |CoAP TKL | | |bi|0 |equal |not-sent || | 669 |CoAP Code | | |dw|ML2 |match-map|mapping-sent||CCCC C | 670 |CoAP Code | | |up|ML3 |match-map|mapping-sent||CCCC C | 671 |CoAP MID | | |bi|0000 |MSB(5) |LSB(11) || M-ID | 672 |CoAP Uri-Path| | |dw|path |equal 1 |not-sent || | 673 +-------------+--+--+--+------+---------+------------++------------+ 675 ML1 = {CON : 0, ACK:1} ML2 = {POST:0, 2.04:1, 0.00:3} 677 Figure 7: CoAP Context to compress header without token 679 8.2. Complete exchange 681 In that example, the Thing is using CoMi and sends queries for 2 SID. 683 CON 684 MID=0x0012 | | 685 POST | | 686 Accept X | | 687 /c/k=AS |------------------------>| 688 | | 689 | | 690 |<------------------------| ACK MID=0x0012 691 | | 0.00 692 | | 693 | | 694 |<------------------------| CON 695 | | MID=0X0034 696 | | Content-Format X 697 ACK MID=0x0034 |------------------------>| 698 0.00 700 Rule ID 3 701 +--------------+--+--+--+------+--------+-----------++------------+ 702 | Field |FL|FP|DI|Target| MO | CDA || Sent | 703 | | | | |Value | | || [bits] | 704 +--------------+--+--+--+------+--------+-----------++------------+ 705 |CoAP version | | |bi| 01 |equal |not-sent || | 706 |CoAP Type | | |up| CON |equal |not-sent || | 707 |CoAP Type | | |dw| ACK |equal |not-sent || | 708 |CoAP TKL | | |bi| 1 |equal |not-sent || | 709 |CoAP Code | | |up| POST |equal |not-sent || | 710 |CoAP Code | | |dw| 0.00 |equal |not-sent || | 711 |CoAP MID | | |bi| 0000 |MSB(8) |LSB ||MMMMMMMM | 712 |CoAP Token | | |up| |ignore |send-value ||TTTTTTTT | 713 |CoAP Uri-Path | | |dw| /c |equal 1 |not-sent || | 714 |CoAP Uri-query| | |dw| ML4 |equal 1 |not-sent ||P | 715 |CoAP Content | | |up| X |equal |not-sent || | 716 +--------------+--+--+--+------+--------+-----------++------------+ 718 Rule ID 4 719 +--------------+--+--+--+------+--------+-----------++------------+ 720 | Field |FL|FP|DI|Target| MO | CDA || Sent | 721 | | | | |Value | | || [bits] | 722 +--------------+--+--+--+------+--------+-----------++------------+ 723 |CoAP version | | |bi| 01 |equal |not-sent || | 724 |CoAP Type | | |dw| CON |equal |not-sent || | 725 |CoAP Type | | |up| ACK |equal |not-sent || | 726 |CoAP TKL | | |bi| 1 |equal |not-sent || | 727 |CoAP Code | | |dw| 2.05 |equal |not-sent || | 728 |CoAP Code | | |up| 0.00 |equal |not-sent || | 729 |CoAP MID | | |bi| 0000 |MSB(8) |LSB ||MMMMMMMM | 730 |CoAP Token | | |dw| |ignore |send-value||TTTTTTTT | 731 |COAP Accept | | |dw| X |equal |not-sent || | 732 +--------------+--+--+--+------+---------+----------++------------+ 734 alternative rule: 736 Rule ID 4 737 +--------------+--+--+--+------+---------+-----------++------------+ 738 | Field |FL|FP|DI|Target| MO | CDA || Sent | 739 | | | | |Value | | || [bits] | 740 +--------------+--+--+--+------+---------+-----------++------------+ 741 |CoAP version | | |bi| 01 |equal |not-sent || | 742 |CoAP Type | | |bi| ML1 |match-map|match-sent ||t | 743 |CoAP TKL | | |bi| 1 |equal |not-sent || | 744 |CoAP Code | | |up| ML2 |match-map|match-sent || cc | 745 |CoAP Code | | |dw| ML3 |match-map|match-sent || cc | 746 |CoAP MID | | |bi| 0000 |MSB(8) |LSB ||MMMMMMMM | 747 |CoAP Token | | |dw| |ignore |send-value ||TTTTTTTT | 748 |CoAP Uri-Path | | |dw| /c |equal 1 |not-sent || | 749 |CoAP Uri-query| | |dw| ML4 |equal 1 |not-sent ||P | 750 |CoAP Content | | |up| X |equal |not-sent || | 751 |COAP Accept | | |dw| x |equal |not-sent || | 752 +--------------+--+--+--+------+---------+-----------++------------+ 754 ML1 {CON:0, ACK:1} ML2 {POST:0, 0.00: 1} ML3 {2.05:0, 0.00:1} 755 ML4 {NULL:0, k=AS:1, K=AZE:2} 757 9. Normative References 759 [I-D.toutain-lpwan-ipv6-static-context-hc] 760 Minaburo, A. and L. Toutain, "LPWAN Static Context Header 761 Compression (SCHC) for IPv6 and UDP", draft-toutain-lpwan- 762 ipv6-static-context-hc-00 (work in progress), September 763 2016. 765 [rfc7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 766 Application Protocol (CoAP)", RFC 7252, 767 DOI 10.17487/RFC7252, June 2014, 768 . 770 [rfc7641] Hartke, K., "Observing Resources in the Constrained 771 Application Protocol (CoAP)", RFC 7641, 772 DOI 10.17487/RFC7641, September 2015, 773 . 775 [rfc7967] Bhattacharyya, A., Bandyopadhyay, S., Pal, A., and T. 776 Bose, "Constrained Application Protocol (CoAP) Option for 777 No Server Response", RFC 7967, DOI 10.17487/RFC7967, 778 August 2016, . 780 Authors' Addresses 782 Ana Minaburo 783 Acklio 784 2bis rue de la Chataigneraie 785 35510 Cesson-Sevigne Cedex 786 France 788 Email: ana@ackl.io 790 Laurent Toutain 791 Institut MINES TELECOM; IMT Atlantique 792 2 rue de la Chataigneraie 793 CS 17607 794 35576 Cesson-Sevigne Cedex 795 France 797 Email: Laurent.Toutain@imt-atlantique.fr