lpwan Working Group A. Minaburo
Internet-Draft Acklio
Intended status: Informational L. Toutain
Expires: June 8, 2017 Institut MINES TELECOM ; TELECOM Bretagne
December 5, 2016

6LPWA Static Context Header Compression (SCHC) for CoAP
draft-ietf-lpwan-coap-static-context-hc-00

Abstract

This draft discusses the way SCHC can be applied to CoAP headers and extend the number of functions (CDF) to optimize compression.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on June 8, 2017.

Copyright Notice

Copyright (c) 2016 IETF Trust and the persons identified as the document authors. All rights reserved.

This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.

1. Introduction

[I-D.toutain-lpwan-ipv6-static-context-hc] defines a compression technique for LPWA network based on static context. This context is said static since the element values composing the context are not learned during packet exchanges but previously installed. The context is known by both ends. A context is composed of a set of rules (referenced by rule ids). A rule describes the header fields with some associated Target Values (TV). A Matching Operator (MO) is associated to each field. The rule is selected if all the MO matches . A Compression Decompression Function is associated to each field to define the link between the compressed and decompressed value for a specific field.

This draft discusses the way SCHC can be applied to CoAP headers and extend the number of functions (CDF) to optimize compression.

2. Compressing CoAP

CoAP [RFC7252] is an implementation of a the REST architecture for contrained devices. Gateway between CoAP and HTTP can be easily build since both protocol uses the same address space (URL), caching mechanisms and methods.

Nevertheless, if limited, the size of a CoAP header may be incompatible with LPWAN constraints and some compression may be needed to reduce the header size. CoAP compression is not straightforward. Some differences between IPv6/UDP and CoAP can be enlighten. CoAP differs from IPv6 and UDP protocols:

2.1. CoAP usages

A LPWAN node can either be a client or a server and sometimes both. In the client mode, the LPWAN node sends request to a server and expected answer or acknowledgements. Acknowledgements can be at 2 different levels:

Note that acknowledgement can be optimized and a REST level acknowledgement can be used as a transport level acknowledgement.

2.2. CoAP protocol analysis

CoAP defines the following fields:

The CoAP protocol must not be altered by the compression/decompression phase, but if no semantic is attributed to a value, it may be changed during this phase. For instance the compression phase may reduce the size of a token but must maintain its unicity. The decompressor will not be able to restore the original value but behavior will remain the same. If no special semantic is assigned to the token, this will be transparent. If a special semantic is assigned to the token, its compression may not be possible.

This implies that the compressor/decompressor must be aware of the protocol state machine and do not processes request and response the same way.

A conservative compression leaves the field value unchanged. Non conservative compression can be used when a CoAP implementation has not been defined to work specifically with LPWAN network and uses large values for fields.

2.2.1. CoAP Compression Decompression Function

To compress more efficiently CoAP message, several Compression/Decompression Function (CDF) must be defined.

2.2.1.1. Static-mapping

The goal of static-mapping is to reduce the size of a field by allocating shorter value. The mapping is known by both ends and stored in a table in both end context. The Static-mapping is conservative.

Static-mapping may be applied to several fields. For instance the type field may be reduced from 2 bits to 1 bit if only CON/ACK type is used, but the main benefit is compressing the code field.

The CoAP code field defines a tricky way to ensure compatibility with HTTP values. Nevertheless only 21 values are defined by [RFC7252] compared to the 255 possible values. So it could efficiently be coded on 5 bits. To allow flexibility and evolution if new codes are introduced, a static mapping table is associated to each instance of this function.

            +------+------------------------------+-----------+
            | Code | Description                  | Mapping   |
            +------+------------------------------+-----------+
            | 0.00 |                              |  0x00     |
            | 0.01 | GET                          |  0x01     |
            | 0.02 | POST                         |  0x02     |
            | 0.03 | PUT                          |  0x03     |
            | 0.04 | DELETE                       |  0x04     |
            | 0.05 | FETCH                        |  0x05     |
            | 0.06 | PATCH                        |  0x06     |
            | 0.07 | iPATCH                       |  0x07     |
            | 2.01 | Created                      |  0x08     |
            | 2.02 | Deleted                      |  0x09     |
            | 2.03 | Valid                        |  0x0A     |
            | 2.04 | Changed                      |  0x0B     |
            | 2.05 | Content                      |  0x0C     |
            | 4.00 | Bad Request                  |  0x0D     |
            | 4.01 | Unauthorized                 |  0x0E     |
            | 4.02 | Bad Option                   |  0x0F     |
            | 4.03 | Forbidden                    |  0x10     |
            | 4.04 | Not Found                    |  0x11     |
            | 4.05 | Method Not Allowed           |  0x12     |
            | 4.06 | Not Acceptable               |  0x13     |
            | 4.12 | Precondition Failed          |  0x14     |
            | 4.13 | Request Entity Too Large     |  0x15     |
            | 4.15 | Unsupported Content-Format   |  0x16     |
            | 5.00 | Internal Server Error        |  0x17     |
            | 5.01 | Not Implemented              |  0x18     |
            | 5.02 | Bad Gateway                  |  0x19     |
            | 5.03 | Service Unavailable          |  0x1A     |
            | 5.04 | Gateway Timeout              |  0x1B     |
            | 5.05 | Proxying Not Supported       |  0x1C     |
            +------+------------------------------+-----------+
 
    

