[Docs] [txt|pdf|xml] [Tracker] [Email] [Nits]

Versions: 00 draft-ietf-lpwan-coap-static-context-hc

Network Working Group                                        A. Minaburo
Internet-Draft                                                    Acklio
Intended status: Informational                                L. Toutain
Expires: May 1, 2017           Institut MINES TELECOM ; TELECOM Bretagne
                                                        October 28, 2016

        6LPWA Static Context Header Compression (SCHC) for CoAP


   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 May 1, 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.

Minaburo & Toutain         Expires May 1, 2017                  [Page 1]

Internet-Draft           LPWAN CoAP compression             October 2016

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:

   o  IPv6 and UDP are symmetrical protocols.  The same fields are found
      in the request and in the answer, only location in the header may
      change (e.g. source and destination fields).  A CoAP request is
      different from an answer.  For instance, the URI-path option is
      mandatory in the request and may not be found in the response.

   o  CoAP also obeys to the client/server paradigm and the compression
      rate can be different if the request is issued from a LPWAN node
      or from an external device.  For instance in the former case the
      token size may be set to one byte.  In the latter case, the token
      size cannot be constraint and be up to 15 byte long.

   o  In IPv6, main header and UDP fields have a fixed size.  In CoAP,
      Token size may vary from 0 to 15 bytes, length is given by a field
      in the header.  More systematically, the options are described
      using the Type-Length-Value principle.  Evenmore regarding the
      option size value, the coding will be different.

Minaburo & Toutain         Expires May 1, 2017                  [Page 2]

Internet-Draft           LPWAN CoAP compression             October 2016

   o  options type in CoAP are not defined with the same value.  The
      Delta TLV coding makes that the type is not independant of
      previous option and may vary regarding the options contained in
      the header.

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:

   o  transport level, a CON message is acknowledged by an ACK message.
      NON confirmable messages are not acknowledged.

   o  REST level, a REST request is acknowledged by an "error" code.
      [RFC7967] defines an option to limit the number of

   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:

   o  version (2 bits): this field can be elided during a compresssion

   o  type (2 bits): defines the type of the transport messages, 4
      values are defined.  Regarding the type of exchange, if only NON
      messages are sent or CON/ACK messages, this field can be reduced
      to 0 or 1 bit.

   o  token length (4 bytes).  The standard allows up to 15 bytes for a
      token length.  If a fix token size is chosen, then this field can
      be elided.  If some variation in length are needed then 1 or 2
      bits could be enough for most of LPWAN applications.

   o  code (8 bits).  This field codes the request and the response
      values.  CoAP represents in a more compact way, coding used in
      HTTP, but the coding is not optimal.

   o  message id (16 bits).  This value is used to acknowledge CON
      frames.  The size of this field is computed to allow the
      anticipation (how many frames can be sent without
      acknowledgement).  When a value is used, [RFC7252] defines the
      time before it can be reused without ambiguities.  This size may

Minaburo & Toutain         Expires May 1, 2017                  [Page 3]

Internet-Draft           LPWAN CoAP compression             October 2016

      be too large for a LPWAN node sending or receiving few messages a

   o  Token (0 to 15 bytes).  Token identifies active flows.  Regarding
      the usage (stability of in time and limited number), a short token
      (1 Byte) can be enough.

   o  options are coded through delta-TLV.  The delta-T depends of
      previous values, length is encoded inside the option.  [RFC7252]
      distinguishes repeatable options that can appear several time in
      the header.  Among them we can distinguish:

      *  list options which appear several time in the header but are
         exclusive such as the Accept option.

      *  cumulative options which appear several time in the header but
         are part of a more generic value such as Uri-Path and Uri-

      For a given flow some value options are stable through time.
      Observe, ETag, If-Match, If-None-Match and Size varies in each
      message.  Options can be stored in a SCHC context and cumulative
      options can be stored globally.

   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.

Minaburo & Toutain         Expires May 1, 2017                  [Page 4]

Internet-Draft           LPWAN CoAP compression             October 2016  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

   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.

   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.

Minaburo & Toutain         Expires May 1, 2017                  [Page 5]

Internet-Draft           LPWAN CoAP compression             October 2016

               | 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

   This CDF can also be applied to path to send a reference instead of
   the path value.  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

Minaburo & Toutain         Expires May 1, 2017                  [Page 6]

Internet-Draft           LPWAN CoAP compression             October 2016

   will be lost, which can generate a traffic increase on the LPWA

   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.  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

2.2.2.  CoAP mandatory header

   Figure 2 proposes some function assignments to the CoAP header

Minaburo & Toutain         Expires May 1, 2017                  [Page 7]

Internet-Draft           LPWAN CoAP compression             October 2016

| 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

2.2.3.  Examples of CoAP header compression  Mandatory header with CON message

   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

Minaburo & Toutain         Expires May 1, 2017                  [Page 8]

Internet-Draft           LPWAN CoAP compression             October 2016

    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

   Figure 3 gives a simple compression rule for CoAP headers without

   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.

   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.

Minaburo & Toutain         Expires May 1, 2017                  [Page 9]

Internet-Draft           LPWAN CoAP compression             October 2016

                   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

   Note that the compressor and decompressor must understand the CoAP

   o  The LC compressor detects a new transport request and allocate a
      new dynamic mapping value.

   o  When receiving a response the ES compressor ES detects that this
      is a response (type=2) therefore the message ID value in

   o  The upstream compressor detects that is an REST answer (code 2.05)
      therefore the path option is not inserted in the uncompress header  Exchange 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

Minaburo & Toutain         Expires May 1, 2017                 [Page 10]

Internet-Draft           LPWAN CoAP compression             October 2016

  | 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

Minaburo & Toutain         Expires May 1, 2017                 [Page 11]

Internet-Draft           LPWAN CoAP compression             October 2016

                   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

3.  Normative References

              Minaburo, A. and L. Toutain, "LPWAN Static Context Header
              Compression (SCHC) for IPv6 and UDP", draft-toutain-lpwan-
              ipv6-static-context-hc-00 (work in progress), September

Minaburo & Toutain         Expires May 1, 2017                 [Page 12]

Internet-Draft           LPWAN CoAP compression             October 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, <http://www.rfc-editor.org/info/rfc3095>.

   [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., Ed. 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, <http://www.rfc-editor.org/info/rfc7967>.

Authors' Addresses

Minaburo & Toutain         Expires May 1, 2017                 [Page 13]

Internet-Draft           LPWAN CoAP compression             October 2016

   Ana Minaburo
   2bis rue de la Chataigneraie
   35510 Cesson-Sevigne Cedex

   Email: ana@ackl.io

   Laurent Toutain
   Institut MINES TELECOM ; TELECOM Bretagne
   2 rue de la Chataigneraie
   CS 17607
   35576 Cesson-Sevigne Cedex

   Email: Laurent.Toutain@telecom-bretagne.eu

Minaburo & Toutain         Expires May 1, 2017                 [Page 14]

Html markup produced by rfcmarkup 1.127, available from https://tools.ietf.org/tools/rfcmarkup/