Frame Layer (80h+)

OSI: Transport Layer

Keywords: framing, error detection, CRC, PHY, encapsulation, low communication overhead, sensors, internet of things, embedded systems, sensor networks

Scope

The scope of this project is to define the Isotropic Sensor Network Frame layer for broadcast and peer to peer connection in distributed sensor area network, wired or wireless, low and high data rate devices, battery powered devices, short-range devices with short operational space, low-cost devices to support trivial sensors, besides the fully featured devices.

Purpose

The purpose of this specifications is to provide a standard for low complexity, low cost, and low power (aware) consumption devices (sensors) to encapsulate higher level protocols.

Typical use:

  • Low-level transmissions, to define basic packet length with CRC

  • Payloads inside nested layers without CRC

Key features

  • Basic Frame Layer for Short Payloads

  • Error Detection using with CRC

  • For use in PHY Transmission as well as Encapsulation of Other Layers

  • Low-Cost and Compact Implementation

Definitions, Acronyms and Abbreviations

CRC

Cyclic Redundancy Check

device

An entity containing this protocol implementation. Also referred as sensor device or just sensor or device.

frame

The format of aggregated bits that are transmitted together in time.

packet

The format of aggregated bits that are transmitted together in time across the physical medium.

LSB

least significant byte/bit

MSB

most significant byte/bit

Packet Formats

Frame layer defines two packet formats:

  1. Short Frame Format, with a single preamble (protocol identification byte) and up to 64 B of user payload data for transmission in error-free channels,

  2. Compact Frame Format, which adds a 8-bit CRC for transmission in error-nous channels

Short Frame Format

Fields

Protocol ID

Length

Payload

Bits

2

6

length x 8

Value

0b11

0..63

data

Protocol ID:

defines the unique protocol identification number

Length:

the last 6 L-bits of first byte represent payload length. Value from 0..63 defines 1..64 payload bytes.

Payload:

embedded data

Compact Frame Format

Fields

Protocol ID

Length

Payload

CRC

Bits

2

6

length x 8

8

Value

0b10

0..63

data

8-bit CRC

Protocol ID:

the first two bits define the unique protocol identification number

Length:

the last 6 L-bits of first byte represent payload length. Value from 0..63 defines 1..64 payload bytes.

Payload:

embedded data

CRC:

protected by the 8-bit CRC polynomial 0x4D as per Philip Koopman found the best for packets up to 64 bytes. Code Example:

/**
 * Calculates 8-bit CRC using module-2 Division on a bit (slow) basis
 *
 * Usage:
 *   uint8_t crc = isn_frame_crc8( first_byte );
 *   crc = isn_frame_crc8( second_byte ^ crc );
 *   crc = isn_frame_crc8( third_byte ^ crc );
 *   ...
 *   crc = isn_frame_crc8( final_byte ^ crc ); // result is the final CRC
 *
 * \arg remainder to be chained and final value represents the crc.
 */
static uint8_t isn_frame_crc8(uint8_t remainder)
{
    uint8_t bit;
    for (bit = 8; bit > 0; --bit) {
        if (remainder & 0x80) {
            remainder = (remainder << 1) ^ 0x4D;
        } else {
            remainder = (remainder << 1);
        }
    }
    return remainder;
}

Long Frame Format

Fields

Protocol ID

Length

Length

Payload

CRC

Bits

4

4

8

length x 8

16

Value

0b0100

MSB length

LSB length

data

16-bit CRC

Protocol ID:

the first four bits define the unique protocol identification number

Length:

Value from 0..4095 define 1..4096 payload size.

Payload:

embedded data

CRC:

protected by the 16-bit CRC polynomial 0xd175 as per Philip Koopman found the best for packets up to 32 kB.

Document Changes

Date

Release

Changes

January 29, 2012

0.1

Draft Specifications, Evaluation

February 14, 2016

1.0

Public version of Renewed Sensor Frame Layer

February 25, 2017

1.1

Removed 0x00 as termination, added CRC8 code example

September 15, 2018

1.2

Added Short Frame, Long Frame is to be revised

June 9, 2021

1.3

Added Long Frame, adaptive switch between Short/Long

References

  • Philip Koopman, Tridib Chakravarty, “Cyclic Redundancy Code (CRC) Polynomial Selection For Embedded Networks”, Preprint: The International Conference on Dependable Systems and Networks, DSN-2004.