Figure 1: CoAP code mapping

Figure 1 gives a possible mapping, it can be changed to add new codes or reduced if some values are never used by both ends.

2.2.1.2. Remapping

With dynamic mapping, the mapping is done dynamically, which means that the other end has no way to the learn the original value. This function is not conservative. The mapping context must be stored in a reliable way on the compressor, if lost the session with LPWAN node will be lost, which can generate a traffic increase on the LPWA network.

This function converts a large number to a smaller one and maintain bi-directional mapping. If the field has no semantic, such as a CoAP token or a message ID, this will reduce the size of the information sent on the link. This mapping only applies for request compression, answers must keep the value original value.

For instance a compression receives a CoAP request with a large token. The compressor reduces the token size by allocating a unused value in a smaller space. When the response come back, the compressor exchange the smallest token with the original one.

This mean that the compressor must be aware of the CoAP state machine, to identify a request and its associated response, but also determine when a token value can be reused.

2.2.1.3. Reduce-entropy

Reduce-entropy is a non-conservative function. the goal is to minimize the increase in a field value. It may be used for the observe option, all increase in the original sequence number will lead to an increase of 1 in the compressed value.

For instance a LPWAN node is a CoAP server and receives Observe responses coming from an outside client. The client uses a clock to generate Observe sequence number. If that value has non particular meaning for the CoAP server, increase of 1 will not change the protocol behavior. Reordering works the same way as for original Observe.

2.2.2. CoAP mandatory header

/--------------------+---------------------+----------------------------------------\
| Field              |Function             | Behavior                               |         
+--------------------+---------------------+----------------------------------------+
|version             |not-sent             |version is always the same              |
+--------------------+---------------------+----------------------------------------+
|type                |value-sent           |if all the types are used               |
|                    |static-mapping       |to reduce to one bit if 2 type are used |
|                    |not-sent             |if only one type is used (e.g. NON)     |
+--------------------+---------------------+----------------------------------------+
|token length        |not-sent             |no tokens or fixed size                 |
|                    |compute-token-length |if token size is reduced                |
|                    |value-sent           |token is sent integrally                |
+--------------------+---------------------+----------------------------------------+                 
|code                |value-sent           |no modification                         |
|                    |static-mapping       |code size reduction                     |
+--------------------+---------------------+----------------------------------------+
|message id          |value-sent           |no modification                         |
|token               |remapping            |reduces message id size                 |                       
+====================+=====================+========================================+
|Content-Format      |value-sent           |no modification                         |
|Accept              |not-sent             |defined in the rule                     |
|Max-Age             |static-mapping       |map the possible value                  |
+--------------------+---------------------+----------------------------------------+
|Path:               |value-sent           |no modification                         |
|Uri-Host+Uri-Port+  |not-sent             |defined in the rule                     |
|Uri-Path*+Uri-Query*|static-mapping       |a value to define a path                |
|                    |                     |                                        |
|Proxy-Uri           |                     |Note: only the full path is stored in   |
|Proxy-Scheme        |                     |context                                 |
+--------------------+---------------------+----------------------------------------+ 
|ETag                |value-sent           |Always sent                             |
|Location-Path       |                     |                                        |
|Location-Query      |                     |                                        |
|If-Match            |                     |                                        |
|If-None-Match       |                     |                                        |
|Size1               |                     |                                        |
+--------------------+---------------------+----------------------------------------+

Figure 2: SCHC functions' example assignment for CoAP

Figure 2 proposes some function assignments to the CoAP header fields.

2.2.3. Examples of CoAP header compression

2.2.3.1. Mandatory header with CON message


 rule id 1
