RFC 8724

SCHC: Generic Framework for Static Context Header Compression and Fragmentation

๐Ÿ“… published April 2020, from ietf

SCHC: Generic Framework for Static Context Header Compression and Fragmentation ๐ŸŽ€

Part 1 of 16 ๐ŸŽ€

Bestie, here's the header tea โ˜•

  • Series: Internet Engineering Task Force (IETF)
  • RFC number: 8724
  • Category: Standards Track (this is a real, official Internet standard, so it's a big deal ๐Ÿ’…)
  • Date: April 2020
  • ISSN: 2070-1721
  • Authors: A. Minaburo (Acklio), L. Toutain (IMT Atlantique), C. Gomez (Universitat Politecnica de Catalunya), D. Barthel (Orange Labs), and JC. Zuniga (SIGFOX)
  • Obsoletes / Updates: the header doesn't list anything this RFC obsoletes or updates, so it's a fresh start ๐ŸŒธ

Abstract

okay so this document defines the Static Context Header Compression and fragmentation (SCHC) framework ๐Ÿฆ‹. It gives you two things: a header compression mechanism, and an optional fragmentation mechanism. SCHC was designed with Low-Power Wide Area Networks (LPWANs) in mind ๐Ÿ”‹.

SCHC compression runs on a common static context that's stored in both the LPWAN device and the network side โœจ. The document defines a generic header compression mechanism and shows how to use it to compress IPv6/UDP headers ๐Ÿ’œ.

It also specifies an optional fragmentation and reassembly mechanism. This can support the IPv6 MTU requirement over LPWAN technologies ๐ŸŒˆ. Fragmentation is needed for IPv6 datagrams that still exceed the Layer 2 maximum payload size after SCHC compression, or when compression wasn't possible at all ๐Ÿ˜ญ.

The SCHC header compression and fragmentation mechanisms don't depend on the specific LPWAN technology they run over ๐Ÿงš. This document only defines generic functionality, and it's flexible about parameter settings and mechanism choices. It standardizes the exchange over the LPWAN between two SCHC entities. Settings and choices that are specific to a technology or product are expected to be grouped into profiles, which are specified in other documents ๐Ÿ“ฆ. Data models for the context and profiles are out of scope ๐Ÿ™ˆ.


Status of This Memo

this is an Internet Standards Track document ๐Ÿ‘‘.

It's a product of the Internet Engineering Task Force (IETF), and it represents the consensus of the IETF community ๐Ÿซถ. It went through public review and was approved for publication by the Internet Engineering Steering Group (IESG). For more on Internet Standards, check Section 2 of RFC 7841 ๐Ÿ’–.

For the current status of this document, any errata, and how to give feedback, go to https://www.rfc-editor.org/info/rfc8724 โœจ.


Copyright (c) 2020 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 (https://trustee.ietf.org/license-info) in effect on the date it was published. Please read these carefully, because they describe your rights and restrictions for 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. They're provided without warranty, as described in the Simplified BSD License ๐Ÿ“.


Table of Contents ๐Ÿ—บ๏ธ

   1.  Introduction
   2.  Requirements Notation
   3.  LPWAN Architecture
   4.  Terminology
   5.  SCHC Overview
     5.1.  SCHC Packet Format
     5.2.  Functional Mapping
   6.  RuleID
   7.  Compression/Decompression
     7.1.  SCHC C/D Rules
     7.2.  Packet Processing
     7.3.  Matching Operators
     7.4.  Compression/Decompression Actions (CDA)
       7.4.1.  Processing Fixed-Length Fields
       7.4.2.  Processing Variable-Length Fields
       7.4.3.  Not-Sent CDA
       7.4.4.  Value-Sent CDA
       7.4.5.  Mapping-Sent CDA
       7.4.6.  LSB CDA
       7.4.7.  DevIID, AppIID CDA
       7.4.8.  Compute-*
   8.  Fragmentation/Reassembly
     8.1.  Overview
     8.2.  SCHC F/R Protocol Elements
       8.2.1.  Messages
       8.2.2.  Tiles, Windows, Bitmaps, Timers, Counters
       8.2.3.  Integrity Checking
       8.2.4.  Header Fields
     8.3.  SCHC F/R Message Formats
       8.3.1.  SCHC Fragment Format
       8.3.2.  SCHC ACK Format
       8.3.3.  SCHC ACK REQ Format
       8.3.4.  SCHC Sender-Abort Format
       8.3.5.  SCHC Receiver-Abort Format
     8.4.  SCHC F/R Modes
       8.4.1.  No-ACK Mode
       8.4.2.  ACK-Always Mode
       8.4.3.  ACK-on-Error Mode
   9.  Padding Management
   10. SCHC Compression for IPv6 and UDP Headers
     10.1.  IPv6 Version Field
     10.2.  IPv6 Traffic Class Field
     10.3.  Flow Label Field
     10.4.  Payload Length Field
     10.5.  Next Header Field
     10.6.  Hop Limit Field
     10.7.  IPv6 Addresses Fields
       10.7.1.  IPv6 Source and Destination Prefixes
       10.7.2.  IPv6 Source and Destination IID
     10.8.  IPv6 Extension Headers
     10.9.  UDP Source and Destination Ports
     10.10. UDP Length Field
     10.11. UDP Checksum Field
   11. IANA Considerations
   12. Security Considerations
     12.1.  Security Considerations for SCHC Compression/Decompression
       12.1.1.  Forged SCHC Packet
       12.1.2.  Compressed Packet Size as a Side Channel to Guess a
               Secret Token
       12.1.3.  Decompressed Packet Different from the Original Packet
     12.2.  Security Considerations for SCHC Fragmentation/Reassembly
       12.2.1.  Buffer Reservation Attack
       12.2.2.  Corrupt Fragment Attack
       12.2.3.  Fragmentation as a Way to Bypass Network Inspection
       12.2.4.  Privacy Issues Associated with SCHC Header Fields
   13. References
     13.1.  Normative References
     13.2.  Informative References
   Appendix A.  Compression Examples
   Appendix B.  Fragmentation Examples
   Appendix C.  Fragmentation State Machines
   Appendix D.  SCHC Parameters
   Appendix E.  Supporting Multiple Window Sizes for Fragmentation
   Appendix F.  ACK-Always and ACK-on-Error on Quasi-Bidirectional
           Links
   Acknowledgements
   Authors' Addresses

1. Introduction โœจ

okay so this document defines the Static Context Header Compression and fragmentation (SCHC) framework ๐Ÿฆ‹. It gives you a header compression mechanism plus an optional fragmentation mechanism. SCHC was designed with Low-Power Wide Area Networks (LPWANs) in mind ๐Ÿ”‹.

LPWAN technologies come with some strict limits on traffic ๐Ÿฅบ. For example, devices sleep most of the time, and they may only receive data for short windows right after transmitting, so the battery lasts ๐Ÿ”‹๐Ÿ’ค. LPWAN technologies are also known for a seriously reduced data unit and/or payload size (see [RFC8376]) ๐Ÿ™ˆ.

Header compression is needed for efficient Internet connectivity to a node inside an LPWAN ๐Ÿ’…. These properties of LPWANs can be exploited to get efficient header compression:

  • The network topology is star-oriented, which means all packets between the same source-destination pair follow the same path ๐ŸŒŸ. For this document's purposes, the architecture can simply be described as Devices (Dev) exchanging information with LPWAN Application Servers (Apps) through a Network Gateway (NGW) ๐Ÿงš.
  • Because devices have built-in applications, the traffic flows to be compressed are known in advance ๐Ÿ’–. New applications don't get installed on an LPWAN device nearly as often as they do on a general-purpose computer or smartphone ๐Ÿ“ฑ.

SCHC compression uses a Context (a set of Rules) where information about header fields is stored ๐Ÿ“š. This Context is static: the values of the header fields and the actions for compression/decompression don't change over time ๐ŸงŠ. That means no complicated resynchronization mechanisms are needed ๐Ÿ™Œ. A return path may be more restricted or expensive, or may sometimes be completely unavailable [RFC8376] ๐Ÿ˜ฌ. So a compression protocol that relies on feedback isn't compatible with these LPWAN characteristics ๐Ÿšซ.

In most cases, a small Rule identifier is enough to represent the full IPv6/UDP headers ๐ŸŽ€. The SCHC header compression mechanism doesn't depend on the specific LPWAN technology it's used over ๐Ÿ’œ.

Also, some LPWAN technologies don't offer a fragmentation functionality. To support the IPv6 MTU requirement of 1280 bytes [RFC8200], they need a fragmentation protocol at the adaptation layer below IPv6 ๐ŸŒˆ. So this document defines an optional fragmentation/reassembly mechanism to help LPWAN technologies meet the IPv6 MTU requirement ๐Ÿซถ.

This document defines generic functionality and is flexible about parameter settings and mechanism choices ๐Ÿ“. Technology-specific settings are expected to be grouped into Profiles specified in other documents ๐Ÿ“ฆ.


2. Requirements Notation ๐Ÿ“

Here's the rule for reading the requirement words, bestie ๐Ÿ‘‘. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here ๐Ÿ’….


3. LPWAN Architecture ๐Ÿ—๏ธ

LPWAN architectures are similar to each other, but every LPWAN technology names its architecture elements differently ๐Ÿ™ƒ. In this document, we use the terminology from [RFC8376], which identifies these entities in a typical LPWAN (see Figure 1) ๐Ÿฆ‹:

  • Devices (Dev) are the end-devices or hosts (for example, sensors, actuators, etc.) ๐ŸŒธ. There can be a very high density of devices per Radio Gateway ๐Ÿคฏ.
  • The Radio Gateway (RGW) is the endpoint of the constrained link ๐Ÿ”—.
  • The Network Gateway (NGW) is the interconnection node between the Radio Gateway and the Internet ๐ŸŒ.
  • The Application Server (App) is the endpoint of the application-level protocol on the Internet side ๐Ÿ’œ.
    ()   ()   ()       |
     ()  () () ()     / \       +---------+
   () () () () () () /   \======|    ^    |             +-----------+
    ()  ()   ()     |           | <--|--> |             |Application|
   ()  ()  ()  ()  / \==========|    v    |=============|   Server  |
     ()  ()  ()   /   \         +---------+             +-----------+
    Dev            RGWs             NGW                      App

Figure 1: LPWAN Architecture (Simplified from That Shown in RFC 8376) โœจ

4. Terminology โœจ

okay so this section is basically our shared vocab list, and it extends the terms from [RFC8376] ๐Ÿ’… Here's the squad:

The SCHC acronym is pronounced like "sheek" in English (or "chic" in French) ๐Ÿฆ‹ So this doc writes "a SCHC Packet" instead of "an SCHC Packet", because it's giving "a sheek packet" ๐Ÿ˜ญ

  • App: LPWAN Application Server, as defined by [RFC8376]. It's the one running an application that sends and receives packets to and from the Dev ๐Ÿ“ฑ
  • AppIID: Application Interface Identifier. The IID that identifies the App interface ๐ŸŽ€
  • Compression Residue: The bits that are left to send (beyond the RuleID itself) after SCHC compression has been applied โœจ
  • Context: A set of Rules used to compress/decompress headers, or to fragment/reassemble a packet ๐Ÿงš
  • Dev: Device, as defined by [RFC8376] ๐ŸŒธ
  • DevIID: Device Interface Identifier. The IID that identifies the Dev interface ๐Ÿ’œ
  • Downlink: From the App to the Dev โฌ‡๏ธ
  • IID: Interface Identifier. See the IPv6 addressing architecture [RFC7136] ๐Ÿซถ
  • L2: Layer 2. The immediate lower layer that SCHC interfaces with, for example an underlying LPWAN technology. It does not necessarily correspond to the OSI model definition of Layer 2 ๐Ÿ“
  • L2 Word: This is the minimum subdivision of payload data that the L2 will carry. In most L2 technologies, the L2 Word is an octet. In bit-oriented radio technologies, the L2 Word might be a single bit. The L2 Word size is assumed to be constant over time for each device ๐Ÿ”ฅ
  • Padding: Extra bits that may be appended by SCHC to a data unit that it passes down to L2 for transmission. SCHC itself operates on bits, not bytes, and does not have any alignment prerequisite. See Section 9 ๐ŸŒˆ
  • Profile: SCHC offers variations in the way it is operated, with a number of parameters listed in Appendix D. A Profile indicates a particular setting of all these parameters. Both ends of a SCHC communication must be provisioned with the same Profile information and with the same set of Rules before the communication starts, so that there is no ambiguity in how they expect to communicate ๐Ÿ‘‘
  • Rule: Part of the Context that describes how a packet is compressed/decompressed or fragmented/reassembled ๐Ÿ“œ
  • RuleID: Rule Identifier. An identifier for a Rule ๐Ÿท๏ธ
  • SCHC: Static Context Header Compression and fragmentation (SCHC), a generic framework โญ
  • SCHC C/D: SCHC Compressor/Decompressor, or SCHC Compression/Decompression. The SCHC entity or mechanism used on both sides, at the Dev and at the network, to achieve compression/decompression of headers ๐Ÿ—œ๏ธ
  • SCHC F/R: SCHC Fragmenter/Reassembler or SCHC Fragmentation/Reassembly. The SCHC entity or mechanism used on both sides, at the Dev and at the network, to achieve fragmentation/reassembly of SCHC Packets ๐Ÿงฉ
  • SCHC Packet: A packet (e.g., an IPv6 packet) whose header has been compressed as per the header compression mechanism defined in this document. If the header compression process is unable to actually compress the packet header, the packet with the uncompressed header is still called a SCHC Packet (in this case, a RuleID is used to indicate that the packet header has not been compressed). See Section 7 for more details ๐Ÿ’–
  • Uplink: From the Dev to the App โฌ†๏ธ

Additional terminology for the optional SCHC F/R is found in Section 8.2 ๐ŸŽ€

Additional terminology for SCHC C/D is found in Section 7.1 ๐Ÿฆ‹


5. SCHC Overview

okay the big picture: SCHC is an adaptation layer sitting between an upper layer (for example, IPv6) and an underlying layer (for example, an LPWAN technology) โœจ It's made of two sublayers, the Compression sublayer and the Fragmentation sublayer, as shown in Figure 2 ๐ŸŒธ

            +----------------+
            |      IPv6      |
         +- +----------------+
         |  |   Compression  |
   SCHC <   +----------------+
         |  |  Fragmentation |
         +- +----------------+
            |LPWAN technology|
            +----------------+

Figure 2: Example of Protocol Stack Comprising IPv6, SCHC, and an LPWAN Technology

Before an upper layer packet (e.g., an IPv6 packet) gets sent down to the underlying layer, header compression is tried first ๐Ÿ—œ๏ธ The result is called a "SCHC Packet", whether or not any compression actually happened ๐Ÿ’… If the underlying layer needs it, the optional SCHC fragmentation MAY be applied to the SCHC Packet ๐Ÿงฉ The receiver does the inverse operations. Figure 3 shows the whole flow ๐Ÿ‘‘

A packet (e.g., an IPv6 packet)
        |                                           ^
        v                                           |
+------------------+                      +--------------------+
| SCHC Compression |                      | SCHC Decompression |
+------------------+                      +--------------------+
        |                                           ^
        |   If no fragmentation (*)                 |
        +-------------- SCHC Packet  -------------->|
        |                                           |
        v                                           |
+--------------------+                       +-----------------+
| SCHC Fragmentation |                       | SCHC Reassembly |
+--------------------+                       +-----------------+
     |     ^                                     |     ^
     |     |                                     |     |
     |     +---------- SCHC ACK (+) -------------+     |
     |                                                 |
     +-------------- SCHC Fragments -------------------+

       Sender                                    Receiver

*: the decision not to use SCHC fragmentation is left to each Profile
+: optional, depends on Fragmentation mode

Figure 3: SCHC Operations at the Sender and the Receiver

5.1. SCHC Packet Format

okay so the SCHC Packet is the Compressed Header followed by the payload from the original packet (see Figure 4) โœจ The Compressed Header is made of the RuleID plus a Compression Residue, which is what you get when you compress the packet header with the Rule that the RuleID points to (see Section 7) ๐Ÿฆ‹ The Compression Residue may be empty, which is so valid ๐Ÿซถ Both the RuleID and the Compression Residue can be variable in size, and they don't have to be a multiple of bytes ๐ŸŒˆ

|------- Compressed Header -------|
+---------------------------------+--------------------+
|  RuleID  |  Compression Residue |      Payload       |
+---------------------------------+--------------------+

Figure 4: SCHC Packet

5.2. Functional Mapping

Figure 5 lines up the functional pieces from Figure 3 with the LPWAN architecture elements from Figure 1 ๐Ÿ—บ๏ธ

        Dev                                               App
+----------------+                               +----+ +----+ +----+
| App1 App2 App3 |                               |App1| |App2| |App3|
|                |                               |    | |    | |    |
|       UDP      |                               |UDP | |UDP | |UDP |
|      IPv6      |                               |IPv6| |IPv6| |IPv6|
|                |                               |    | |    | |    |
|SCHC C/D and F/R|                               |    | |    | |    |
+--------+-------+                               +----+ +----+ +----+
         |  +---+     +---+    +----+    +----+    .      .      .
         +~ |RGW| === |NGW| == |SCHC| == |SCHC|..... Internet ....
            +---+     +---+    |F/R |    |C/D |
                               +----+    +----+

Figure 5: Architectural Mapping

SCHC C/D and SCHC F/R live on both sides of the LPWAN transmission, which we'll call the "Dev side" and the "Network Infrastructure side" ๐Ÿ 

Uplink goes like this ๐Ÿš€ The Device application uses IPv6 or IPv6/UDP. Before sending, the Dev compresses the headers using SCHC C/D. If the resulting SCHC Packet needs to be fragmented by SCHC, SCHC F/R does that too (see Section 8) ๐Ÿงฉ The resulting SCHC Fragments go to an LPWAN Radio Gateway (RGW), which forwards them to a Network Gateway (NGW) ๐Ÿ“ก The NGW sends the data to a SCHC F/R for reassembly (if it's needed) and then to the SCHC C/D for decompression ๐Ÿ—œ๏ธ After decompression, the packet can go over the Internet to one or several Apps ๐Ÿ’Œ

The SCHC F/R and SCHC C/D on the Network Infrastructure side can be part of the NGW, or they can sit in the Internet, as long as a tunnel is set up between them and the NGW ๐ŸŒ For some LPWAN technologies, it may be a good idea to put the SCHC F/R functionality closer to the NGW, to better handle the time constraints of those technologies โฑ๏ธ

The SCHC C/Ds on both sides MUST share the same set of Rules. So MUST the SCHC F/Rs on both sides. ๐Ÿ”’โœจ

Downlink works the same way as Uplink, just with the order of the architecture elements reversed โฌ‡๏ธ๐ŸŽ€

6. RuleID ๐ŸŽ€

Okay so RuleIDs are basically the name tags for the Rules that do the compression/decompression or the fragmentation/reassembly. ๐Ÿท๏ธโœจ

The scope of a compression/decompression RuleID is the link between the SCHC C/D in a given Dev and its buddy, the SCHC C/D on the Network Infrastructure side. Same deal for fragmentation/reassembly RuleIDs, just with the SCHC F/R pair instead. And if that link goes both ways, the scope covers both directions. ๐Ÿฆ‹

RuleIDs belong to the Context of one specific Dev, so they're super local. That means multiple Dev instances, each with their own Context, MAY reuse the same RuleID for totally different Rules. Iconic, right? ๐Ÿ’…

Now the Network Infrastructure side has to figure out which Rule applies to Uplink traffic, so the SCHC C/D or SCHC F/R needs to link the RuleID to the Dev identifier. For Downlink traffic it's the other way around: the SCHC C/D or SCHC F/R on the Network Infrastructure side first has to find the destination Dev, and only then can it look for the right Rule (and its RuleID) inside that Dev's Context. It's like checking the guest list before you find the table ๐Ÿ“๐Ÿงš

Compression/decompression Rules and fragmentation/reassembly Rules share the same RuleID space, as long as they're inside the same scope. ๐ŸŒˆ

The size of RuleIDs isn't specified in this document. That's up to each implementation, and it can change depending on the LPWAN technology and how many Rules you've got, among other stuff. The size gets defined in Profiles. ๐Ÿ’œ

RuleIDs get used in two main ways:

  • For SCHC C/D, to identify the Rule that is used to compress a packet header. ๐Ÿซถ
    • At least one RuleID MUST be allocated to tagging packets for which SCHC compression was not possible (i.e., no matching compression Rule was found). This one is non-negotiable, bestie ๐Ÿ˜ญ
  • In SCHC F/R, to identify the specific mode and settings of fragmentation/reassembly for one direction of data traffic (Uplink or Downlink).
    • When SCHC F/R is used for both communication directions, at least two RuleID values are needed for fragmentation/reassembly: one per direction of data traffic. The reason is that fragmentation/reassembly may entail control messages flowing in the reverse direction compared to data traffic, so you can't just use one ID for both. ๐Ÿ”ฅ

7. Compression/Decompression ๐Ÿฆ‹

Compression with SCHC is all about a set of Rules, which together make up the Context of SCHC C/D. The Context is what lets you compress or decompress headers. ๐ŸŽ€

Here's the tea: SCHC skips the Context synchronization traffic that eats up so much bandwidth in other header compression schemes, like RObust Header Compression (RoHC) [RFC5795]. ngl, that's a huge W for LPWANs. Since packet content in LPWANs is super predictable, static Contexts can be stored ahead of time. โœจ

The Contexts MUST be stored at both ends. They can be learned through a provisioning protocol, through out-of-band means, or by pre-provisioning. How the Contexts get provisioned is out of the scope of this document, so that's a whole other story ๐Ÿ’…


7.1. SCHC C/D Rules ๐Ÿ’–

The big idea behind SCHC compression is that instead of sending known field values, you send the RuleID to the other end. That RuleID points to a Rule that matches the original packet values. So if both ends already know a value, all you need to send over the LPWAN is the RuleID. Lowkey genius ๐Ÿงš

How Rules get generated is out of the scope of this document. The Rules MAY be changed at run-time, but the mechanism for doing that is also out of scope. ๐ŸŒธ

The SCHC C/D Context is a set of Rules. Check out Figure 6 for a high-level, abstract view of the Context. The formal specification of how the Rules are represented is outside the scope of this document too. ๐Ÿซถ

     /-----------------------------------------------------------------\
     |                         Rule N                                  |
    /-----------------------------------------------------------------\|
    |                       Rule i                                    ||
   /-----------------------------------------------------------------\||
   |  (FID)            Rule 1                                        |||
   |+-------+--+--+--+------------+-----------------+---------------+|||
   ||Field 1|FL|FP|DI|Target Value|Matching Operator|Comp/Decomp Act||||
   |+-------+--+--+--+------------+-----------------+---------------+|||
   ||Field 2|FL|FP|DI|Target Value|Matching Operator|Comp/Decomp Act||||
   |+-------+--+--+--+------------+-----------------+---------------+|||
   ||...    |..|..|..|   ...      | ...             | ...           ||||
   |+-------+--+--+--+------------+-----------------+---------------+||/
   ||Field N|FL|FP|DI|Target Value|Matching Operator|Comp/Decomp Act|||
   |+-------+--+--+--+------------+-----------------+---------------+|/
   |                                                                 |
   \-----------------------------------------------------------------/

                        Figure 6: A SCHC C/D Context

Each Rule has a list of Field Descriptors. Every Field Descriptor is made of a Field Identifier (FID), a Field Length (FL), a Field Position (FP), a Direction Indicator (DI), a Target Value (TV), a Matching Operator (MO), and a Compression/Decompression Action (CDA). It's basically a little checklist for each header field ๐Ÿ“๐ŸŽ€

A Rule doesn't explain how the compressor parses a packet header to find and identify each field (like the IPv6 Source Address, the UDP Destination Port, or a CoAP URI path option). That's assumed to be handled by a protocol parser sitting next to SCHC, which can identify all the fields in the headers being compressed and label them with a Field ID. Rules only describe how each header field gets compressed or decompressed once it's been identified. Separation of concerns, slay ๐Ÿ‘‘

Inside a Rule, the Field Descriptors are listed in the same order the fields show up in the packet header. Each Field Descriptor uses these entries:

  • Field Identifier (FID) designates a protocol and field (e.g., UDP Destination Port), unambiguously among all protocols that a SCHC compressor processes. If there's protocol nesting, the Field ID also tells you what the nesting is. ๐Ÿช†
  • Field Length (FL) represents the length of the original field. It can be either a fixed value (in bits) if the length is known when the Rule is created, or a type if the length is variable. The length of a header field is defined by its own protocol specification (e.g., IPv6 or UDP). If the length is variable, the type defines the process to compute the length and its unit (bits, bytes...). ๐Ÿ“
  • Field Position (FP): most of the time, a field only shows up once in a packet header. But some fields can appear multiple times, like the uri-path of CoAP. FP tells you which occurrence this Field Descriptor applies to. The default value is 1, and the value 1 designates the first occurrence. The value 0 is special: it means "don't care", and you can read more about that in Section 7.2. ๐ŸŒŸ
  • A Direction Indicator (DI) tells you which packet direction(s) this Field Descriptor applies to. This lets you do asymmetric processing while using the same Rule. There are three possible values:
    • Up: this Field Descriptor is only applicable to packets traveling Uplink.
    • Dw: this Field Descriptor is only applicable to packets traveling Downlink.
    • Bi: this Field Descriptor is applicable to packets traveling Uplink or Downlink.
  • Target Value (TV) is the value used to match against the packet header field. It can be a scalar value of any type (integer, strings, etc.) or a more complex structure (array, list, etc.). The types and representations are out of scope for this document. ๐Ÿ’
  • Matching Operator (MO) is the operator used to match the field value and the Target Value. The Matching Operator may need some parameters. The set of MOs defined in this document can be found in Section 7.3. ๐Ÿ”
  • Compression/Decompression Action (CDA) describes the pair of actions performed at the compressor to compress a header field and at the decompressor to recover the original value of the header field. Some CDAs might use parameter values for their operation. The set of CDAs defined in this document can be found in Section 7.4. ๐Ÿ’ซ

7.2. Packet Processing โœจ

okay bestie, compression and decompression go through a few phases, and I'm obsessed with how they fit together ๐Ÿ’…

Compression Rule selection ๐Ÿ”: the big idea is to browse the Rule set and find a Rule with a matching Field Descriptor (given the DI and FP) for all and only the header fields that show up in the packet being compressed. The detailed algorithm goes like this:

  • Check the FIDs ๐Ÿ†”: If any header field of the packet being examined cannot be matched with a Field Descriptor with the correct FID, the Rule MUST be disregarded. If any Field Descriptor in the Rule has a FID that cannot be matched to one of the header fields of the packet being examined, the Rule MUST be disregarded.
  • Match by direction โžก๏ธโฌ…๏ธ: next, the Field Descriptors get matched by their direction, using the DI. If any field of the packet header cannot be matched with a Field Descriptor with the correct FID and DI, the Rule MUST be disregarded.
  • Narrow by FP ๐Ÿ“: then the Field Descriptors are further selected according to FP. If any field of the packet header cannot be matched with a Field Descriptor with the correct FID, DI and FP, the Rule MUST be disregarded.

FP=0 is "don't care" ๐Ÿซถ, which means the comparison of this Field Descriptor's FP with the position of the field being compressed returns True, no matter what that position is. It's super useful for protocol headers where the order of some fields doesn't matter, like uri-queries in CoAP. But be careful! Rules with FP=0 can lead to decompressed packets with fields in a different order than the original packet. ๐Ÿ˜ญ

  • Compare the values with MO ๐ŸŽฏ: once every header field has a Field Descriptor with matching FID, DI, and FP, each packet field's value gets compared to the matching TV stored in the Rule for that field, using the MO. If every field in the packet header satisfies its MO (so all the MO results are True), that Rule is valid for compressing the header. Otherwise, the Rule MUST be disregarded.

This spec doesn't stop multiple Rules from passing all those steps and being valid, so which one to use is up to the implementation ๐ŸŒธ. As long as the same Rule set is installed at both ends, that freedom doesn't cause an interoperability issue. Slay.

No valid Rule? ๐Ÿ™ˆ If no valid compression Rule is found, the packet MUST be sent uncompressed using the RuleID dedicated to this purpose (see Section 6). The entire packet header becomes the Compression Residue (see Figure 4). Sending an uncompressed header is likely to require SCHC F/R.

Compression ๐Ÿ—œ๏ธ: if a valid Rule is found, each header field gets compressed according to the CDAs of the Rule. The fields are compressed in the order the Field Descriptors appear in the Rule. Each field's compression gives a residue, and that residue might be empty. The Compression Residue for the packet header is all the non-empty residues glued together, in the order the Field Descriptors appear in the Rule. So the order of the Field Descriptors in the Rule is semantically important, no cap ๐Ÿ‘‘

       |------------------- Compression Residue -------------------|
       +-----------------+-----------------+-----+-----------------+
       | field 1 residue | field 2 residue | ... | field N residue |
       +-----------------+-----------------+-----+-----------------+

Figure 7: Compression Residue Structure

Sending ๐Ÿ“ฆ: the RuleID gets sent to the other end together with the Compression Residue (which could be empty) or the uncompressed header, and it's directly followed by the payload (see Figure 4). How the RuleID is sent gets specified in the Profile, and that's out of scope for this document. For example, it could be included in an L2 header or sent as part of the L2 payload. ๐ŸŽ€

Decompression ๐Ÿ”“: when decompressing on the Network Infrastructure side, the SCHC C/D needs to find the correct Rule based on the L2 address of the Dev. On the Dev side, only the RuleID is needed to find the right Rule, since the Dev usually only holds Rules that apply to itself. ๐Ÿงš

This Rule describes the compressed header format. From it, the decompressor figures out the order of the residues, whether each residue is fixed-size or variable-size (see Section 7.4.2), and the size of the fixed-size residues. ๐Ÿง 

So from the received compressed header, it can pull out all the residue values and match them to their header fields. โœจ

For each field in the header, the receiver applies the CDA action linked to that field to rebuild the original header field value. The CDA application order can be different from the order the fields are listed in the Rule. Compute-* MUST be applied after the CDAs of all the fields it computes on have been applied. Order matters, bestie ๐Ÿ’€


7.3. Matching Operators

MOs are functions used on the compression side of SCHC C/D. They aren't typed, so they can be applied to integers, strings, or any other data type. The result of an operation is either True or False. These are the MOs defined by this spec:

  • equal: The match result is True if the field value in the packet matches the TV. ๐Ÿ’–
  • ignore: No matching gets attempted between the field value in the packet and the TV in the Rule. The result is always True. ๐Ÿ™ˆ
  • MSB(x): A match happens if the most significant (leftmost) x bits of the packet header field value equal the TV in the Rule. The x parameter of the MSB MO says how many bits are compared. If the FL is described as variable, x has to be a multiple of the FL unit. For example, x has to be a multiple of 8 if the unit of the variable length is bytes. ๐Ÿ”ข
  • match-mapping: With match-mapping, TV is a list of values, and each value in the list gets an index. Compression works by sending the index instead of the original header field value. This operator matches if the header field value equals one of the values in the target list. ๐Ÿ—บ๏ธ

7.4. Compression/Decompression Actions (CDA)

The CDA says what happens to header fields during compression, and what the decompressor does to restore the original value. The CDAs defined by this document are covered in detail in Section 7.4.3 to Section 7.4.8. They're summarized in Table 1 ๐Ÿ‘‘

     +--------------+------------------------+-----------------------+
     | Action       | Compression            | Decompression         |
     +==============+========================+=======================+
     | not-sent     | elided                 | use TV stored in Rule |
     +--------------+------------------------+-----------------------+
     | value-sent   | send                   | use received value    |
     +--------------+------------------------+-----------------------+
     | mapping-sent | send index             | retrieve value from   |
     |              |                        | TV list               |
     +--------------+------------------------+-----------------------+
     | LSB          | send least significant | concatenate TV and    |
     |              | bits (LSB)             | received value        |
     +--------------+------------------------+-----------------------+
     | compute-*    | elided                 | recompute at          |
     |              |                        | decompressor          |
     +--------------+------------------------+-----------------------+
     | DevIID       | elided                 | build IID from L2 Dev |
     |              |                        | addr                  |
     +--------------+------------------------+-----------------------+
     | AppIID       | elided                 | build IID from L2 App |
     |              |                        | addr                  |
     +--------------+------------------------+-----------------------+

Table 1: Compression and Decompression Actions

The first column shows the action's name. The second and third columns show what the compression and decompression behaviors are for each action. ๐Ÿ“‹

7.4.1. Processing Fixed-Length Fields

If the Field Descriptor says the field has a fixed length, then applying the CDA to compress it results in a fixed number of bits. The residue for that field is just the bits that come out of applying the CDA to the field. This value may be empty (for example, with the not-sent CDA), and in that case the field residue is left out of the Compression Residue. ๐ŸŒท

   |- field residue -|
   +-----------------+
   |      value      |
   +-----------------+

Figure 8: Fixed-Size Field Residue Structure

7.4.2. Processing Variable-Length Fields

If the Field Descriptor says the field has a variable length, then applying the CDA to compress it might give a value of fixed size (for example, with not-sent or mapping-sent) or a value of variable size (for example, with value-sent or LSB). In the variable-size case, the residue for that field is the bits from applying the CDA to the field, with the size of the value placed in front. The most significant bit of the size is stored on the left (the leftmost bit of the residue field). ๐Ÿง

   |--- field residue ---|
   +-------+-------------+
   |  size |    value    |
   +-------+-------------+

Figure 9: Variable-Size Field Residue Structure

The size (in the unit defined by the FL) gets encoded on 4, 12, or 28 bits like this:

  • If the size is between 0 and 14, it's encoded as a 4-bit unsigned integer.
  • Sizes between 15 and 254 are encoded as 0b1111 followed by the 8-bit unsigned integer.
  • Larger sizes are encoded as 0xfff followed by the 16-bit unsigned integer.

If the Field Descriptor says the field has a variable length and that field isn't present in the packet header being compressed, size 0 MUST be sent to show that it's absent. ๐Ÿ™…โ€โ™€๏ธ

7.4.3. Not-Sent CDA

The not-sent action can be used when the field value is specified in a Rule, which means both the Compressor and the Decompressor already know it. This action SHOULD be used with the "equal" MO. If MO is "ignore", there's a risk of ending up with a decompressed field value that's different from the original field that got compressed. ๐Ÿ˜ฌ

The compressor doesn't send any residue for a field where not-sent compression is applied. ๐Ÿค

The decompressor restores the field value using the TV stored in the matched Rule, identified by the received RuleID. ๐ŸŽฏ

7.4.4. Value-Sent CDA

The value-sent action can be used when the field value isn't known by both the Compressor and the Decompressor. The field gets sent in its entirety, using the same bit order as in the original packet header. ๐Ÿ“จ

If this action is used on a variable-length field, the size of the residue value (in the units defined in FL) MUST be sent as described in Section 7.4.2. ๐Ÿ”ข

This action is generally used with the "ignore" MO. ๐Ÿซถ

7.4.5. Mapping-Sent CDA ๐Ÿฆ‹

okay so mapping-sent is giving "send the number, not the whole thing" ๐Ÿ’… It sends an index (the position in the TV list of values) instead of the original value. This action is used together with the "match-mapping" MO.

On the compressor side, the match-mapping MO searches the TV for a match with the header field value. Then mapping-sent sends the matching index as the field residue. The most significant bit of the index goes on the left, so it's the leftmost bit of the residue field โœจ

On the decompressor side, the CDA takes the received index and looks it up in the TV list to get the field value back ๐Ÿซถ

The number of bits sent is the minimal size for coding all the possible indices. So just enough bits to fit every index, nothing extra ๐Ÿ™ˆ

The first element in the list MUST be represented by index value 0, and successive elements in the list MUST have indices incremented by 1. Strict rules, bestie ๐Ÿ”ฅ

7.4.6. LSB CDA ๐Ÿ’œ

The LSB action is used together with the "MSB(x)" MO to skip sending the most significant part of the packet field when the receiving end already knows that part ๐Ÿง 

The compressor sends the LSBs as the field residue value. The number of bits sent is the original header field length minus the length specified in the MSB(x) MO. The bits show up in the residue in the same bit order as in the original packet header.

The decompressor concatenates the x most significant bits of the TV and the received residue value. Put them together and boom, full field โœจ

If this action is performed on a variable-length field, the size of the residue value (using the units defined in FL) MUST be sent as described in Section 7.4.2. Don't skip this one, it's important ๐Ÿ’–

7.4.7. DevIID, AppIID CDA ๐ŸŒˆ

These actions are used to process the DevIID and AppIID of the IPv6 addresses, respectively. AppIID CDA is less common since most current LPWAN technologies frames contain a single L2 address, which is the Dev's address. So the DevIID is the main character here ๐Ÿ‘‘

The DevIID value MAY be computed from the Dev ID present in the L2 header, or from some other stable identifier. The computation is specific to each Profile and MAY depend on the Dev ID size. It depends on the Profile, babe ๐Ÿซถ

In the Downlink direction, at the compressor, the DevIID CDA may be used to generate the L2 addresses on the LPWAN, based on the packet's Destination Address. Reverse engineering the address, iconic ๐Ÿฆ‹

7.4.8. Compute-* ๐Ÿงš

Some fields can be elided at the compressor and recomputed locally at the decompressor. So the sender doesn't even bother sending them, the receiver just works it out ๐Ÿ’…

Because the field is uniquely identified by its FID (e.g., IPv6 length), the relevant protocol specification unambiguously defines the algorithm for such computation. No guessing, the spec tells you exactly how ๐Ÿ”ฅ

An example of a field that knows how to recompute itself is IPv6 length. It literally does its own math ๐Ÿงฎ๐Ÿ’–

8. Fragmentation/Reassembly โœจ

8.1. Overview ๐ŸŒธ

In LPWAN technologies, the L2 MTU typically ranges from tens to hundreds of bytes. Some of these technologies do not have an internal fragmentation/reassembly mechanism, so SCHC has to step in ๐Ÿฆ‹

The optional SCHC F/R functionality enables such LPWAN technologies to comply with the IPv6 MTU requirement of 1280 bytes [RFC8200]. It is OPTIONAL to implement per this specification, but Profiles may specify that it is REQUIRED. So it's optional for now, but a Profile can make it mandatory ๐Ÿ‘‘

This specification includes several SCHC F/R modes, which allow for a range of reliability options such as optional SCHC Fragment retransmission. More modes may be defined in the future ๐ŸŒˆ

The same SCHC F/R mode MUST be used for all SCHC Fragments of a given SCHC Packet. One mode per packet, no switching mid-flight ๐Ÿ’… This document does not specify which mode(s) must be implemented and used over a specific LPWAN technology. That information will be given in Profiles ๐Ÿซถ

SCHC allows transmitting non-fragmented SCHC Packet concurrently with fragmented SCHC Packets. In addition, SCHC F/R provides protocol elements that allow transmitting several fragmented SCHC Packets concurrently, i.e., interleaving the transmission of fragments from different fragmented SCHC Packets. A Profile MAY restrict the latter behavior. Multitasking queen ๐Ÿงš

The L2 Word size (see Section 4) determines the encoding of some messages. SCHC F/R usually generates SCHC Fragments and SCHC ACKs that are multiples of L2 Words ๐Ÿ’œ

8.2. SCHC F/R Protocol Elements ๐Ÿฆ‹

This subsection describes the different elements that are used to enable the SCHC F/R functionality defined in this document. These elements include the SCHC F/R messages, tiles, windows, bitmaps, counters, timers, and header fields. It's the cast list for the whole fragmentation show ๐ŸŽ€

The elements are described here in a generic manner. Their application to each SCHC F/R mode is found in Section 8.4.

8.2.1. Messages ๐Ÿ’Œ

SCHC F/R defines the following messages:

  • SCHC Fragment: A message that carries part of a SCHC Packet from the sender to the receiver.
  • SCHC ACK: An acknowledgement for fragmentation, by the receiver to the sender. This message is used to indicate whether or not the reception of pieces of, or the whole of, the fragmented SCHC Packet was successful.
  • SCHC ACK REQ: A request by the sender for a SCHC ACK from the receiver.
  • SCHC Sender-Abort: A message by the sender telling the receiver that it has aborted the transmission of a fragmented SCHC Packet.
  • SCHC Receiver-Abort: A message by the receiver to tell the sender to abort the transmission of a fragmented SCHC Packet.

The format of these messages is provided in Section 8.3 ๐Ÿ“ฆ

8.2.2. Tiles, Windows, Bitmaps, Timers, Counters ๐Ÿงฉ

8.2.2.1. Tiles ๐Ÿ“

The SCHC Packet is fragmented into pieces, hereafter called "tiles". The tiles MUST be non-empty and pairwise disjoint. Their union MUST be equal to the SCHC Packet. So no empty tiles, no overlaps, and they add up to the whole packet, no cap ๐Ÿ’ฏ

See Figure 10 for an example.

                                   SCHC Packet
           +----+--+-----+---+----+-+---+-----+...-----+----+---+------+
   Tiles   |    |  |     |   |    | |   |     |        |    |   |      |
           +----+--+-----+---+----+-+---+-----+...-----+----+---+------+

                 Figure 10: SCHC Packet Fragmented in Tiles

Modes (see Section 8.4) MAY place additional constraints on tile sizes. Each mode can be extra about it ๐Ÿ™„

Each SCHC Fragment message carries at least one tile in its Payload, if the Payload field is present.

8.2.2.2. Windows ๐ŸชŸ

Some SCHC F/R modes may handle successive tiles in groups, called windows. Think of it like tiles stacked into little boxes ๐Ÿ“ฆ

If windows are used:

  • all the windows of a SCHC Packet, except the last one, MUST contain the same number of tiles. This number is WINDOW_SIZE.
  • WINDOW_SIZE MUST be specified in a Profile.
  • the windows are numbered.
  • their numbers MUST increment by 1 from 0 upward, from the start of the SCHC Packet to its end.
  • the last window MUST contain WINDOW_SIZE tiles or less.
  • tiles are numbered within each window.
  • the tile indices MUST decrement by 1 from WINDOW_SIZE - 1 downward, looking from the start of the SCHC Packet toward its end.
  • therefore, each tile of a SCHC Packet is uniquely identified by a window number and a tile index within this window.

See Figure 11 for an example.

        +---------------------------------------------...-----------+
        |                       SCHC Packet                         |
        +---------------------------------------------...-----------+

Tile#   | 4 | 3 | 2 | 1 | 0 | 4 | 3 | 2 | 1 | 0 | 4 |     | 0 | 4 |3|
Window# |-------- 0 --------|-------- 1 --------|- 2  ... 27 -|- 28-|

  Figure 11: SCHC Packet Fragmented in Tiles Grouped in 29 Windows,
                         with WINDOW_SIZE = 5

Appendix E discusses the benefits of selecting one among multiple window sizes depending on the size of the SCHC Packet to be fragmented. Pick your window size wisely ๐ŸŽ€

When windows are used:

  • Bitmaps (see Section 8.2.2.3) MAY be sent back by the receiver to the sender in a SCHC ACK message.
  • A Bitmap corresponds to exactly one Window.

8.2.2.3. Bitmaps ๐Ÿงพ

Each bit in the Bitmap for a window corresponds to a tile in the window. Therefore, each Bitmap has WINDOW_SIZE bits. The bit at the leftmost position corresponds to the tile numbered WINDOW_SIZE - 1. Consecutive bits, going right, correspond to sequentially decreasing tile indices. In Bitmaps for windows that are not the last one of a SCHC Packet, the bit at the rightmost position corresponds to the tile numbered 0. In the Bitmap for the last window, the bit at the rightmost position corresponds either to the tile numbered 0 or to a tile that is sent/received as "the last one of the SCHC Packet" without explicitly stating its number (see Section 8.3.1.2). It's a lot of bit-counting, but you've got this ๐Ÿง 

At the receiver:

  • a bit set to 1 in the Bitmap indicates that a tile associated with that bit position has been correctly received for that window. โœ…
  • a bit set to 0 in the Bitmap indicates that there has been no tile correctly received, associated with that bit position, for that window. Possible reasons include that the tile was not sent at all, not received, or received with errors. Could be a lot of reasons, honestly ๐Ÿ’€

8.2.2.4. Timers and Counters โฐ

Some SCHC F/R modes can use the following timers and counters:

  • Inactivity Timer: a SCHC Fragment receiver uses this timer to abort waiting for a SCHC F/R message.
  • Retransmission Timer: a SCHC Fragment sender uses this timer to abort waiting for an expected SCHC ACK.
  • Attempts: this counter counts the requests for SCHC ACKs, up to MAX_ACK_REQUESTS.

8.2.3. Integrity Checking ๐Ÿ”

The integrity of the fragmentation-reassembly process of a SCHC Packet MUST be checked at the receive end. A Profile MUST specify how integrity checking is performed. Checking is not optional, periodt ๐Ÿ’…

It is RECOMMENDED that integrity checking be performed by computing a Reassembly Check Sequence (RCS) based on the SCHC Packet at the sender side and transmitting it to the receiver for comparison with the RCS locally computed after reassembly. The receiver does its own math and compares notes ๐Ÿงฎ

The RCS supports UDP checksum elision by SCHC C/D (see Section 10.11). So the RCS can cover for the UDP checksum, which is a whole mood โœจ

The CRC32 polynomial 0xEDB88320 (i.e., the reversed polynomial representation, which is used in the Ethernet standard [ETHERNET]) is RECOMMENDED as the default algorithm for computing the RCS. Same polynomial as Ethernet, classic move ๐ŸŒˆ

The RCS MUST be computed on the full SCHC Packet concatenated with the padding bits, if any, of the SCHC Fragment carrying the last tile. The rationale is that the SCHC reassembler has no way of knowing the boundary between the last tile and the padding bits. Indeed, this requires decompressing the SCHC Packet, which is out of the scope of the SCHC reassembler. The reassembler isn't allowed to peek inside, so it just takes everything ๐Ÿ™ˆ

The concatenation of the complete SCHC Packet and any padding bits, if present, of the last SCHC Fragment does not generally constitute an integer number of bytes. CRC libraries are usually byte oriented. It is RECOMMENDED that the concatenation of the complete SCHC Packet and any last fragment padding bits be zero-extended to the next byte boundary and that the RCS be computed on that byte array. Bits don't fit neatly into bytes, so we pad it out and then do the math ๐Ÿ’–

8.2.4. Header Fields โœจ

Okay bestie, the SCHC F/R messages carry a bunch of fields, and the formats in Section 8.3 are where they all live ๐Ÿ’…

  • RuleID ๐Ÿ‘‘: this one is in literally every SCHC F/R message. The Rule tells the receiver:
    • that a SCHC F/R message is being carried, as opposed to an unfragmented SCHC Packet,
    • which SCHC F/R mode is being used,
    • in case this mode uses windows, what the value of WINDOW_SIZE is, and
    • what other optional fields are present and what the field sizes are.

The Rule tells apart a non-fragmented SCHC Packet from SCHC Fragments. It also tells apart SCHC Fragments of fragmented SCHC Packets that use different SCHC F/R modes or different parameters, so interleaved transmission of these is possible ๐Ÿฆ‹

All SCHC F/R messages pertaining to the same SCHC Packet MUST bear the same RuleID.

  • Datagram Tag (DTag) ๐ŸŽ€: this field lets you tell apart SCHC F/R messages from different SCHC Packets that might be using the same RuleID at the same time. So you can interleave fragments of a new SCHC Packet with fragments of an older one under the same RuleID. Iconic ๐Ÿ˜ญ

The size of the DTag field (called "T", in bits) is defined by each Profile for each RuleID. When T is 0, the DTag field does not appear in the SCHC F/R messages and the DTag value is defined as 0.

When T is 0, there can be no more than one fragmented SCHC Packet in transit for each fragmentation RuleID.

If T is not 0, DTag:

  • MUST be set to the same value for all the SCHC F/R messages related to the same fragmented SCHC Packet, and
  • MUST be set to different values for SCHC F/R messages related to different SCHC Packets that are being fragmented under the same RuleID and whose transmission may overlap.
  • W ๐ŸŒธ: the W field is optional. It is only present if windows are used. Its presence and size (called "M", in bits) is defined by each SCHC F/R mode and each Profile for each RuleID.

This field carries information about the window a SCHC F/R message relates to. If it's present, W MUST carry the same value for all the SCHC F/R messages related to the same window. Depending on the mode and Profile, W may carry the full window number, or just the LSB or some other partial representation of the window number.

  • Fragment Compressed Number (FCN) ๐Ÿงš: the FCN field is in the SCHC Fragment Header. Its size (called "N", in bits) is defined by each Profile for each RuleID.

This field tells you how far along the sequence of tiles is, based on the SCHC Fragment messages being sent. For example, it can hold a partial, efficient version of a bigger tile index. How exactly the FCN field gets used is left up to each SCHC F/R mode. Two values are reserved for special jobs, though, and they help run the SCHC F/R process:

  • The FCN value with all the bits equal to 1 (called "All-1") signals that the very last tile of a SCHC Packet has been transmitted. By extension, if windows are used, the last window of a packet is called the "All-1" window.
  • If windows are used, the FCN value with all the bits equal to 0 (called "All-0") signals the last tile of a window that is not the last one of the SCHC packet. By extension, such a window is called an "All-0 window".
  • Reassembly Check Sequence (RCS) ๐Ÿ’…: this field only shows up in the All-1 SCHC Fragments. Its size (called "U", in bits) is defined by each Profile for each RuleID.

See Section 8.2.3 for the RCS default size, default polynomial, and details on how RCS is computed.

  • C (integrity Check) ๐Ÿ”ฅ: C is a 1-bit field. It's used in the SCHC ACK message to report on the integrity check of the reassembled SCHC Packet (see Section 8.2.3).

A value of 1 means the integrity check was performed and was successful. A value of 0 means the integrity check was not performed, or it failed. ๐Ÿ’€

  • Compressed Bitmap ๐Ÿ“: the Compressed Bitmap goes together with windows and Bitmaps (see Section 8.2.2.3). Its presence and size are defined for each SCHC F/R mode for each RuleID.

This field shows up in the SCHC ACK message to report on the receiver Bitmap (see Section 8.3.2.1).


8.3. SCHC F/R Message Formats ๐Ÿ’Œ

This section defines the SCHC Fragment formats, the SCHC ACK format, the SCHC ACK REQ format, and the SCHC Abort formats.

8.3.1. SCHC Fragment Format

A SCHC Fragment follows the general format shown in Figure 12. It has a SCHC Fragment Header and a SCHC Fragment Payload. The SCHC Fragment Payload carries one or several tile(s).

   +-----------------+-----------------------+~~~~~~~~~~~~~~~~~~~~~
   | Fragment Header | Fragment Payload      | padding (as needed)
   +-----------------+-----------------------+~~~~~~~~~~~~~~~~~~~~~

Figure 12: SCHC Fragment General Format

8.3.1.1. Regular SCHC Fragment

The Regular SCHC Fragment format is shown in Figure 13. Regular SCHC Fragments are generally used to carry tiles that are not the last one of a SCHC Packet. The DTag field and the W field are OPTIONAL, and their presence is specified by each mode and Profile. ๐Ÿฉท

   |-- SCHC Fragment Header ----|
            |-- T --|-M-|-- N --|
   +-- ... -+- ... -+---+- ... -+--------...-------+~~~~~~~~~~~~~~~~~~~~
   | RuleID | DTag  | W |  FCN  | Fragment Payload | padding (as needed)
   +-- ... -+- ... -+---+- ... -+--------...-------+~~~~~~~~~~~~~~~~~~~~

Figure 13: Detailed Header Format for Regular SCHC Fragments

The FCN field MUST NOT contain all bits set to 1.

Profiles MUST ensure that a SCHC Fragment with FCN equal to 0 (called an "All-0 SCHC Fragment") is distinguishable by size, even in the presence of padding, from a SCHC ACK REQ message (see Section 8.3.3) with the same RuleID value and with the same T, M, and N values. This condition is met if the Payload is at least the size of an L2 Word. This condition is also met if the SCHC Fragment Header is a multiple of L2 Words. ๐Ÿง 

8.3.1.2. All-1 SCHC Fragment

The All-1 SCHC Fragment format is shown in Figure 14. The sender uses the All-1 SCHC Fragment format for the message that completes the emission of a fragmented SCHC Packet. The DTag field, the W field, the RCS field, and the Payload are OPTIONAL, and their presence is specified by each mode and Profile. At least one of RCS field or Fragment Payload MUST be present. The FCN field is all ones. โœจ

   |------- SCHC Fragment Header -------|
            |-- T --|-M-|-- N --|-- U --|
   +-- ... -+- ... -+---+- ... -+- ... -+-----...-----+~~~~~~~~~~~~~~~~~
   | RuleID | DTag  | W | 11..1 |  RCS  | FragPayload | pad. (as needed)
   +-- ... -+- ... -+---+- ... -+- ... -+-----...-----+~~~~~~~~~~~~~~~~~
                          (FCN)

Figure 14: Detailed Header Format for the All-1 SCHC Fragment

Profiles MUST ensure that an All-1 SCHC Fragment message is distinguishable by size, even in the presence of padding, from a SCHC Sender-Abort message (see Section 8.3.4) with the same RuleID value and with the same T, M, and N values. This condition is met if the RCS is present and is at least the size of an L2 Word, or if the Payload is present and is at least the size of an L2 Word. This condition is also met if the SCHC Sender-Abort Header is a multiple of L2 Words. ๐ŸŒˆ

8.3.2. SCHC ACK Format

The SCHC ACK message is shown in Figure 15. The DTag field and the W field are OPTIONAL, and their presence is specified by each mode and Profile. The Compressed Bitmap field MUST be present in SCHC F/R modes that use windows, and MUST NOT be present in other modes. ๐Ÿซถ

   |--- SCHC ACK Header ----|
            |-- T --|-M| 1 |
   +-- ... -+- ... -+---+---+~~~~~~~~~~~~~~~~~~
   | RuleID |  DTag | W |C=1| padding as needed                (success)
   +-- ... -+- ... -+---+---+~~~~~~~~~~~~~~~~~~

   +-- ... -+- ... -+---+---+------ ... ------+~~~~~~~~~~~~~~~
   | RuleID |  DTag | W |C=0|Compressed Bitmap| pad. as needed (failure)
   +-- ... -+- ... -+---+---+------ ... ------+~~~~~~~~~~~~~~~

Figure 15: Format of the SCHC ACK Message

The SCHC ACK Header contains a C bit (see Section 8.2.4).

If the C bit is set to 1 (integrity check successful), no Bitmap is carried.

If the C bit is set to 0 (integrity check not performed or failed) and if windows are used, a Compressed Bitmap for the window referred to by the W field is transmitted as specified in Section 8.3.2.1.

8.3.2.1. Bitmap Compression ๐Ÿซถ

okay so this is where we shrink the SCHC ACK bitmap, and it's giving packing-my-suitcase energy ๐Ÿงณโœจ For transmission, the Compressed Bitmap in the SCHC ACK message is defined by the following algorithm (see Figure 16 for a follow-along example) ๐Ÿ’…:

  • Build a temporary SCHC ACK message that contains the Header followed by the original Bitmap (see Section 8.2.2.3 for a description of Bitmaps) ๐ŸŒธ.
  • Position scissors at the end of the Bitmap, after its last bit โœ‚๏ธ.
  • While the bit on the left of the scissors is 1 and belongs to the Bitmap, keep moving left, then stop ๐Ÿฆ‹.
  • Then, while the scissors are not on an L2 Word boundary of the SCHC ACK message and there is a Bitmap bit on the right of the scissors, keep moving right, then stop ๐Ÿ’–.
  • At this point, cut and drop off any bits to the right of the scissors โœจ.

When one or more bits have effectively been dropped off as a result of the above algorithm, the SCHC ACK message is a multiple of L2 Words; no padding bits will be appended ๐ŸŽ€. Literally no padding, bestie ๐Ÿ™ˆ.

Because the SCHC Fragment sender knows the size of the original Bitmap, it can reconstruct the original Bitmap from the Compressed Bitmap received in the SCHC ACK message ๐Ÿงš.

Figure 16 shows an example where L2 Words are actually bytes and where the original Bitmap contains 17 bits, the last 15 of which are all set to 1 ๐ŸŒˆ.

   |--- SCHC ACK Header ----|--------      Bitmap     --------|
            |-- T --|-M-| 1 |
   +-- ... -+- ... -+---+---+---------------------------------+
   | RuleID |  DTag | W |C=0|1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1|
   +-- ... -+- ... -+---+---+---------------------------------+
          next L2 Word boundary ->|

            Figure 16: SCHC ACK Header Plus Uncompressed Bitmap

Figure 17 shows that the last 14 bits are not sent ๐Ÿ‘‘.

   |--- SCHC ACK Header ----|CpBmp|
            |-- T --|-M-| 1 |
   +-- ... -+- ... -+---+---+-----+
   | RuleID |  DTag | W |C=0|1 0 1|
   +-- ... -+- ... -+---+---+-----+
          next L2 Word boundary ->|

        Figure 17: Resulting SCHC ACK Message with Compressed Bitmap

Figure 18 shows an example of a SCHC ACK with tile indices ranging from 6 down to 0, where the Bitmap indicates that the second and the fourth tile of the window have not been correctly received ๐Ÿ“.

   |--- SCHC ACK Header ----|--- Bitmap --|
            |-- T --|-M-| 1 |6 5 4 3 2 1 0| (tile #)
   +--------+-------+---+---+-------------+
   | RuleID |  DTag | W |C=0|1 0 1 0 1 1 1|     uncompressed Bitmap
   +--------+-------+---+---+-------------+
      next L2 Word boundary ->|<-- L2 Word --->|

   +--------+-------+---+---+-------------+~~~~+
   | RuleID |  DTag | W |C=0|1 0 1 0 1 1 1|pad.| transmitted SCHC ACK
   +--------+-------+---+---+-------------+~~~~+
      next L2 Word boundary ->|<-- L2 Word --->|

          Figure 18: Example of a SCHC ACK Message, Missing Tiles

Figure 19 shows an example of a SCHC ACK with tile indices ranging from 6 down to 0, where integrity check has not been performed or has failed and the Bitmap indicates that there is no missing tile in that window ๐Ÿ”ฅ.

   |--- SCHC ACK Header ----|--- Bitmap --|
            |-- T --|-M-| 1 |6 5 4 3 2 1 0| (tile #)
   +--------+-------+---+---+-------------+
   | RuleID |  DTag | W |C=0|1 1 1 1 1 1 1|  with uncompressed Bitmap
   +--------+-------+---+---+-------------+
      next L2 Word boundary ->|

   +-- ... -+- ... -+---+---+-+
   | RuleID |  DTag | W |C=0|1|                  transmitted SCHC ACK
   +-- ... -+- ... -+---+---+-+
      next L2 Word boundary ->|

         Figure 19: Example of a SCHC ACK Message, No Missing Tile

8.3.3. SCHC ACK REQ Format ๐Ÿ™‹โ€โ™€๏ธ

okay so the SCHC ACK REQ is how a sender asks the receiver for a SCHC ACK ๐Ÿ’Œ. Its format is shown in Figure 20 ๐Ÿฆ‹. The DTag field and the W field are OPTIONAL, their presence is specified by each mode and Profile ๐ŸŒท. The FCN field is all zero ๐Ÿผ.

   |--- SCHC ACK REQ Header ----|
            |-- T --|-M-|-- N --|
   +-- ... -+- ... -+---+- ... -+~~~~~~~~~~~~~~~~~~~~~
   | RuleID | DTag  | W |  0..0 | padding (as needed)      (no payload)
   +-- ... -+- ... -+---+- ... -+~~~~~~~~~~~~~~~~~~~~~

                       Figure 20: SCHC ACK REQ Format

8.3.4. SCHC Sender-Abort Format ๐Ÿšจ

okay so when a SCHC Fragment sender needs to bail on a fragmented SCHC Packet transmission, it sends a SCHC Sender-Abort message to the SCHC Fragment receiver ๐Ÿซฃ.

The SCHC Sender-Abort format is shown in Figure 21 ๐Ÿ’œ. The DTag field and the W field are OPTIONAL, their presence is specified by each mode and Profile ๐ŸŒธ. The FCN field is all ones โœจ.

   |--- Sender-Abort Header ----|
            |-- T --|-M-|-- N --|
   +-- ... -+- ... -+---+- ... -+~~~~~~~~~~~~~~~~~~~~~
   | RuleID | DTag  | W | 11..1 | padding (as needed)
   +-- ... -+- ... -+---+- ... -+~~~~~~~~~~~~~~~~~~~~~

                    Figure 21: SCHC Sender-Abort Format

If the W field is present:

  • the fragment sender MUST set it to all ones. Other values are RESERVED ๐Ÿ“.
  • the fragment receiver MUST check its value. If the value is different from all ones, the message MUST be ignored ๐Ÿ™ˆ.

The SCHC Sender-Abort MUST NOT be acknowledged ๐Ÿ›‘.


8.3.5. SCHC Receiver-Abort Format ๐Ÿงฏ

okay so when a SCHC Fragment receiver needs to abort an ongoing fragmented SCHC Packet transmission, it transmits a SCHC Receiver-Abort message to the SCHC Fragment sender ๐Ÿ’….

The SCHC Receiver-Abort format is shown in Figure 22 ๐ŸŽ€. The DTag field and the W field are OPTIONAL, their presence is specified by each mode and Profile ๐ŸŒผ.

   |-- Receiver-Abort Header ---|
              |--- T ---|-M-| 1 |
   +--- ... --+-- ... --+---+---+-+-+-+-+-+-+-+-+-+-+-+
   |  RuleID  |   DTag  | W |C=1| 1..1|      1..1     |
   +--- ... --+-- ... --+---+---+-+-+-+-+-+-+-+-+-+-+-+
              next L2 Word boundary ->|<-- L2 Word -->|

                   Figure 22: SCHC Receiver-Abort Format

If the W field is present:

  • the fragment receiver MUST set it to all ones. Other values are RESERVED ๐Ÿซถ.
  • if the value is different from all ones, the fragment sender MUST ignore the message ๐ŸŒˆ.

The SCHC Receiver-Abort has the same header as a SCHC ACK message. The bits that follow the SCHC Receiver-Abort Header MUST be as follows ๐Ÿง:

  • if the Header does not end at an L2 Word boundary, append bits set to 1 as needed to reach the next L2 Word boundary.
  • append exactly one more L2 Word with bits all set to ones.

Such a bit pattern never occurs in a legitimate SCHC ACK. This is how the fragment sender recognizes a SCHC Receiver-Abort โœจ.

The SCHC Receiver-Abort MUST NOT be acknowledged ๐Ÿšซ.


8.4. SCHC F/R Modes ๐ŸŒˆ

okay so this spec includes several SCHC F/R modes that:

  • allow for a range of reliability options, such as optional SCHC Fragment retransmission ๐Ÿ’–.
  • support various LPWAN characteristics, such as links with variable MTU or unidirectional links ๐Ÿ›ฐ๏ธ.

More modes may be defined in the future ๐Ÿ”ฎ.

Appendix B provides examples of fragmentation sessions based on the modes described hereafter ๐Ÿ“š.

Appendix C provides examples of Finite State Machines implementing the SCHC F/R modes described hereafter ๐Ÿง .


8.4.1. No-ACK Mode ๐Ÿ™…โ€โ™€๏ธ

okay so No-ACK mode was designed under the assumption that data unit out-of-sequence delivery does not occur between the entity performing fragmentation and the entity performing reassembly ๐Ÿ™ˆ. This mode supports L2 technologies that have a variable MTU ๐ŸŒธ.

In No-ACK mode, there is no communication from the fragment receiver to the fragment sender ๐Ÿค. The sender transmits all the SCHC Fragments without expecting any acknowledgement ๐Ÿ’Œ. Therefore, No-ACK does not require bidirectional links: unidirectional links are just fine ๐Ÿ›ธโœจ.

In No-ACK mode, only the All-1 SCHC Fragment is padded as needed. The other SCHC Fragments are intrinsically aligned to L2 Words ๐ŸŽ€.

The tile sizes are not required to be uniform. Windows are not used. The Retransmission Timer is not used. The Attempts counter is not used ๐Ÿงšโ€โ™€๏ธ.

Each Profile MUST specify which RuleID value(s) corresponds to SCHC F/R messages operating in this mode ๐Ÿ‘‘.

The W field MUST NOT be present in the SCHC F/R messages. SCHC ACK MUST NOT be sent. SCHC ACK REQ MUST NOT be sent. SCHC Sender-Abort MAY be sent. SCHC Receiver-Abort MUST NOT be sent ๐Ÿ’….

The value of N (size of the FCN field) is RECOMMENDED to be 1 ๐Ÿฆ‹.

Each Profile, for each RuleID value, MUST define:

  • the size of the DTag field,
  • the size and algorithm for the RCS field, and
  • the expiration time of the Inactivity Timer.

Each Profile, for each RuleID value, MAY define

  • a value of N different from the recommended one, and
  • the meaning of values sent in the FCN field, for values different from the All-1 value.

For each active pair of RuleID and DTag values, the receiver MUST maintain an Inactivity Timer. If the receiver is under-resourced to do this, it MUST silently drop the related messages ๐Ÿซ .


8.4.1.1. Sender Behavior ๐Ÿ“ค

At the beginning of the fragmentation of a new SCHC Packet, the fragment sender MUST select a RuleID and DTag value pair for this SCHC Packet ๐ŸŽฏ.

Each SCHC Fragment MUST contain exactly one tile in its Payload. The tile MUST be at least the size of an L2 Word. The sender MUST transmit the SCHC Fragments messages in the order that the tiles appear in the SCHC Packet ๐Ÿผ. Except for the last tile of a SCHC Packet, each tile MUST be of a size that complements the SCHC Fragment Header so that the SCHC Fragment is a multiple of L2 Words without the need for padding bits ๐Ÿงฉ. Except for the last one, the SCHC Fragments MUST use the Regular SCHC Fragment format specified in Section 8.3.1.1. The SCHC Fragment that carries the last tile MUST be an All-1 SCHC Fragment, described in Section 8.3.1.2 ๐Ÿ.

The sender MAY transmit a SCHC Sender-Abort ๐Ÿ™‹โ€โ™€๏ธ.

Figure 39 shows an example of a corresponding state machine ๐Ÿ—บ๏ธ.


8.4.1.2. Receiver Behavior ๐Ÿ“ฅ

Upon receiving each Regular SCHC Fragment:

  • the receiver MUST reset the Inactivity Timer.
  • the receiver assembles the payloads of the SCHC Fragments.

On receiving an All-1 SCHC Fragment:

  • the receiver MUST append the All-1 SCHC Fragment Payload and the padding bits to the previously received SCHC Fragment Payloads for this SCHC Packet.
  • the receiver MUST perform the integrity check.
  • if integrity checking fails, the receiver MUST drop the reassembled SCHC Packet.
  • the reassembly operation concludes.

On expiration of the Inactivity Timer, the receiver MUST drop the SCHC Packet being reassembled.

On receiving a SCHC Sender-Abort, the receiver MAY drop the SCHC Packet being reassembled.

Figure 40 shows an example of a corresponding state machine ๐ŸŒท.

8.4.2. ACK-Always Mode โœจ

okay bestie, ACK-Always mode is giving reliable, lock-step energy ๐Ÿ’– It's built on three assumptions:

  • Data unit out-of-sequence delivery does not occur between the entity performing fragmentation and the entity performing reassembly,
  • The L2 MTU value does not change while the fragments of a SCHC Packet are being transmitted, and
  • There is a feedback path from the reassembler to the fragmenter. See Appendix F for a discussion on using ACK-Always mode on quasi-bidirectional links ๐Ÿฆ‹

In ACK-Always mode, everything happens in windows ๐ŸชŸ The fragment receiver sends an acknowledgement to the fragment sender at the end of each window of SCHC Fragments. It can be positive or negative, so it's always clear what's going on ๐Ÿซถ

The tiles don't have to be the same size ๐ŸŽ€ In ACK-Always mode, only the All-1 SCHC Fragment gets padded when needed. The other SCHC Fragments are already lined up with L2 Words, so they're naturally aligned โœจ

Here's the basic idea ๐Ÿงš After a first blind transmission of all the tiles in a window, the fragment sender keeps retransmitting whichever tiles are reported missing. This goes on until the fragment receiver says every tile in the window has arrived correctly, or until too many attempts have been made ๐Ÿ˜ญ The sender only moves on to the next window once it knows every tile in the current window was fully and correctly received. That's a per-window lock-step between the sender and the receiver, and honestly iconic ๐Ÿ‘‘

Each Profile MUST specify which RuleID value(s) correspond to SCHC F/R messages operating in this mode.

The W field MUST be present and its size M MUST be 1 bit.

Each Profile, for each RuleID value, MUST define:

  • the value of N,
  • the value of WINDOW_SIZE, which MUST be strictly less than 2^N,
  • the size and algorithm for the RCS field,
  • the value of T,
  • the value of MAX_ACK_REQUESTS,
  • the expiration time of the Retransmission Timer, and
  • the expiration time of the Inactivity Timer.

For each active pair of RuleID and DTag values, the sender MUST maintain:

  • one Attempts counter
  • one Retransmission Timer

For each active pair of RuleID and DTag values, the receiver MUST maintain:

  • one Inactivity Timer, and
  • one Attempts counter.

8.4.2.1. Sender Behavior ๐Ÿ’…

At the beginning of the fragmentation of a new SCHC Packet, the fragment sender MUST select a RuleID and DTag value pair for this SCHC Packet.

Each SCHC Fragment MUST contain exactly one tile in its Payload. All tiles with the index 0, as well as the last tile, MUST be at least the size of an L2 Word ๐Ÿ“

In all SCHC Fragment messages, the W field MUST be filled with the LSB of the window number that the sender is currently processing.

For a SCHC Fragment that carries a tile other than the last one of the SCHC Packet:

  • the Fragment MUST be of the Regular type specified in Section 8.3.1.1.
  • the FCN field MUST contain the tile index.
  • each tile MUST be of a size that complements the SCHC Fragment Header so that the SCHC Fragment is a multiple of L2 Words without the need for padding bits.

The SCHC Fragment that carries the last tile MUST be an All-1 SCHC Fragment, described in Section 8.3.1.2 ๐ŸŒˆ

The fragment sender MUST start by transmitting the window numbered 0 ๐Ÿ”ฅ

All message receptions being discussed in the rest of this section are to be understood as "matching the RuleID and DTag pair being processed", even if not spelled out, for brevity. (Shorthand, but we all know what we mean ๐Ÿ™ˆ)

The sender starts with a "blind transmission" phase, in which it MUST transmit all the tiles composing the window, in decreasing tile index order ๐Ÿฆ‹

Then it enters a "retransmission phase" ๐Ÿ’œ in which it MUST initialize an Attempts counter to 0, it MUST start a Retransmission Timer, and it MUST await a SCHC ACK.

  • Then, upon receiving a SCHC ACK:
    • if the SCHC ACK indicates that some tiles are missing at the receiver, then the sender MUST transmit all the tiles that have been reported missing, it MUST increment Attempts, it MUST reset the Retransmission Timer, and MUST await the next SCHC ACK.
    • if the current window is not the last one and the SCHC ACK indicates that all tiles were correctly received, the sender MUST stop the Retransmission Timer, it MUST advance to the next fragmentation window, and it MUST start a blind transmission phase as described above โœจ
    • if the current window is the last one and the SCHC ACK indicates that more tiles were received than the sender sent, the fragment sender MUST send a SCHC Sender-Abort, and it MAY exit with an error condition ๐Ÿ’€
    • if the current window is the last one and the SCHC ACK indicates that all tiles were correctly received, yet the integrity check was a failure, the fragment sender MUST send a SCHC Sender-Abort, and it MAY exit with an error condition ๐Ÿ˜ญ
    • if the current window is the last one and the SCHC ACK indicates that integrity checking was successful, the sender exits successfully ๐Ÿ‘‘
  • on Retransmission Timer expiration:
    • if Attempts is strictly less than MAX_ACK_REQUESTS, the fragment sender MUST send a SCHC ACK REQ and MUST increment the Attempts counter.
    • otherwise, the fragment sender MUST send a SCHC Sender-Abort, and it MAY exit with an error condition.

At any time:

  • on receiving a SCHC Receiver-Abort, the fragment sender MAY exit with an error condition.
  • on receiving a SCHC ACK that bears a W value different from the W value that it currently uses, the fragment sender MUST silently discard and ignore that SCHC ACK ๐Ÿ™ˆ

Figure 41 shows an example of a corresponding state machine ๐Ÿงš

8.4.2.2. Receiver Behavior โœจ

okay so now we're on the receiver's side ๐Ÿซถ When a SCHC Fragment shows up with a RuleID and DTag pair that isn't being processed right now:

  • the receiver SHOULD check that the DTag value hasn't recently been used for that RuleID value, so the fragment isn't a leftover from an older fragmented SCHC Packet transmission ๐Ÿ‘€ The initial value of the Inactivity Timer is the RECOMMENDED lifetime for the DTag value at the receiver. If the fragment turns out to be a leftover, the receiver MAY quietly ignore it and drop it.
  • the receiver MUST start a process to assemble a new SCHC Packet with that RuleID and DTag value pair.
  • the receiver MUST start an Inactivity Timer for that RuleID and DTag pair. It MUST initialize an Attempts counter to 0 for that RuleID and DTag pair. It MUST initialize a window counter to 0. If the receiver is under-resourced to do this, it MUST respond to the sender with a SCHC Receiver-Abort. ๐Ÿ˜ฌ

In the rest of this section, "local W bit" means the least significant bit of the window counter of the receiver. ๐ŸŽ€

On reception of any SCHC F/R message for the RuleID and DTag pair being processed, the receiver MUST reset the Inactivity Timer pertaining to that RuleID and DTag pair. โฐ

All message receptions being discussed in the rest of this section are to be understood as "matching the RuleID and DTag pair being processed", even if not spelled out, for brevity. (we're not typing that every time, bestie ๐Ÿ’…)

The receiver MUST first initialize an empty Bitmap for the first window, then enter an "acceptance phase", in which:

  • on receiving a SCHC Fragment or a SCHC ACK REQ, either one having the W bit different from the local W bit, the receiver MUST silently ignore and discard that message. ๐Ÿ™ˆ
  • on receiving a SCHC ACK REQ with the W bit equal to the local W bit, the receiver MUST send a SCHC ACK for this window.
  • on receiving a SCHC Fragment with the W bit equal to the local W bit, the receiver MUST assemble the received tile based on the window counter and on the FCN field in the SCHC Fragment, and it MUST update the Bitmap.
    • if the SCHC Fragment received is an All-0 SCHC Fragment, the current window is determined to be a not-last window, the receiver MUST send a SCHC ACK for this window, and it MUST enter the "retransmission phase" for this window.
    • if the SCHC Fragment received is an All-1 SCHC Fragment, the current window is determined to be the last window, the padding bits of the All-1 SCHC Fragment MUST be assembled after the received tile, the receiver MUST perform the integrity check, and it MUST send a SCHC ACK for this window. Then:
      • If the integrity check indicates that the full SCHC Packet has been correctly reassembled, the receiver MUST enter the "clean-up phase" for this window. ๐Ÿฅณ
      • If the integrity check indicates that the full SCHC Packet has not been correctly reassembled, the receiver enters the "retransmission phase" for this window.

In the "retransmission phase":

  • if the window is a not-last window:
    • on receiving a SCHC Fragment that is not All-0 or All-1 and that has a W bit different from the local W bit, the receiver MUST increment its window counter and allocate a fresh Bitmap, it MUST assemble the tile received and update the Bitmap, and it MUST enter the "acceptance phase" for that new window.
    • on receiving a SCHC ACK REQ with a W bit different from the local W bit, the receiver MUST increment its window counter and allocate a fresh Bitmap, it MUST send a SCHC ACK for that new window, and it MUST enter the "acceptance phase" for that new window.
    • on receiving a SCHC All-0 Fragment with a W bit different from the local W bit, the receiver MUST increment its window counter and allocate a fresh Bitmap, it MUST assemble the tile received and update the Bitmap, it MUST send a SCHC ACK for that new window, and it MUST stay in the "retransmission phase" for that new window.
    • on receiving a SCHC All-1 Fragment with a W bit different from the local W bit, the receiver MUST increment its window counter and allocate a fresh Bitmap; it MUST assemble the tile received, including the padding bits; it MUST update the Bitmap and perform the integrity check; it MUST send a SCHC ACK for the new window, which is determined to be the last window. Then:
      • If the integrity check indicates that the full SCHC Packet has been correctly reassembled, the receiver MUST enter the "clean-up phase" for that new window.
      • If the integrity check indicates that the full SCHC Packet has not been correctly reassembled, the receiver enters the "retransmission phase" for that new window.
    • on receiving a SCHC Fragment with a W bit equal to the local W bit:
      • if the SCHC Fragment received is an All-1 SCHC Fragment, the receiver MUST silently ignore it and discard it.
      • otherwise, the receiver MUST assemble the tile received and update the Bitmap. If the Bitmap becomes fully populated with 1's or if the SCHC Fragment is an All-0, the receiver MUST send a SCHC ACK for this window. ๐Ÿ“ฆ
    • on receiving a SCHC ACK REQ with the W bit equal to the local W bit, the receiver MUST send a SCHC ACK for this window.
  • if the window is the last window:
    • on receiving a SCHC Fragment or a SCHC ACK REQ, either one having a W bit different from the local W bit, the receiver MUST silently ignore and discard that message.
    • on receiving a SCHC ACK REQ with the W bit equal to the local W bit, the receiver MUST send a SCHC ACK for this window.
    • on receiving a SCHC Fragment with a W bit equal to the local W bit:
      • if the SCHC Fragment received is an All-0 SCHC Fragment, the receiver MUST silently ignore it and discard it.
      • otherwise, the receiver MUST update the Bitmap, and it MUST assemble the tile received. If the SCHC Fragment received is an All-1 SCHC Fragment, the receiver MUST assemble the padding bits of the All-1 SCHC Fragment after the received tile, it MUST perform the integrity check, and:
        • if the integrity check indicates that the full SCHC Packet has been correctly reassembled, the receiver MUST send a SCHC ACK, and it enters the "clean-up phase".
        • if the integrity check indicates that the full SCHC Packet has not been correctly reassembled:
          • if the SCHC Fragment received was an All-1 SCHC Fragment, the receiver MUST send a SCHC ACK for this window.

In the "clean-up phase":

  • On receiving an All-1 SCHC Fragment or a SCHC ACK REQ, either one having the W bit equal to the local W bit, the receiver MUST send a SCHC ACK. ๐Ÿงน
  • Any other SCHC Fragment received MUST be silently ignored and discarded.

At any time, on sending a SCHC ACK, the receiver MUST increment the Attempts counter.

At any time, on incrementing its window counter, the receiver MUST reset the Attempts counter.

At any time, on expiration of the Inactivity Timer, on receiving a SCHC Sender-Abort, or when Attempts reaches MAX_ACK_REQUESTS, the receiver MUST send a SCHC Receiver-Abort, and it MAY exit the receive process for that SCHC Packet. ๐Ÿšช

Figure 42 shows an example of a corresponding state machine. ๐Ÿฆ‹


8.4.3. ACK-on-Error Mode ๐Ÿ’œ

The ACK-on-Error mode supports L2 technologies that have variable MTU and out-of-order delivery. It requires an L2 that provides a feedback path from the reassembler to the fragmenter. See Appendix F for a discussion on using ACK-on-Error mode on quasi-bidirectional links. ๐ŸŒˆ

In ACK-on-Error mode, windows are used. ๐ŸชŸ

All tiles except the last one and the penultimate one MUST be of equal size, hereafter called "regular". The size of the last tile MUST be smaller than or equal to the regular tile size. Regarding the penultimate tile, a Profile MUST pick one of the following two options:

  • The penultimate tile size MUST be the regular tile size, or
  • the penultimate tile size MUST be either the regular tile size or the regular tile size minus one L2 Word.

A SCHC Fragment message carries one or several contiguous tiles, which may span multiple windows. A SCHC ACK reports on the reception of exactly one window of tiles.

See Figure 23 for an example. ๐Ÿ‘€

        +---------------------------------------------...-----------+
        |                       SCHC Packet                         |
        +---------------------------------------------...-----------+

Tile#   | 4 | 3 | 2 | 1 | 0 | 4 | 3 | 2 | 1 | 0 | 4 |     | 0 | 4 |3|
Window# |-------- 0 --------|-------- 1 --------|- 2  ... 27 -|- 28-|


SCHC Fragment msg   |-----------|

Figure 23: SCHC Packet Fragmented in Tiles, ACK-on-Error Mode

The W field is wide enough that it unambiguously represents an absolute window number. The fragment receiver sends SCHC ACKs to the fragment sender about windows for which tiles are missing. No SCHC ACK is sent by the fragment receiver for windows that it knows have been fully received. ๐Ÿ“ฌ

The fragment sender retransmits SCHC Fragments for tiles that are reported missing. It can advance to next windows even before it has ascertained that all tiles belonging to previous windows have been correctly received, and it can still later retransmit SCHC Fragments with tiles belonging to previous windows. Therefore, the sender and the receiver may operate in a decoupled fashion. The fragmented SCHC Packet transmission concludes when:

  • integrity checking shows that the fragmented SCHC Packet has been correctly reassembled at the receive end, and this information has been conveyed back to the sender, or
  • too many retransmission attempts were made, or
  • the receiver determines that the transmission of this fragmented SCHC Packet has been inactive for too long.

Each Profile MUST specify which RuleID value(s) corresponds to SCHC F/R messages operating in this mode.

The W field MUST be present in the SCHC F/R messages.

Each Profile, for each RuleID value, MUST define:

  • the tile size (a tile does not need to be multiple of an L2 Word, but it MUST be at least the size of an L2 Word),
  • the value of M,
  • the value of N,
  • the value of WINDOW_SIZE, which MUST be strictly less than 2^N,
  • the size and algorithm for the RCS field,
  • the value of T,
  • the value of MAX_ACK_REQUESTS,
  • the expiration time of the Retransmission Timer,
  • the expiration time of the Inactivity Timer,
  • if the last tile is carried in a Regular SCHC Fragment or an All-1 SCHC Fragment (see Section 8.4.3.1), and
  • if the penultimate tile MAY be one L2 Word smaller than the regular tile size. In this case, the regular tile size MUST be at least twice the L2 Word size.

For each active pair of RuleID and DTag values, the sender MUST maintain:

  • one Attempts counter, and
  • one Retransmission Timer.

For each active pair of RuleID and DTag values, the receiver MUST maintain:

  • one Inactivity Timer, and
  • one Attempts counter.

8.4.3.1. Sender Behavior โœจ

Okay so, at the very start of fragmenting a brand new SCHC Packet ๐ŸŽ€:

  • the fragment sender MUST select a RuleID and DTag value pair for this SCHC Packet. A Rule MUST NOT be selected if the values of M and WINDOW_SIZE for that Rule are such that the SCHC Packet cannot be fragmented in (2^M) * WINDOW_SIZE tiles or less.
  • the fragment sender MUST initialize the Attempts counter to 0 for that RuleID and DTag value pair.

A Regular SCHC Fragment message carries one or more tiles in its payload ๐Ÿ“ฆ. If more than one tile rides in a single Regular SCHC Fragment:

  • the selected tiles MUST be contiguous in the original SCHC Packet, and
  • they MUST be placed in the SCHC Fragment Payload right next to each other, in the same order they show up in the SCHC Packet, going from the start of the SCHC Packet toward its end.

Tiles that aren't the last one MUST be sent in Regular SCHC Fragments specified in Section 8.3.1.1. The FCN field MUST contain the tile index of the first tile sent in that SCHC Fragment. ๐Ÿงš

In a Regular SCHC Fragment message, the sender MUST fill the W field with the window number of the first tile sent in that SCHC Fragment.

A Profile MUST define if the last tile of a SCHC Packet is sent:

  • in a Regular SCHC Fragment, alone or as part of a multi-tiles Payload,
  • alone in an All-1 SCHC Fragment, or
  • with any of the above two methods.

In an All-1 SCHC Fragment message, the sender MUST fill the W field with the window number of the last tile of the SCHC Packet. ๐Ÿ’–

The fragment sender MUST send SCHC Fragments such that, all together, they contain all the tiles of the fragmented SCHC Packet. No tile left behind, bestie ๐Ÿซถ

The fragment sender MUST send at least one All-1 SCHC Fragment.

In doing the two items above, the sender MUST ascertain that the receiver will not receive the last tile through both a Regular SCHC Fragment and an All-1 SCHC Fragment. Don't double-send the last tile, babe ๐Ÿ’€

The fragment sender MUST listen for SCHC ACK messages after having sent:

  • an All-1 SCHC Fragment, or
  • a SCHC ACK REQ.

A Profile MAY specify other times at which the fragment sender MUST listen for SCHC ACK messages. For example, this could be after sending a complete window of tiles. ๐ŸŒธ

Each time a fragment sender sends an All-1 SCHC Fragment or a SCHC ACK REQ:

  • it MUST increment the Attempts counter, and
  • it MUST reset the Retransmission Timer.

On Retransmission Timer expiration:

  • if the Attempts counter is strictly less than MAX_ACK_REQUESTS, the fragment sender MUST send either the All-1 SCHC Fragment or a SCHC ACK REQ with the W field corresponding to the last window,
  • otherwise, the fragment sender MUST send a SCHC Sender-Abort, and it MAY exit with an error condition. Times up, we're out ๐Ÿ˜ญ

All message receptions being discussed in the rest of this section are to be understood as "matching the RuleID and DTag pair being processed", even if not spelled out, for brevity. โœจ

On receiving a SCHC ACK:

  • if the W field in the SCHC ACK corresponds to the last window of the SCHC Packet:
    • if the C bit is set, the sender MAY exit successfully. ๐Ÿ‘‘
    • otherwise:
      • if the Profile mandates that the last tile be sent in an All-1 SCHC Fragment:
        • if the SCHC ACK shows no missing tile at the receiver, the sender:
          • MUST send a SCHC Sender-Abort, and
          • MAY exit with an error condition.
        • otherwise:
          • the fragment sender MUST send SCHC Fragment messages containing all the tiles that are reported missing in the SCHC ACK.
          • if the last of these SCHC Fragment messages is not an All-1 SCHC Fragment, then the fragment sender MUST in addition send after it a SCHC ACK REQ with the W field corresponding to the last window.
          • in doing the two items above, the sender MUST ascertain that the receiver will not receive the last tile through both a Regular SCHC Fragment and an All-1 SCHC Fragment.
      • otherwise:
        • if the SCHC ACK shows no missing tile at the receiver, the sender MUST send the All-1 SCHC Fragment
        • otherwise:
          • the fragment sender MUST send SCHC Fragment messages containing all the tiles that are reported missing in the SCHC ACK.
          • the fragment sender MUST then send either the All-1 SCHC Fragment or a SCHC ACK REQ with the W field corresponding to the last window.
  • otherwise, the fragment sender:
    • MUST send SCHC Fragment messages containing the tiles that are reported missing in the SCHC ACK.
    • then, it MAY send a SCHC ACK REQ with the W field corresponding to the last window.

See Figure 43 for one among several possible examples of a Finite State Machine implementing a sender behavior obeying this specification. ๐Ÿฆ‹

8.4.3.2. Receiver Behavior ๐ŸŒˆ

On receiving a SCHC Fragment with a RuleID and DTag pair not being processed at that time, the receiver is doing detective work ๐Ÿ•ต๏ธโ€โ™€๏ธ:

  • the receiver SHOULD check if the DTag value has not recently been used for that RuleID value, which makes sure the received SCHC Fragment isn't a leftover remnant from an earlier fragmented SCHC Packet transmission. The initial value of the Inactivity Timer is the RECOMMENDED lifetime for the DTag value at the receiver. If the SCHC Fragment turns out to be such a remnant, the receiver MAY silently ignore it and discard it. ๐Ÿ™ˆ
  • the receiver MUST start a process to assemble a new SCHC Packet with that RuleID and DTag value pair. The receiver MUST start an Inactivity Timer for that RuleID and DTag value pair. It MUST initialize an Attempts counter to 0 for that RuleID and DTag value pair. If the receiver is under-resourced to do this, it MUST respond to the sender with a SCHC Receiver-Abort.

On reception of any SCHC F/R message for the RuleID and DTag pair being processed, the receiver MUST reset the Inactivity Timer pertaining to that RuleID and DTag pair. โฐ

All message receptions being discussed in the rest of this section are to be understood as "matching the RuleID and DTag pair being processed", even if not spelled out, for brevity.

On receiving a SCHC Fragment message, the receiver figures out which tiles arrived, based on the payload length and on the W and FCN fields of the SCHC Fragment ๐Ÿ”.

  • if the FCN is All-1, if a Payload is present, the full SCHC Fragment Payload MUST be assembled including the padding bits. This is because the size of the last tile is not known by the receiver; therefore, padding bits are indistinguishable from the tile data bits, at this stage. They will be removed by the SCHC C/D sublayer. If the size of the SCHC Fragment Payload exceeds or equals the size of one regular tile plus the size of an L2 Word, this SHOULD raise an error flag. ๐Ÿšฉ
  • otherwise, tiles MUST be assembled based on the a priori known tile size.
    • If allowed by the Profile, the end of the payload MAY contain the last tile, which may be shorter. Padding bits are indistinguishable from the tile data bits, at this stage.
    • The payload may contain the penultimate tile that, if allowed by the Profile, MAY be exactly one L2 Word shorter than the regular tile size.
    • Otherwise, padding bits MUST be discarded. This is possible because:
      • the size of the tiles is known a priori,
      • tiles are larger than an L2 Word, and
      • padding bits are always strictly less than an L2 Word.

On receiving a SCHC ACK REQ or an All-1 SCHC Fragment:

  • if the receiver knows of any windows with missing tiles for the packet being reassembled, it MUST return a SCHC ACK for the lowest-numbered such window:
  • otherwise:
    • if it has received at least one tile, it MUST return a SCHC ACK for the highest-numbered window it currently has tiles for,
    • otherwise, it MUST return a SCHC ACK for window numbered 0.

A Profile MAY specify other times and circumstances at which a receiver sends a SCHC ACK, and which window the SCHC ACK reports about in these circumstances. ๐Ÿ’…

Upon sending a SCHC ACK, the receiver MUST increase the Attempts counter.

After receiving an All-1 SCHC Fragment, a receiver MUST check the integrity of the reassembled SCHC Packet at least every time it prepares for sending a SCHC ACK for the last window. ๐Ÿง

Upon receiving a SCHC Sender-Abort, the receiver MAY exit with an error condition.

Upon expiration of the Inactivity Timer, the receiver MUST send a SCHC Receiver-Abort, and it MAY exit with an error condition.

On the Attempts counter exceeding MAX_ACK_REQUESTS, the receiver MUST send a SCHC Receiver-Abort, and it MAY exit with an error condition. ๐Ÿ’€

Reassembly of the SCHC Packet concludes when:

  • a Sender-Abort has been received, or
  • the Inactivity Timer has expired, or
  • the Attempts counter has exceeded MAX_ACK_REQUESTS, or
  • at least an All-1 SCHC Fragment has been received and integrity checking of the reassembled SCHC Packet is successful. Main quest complete ๐Ÿ‘‘๐ŸŽ€

See Figure 44 for one among several possible examples of a Finite State Machine implementing a receiver behavior obeying this specification. The example provided is meant to match the sender Finite State Machine of Figure 43. ๐Ÿฆ‹

9. Padding Management โœจ

okay so SCHC C/D and SCHC F/R work on bits, not bytes ๐Ÿซถ SCHC itself has zero alignment prerequisites, so a SCHC Packet can be any number of bits, bestie ๐Ÿฆ‹

BUT if your L2 wants everything lined up on coarser boundaries (like bytes), the SCHC messages MUST be padded ๐Ÿ™ˆ and when padding happens, the number of appended bits MUST be strictly less than the L2 Word size. no cap, that's the rule ๐Ÿ’…

If a SCHC Packet goes out unfragmented (see Figure 24), it gets padded as needed for transmission ๐ŸŽ€

If a SCHC Packet needs fragmenting, the packet itself is NOT padded. only the SCHC F/R messages get padded as needed, and some of them are already intrinsically aligned to L2 Words, so they're literally already lined up โœจ

   A packet (e.g., an IPv6 packet)
            |                                           ^ (padding bits
            v                                           |       dropped)
   +------------------+                      +--------------------+
   | SCHC Compression |                      | SCHC Decompression |
   +------------------+                      +--------------------+
            |                                           ^
            |   If no fragmentation,                    |
            +---- SCHC Packet + padding as needed ----->|
            |                                           | (integrity
            v                                           |  checked)
   +--------------------+                       +-----------------+
   | SCHC Fragmentation |                       | SCHC Reassembly |
   +--------------------+                       +-----------------+
        |       ^                                   |       ^
        |       |                                   |       |
        |       +--- SCHC ACK + padding as needed --+       |
        |                                                   |
        +------- SCHC Fragments + padding as needed---------+

           Sender                                    Receiver

          Figure 24: SCHC Operations, Including Padding as Needed

Each Profile MUST specify the size of the L2 Word. The L2 Word might actually be a single bit, in which case no padding takes place at all ๐Ÿ’€

A Profile MUST define the value of the padding bits if the L2 Word is wider than a single bit. The RECOMMENDED value is 0 ๐ŸŒธ

10. SCHC Compression for IPv6 and UDP Headers ๐Ÿ’–

This section walks through the IPv6 and UDP header fields and how each one can get compressed ๐Ÿงš An example set of Rules for UDP/IPv6 header compression is provided in Appendix A, so go peek at that for the full vibe โœจ

10.1. IPv6 Version Field ๐ŸŒˆ

The IPv6 version field is labeled by the protocol parser as the "version" field of the IPv6 protocol, so it only exists for IPv6 packets ๐ŸŽ€ In the Rule, TV is set to 6, MO to "ignore" and CDA to "not-sent" ๐Ÿ’…

10.2. IPv6 Traffic Class Field ๐Ÿฆ‹

If the Diffserv field doesn't vary and both sides know it, the Field Descriptor in the Rule SHOULD contain a TV with that well-known value, an "equal" MO, and a "not-sent" CDA โœจ

Otherwise (e.g., ECN bits need to be transmitted), there are two possibilities, depending on how much the value varies ๐Ÿ‘‘

  • One possibility is to not compress the field and send the original value. In the Rule, TV is not set to any particular value, MO is set to "ignore", and CDA is set to "value-sent" ๐Ÿ’œ
  • If some upper bits in the field are constant and known, a better option is to only send the LSBs. In the Rule, TV is set to a value with the stable known upper part, MO is set to MSB(x), and CDA to LSB ๐Ÿซถ

ECN functionality depends on both bits of the ECN field, which are the 2 LSBs of this field. So sending only a single LSB of this field is NOT RECOMMENDED ๐Ÿ˜ญ

10.3. Flow Label Field ๐ŸŒธ

If the flow label is not set, i.e., its value is zero, the Field Descriptor in the Rule SHOULD contain a TV set to 0, an "equal" MO, and a "not-sent" CDA ๐Ÿ“

If the flow label is set to a pseudorandom value according to [RFC6437], then in the Rule, TV is not set to any particular value, MO is set to "ignore", and CDA is set to "value-sent" ๐ŸŽ€

If the flow label is set according to some prior agreement, i.e., by a flow state establishment method as allowed by [RFC6437], the Field Descriptor in the Rule SHOULD contain a TV with this agreed-upon value, an "equal" MO, and a "not-sent" CDA ๐Ÿค

10.4. Payload Length Field ๐Ÿงš

This field can be elided for the transmission on the LPWAN, because the SCHC C/D recomputes the original payload length value ๐ŸŒˆ In the Field Descriptor, TV is not set, MO is set to "ignore", and CDA is "compute-*" โญ

10.5. Next Header Field ๐Ÿ’…

If the Next Header field doesn't vary and both sides know it, the Field Descriptor in the Rule SHOULD contain a TV with this Next Header value, the MO SHOULD be "equal", and the CDA SHOULD be "not-sent" ๐Ÿ’–

Otherwise, TV is not set in the Field Descriptor, MO is set to "ignore", and CDA is set to "value-sent". Alternatively, a matching-list MAY also be used ๐Ÿฆ‹

10.6. Hop Limit Field ๐ŸŒธ

The field behavior for this field is different for Uplink and Downlink, and it's lowkey interesting ๐Ÿ‘€ In Uplink, there's no IP forwarding between the Dev and the SCHC C/D, so the value stays relatively constant. The Downlink value depends on Internet routing and can change more frequently ๐ŸŒ The DI can be used to tell both directions apart ๐Ÿ’œ

  • In an Up Field Descriptor, elide the field. The TV is set to the known constant value, the MO is set to "equal", and the CDA is set to "not-sent" โœจ
  • In a Dw Field Descriptor, the Hop Limit is elided for transmission and forced to 1 at the receiver, by setting TV to 1, MO to "ignore", and CDA to "not-sent". This prevents any further forwarding ๐Ÿ›‘

10.7. IPv6 Addresses Fields ๐Ÿซถ

As in 6LoWPAN [RFC4944], IPv6 addresses are split into two 64-bit-long fields: one for the prefix and one for the Interface Identifier (IID). These fields SHOULD be compressed ๐Ÿ”ฅ To allow for a single Rule being used for both directions, these values are identified by their role (Dev or App) and NOT by their position in the header (source or destination). slay, right? ๐Ÿ‘‘

10.7.1. IPv6 Source and Destination Prefixes ๐ŸŒˆ

Both ends MUST be configured with the appropriate prefixes ๐ŸŽ€ For a specific flow, the source and destination prefixes can be unique and stored in the Context. In that case, the TV for the source and destination prefixes contains the values, MO is set to "equal", and CDA is set to "not-sent" ๐Ÿ’–

If the Rule is meant to compress packets with different prefix values, match-mapping SHOULD be used. The different prefixes are listed in the TV, MO is set to "match-mapping", and CDA is set to "mapping-sent". See Figure 26 ๐Ÿงš

Otherwise, TV is not set, MO is set to "ignore", and CDA is set to "value-sent" ๐Ÿ“

10.7.2. IPv6 Source and Destination IID ๐Ÿฆ‹

If the Dev or App IID are based on an L2 address, then the IID can be reconstructed with info from the L2 header ๐Ÿง  In that case, TV is not set, MO is set to "ignore", and CDA is set to "DevIID" or "AppIID". On LPWAN technologies where the frames carry a single identifier (corresponding to the Dev), AppIID can't be used ๐Ÿ™…โ€โ™€๏ธ

As described in [RFC8065], it may be undesirable to build the Dev IPv6 IID out of the Dev address. Another static value is used instead. In that case, the TV contains the static value, the MO operator is set to "equal", and the CDA is set to "not-sent" ๐ŸŒธ

If several IIDs are possible, then the TV contains the list of possible IIDs, MO is set to "match-mapping", and CDA is set to "mapping-sent" ๐ŸŒˆ

It may also happen that the IID variability only shows up on a few bytes. In that case, TV is set to the stable part of the IID, MO is set to "MSB", and CDA is set to "LSB" ๐ŸŽ€

Finally, the IID can be sent in its entirety on the L2. In that case, TV is not set, MO is set to "ignore", and CDA is set to "value-sent" ๐Ÿ’…

10.8. IPv6 Extension Headers ๐Ÿ™ˆ

This document does not provide recommendations on how to compress IPv6 extension headers. that's a whole other era, bestie ๐Ÿ•ฐ๏ธ

10.9. UDP Source and Destination Ports ๐Ÿฆ‹

To allow for a single Rule being used for both directions, the UDP port values are identified by their role (Dev or App) and NOT by their position in the header (source or destination). The SCHC C/D MUST be aware of the traffic direction (Uplink, Downlink) to select the appropriate field ๐Ÿงญ The following Rules apply for Dev and App port numbers ๐Ÿ’œ

If both ends know the port number, it can be elided. The TV contains the port number, MO is set to "equal", and CDA is set to "not-sent" โœจ

If the port variation is on few bits, the TV contains the stable part of the port number, MO is set to "MSB", and CDA is set to "LSB" ๐ŸŒธ

If some well-known values are used, the TV can contain the list of these values, MO is set to "match-mapping", and CDA is set to "mapping-sent" ๐Ÿ“

Otherwise, the port numbers are sent over the L2. TV is not set, MO is set to "ignore" and CDA is set to "value-sent" ๐ŸŽ€

10.10. UDP Length Field ๐ŸŒˆ

The parser MUST NOT label this field unless the UDP Length value matches the Payload Length value from the IPv6 header ๐Ÿ™…โ€โ™€๏ธ TV is not set, MO is set to "ignore", and CDA is set to "compute-*" ๐Ÿ’–

10.11. UDP Checksum Field ๐Ÿ˜ญ

The UDP checksum operation is mandatory with IPv6 for most packets, but there are exceptions [RFC8200]. ngl, the exceptions are where it gets spicy ๐ŸŒถ๏ธ

For instance, protocols that use UDP as a tunnel encapsulation may enable zero-checksum mode for a specific port (or set of ports) for sending and/or receiving. [RFC8200] requires any node implementing zero-checksum mode to follow the requirements specified in "Applicability Statement for the Use of IPv6 UDP Datagrams with Zero Checksums" [RFC6936] ๐Ÿ“œ

6LoWPAN Header Compression [RFC6282] also specifies that a UDP checksum can be elided by the compressor and recomputed by the decompressor when an upper layer guarantees the integrity of the UDP payload and pseudo-header. A specific example of this is when a message integrity check protects the compressed message between the compressor that elides the UDP checksum and the decompressor that computes it, with a strength that is identical or better to the UDP checksum ๐Ÿ”

Similarly, a SCHC compressor MAY elide the UDP checksum when another layer guarantees at least equal integrity protection for the UDP payload and the pseudo-header. In this case, TV is not set, MO is set to "ignore", and CDA is set to "compute-*" ๐Ÿซถ

In particular, when SCHC fragmentation is used, a fragmentation RCS of 2 bytes or more provides equal or better protection than the UDP checksum. In that case, if the compressor is collocated with the fragmentation point and the decompressor is collocated with the packet reassembly point, and if the SCHC Packet is fragmented even when it would fit unfragmented in the L2 MTU, then the compressor MAY verify and then elide the UDP checksum. Whether and when the UDP Checksum is elided is to be specified in the Profile ๐Ÿง 

Since the compression happens before the fragmentation, implementers should understand the risks when dealing with unprotected data below the transport layer, and take special care when manipulating that data. this part is giving serious caution energy ๐Ÿšจ

In other cases, the checksum SHOULD be explicitly sent. TV is not set, MO is set to "ignore" and CDA is set to "value-sent" ๐Ÿ’œ

11. IANA Considerations ๐ŸŽ€

This document has no IANA actions ๐ŸŒธ

12. Security Considerations โœจ

Okay so bestie, security is where things get spicy ๐Ÿ”ฅ. As we covered back in Section 5, SCHC is expected to be implemented on top of LPWAN technologies, and those are expected to implement security measures of their own ๐Ÿ”. Still, we're going to look at the sneaky threats that could creep into an LPWAN once we add the SCHC functionalities. Main character energy, but make it secure ๐Ÿ’….

12.1. Security Considerations for SCHC Compression/Decompression ๐ŸŽ€

12.1.1. Forged SCHC Packet ๐Ÿ’€

Let's imagine an attacker is able to send a forged SCHC Packet to a SCHC decompressor. Scary, right? ๐Ÿ™ˆ

First, the case where the RuleID in that forged packet doesn't match a Rule in the Rule table. Here an implementation ought to notice that the RuleID is invalid and should silently drop the offending SCHC Packet. Bye bye, bad packet ๐Ÿ‘‹.

Now, say the RuleID does match a Rule in the table. With the CDAs defined in this document, the reconstructed packet is, at most, a constant number of bits bigger than the SCHC Packet that was received. This assumes the compute-* decompression actions produce a bounded number of bits, no matter what the incoming SCHC Packet looks like. This property holds for IPv6 Length, UDP Length, and UDP Checksum, which is why this document recommends the compute-* CDA for them ๐Ÿงš.

So, SCHC decompression does not amplify attacks beyond adding a bounded number of bits to the SCHC Packet received. The bound is determined by the Rule stored in the receiving device. Lowkey genius ๐Ÿง .

As a general safety measure, a SCHC decompressor should never reconstruct a packet larger than MAX_PACKET_SIZE (defined in a Profile, with 1500 bytes as the generic default). Nobody gets to build a giant packet and call it a day ๐Ÿšซ.

12.1.2. Compressed Packet Size as a Side Channel to Guess a Secret Token ๐Ÿ•ต๏ธโ€โ™€๏ธ

Some packet compression methods are known to be susceptible to attacks such as BREACH and CRIME ๐Ÿ˜ญ. The attack goes like this: the attacker injects arbitrary data into the packet and watches the resulting compressed packet size. That observed size can reflect a correlation between the arbitrary data and some content that was meant to stay secret, like a security token, so the attacker can get at the secret. Iconic behaviour from the bad guys, honestly ๐Ÿ’€.

SCHC compression is different, though ๐Ÿ’–. It works header field by header field, and the SCHC Packet is just a mere concatenation of the compression residues of each individual field. Any correlation between header fields does not change the SCHC Packet size compressed under the same Rule. Slay ๐Ÿ‘‘.

If SCHC C/D is used to compress packets that include a secret information field, such as a token, the Rule set should be designed so that the size of the compression residue for that field stays the same no matter what the secret's value is. One way to do this is, e.g., sending this field in extenso with the "ignore" MO and the "value-sent" CDA โœจ. This recommendation is disputable if it is ascertained that the Rule set itself will remain secret, so keep that in mind ๐Ÿฆ‹.

12.1.3. Decompressed Packet Different from the Original Packet ๐ŸŒธ

As explained in Section 7.2, using FPs with value 0 in Field Descriptors in a Rule may result in header fields showing up in the decompressed packet in a different order from the original packet. Also, as stated in Section 7.4.3, using an "ignore" MO together with a "not-sent" CDA will make the header field take the TV value, which is likely to be different from the original value. Not me getting a different value than I sent ๐Ÿ™ƒ.

Depending on the protocol, the order of header fields in the packet may or may not be functionally significant. It's giving "it depends" energy ๐Ÿคทโ€โ™€๏ธ.

Furthermore, if the packet is protected by a checksum or a similar integrity protection mechanism, and the checksum is transmitted instead of being recomputed as part of the decompression, these situations may result in the packet being considered corrupt and dropped. Oof ๐Ÿ˜ญ.

12.2. Security Considerations for SCHC Fragmentation/Reassembly ๐Ÿงฉ

12.2.1. Buffer Reservation Attack ๐Ÿšง

Let's assume an attacker is able to send a forged SCHC Fragment to a SCHC reassembler.

A node can perform a buffer reservation attack: the receiver reserves buffer space for the SCHC Packet. If the implementation has only one buffer, other incoming fragmented SCHC Packets get dropped while that buffer is occupied during the reassembly timeout. Once the timeout expires, the attacker can repeat the same procedure and iterate, creating a denial-of-service attack ๐Ÿ’€. An implementation may have multiple reassembly buffers. The cost to mount this attack is linear with the number of buffers at the target node. Better yet, for the attacker, the cost can be increased if individual fragments of multiple SCHC Packets can be stored in the reassembly buffer. The finer grained the reassembly buffer (down to the smallest tile size), the higher the cost of the attack ๐Ÿ’ช.

If buffer overload does occur, a smart receiver could selectively discard SCHC Packets being reassembled based on sender behaviour, which may help identify which SCHC Fragments were sent by the attacker. Another mild countermeasure is for the target to abort the fragmentation/reassembly session as early as it detects a non-identical SCHC Fragment duplicate, anticipating an eventual corrupt SCHC Packet, so the sender doesn't waste effort sending the rest of the fragments for that SCHC Packet ๐Ÿซถ.

12.2.2. Corrupt Fragment Attack ๐Ÿฆนโ€โ™€๏ธ

Let's assume an attacker is able to send a forged SCHC Fragment to a SCHC reassembler. The malicious node is additionally assumed to be able to hear an incoming communication destined to the target node. Very spy-core ๐Ÿ•ถ๏ธ.

It can then send a forged SCHC Fragment that looks like it belongs to a SCHC Packet already being reassembled at the target node. This can cause the SCHC Packet to be considered corrupt and dropped by the receiver. The amplification happens here because a single spoofed SCHC Fragment renders a full sequence of legitimate SCHC Fragments useless ๐Ÿ˜ค. If the target uses ACK-Always or ACK-on-Error mode, such a malicious node can also interfere with the acknowledgement and repetition algorithm of SCHC F/R. A single spoofed ACK, with all Bitmap bits set to 0, will trigger the repetition of WINDOW_SIZE tiles. This protocol loop amplification drains the energy source of the target node and eats up the channel bandwidth ๐Ÿ”‹. Similarly, a spoofed ACK REQ will trigger the sending of a SCHC ACK, which may be much larger than the ACK REQ if WINDOW_SIZE is large. These consequences should be borne in mind when defining profiles for SCHC over specific LPWAN technologies, bestie. Don't skip this part ๐Ÿ“.

12.2.3. Fragmentation as a Way to Bypass Network Inspection ๐Ÿšซ

Fragmentation is known for potentially letting someone force through a Network Inspection device (e.g., firewall) packets that would be rejected if they weren't fragmented. This involves sending overlapping fragments to rewrite fields whose initial value led the Network Inspection device to let the flow through. Sneaky, sneaky ๐Ÿ.

SCHC F/R is expected to be used over one LPWAN link, where no Network Inspection device is expected to sit. As described in Section 5.2, even if the SCHC F/R on the Network Infrastructure side is located in the Internet, a tunnel is to be established between it and the NGW ๐Ÿ›ก๏ธ.

12.2.4. Privacy Issues Associated with SCHC Header Fields ๐Ÿ”’

SCHC F/R allocates a DTag value to fragments belonging to the same SCHC Packet. Concerns were raised that, if DTag is a wide counter that is incremented in a predictable fashion for each new fragmented SCHC Packet, it might lead to a privacy issue, such as enabling tracking of a device across LPWANs. Tracking vibes, not it ๐Ÿ‘€.

However, SCHC F/R is expected to be used over exactly one LPWAN link. As described in Section 5.2, even if the SCHC F/R on the Network Infrastructure side is located in the Internet, a tunnel is to be established between it and the NGW. Therefore, assuming the tunnel provides confidentiality, neither the DTag field nor any other SCHC-introduced field is visible over the Internet ๐Ÿซฃโœจ.

13. References ๐Ÿ“š

13.1. Normative References

13.2. Informative References

Appendix A. Compression Examples ๐Ÿ’–

okay so this section is the fun part ๐Ÿ’… It walks through some compression scenarios for IPv6/UDP so you can actually see how SCHC behaves in practice. The whole goal is to show the behavior, bestie ๐ŸŽ€

The mechanisms in this document can be applied to a Dev that runs some applications over CoAP ๐Ÿงš In this example there are three flows:

  • The first is device management over CoAP, using Link Local IPv6 addresses and UDP ports 123 and 124 for Dev and App, respectively.
  • The second is a CoAP server for measurements done by the Dev (using ports 5683) with Global IPv6 Address prefixes alpha::IID/64 to beta::1/64.
  • The last is for legacy applications using different port numbers, where the destination IPv6 address prefix is gamma::1/64.

Figure 25 shows the protocol stack ๐Ÿฆ‹ IPv6 and UDP are drawn with dotted lines because they get compressed on the radio link.

 Management   Data
+----------+---------+---------+
|   CoAP   |  CoAP   | legacy  |
+----||----+---||----+---||----+
.   UDP    .  UDP    |   UDP   |
................................
.   IPv6   .  IPv6   .  IPv6   .
+------------------------------+
|    SCHC Header compression   |
|      and fragmentation       |
+------------------------------+
|      LPWAN L2 technologies   |
+------------------------------+
         Dev or NGW

            Figure 25: Simplified Protocol Stack for LP-WAN

Rule 0 is the special RuleID used to tag an uncompressed UDP/IPV6 packet. Rules 1 to 3 are the real compression rules, and they're laid out below ๐Ÿ’œ

Rule 0
  Special RuleID used to tag an uncompressed UDP/IPV6 packet.

Rule 1
 +----------------+--+--+--+---------+--------+------------++------+
 |       FID      |FL|FP|DI|    TV   |   MO   |     CDA    || Sent |
 |                |  |  |  |         |        |            ||[bits]|
 +----------------+--+--+--+---------+---------------------++------+
 |IPv6 Version    |4 |1 |Bi|6        | ignore | not-sent   ||      |
 |IPv6 Diffserv   |8 |1 |Bi|0        | equal  | not-sent   ||      |
 |IPv6 Flow Label |20|1 |Bi|0        | equal  | not-sent   ||      |
 |IPv6 Length     |16|1 |Bi|         | ignore | compute-*  ||      |
 |IPv6 Next Header|8 |1 |Bi|17       | equal  | not-sent   ||      |
 |IPv6 Hop Limit  |8 |1 |Bi|255      | ignore | not-sent   ||      |
 |IPv6 DevPrefix  |64|1 |Bi|FE80::/64| equal  | not-sent   ||      |
 |IPv6 DevIID     |64|1 |Bi|         | ignore | DevIID     ||      |
 |IPv6 AppPrefix  |64|1 |Bi|FE80::/64| equal  | not-sent   ||      |
 |IPv6 AppIID     |64|1 |Bi|::1      | equal  | not-sent   ||      |
 +================+==+==+==+=========+========+============++======+
 |UDP DevPort     |16|1 |Bi|123      | equal  | not-sent   ||      |
 |UDP AppPort     |16|1 |Bi|124      | equal  | not-sent   ||      |
 |UDP Length      |16|1 |Bi|         | ignore | compute-*  ||      |
 |UDP checksum    |16|1 |Bi|         | ignore | compute-*  ||      |
 +================+==+==+==+=========+========+============++======+

             Figure 26: Context Rules - Rule 0 and Rule 1

Rule 2
 +----------------+--+--+--+---------+--------+------------++------+
 |       FID      |FL|FP|DI|    TV   |   MO   |     CDA    || Sent |
 |                |  |  |  |         |        |            ||[bits]|
 +----------------+--+--+--+---------+--------+------------++------+
 |IPv6 Version    |4 |1 |Bi|6        | ignore | not-sent   ||      |
 |IPv6 Diffserv   |8 |1 |Bi|0        | equal  | not-sent   ||      |
 |IPv6 Flow Label |20|1 |Bi|0        | equal  | not-sent   ||      |
 |IPv6 Length     |16|1 |Bi|         | ignore | compute-*  ||      |
 |IPv6 Next Header|8 |1 |Bi|17       | equal  | not-sent   ||      |
 |IPv6 Hop Limit  |8 |1 |Bi|255      | ignore | not-sent   ||      |
 |IPv6 DevPrefix  |64|1 |Bi|[alpha/64, match- |mapping-sent||   1  |
 |                |  |  |  |fe80::/64] mapping|            ||      |
 |IPv6 DevIID     |64|1 |Bi|         | ignore | DevIID     ||      |
 |IPv6 AppPrefix  |64|1 |Bi|[beta/64,| match- |mapping-sent||   2  |
 |                |  |  |  |alpha/64,| mapping|            ||      |
 |                |  |  |  |fe80::64]|        |            ||      |
 |IPv6 AppIID     |64|1 |Bi|::1000   | equal  | not-sent   ||      |
 +================+==+==+==+=========+========+============++======+
 |UDP DevPort     |16|1 |Bi|5683     | equal  | not-sent   ||      |
 |UDP AppPort     |16|1 |Bi|5683     | equal  | not-sent   ||      |
 |UDP Length      |16|1 |Bi|         | ignore | compute-*  ||      |
 |UDP checksum    |16|1 |Bi|         | ignore | compute-*  ||      |
 +================+==+==+==+=========+========+============++======+

                  Figure 27: Context Rules - Rule 2

Rule 3
 +----------------+--+--+--+---------+--------+------------++------+
 |       FID      |FL|FP|DI|    TV   |   MO   |     CDA    || Sent |
 |                |  |  |  |         |        |            ||[bits]|
 +----------------+--+--+--+---------+--------+------------++------+
 |IPv6 Version    |4 |1 |Bi|6        | ignore | not-sent   ||      |
 |IPv6 Diffserv   |8 |1 |Bi|0        | equal  | not-sent   ||      |
 |IPv6 Flow Label |20|1 |Bi|0        | equal  | not-sent   ||      |
 |IPv6 Length     |16|1 |Bi|         | ignore | compute-*  ||      |
 |IPv6 Next Header|8 |1 |Bi|17       | equal  | not-sent   ||      |
 |IPv6 Hop Limit  |8 |1 |Up|255      | ignore | not-sent   ||      |
 |IPv6 Hop Limit  |8 |1 |Dw|         | ignore | value-sent ||   8  |
 |IPv6 DevPrefix  |64|1 |Bi|alpha/64 | equal  | not-sent   ||      |
 |IPv6 DevIID     |64|1 |Bi|         | ignore | DevIID     ||      |
 |IPv6 AppPrefix  |64|1 |Bi|gamma/64 | equal  | not-sent   ||      |
 |IPv6 AppIID     |64|1 |Bi|::1000   | equal  | not-sent   ||      |
 +================+==+==+==+=========+========+============++======+
 |UDP DevPort     |16|1 |Bi|8720     | MSB(12)| LSB        ||   4  |
 |UDP AppPort     |16|1 |Bi|8720     | MSB(12)| LSB        ||   4  |
 |UDP Length      |16|1 |Bi|         | ignore | compute-*  ||      |
 |UDP checksum    |16|1 |Bi|         | ignore | compute-*  ||      |
 +================+==+==+==+=========+========+============++======+

                  Figure 28: Context Rules - Rule 3

Figures 26 to 28 describe an example of a Rule set ๐ŸŒธ In this example, 0 was picked as the special RuleID that tags packets which can't be compressed with any compression Rule. All the fields in Rules 1-3 show up in the IPv6 and UDP headers. The DevIID value gets inferred from the L2 header. Rules 2-3 use global addresses, and how the Dev learns the prefix is not in the scope of this document. Rule 3 squishes each port number down to 4 bits โœจ

Appendix B. Fragmentation Examples ๐Ÿฆ‹

This section gives examples for the various fragment reliability modes specified in this document ๐Ÿงš In the drawings, Bitmaps are shown in their uncompressed form.

Figure 29 shows a No-ACK mode transmission of a SCHC Packet that needs 11 SCHC Fragments. FCN is 1 bit wide here.

        Sender               Receiver
          |-------FCN=0-------->|
          |-------FCN=0-------->|
          |-------FCN=0-------->|
          |-------FCN=0-------->|
          |-------FCN=0-------->|
          |-------FCN=0-------->|
          |-------FCN=0-------->|
          |-------FCN=0-------->|
          |-------FCN=0-------->|
          |-------FCN=0-------->|
          |-----FCN=1 + RCS --->| Integrity check: success
        (End)

              Figure 29: No-ACK Mode, 11 SCHC Fragments

For the following examples, N (the size of the FCN field) is 3 bits, so the All-1 FCN value is 7 ๐Ÿ’…

Figure 30 is an ACK-on-Error mode transmission of a SCHC Packet fragmented in 11 tiles, with one tile per SCHC Fragment, WINDOW_SIZE=7, and no lost SCHC Fragment ๐Ÿ“

        Sender               Receiver
          |-----W=0, FCN=6----->|
          |-----W=0, FCN=5----->|
          |-----W=0, FCN=4----->|
          |-----W=0, FCN=3----->|
          |-----W=0, FCN=2----->|
          |-----W=0, FCN=1----->|
          |-----W=0, FCN=0----->|
      (no ACK)
          |-----W=1, FCN=6----->|
          |-----W=1, FCN=5----->|
          |-----W=1, FCN=4----->|
          |--W=1, FCN=7 + RCS-->| Integrity check: success
          |<-- ACK, W=1, C=1 ---| C=1
        (End)

      Figure 30: ACK-on-Error Mode, 11 Tiles, One Tile per SCHC
                   Fragment, No Lost SCHC Fragment

Figure 31 is also ACK-on-Error with 11 tiles, one tile per SCHC Fragment and WINDOW_SIZE=7, but this time three SCHC Fragments get lost ๐Ÿ˜ญ

        Sender               Receiver
          |-----W=0, FCN=6----->|
          |-----W=0, FCN=5----->|
          |-----W=0, FCN=4--X-->|
          |-----W=0, FCN=3----->|
          |-----W=0, FCN=2--X-->|
          |-----W=0, FCN=1----->|
          |-----W=0, FCN=0----->|        6543210
          |<-- ACK, W=0, C=0 ---| Bitmap:1101011
          |-----W=0, FCN=4----->|
          |-----W=0, FCN=2----->|
      (no ACK)
          |-----W=1, FCN=6----->|
          |-----W=1, FCN=5----->|
          |-----W=1, FCN=4--X-->|
          |- W=1, FCN=7 + RCS ->| Integrity check: failure
          |<-- ACK, W=1, C=0 ---| C=0, Bitmap:1100001
          |-----W=1, FCN=4----->| Integrity check: success
          |<-- ACK, W=1, C=1 ---| C=1
        (End)

      Figure 31: ACK-on-Error Mode, 11 Tiles, One Tile per SCHC
                   Fragment, Lost SCHC Fragments

Figure 32 is the big one ๐ŸŒˆ It shows an ACK-on-Error mode transmission of a SCHC Packet fragmented in 73 tiles, with N=5, WINDOW_SIZE=28, M=2, and three lost SCHC Fragments. Watch the window slide and the tile counts change as things get resent ๐Ÿ‘‘

   Sender               Receiver
    |-----W=0, FCN=27----->| 4 tiles sent
    |-----W=0, FCN=23----->| 4 tiles sent
    |-----W=0, FCN=19----->| 4 tiles sent
    |-----W=0, FCN=15--X-->| 4 tiles sent (not received)
    |-----W=0, FCN=11----->| 4 tiles sent
    |-----W=0, FCN=7 ----->| 4 tiles sent
    |-----W=0, FCN=3 ----->| 4 tiles sent
    |-----W=1, FCN=27----->| 4 tiles sent
    |-----W=1, FCN=23----->| 4 tiles sent
    |-----W=1, FCN=19----->| 4 tiles sent
    |-----W=1, FCN=15----->| 4 tiles sent
    |-----W=1, FCN=11----->| 4 tiles sent
    |-----W=1, FCN=7 ----->| 4 tiles sent
    |-----W=1, FCN=3 --X-->| 4 tiles sent (not received)
    |-----W=2, FCN=27----->| 4 tiles sent
    |-----W=2, FCN=23----->| 4 tiles sent
^   |-----W=2, FCN=19----->| 1 tile sent
|   |-----W=2, FCN=18----->| 1 tile sent
|   |-----W=2, FCN=17----->| 1 tile sent
    |-----W=2, FCN=16----->| 1 tile sent
s   |-----W=2, FCN=15----->| 1 tile sent
m   |-----W=2, FCN=14----->| 1 tile sent
a   |-----W=2, FCN=13--X-->| 1 tile sent (not received)
l   |-----W=2, FCN=12----->| 1 tile sent
l   |---W=2, FCN=31 + RCS->| Integrity check: failure
e   |<--- ACK, W=0, C=0 ---| C=0, Bitmap:1111111111110000111111111111
r   |-----W=0, FCN=15----->| 1 tile sent
    |-----W=0, FCN=14----->| 1 tile sent
L   |-----W=0, FCN=13----->| 1 tile sent
2   |-----W=0, FCN=12----->| 1 tile sent
    |<--- ACK, W=1, C=0 ---| C=0, Bitmap:1111111111111111111111110000
M   |-----W=1, FCN=3 ----->| 1 tile sent
T   |-----W=1, FCN=2 ----->| 1 tile sent
U   |-----W=1, FCN=1 ----->| 1 tile sent
    |-----W=1, FCN=0 ----->| 1 tile sent
|   |<--- ACK, W=2, C=0 ---| C=0, Bitmap:1111111111111101000000000001
|   |-----W=2, FCN=13----->| Integrity check: success
V   |<--- ACK, W=2, C=1 ---| C=1
  (End)

              Figure 32: ACK-on-Error Mode, Variable MTU

In this example, the L2 MTU drops right before the "W=2, FCN=19" fragment goes out, so each SCHC Fragment after that has room for just one tile. Before any retransmissions, the 73 tiles travel in 25 SCHC Fragments total, and the last nine are smaller. ๐Ÿงš

Quick heads up: other sequences of events (like when the Receiver decides to send ACKs) are also fine under this spec. Profiles might limit that flexibility. ๐Ÿ’…

Figure 33 shows an ACK-Always mode transfer of a SCHC Packet cut into 11 tiles, one tile per SCHC Fragment, with N=3, WINDOW_SIZE=7, and zero loss. It's so clean! โœจ

        Sender               Receiver
          |-----W=0, FCN=6----->|
          |-----W=0, FCN=5----->|
          |-----W=0, FCN=4----->|
          |-----W=0, FCN=3----->|
          |-----W=0, FCN=2----->|
          |-----W=0, FCN=1----->|
          |-----W=0, FCN=0----->|
          |<-- ACK, W=0, C=0 ---| Bitmap:1111111
          |-----W=1, FCN=6----->|
          |-----W=1, FCN=5----->|
          |-----W=1, FCN=4----->|
          |--W=1, FCN=7 + RCS-->| Integrity check: success
          |<-- ACK, W=1, C=1 ---| C=1
        (End)

  Figure 33: ACK-Always Mode, 11 Tiles, One Tile per SCHC Fragment,
                               No Loss

Figure 34 is the same 11-tile setup (one tile per SCHC Fragment, N=3, WINDOW_SIZE=7), but this time three SCHC Fragments get lost. The recovery is where it gets good. ๐Ÿ˜ญ๐Ÿ”ฅ

        Sender               Receiver
          |-----W=0, FCN=6----->|
          |-----W=0, FCN=5----->|
          |-----W=0, FCN=4--X-->|
          |-----W=0, FCN=3----->|
          |-----W=0, FCN=2--X-->|
          |-----W=0, FCN=1----->|
          |-----W=0, FCN=0----->|        6543210
          |<-- ACK, W=0, C=0 ---| Bitmap:1101011
          |-----W=0, FCN=4----->|
          |-----W=0, FCN=2----->|
          |<-- ACK, W=0, C=0 ---| Bitmap:1111111
          |-----W=1, FCN=6----->|
          |-----W=1, FCN=5----->|
          |-----W=1, FCN=4--X-->|
          |--W=1, FCN=7 + RCS-->| Integrity check: failure
          |<-- ACK, W=1, C=0 ---| C=0, Bitmap:11000001
          |-----W=1, FCN=4----->| Integrity check: success
          |<-- ACK, W=1, C=1 ---| C=1
        (End)

  Figure 34: ACK-Always Mode, 11 Tiles, One Tile per SCHC Fragment,
                       Three Lost SCHC Fragments

Figure 35 is a six-tile SCHC Packet, one tile per SCHC Fragment, N=3, WINDOW_SIZE=7, with three lost SCHC Fragments. Each lost one only needs a single retry to get back. Main character energy ๐Ÿ‘‘

          Sender                Receiver
             |-----W=0, FCN=6----->|
             |-----W=0, FCN=5----->|
             |-----W=0, FCN=4--X-->|
             |-----W=0, FCN=3--X-->|
             |-----W=0, FCN=2--X-->|
             |--W=0, FCN=7 + RCS-->| Integrity check: failure
             |<-- ACK, W=0, C=0 ---| C=0, Bitmap:1100001
             |-----W=0, FCN=4----->| Integrity check: failure
             |-----W=0, FCN=3----->| Integrity check: failure
             |-----W=0, FCN=2----->| Integrity check: success
             |<-- ACK, W=0, C=1 ---| C=1
           (End)

       Figure 35: ACK-Always Mode, Six Tiles, One Tile per SCHC
                 Fragment, Three Lost SCHC Fragments

Figure 36 uses that same six-tile setup (N=3, WINDOW_SIZE=7, three lost SCHC Fragments), except now the second SCHC ACK gets lost too. The Sender waits, then sends an ACK REQ to get things moving again. ๐Ÿ™ˆ

          Sender                Receiver
             |-----W=0, FCN=6----->|
             |-----W=0, FCN=5----->|
             |-----W=0, FCN=4--X-->|
             |-----W=0, FCN=3--X-->|
             |-----W=0, FCN=2--X-->|
             |--W=0, FCN=7 + RCS-->| Integrity check: failure
             |<-- ACK, W=0, C=0 ---| C=0, Bitmap:1100001
             |-----W=0, FCN=4----->| Integrity check: failure
             |-----W=0, FCN=3----->| Integrity check: failure
             |-----W=0, FCN=2----->| Integrity check: success
             |<-X-ACK, W=0, C=1 ---| C=1
    timeout  |                     |
             |--- W=0, ACK REQ --->| ACK REQ
             |<-- ACK, W=0, C=1 ---| C=1
           (End)

       Figure 36: ACK-Always Mode, Six Tiles, One Tile per SCHC
                       Fragment, SCHC ACK Loss

Figure 37 is another six-tile SCHC Packet (N=3, WINDOW_SIZE=7), where three SCHC Fragments get lost and then one of the retransmitted ones is lost again. Persistence is everything, bestie! ๐ŸŒˆ

           Sender                Receiver
             |-----W=0, FCN=6----->|
             |-----W=0, FCN=5----->|
             |-----W=0, FCN=4--X-->|
             |-----W=0, FCN=3--X-->|
             |-----W=0, FCN=2--X-->|
             |--W=0, FCN=7 + RCS-->| Integrity check: failure
             |<-- ACK, W=0, C=0 ---| C=0, Bitmap:1100001
             |-----W=0, FCN=4----->| Integrity check: failure
             |-----W=0, FCN=3----->| Integrity check: failure
             |-----W=0, FCN=2--X-->|
      timeout|                     |
             |--- W=0, ACK REQ --->| ACK REQ
             |<-- ACK, W=0, C=0 ---| C=0, Bitmap: 1111101
             |-----W=0, FCN=2----->| Integrity check: success
             |<-- ACK, W=0, C=1 ---| C=1
           (End)

      Figure 37: ACK-Always Mode, Six Tiles, Retransmitted SCHC
                         Fragment Lost Again

Figure 38 is the big one! A 28-tile SCHC Packet with one tile per SCHC Fragment, N=5, WINDOW_SIZE=24, and two lost SCHC Fragments. Honestly, it's giving marathon ๐Ÿƒโ€โ™€๏ธ๐Ÿ’–

      Sender               Receiver
        |-----W=0, FCN=23----->|
        |-----W=0, FCN=22----->|
        |-----W=0, FCN=21--X-->|
        |-----W=0, FCN=20----->|
        |-----W=0, FCN=19----->|
        |-----W=0, FCN=18----->|
        |-----W=0, FCN=17----->|
        |-----W=0, FCN=16----->|
        |-----W=0, FCN=15----->|
        |-----W=0, FCN=14----->|
        |-----W=0, FCN=13----->|
        |-----W=0, FCN=12----->|
        |-----W=0, FCN=11----->|
        |-----W=0, FCN=10--X-->|
        |-----W=0, FCN=9 ----->|
        |-----W=0, FCN=8 ----->|
        |-----W=0, FCN=7 ----->|
        |-----W=0, FCN=6 ----->|
        |-----W=0, FCN=5 ----->|
        |-----W=0, FCN=4 ----->|
        |-----W=0, FCN=3 ----->|
        |-----W=0, FCN=2 ----->|
        |-----W=0, FCN=1 ----->|
        |-----W=0, FCN=0 ----->|
        |                      |
        |<--- ACK, W=0, C=0 ---| Bitmap:110111111111101111111111
        |-----W=0, FCN=21----->|
        |-----W=0, FCN=10----->|
        |<--- ACK, W=0, C=0 ---| Bitmap:111111111111111111111111
        |-----W=1, FCN=23----->|
        |-----W=1, FCN=22----->|
        |-----W=1, FCN=21----->|
        |--W=1, FCN=31 + RCS-->| Integrity check: success
        |<--- ACK, W=1, C=1 ---| C=1
      (End)

  Figure 38: ACK-Always Mode, 28 Tiles, One Tile per SCHC Fragment,
                         Lost SCHC Fragments

Appendix C. Fragmentation State Machines ๐Ÿฆ‹

Here are the fragmentation state machines for the sender and the receiver. There's one for each reliability mode, and they're all drawn out in the figures below. ๐Ÿ’œ

            +===========+
+------------+  Init     |
|  FCN=0     +===========+
|  No Window
|  No Bitmap
|                   +-------+
|          +========+==+    | More Fragments
|          |           | <--+ ~~~~~~~~~~~~~~~~~~~~
+--------> |   Send    |      send Fragment (FCN=0)
           +===+=======+
               |  last fragment
               |  ~~~~~~~~~~~~
               |  FCN = 1
               v  send fragment+RCS
           +============+
           |    END     |
           +============+

         Figure 39: Sender State Machine for the No-ACK Mode
                     +------+ Not All-1
          +==========+=+    | ~~~~~~~~~~~~~~~~~~~
          |            + <--+ set Inactivity Timer
          |  RCV Frag  +-------+
          +=+===+======+       |All-1 &
  All-1 &   |   |              |RCS correct
RCS wrong   |   |Inactivity    |
            |   |Timer Exp.    |
            v   |              |
 +==========++  |              v
 |   Error   |<-+     +========+==+
 +===========+        |    END    |
                      +===========+

        Figure 40: Receiver State Machine for the No-ACK Mode
              +=======+
              | INIT  |       FCN!=0 & more frags
              |       |       ~~~~~~~~~~~~~~~~~~~~~~
              +======++  +--+ send Window + frag(FCN)
                 W=0 |   |  | FCN-
  Clear lcl_bm       |   |  v set lcl_bm
       FCN=max value |  ++==+========+
                     +> |            |
+---------------------> |    SEND    |
|                       +==+===+=====+
|      FCN==0 & more frags |   | last frag
|    ~~~~~~~~~~~~~~~~~~~~~ |   | ~~~~~~~~~~~~~~~
|               set lcl_bm |   | set lcl_bm
|   send wnd + frag(all-0) |   | send wnd+frag(all-1)+RCS
|       set Retrans_Timer  |   | set Retrans_Timer
|                          |   |
|Recv_wnd == wnd &         |   |
|lcl_bm==recv_bm &         |   |  +----------------------+
|more frag                 |   |  | lcl_bm!=rcv-bm       |
|~~~~~~~~~~~~~~~~~~~~~~    |   |  | ~~~~~~~~~            |
|Stop Retrans_Timer        |   |  | Attempt++            v
|clear lcl_bm              v   v  |                +=====+=+
|window=next_window   +====+===+==+===+            |Resend |
+---------------------+               |            |Missing|
                 +----+     Wait      |            |Frag   |
not expected wnd |    |    Bitmap     |            +=======+
~~~~~~~~~~~~~~~~ +--->+               ++Retrans_Timer Exp  |
    discard frag      +==+=+===+=+==+=+| ~~~~~~~~~~~~~~~~~ |
                         | |   | ^  ^  |reSend(empty)All-* |
                         | |   | |  |  |Set Retrans_Timer  |
                         | |   | |  +--+Attempt++          |
  C_bit==1 &             | |   | +-------------------------+
Recv_window==window &    | |   |   all missing frags sent
             no more frag| |   |   ~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~~~~~~~| |   |   Set Retrans_Timer
       Stop Retrans_Timer| |   |
 +=============+         | |   |
 |     END     +<--------+ |   |
 +=============+           |   | Attempt > MAX_ACK_REQUESTS
            All-1 Window & |   | ~~~~~~~~~~~~~~~~~~
               C_bit ==0 & |   v Send Abort
          lcl_bm==recv_bm  | +=+===========+
              ~~~~~~~~~~~~ +>|    ERROR    |
                Send Abort   +=============+

       Figure 41: Sender State Machine for the ACK-Always Mode

Okay, the state machines are my favorite part, and this one's a whole maze ๐Ÿฆ‹๐ŸŒธ

    Not All- & w=expected +---+   +---+w = Not expected
    ~~~~~~~~~~~~~~~~~~~~~ |   |   |   |~~~~~~~~~~~~~~~~
    Set lcl_bm(FCN)       |   v   v   |discard
                         ++===+===+===+=+
   +---------------------+     Rcv      +--->* ABORT
   |  +------------------+   Window     |
   |  |                  +=====+==+=====+
   |  |       All-0 & w=expect |  ^ w =next & not-All
   |  |     ~~~~~~~~~~~~~~~~~~ |  |~~~~~~~~~~~~~~~~~~~~~
   |  |    set lcl_bm(FCN)     |  |expected = next window
   |  |      send lcl_bm       |  |Clear lcl_bm
   |  |                        |  |
   |  | w=expected & not-All   |  |
   |  | ~~~~~~~~~~~~~~~~~~     |  |
   |  |     set lcl_bm(FCN)+-+ |  | +--+ w=next & All-0
   |  |     if lcl_bm full | | |  | |  | ~~~~~~~~~~~~~~~
   |  |     send lcl_bm    | | |  | |  | expected = nxt wnd
   |  |                    v | v  | |  | Clear lcl_bm
   |  |w=expected& All-1 +=+=+=+==+=++ | set lcl_bm(FCN)
   |  |  ~~~~~~~~~~~  +->+    Wait   +<+ send lcl_bm
   |  |    discard    +--|    Next   |
   |  | All-0  +---------+  Window   +--->* ABORT
   |  | ~~~~~  +-------->+========+=++
   |  | snd lcl_bm  All-1 & w=next| |  All-1 & w=nxt
   |  |                & RCS wrong| |  & RCS right
   |  |          ~~~~~~~~~~~~~~~~~| | ~~~~~~~~~~~~~~~~~~
   |  |            set lcl_bm(FCN)| |set lcl_bm(FCN)
   |  |                send lcl_bm| |send lcl_bm
   |  |                           | +----------------------+
   |  |All-1 & w=expected         |                        |
   |  |& RCS wrong                v   +---+ w=expected &   |
   |  |~~~~~~~~~~~~~~~~~~~~  +====+=====+ | RCS wrong      |
   |  |set lcl_bm(FCN)       |          +<+ ~~~~~~~~~~~~~~ |
   |  |send lcl_bm           | Wait End |   set lcl_bm(FCN)|
   |  +--------------------->+          +--->* ABORT       |
   |                         +===+====+=+-+ All-1&RCS wrong|
   |                             |    ^   | ~~~~~~~~~~~~~~~|
   |      w=expected & RCS right |    +---+   send lcl_bm  |
   |      ~~~~~~~~~~~~~~~~~~~~~~ |                         |
   |       set lcl_bm(FCN)       | +-+ Not All-1           |
   |        send lcl_bm          | | | ~~~~~~~~~           |
   |                             | | |  discard            |
   |All-1&w=expected & RCS right | | |                     |
   |~~~~~~~~~~~~~~~~~~~~~~~~~~~~ v | v +----+All-1         |
   |set lcl_bm(FCN)            +=+=+=+=+==+ |~~~~~~~~~     |
   |send lcl_bm                |          +<+Send lcl_bm   |
   +-------------------------->+    END   |                |
                               +==========+<---------------+

          --->* ABORT

          In any state
             on receiving a SCHC ACK REQ
                Send a SCHC ACK for the current window

         Figure 42: Receiver State Machine for the ACK-Always Mode

Next up is the sender side of the ACK-on-Error mode, and it's giving busy but make it make sense ๐Ÿ’…โœจ

                     +=======+
                     |       |
                     | INIT  |
                     |       |       FCN!=0 & more frags
                     +======++       ~~~~~~~~~~~~~~~~~~~~~~
        Frag RuleID trigger |   +--+ Send cur_W + frag(FCN);
        ~~~~~~~~~~~~~~~~~~~ |   |  | FCN--;
     cur_W=0; FCN=max_value;|   |  | set [cur_W, cur_Bmp]
       clear [cur_W, Bmp_n];|   |  v
             clear rcv_Bmp  |  ++==+==========+       **BACK_TO_SEND
                            +->+              |   cur_W==rcv_W &
         **BACK_TO_SEND        |     SEND     |   [cur_W,Bmp_n]==rcv_Bmp
   +-------------------------->+              |   & more frags
   |  +----------------------->+              |   ~~~~~~~~~~~~
   |  |                        ++==+==========+   cur_W++;
   |  |      FCN==0 & more frags|  |last frag     clear [cur_W, Bmp_n]
   |  |  ~~~~~~~~~~~~~~~~~~~~~~~|  |~~~~~~~~~
   |  |        set cur_Bmp;     |  |set [cur_W, Bmp_n];
   |  |send cur_W + frag(All-0);|  |send cur_W + frag(All-1)+RCS;
   |  |        set Retrans_Timer|  |set Retrans_Timer
   |  |                         |  | +---------------------------------+
   |  |                         |  | |cur_W ==                         |
   |  |Retrans_Timer expires &  |  | |   rcv_W & [cur_W,Bmp_n]!=rcv_Bmp|
   |  |more Frags               |  | |  ~~~~~~~~~~~~~~~~~~~            |
   |  |~~~~~~~~~~~~~~~~~~~~     |  | |  Attempts++; W=cur_W            |
   |  |stop Retrans_Timer;      |  | | +--------+           rcv_W==Wn &|
   |  |[cur_W,Bmp_n]==cur_Bmp;  v  v | |        v   [Wn,Bmp_n]!=rcv_Bmp|
   |  |cur_W++            +=====+==+=+=+==+   +=+=========+ ~~~~~~~~~~~|
   |  +-------------------+               |   | Resend    | Attempts++;|
   +----------------------+   Wait x ACK  |   | Missing   |       W=Wn |
   +--------------------->+               |   | Frags(W)  +<-----------+
   |         rcv_W==Wn &+-+               |   +======+====+
   | [Wn,Bmp_n]!=rcv_Bmp| ++=+===+===+==+=+          |
   |      ~~~~~~~~~~~~~~|  ^ |   |   |  ^            |
   |        send (cur_W,+--+ |   |   |  +------------+
   |        ALL-0-empty)     |   |   |     all missing frag sent(W)
   |                         |   |   |     ~~~~~~~~~~~~~~~~~
   |  Retrans_Timer expires &|   |   |     set Retrans_Timer
   |            No more Frags|   |   |
   |           ~~~~~~~~~~~~~~|   |   |
   |      stop Retrans_Timer;|   |   |
   |(re)send frag(All-1)+RCS |   |   |
   +-------------------------+   |   |
                    cur_W==rcv_W&|   |
          [cur_W,Bmp_n]==rcv_Bmp&|   | Attempts > MAX_ACK_REQUESTS
     No more Frags & RCS flag==OK|   | ~~~~~~~~~~
               ~~~~~~~~~~~~~~~~~~|   | send Abort
    +=========+stop Retrans_Timer|   |  +===========+
    |   END   +<-----------------+   +->+   ERROR   |
    +=========+                         +===========+

         Figure 43: Sender State Machine for the ACK-on-Error Mode

This one is just an example, so it's not normative, and the spec in Section 8.4.3.1 is allowed to do the steps in a different order than this picture shows ๐ŸŽ€

Last but not least, the receiver for ACK-on-Error, which is the most dramatic one of the whole bunch ๐Ÿ˜ญ๐Ÿ”ฅ

                    +=======+        New frag RuleID received
                    |       |        ~~~~~~~~~~~~~
                    | INIT  +-------+cur_W=0;clear([cur_W,Bmp_n]);
                    +=======+       |sync=0
                                    |
       Not All* & rcv_W==cur_W+---+ | +--+
         ~~~~~~~~~~~~~~~~~~~~ |   | | | (E)
         set[cur_W,Bmp_n(FCN)]|   v v v  |
                             ++===+=+=+==+=+
      +----------------------+             +--+ All-0&Full[cur_W,Bmp_n]
      |           ABORT *<---+  Rcv Window |  | ~~~~~~~~~~
      |  +-------------------+             +<-+ cur_W++;set Inact_timer;
      |  |                +->+=+=+=+=+=+===+    clear [cur_W,Bmp_n]
      |  | All-0 empty(Wn)|    | | | ^ ^
      |  | ~~~~~~~~~~~~~~ +----+ | | | |rcv_W==cur_W & sync==0;
      |  | sendACK([Wn,Bmp_n])   | | | |& Full([cur_W,Bmp_n])
      |  |                       | | | |& All* || last_miss_frag
      |  |                       | | | |~~~~~~~~~~~~~~~~~~~~~~
      |  |    All* & rcv_W==cur_W|(C)| |sendACK([cur_W,Bmp_n]);
      |  |              & sync==0| | | |cur_W++; clear([cur_W,Bmp_n])
      |  |&no_full([cur_W,Bmp_n])| |(E)|
      |  |      ~~~~~~~~~~~~~~~~ | | | |              +========+
      |  | sendACK([cur_W,Bmp_n])| | | |              | Error/ |
      |  |                       | | | |   +----+     | Abort  |
      |  |                       v v | |   |    |     +===+====+
      |  |                   +===+=+=+=+===+=+ (D)        ^
      |  |                +--+    Wait x     |  |         |
      |  | All-0 empty(Wn)+->| Missing Frags |<-+         |
      |  | ~~~~~~~~~~~~~~    +=============+=+            |
      |  | sendACK([Wn,Bmp_n])             +--------------+
      |  |                                       *ABORT
      v  v
     (A)(B)
                                      (D) All* || last_miss_frag
       (C) All* & sync>0                  & rcv_W!=cur_W & sync>0
           ~~~~~~~~~~~~                   & Full([rcv_W,Bmp_n])
           Wn=oldest[not full(W)];        ~~~~~~~~~~~~~~~~~~~~
           sendACK([Wn,Bmp_n])            Wn=oldest[not full(W)];
                                          sendACK([Wn,Bmp_n]);sync--

                                ABORT-->* Uplink Only &
                                          Inact_Timer expires
       (E) Not All* & rcv_W!=cur_W        || Attempts > MAX_ACK_REQUESTS
           ~~~~~~~~~~~~~~~~~~~~           ~~~~~~~~~~~~~~~~~~~~~
           sync++; cur_W=rcv_W;           send Abort
           set[cur_W,Bmp_n(FCN)]

     (A)(B)
      |  |
      |  | All-1 & rcv_W==cur_W & RCS!=OK        All-0 empty(Wn)
      |  | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~     +-+  ~~~~~~~~~~
      |  | sendACK([cur_W,Bmp_n],C=0)       | v  sendACK([Wn,Bmp_n])
      |  |                      +===========+=++
      |  +--------------------->+   Wait End   +-+
      |                         +=====+=+====+=+ | All-1
      |     rcv_W==cur_W & RCS==OK    | |    ^   | & rcv_W==cur_W
      |     ~~~~~~~~~~~~~~~~~~~~~~    | |    +---+ & RCS!=OK
      |  sendACK([cur_W,Bmp_n],C=1)   | |          ~~~~~~~~~~~~~~~~~~~
      |                               | | sendACK([cur_W,Bmp_n],C=0);
      |                               | |          Attempts++
      |All-1 & Full([cur_W,Bmp_n])    | |
      |& RCS==OK & sync==0            | +-->* ABORT
      |~~~~~~~~~~~~~~~~~~~            v
      |sendACK([cur_W,Bmp_n],C=1)   +=+=========+
      +---------------------------->+    END    |
                                    +===========+

        Figure 44: Receiver State Machine for the ACK-on-Error Mode

Appendix D. SCHC Parameters โœจ

okay so this section is the checklist for the LPWAN technology-specific docs ๐Ÿ“ it says what those docs need to cover ๐Ÿ’…

  • Most common use cases and deployment scenarios ๐ŸŒธ
  • Mapping of the SCHC architectural elements onto the LPWAN architecture ๐Ÿฆ‹
  • Assessment of LPWAN integrity checking ๐Ÿ”
  • Various potential channel conditions for the technology, plus the matching recommended use of SCHC C/D and SCHC F/R ๐Ÿ“ถ

this part lists the parameters that need to be defined in the Profile ๐ŸŽ€

  • RuleID numbering scheme, whether RuleIDs are fixed-size or variable-size, the number of Rules, and how the RuleID gets transmitted ๐Ÿงš
  • the maximum packet size that should ever be reconstructed by SCHC decompression (MAX_PACKET_SIZE). See Section 12. ๐Ÿซถ
  • Padding: the size of the L2 Word. For most LPWAN technologies that's a byte, and for some it's a bit ๐Ÿ’œ
  • Whether to use the SCHC fragmentation mechanism at all. If yes, the document must describe:
    • which reliability mode(s) are used, and in which cases (e.g., based on link channel condition) ๐Ÿ”ฅ
    • the RuleID values assigned to each mode in use ๐Ÿ“
    • the presence and number of bits for DTag (T) for each RuleID value, plus the lifetime of DTag at the receiver โญ
    • support for interleaved packet transmission, and to what extent ๐ŸŒˆ
    • WINDOW_SIZE, for modes that use windows ๐ŸชŸ
    • the number of bits for W (M) for each RuleID value, for modes that use windows ๐ŸŽ€
    • the number of bits for FCN (N) for each RuleID value, and the meaning of the FCN values ๐Ÿ”ข
    • what makes an All-0 SCHC Fragment and a SCHC ACK REQ distinguishable (see Section 8.3.1.1) ๐Ÿ™ˆ
    • what makes an All-1 SCHC Fragment and a SCHC Sender-Abort distinguishable (see Section 8.3.1.2) ๐Ÿ’€
    • for RuleIDs that use ACK-on-Error mode: whether the last tile of a SCHC Packet is sent in a Regular SCHC Fragment, alone in an All-1 SCHC Fragment, or with either of these two methods ๐Ÿ‘‘
    • for RuleIDs that use ACK-on-Error mode: whether the penultimate tile of a SCHC Packet is of the regular size only, or whether it can also be one L2 Word shorter โœจ
    • for RuleIDs that use ACK-on-Error mode: the times at which the sender must listen for SCHC ACKs ๐Ÿ‘‚
    • the size of RCS and the algorithm for computing it, for each RuleID, if it's different from the default CRC32. Byte fill-up with zeroes or some other mechanism is to be specified. Support for UDP checksum elision also goes here ๐Ÿงฎ
    • the Retransmission Timer duration for each RuleID value, if applicable to the SCHC F/R mode โฑ๏ธ
    • the Inactivity Timer duration for each RuleID value, if applicable to the SCHC F/R mode ๐Ÿ˜ด
    • the MAX_ACK_REQUESTS value for each RuleID value, if applicable to the SCHC F/R mode ๐Ÿ”
  • if the L2 Word is wider than a bit and SCHC fragmentation is used, the value of the padding bits (0 or 1) ๐Ÿงธ

a Profile may define a delay to be added after each SCHC message transmission, so it can follow local regulations or other constraints the applications have ๐Ÿ•ฐ๏ธ

  • in some LPWAN technologies, as part of energy-saving techniques, Downlink transmission is only possible right after an Uplink transmission. To avoid a potentially high delay in the Downlink transmission of a fragmented SCHC Packet, the SCHC Fragment receiver may perform an Uplink transmission as soon as possible after receiving a SCHC Fragment that is not the last one. That Uplink transmission may be triggered by the L2 (e.g., an L2 ACK sent in response to a SCHC Fragment encapsulated in an L2 PDU that requires an L2 ACK), or it may be triggered from an upper layer. See Appendix F. ๐Ÿ›ฐ๏ธ
  • the following parameters need to be addressed in documents other than this one, though not necessarily in the LPWAN technology-specific documents:
    • the way the Contexts are provisioned ๐Ÿ“ฆ
    • the way the Rules are generated ๐Ÿ› ๏ธ

Appendix E. Supporting Multiple Window Sizes for Fragmentation ๐ŸชŸ

for ACK-Always or ACK-on-Error, implementers can choose to support a single window size or multiple window sizes. Multiple sizes, when they're feasible, can give performance optimizations ๐Ÿš€ For example, a large WINDOW_SIZE should be used for packets that need to be split into a large number of tiles. But when the number of tiles needed to carry a packet is low, a smaller WINDOW_SIZE and therefore a shorter Bitmap may be enough to report reception status on all tiles ๐Ÿฅฐ If multiple window sizes are supported, the RuleID signals which WINDOW_SIZE is in use for a specific packet transmission ๐Ÿท๏ธ


the ACK-Always and ACK-on-Error modes of SCHC F/R are bidirectional protocols, so they need a feedback path from the reassembler back to the fragmenter ๐Ÿ”„

some LPWAN technologies give you quasi-bidirectional connectivity ๐Ÿซ  That means a Downlink transmission from the Network Infrastructure can only happen right after an Uplink transmission by the Dev.

so when you send fragmented SCHC Packets Downlink over these quasi-bidirectional links, this can happen ๐Ÿ˜ฑ if an Uplink SCHC ACK is lost, the SCHC ACK REQ message from the sender could get stuck in the Downlink queue at the Network Infrastructure forever, just waiting for a transmission opportunity ๐Ÿ’€

there are lots of ways to avoid this deadlock ๐Ÿ™Œ The Dev application might be sending recurring Uplink messages like keep-alives, or the Dev application stack might be sending other recurring Uplink messages as part of how it works. Those are out of the control of this generic SCHC specification, though ๐Ÿคทโ€โ™€๏ธ

so to cope with quasi-bidirectional links, a SCHC-over-foo specification may want to amend the SCHC F/R specification to add a timer-based retransmission of the SCHC ACK ๐Ÿ’ซ Here's an example of the suggested behavior for ACK-Always mode. Because it's only an example, [RFC2119] language is deliberately not used here ๐Ÿ“–

for Downlink transmission of a fragmented SCHC Packet in ACK-Always mode, the SCHC Fragment receiver may support timer-based SCHC ACK retransmission ๐Ÿ” In this mechanism, the SCHC Fragment receiver initializes and starts a timer (the UplinkACK Timer) after transmitting a SCHC ACK. The exception is when the SCHC ACK is sent in response to the last SCHC Fragment of a packet (an All-1 fragment). In that case, the SCHC Fragment receiver does not start a timer after transmitting the SCHC ACK ๐Ÿ

if, after transmitting a SCHC ACK that is not an All-1 fragment, and before the corresponding UplinkACK timer expires, the SCHC Fragment receiver receives a SCHC Fragment that belongs to the current window (e.g., a missing SCHC Fragment from the current window) or to the next window, the UplinkACK timer for that SCHC ACK is stopped ๐Ÿ›‘ But if the UplinkACK timer expires, the SCHC ACK is resent, and the UplinkACK timer is reinitialized and restarted โฐ

the default initial value for the UplinkACK Timer, and the maximum number of retries for a specific SCHC ACK (denoted MAX_ACK_REQUESTS), are to be defined in a Profile ๐Ÿ“‹ The initial value of the UplinkACK timer is expected to be greater than that of the Retransmission timer, so a (buffered) SCHC Fragment that needs retransmitting finds a chance to be sent ๐Ÿช„ One exception to this recommendation is the special case of All-1 SCHC Fragment transmission ๐ŸŽฏ

when the SCHC Fragment sender transmits the All-1 SCHC Fragment, it starts its Retransmission Timer with a large timeout value (e.g., several times that of the initial UplinkACK Timer) ๐Ÿ•ฐ๏ธ If a SCHC ACK is received before this timer expires, the SCHC Fragment sender retransmits any lost SCHC Fragments reported by the SCHC ACK. If the SCHC ACK confirms successful reception of all SCHC Fragments of the last window, the transmission of the fragmented SCHC Packet is considered complete ๐ŸŽ‰ If the timer expires and no SCHC ACK has been received since the timer started, the SCHC Fragment sender assumes the All-1 SCHC Fragment was successfully received (and possibly the last SCHC ACK was lost). This mechanism assumes that the Retransmission Timer for the All-1 SCHC Fragment is long enough to allow several SCHC ACK retries if the All-1 SCHC Fragment hasn't been received by the SCHC Fragment receiver. It also assumes that it's unlikely that several ACKs all get lost ๐Ÿซฃ


Acknowledgements ๐Ÿซถ

thanks to (in alphabetical order) Sergio Aguilar Romero, David Black, Carsten Bormann, Deborah Brungard, Brian Carpenter, Philippe Clavier, Alissa Cooper, Roman Danyliw, Daniel Ducuara Beltran, Diego Dujovne, Eduardo Ingles Sanchez, Rahul Jadhav, Benjamin Kaduk, Arunprabhu Kandasamy, Suresh Krishnan, Mirja Kuehlewind, Barry Leiba, Sergio Lopez Bernal, Antoni Markovski, Alexey Melnikov, Georgios Papadopoulos, Alexander Pelov, Charles Perkins, Edgar Ramos, Alvaro Retana, Adam Roach, Shoichi Sakane, Joseph Salowey, Pascal Thubert, and Eric Vyncke for useful design considerations, reviews and comments ๐Ÿ’–

Carles Gomez has been funded in part by the Spanish Government (Ministerio de Educacion, Cultura y Deporte) through the Jose Castillejo grant CAS15/00336, and by the ERDF and the Spanish Government through project TEC2016-79988-P ๐Ÿ‡ช๐Ÿ‡ธ Part of his contribution to this work was carried out during his stay as a visiting scholar at the Computer Laboratory of the University of Cambridge ๐ŸŽ“


Authors' Addresses ๐Ÿ’Œ

Ana Minaburo

Acklio
1137A avenue des Champs Blancs
35510 Cesson-Sevigne Cedex
France

Email: ana@ackl.io

Laurent Toutain

IMT Atlantique
2 rue de la Chataigneraie
CS 17607
35576 Cesson-Sevigne Cedex
France

Email: Laurent.Toutain@imt-atlantique.fr

Carles Gomez

Universitat Politecnica de Catalunya
C/Esteve Terradas, 7
08860 Castelldefels
Spain

Email: carlesgo@entel.upc.edu

Dominique Barthel

Orange Labs
28 chemin du Vieux Chene
38243 Meylan
France

Email: dominique.barthel@orange.com

Juan Carlos Zuniga

SIGFOX
425 rue Jean Rostand
31670 Labege
France

Email: JuanCarlos.Zuniga@sigfox.com

that's the whole thing, bestie! ๐ŸŒˆ๐Ÿ’…โœจ we made it through all 16 parts ๐ŸŽ€

๐Ÿ“ฆ where this page comes from