+-------------+-------+-----+---------------+----------------+
| Field       |TV     |MO   |CDF            | Sent           |
+=============+=======+=====+===============+================+ 
|CoAP version | 01    |=    |not-sent       |                |
|CoAP Type    |       |     |value-sent     |TT              |
|CoAP TKL     | 0000  |=    |not-sent       |                |
|CoAP Code    |       |     |static-map     |  CC CCC        |
|CoAP MID     |       |     |dynamic-map    |         M-ID   |
|CoAP Path    |/path  |     |not-sent       |                |
+-------------+-------+-----+---------------+----------------+

Figure 3: CoAP Context to compress header without token

In this first scenario, the LPWAN compressor receives from outside client a POST message, which is immediately acknowledged by the ES. For this simple scenario, the rules are described Figure 3 Figure 3 gives a simple compression rule for CoAP headers without tokens.

The version fields and Token Length are elided. Code has shrunk to 5 bits using the static-mapping function. Message-ID has shrunk to 9 bits to preserve alignment on byte boundary.

Figure 4 shows the time diagram of the exchange. A LPWAN Application Server sends a CON message. Compression reduces the header sending only the Type, a mapped code and the Message ID is change to a value on 9 bits. The receiver decompress the header. The message ID value is changed.

                   End System                      LPWA LC
                        |                            | 
                        |        rule id=1           |<----------------------   
                        |<---------------------------|   +-+-+--+----+--------+
  <-------------------- |  TTCC CCCM MMMM MMMM       |   |1|0| 4|0.01| 0x1234 |
 +-+-+--+----+--------+ |  0000 0010 0000 0001       |   |  0xb4   p    a   t |
 |1|0| 1|0.01| 0x0001 | |                            |   |  h   |
 |  0xb4   p    a   t | |                            |   +------+
 |  h   |               |                            |    dynamic mapping
 +------+               |                            |    +--------+--------+
                        |                            |    |0x1234  |  0x01  |
                        |                            |    +--------+--------+
----------------------->|       rule id=1            |
+-+-+--+----+--------+  |--------------------------->|
|1|2| 0|2.05| 0x0001 |  |    TTCC CCCM MMMM MMMM     |------------------------>
+-+-+--+----+--------+  |    1000 0000 0000 0001     | +-+-+--+----+--------+
                        |                            | |1|2| 0|2.05| 0x1234 |
                        v                            v +-+-+--+----+--------+
 

Figure 4: Compression with global addresses

The CON message is a request, therefore the LC process to a dynamic mapping. When the ES receives the ACK message, this will not initiate locally a the message ID mapping since it is a response. The LC receives the ACK and uncompress it to restore the original value. Dynamic Mapping context lifetime follows the same rules as message ID duration.

  • The LC compressor detects a new transport request and allocate a new dynamic mapping value.
  • When receiving a response the ES compressor ES detects that this is a response (type=2) therefore the message ID value in unchanged.
  • The upstream compressor detects that is an REST answer (code 2.05) therefore the path option is not inserted in the uncompress header

2.2.3.2. Exchange with token

 
  +----------------+------------------------+----------------+-----------------+
  | Field          |   Function             | Ctxt Value     | Sent compressed |
  +----------------+------------------------+----------------+-----------------+
  |CoAP version    | not-sent               |                |                 |
  |CoAP Type       | value-sent             |                |TT               |
  |CoAP TKL        | compute-token-length   |                |  LL             |
  |CoAP Code       | map-code               | mapping table  |      CCCC C     |
  |CoAP MID        | remapping              | 7 bits         |            M-ID |
  |CoAP Token      | remapping              | 8 bits         |            token|
  |CoAP Path       | not-sent               |/data/humidity  |
  +----------------+------------------------+----------------+-----------------+

Figure 5: CoAP Context to compress header with token

 
                   End System                      LPWA LC
                        |                            | 
                        |        SHIM=1              |<----------------------   
                        |<---------------------------|   +-+-+--+----+--------+
  <-------------------- |  TT LL CCCC  C  MMMMMMM    |   |1|0| 4|0.01| 0x1234 |
 +-+-+--+----+--------+ |  00 01 0000  1  0000001    |   |      DEADBEEF      |
 |1|0| 1|0.01| 0x0001 | |  0000  0001                |   |  0xb4   d    a   t |
 |  01   0xb4   d   a | |  Token                     |   |   a     0x08 h   u |
 |    t   a    0x08 h | |                            |   |   m     i    d   i |
 |    u   m     i   d | |                            |   |   t     y  |
 |    i   t     y  |    |                            |   +------------+
 +-----------------+    |                            | Mid mapping: 1234 -> 1
                        |                            | Tk  mapping: DEADBEEF -> 1
----------------------->|       SHIM=1               |
+-+-+--+----+--------+  |--------------------------->|
|1|2| 0|0.00| 0x0001 |  |    TT LL CCCC C MMMMMMMM   |------------------------>
+-+-+--+----+--------+  |    10 01 0000 0 00000001   | +-+-+--+----+--------+
                        |                            | |1|2| 0|0.00| 0x1234 |
                        |                            | +-+-+--+----+--------+
----------------------->|                            |
+-+-+--+----+--------+  |--------------------------->|
|1|0| 0|2.05| 0xCAFE |  |    TT LL CCCC C MMMMMMMM   |------------------------>
| 0x01    2     5    |  |    00 01 1100 0 00000002   | +-+-+--+----+--------+
+--------------------+  |    0000  0001              | |1|0| 4|2.05| 0x0001 |
                        |    2 5                     | |       DEADBEEF     |
                        |                            | |    2    5 |
Mid mapping: CAFE -> 1  |                            | +-----------+
                        |                            |
                        |                            |<------------------------
                        |<---------------------------| +-+-+--+----+--------+
<-----------------------|     TT LL CCCC C  MMMMMMMM | |1|2| 0|0.00|0x0001  |
+-+-+--+----+--------+  |     10 00 0000 0  00000002 | +-+-+--+----+--------+
|1|2| 0|0.00| 0xCAFE |  |                            |
+-+-+--+----+--------+  |                            |
                        v                            v
 
 

Figure 6: Compression with token

The following scenario introduces tokens. The LC manages two remapping contexts. One for Message ID and the other for token. ES manages one context for Message ID. Mapping is trigged by the reception of CON messages to compress or CoAP requests to compress. Note that the compressed message ID size has been reduced to 7 bits, compared to the previous example, to maintain byte boundary alignment.

3. Normative References

[I-D.toutain-lpwan-ipv6-static-context-hc] Minaburo, A. and L. Toutain, "LPWAN Static Context Header Compression (SCHC) for IPv6 and UDP", Internet-Draft draft-toutain-lpwan-ipv6-static-context-hc-00, September 2016.
[RFC1332] McGregor, G., "The PPP Internet Protocol Control Protocol (IPCP)", RFC 1332, DOI 10.17487/RFC1332, May 1992.
[RFC3095] Bormann, C., Burmeister, C., Degermark, M., Fukushima, H., Hannu, H., Jonsson, L-E., Hakenberg, R., Koren, T., Le, K., Liu, Z., Martensson, A., Miyazaki, A., Svanbro, K., Wiebke, T., Yoshimura, T. and H. Zheng, "RObust Header Compression (ROHC): Framework and four profiles: RTP, UDP, ESP, and uncompressed", RFC 3095, DOI 10.17487/RFC3095, July 2001.
[RFC4944] Montenegro, G., Kushalnagar, N., Hui, J. and D. Culler, "Transmission of IPv6 Packets over IEEE 802.15.4 Networks", RFC 4944, DOI 10.17487/RFC4944, September 2007.
[RFC4997] Finking, R. and G. Pelletier, "Formal Notation for RObust Header Compression (ROHC-FN)", RFC 4997, DOI 10.17487/RFC4997, July 2007.
[RFC5225] Pelletier, G. and K. Sandlund, "RObust Header Compression Version 2 (ROHCv2): Profiles for RTP, UDP, IP, ESP and UDP-Lite", RFC 5225, DOI 10.17487/RFC5225, April 2008.
[RFC6282] Hui, J. and P. Thubert, "Compression Format for IPv6 Datagrams over IEEE 802.15.4-Based Networks", RFC 6282, DOI 10.17487/RFC6282, September 2011.
[RFC7252] Shelby, Z., Hartke, K. and C. Bormann, "The Constrained Application Protocol (CoAP)", RFC 7252, DOI 10.17487/RFC7252, June 2014.
[RFC7967] Bhattacharyya, A., Bandyopadhyay, S., Pal, A. and T. Bose, "Constrained Application Protocol (CoAP) Option for No Server Response", RFC 7967, DOI 10.17487/RFC7967, August 2016.

Authors' Addresses

Ana Minaburo Acklio 2bis rue de la Chataigneraie 35510 Cesson-Sevigne Cedex, France EMail: ana@ackl.io
Laurent Toutain Institut MINES TELECOM ; TELECOM Bretagne 2 rue de la Chataigneraie CS 17607 35576 Cesson-Sevigne Cedex, France EMail: Laurent.Toutain@telecom-bretagne.eu

Table of Contents