in RIOT? R I O T S U M M I T 2 0 2 0 - B A R T M O O N S MAIN - - PowerPoint PPT Presentation

in riot
SMART_READER_LITE
LIVE PREVIEW

in RIOT? R I O T S U M M I T 2 0 2 0 - B A R T M O O N S MAIN - - PowerPoint PPT Presentation

Static Context Header Compression [sjiek] Where do we want to go in RIOT? R I O T S U M M I T 2 0 2 0 - B A R T M O O N S MAIN GOAL Integrate libSCHC for standard, IPv6-based connectivity to the smallest devices reliable


slide-1
SLIDE 1

R I O T S U M M I T 2 0 2 0 - B A R T M O O N S

[sjiek]

Static Context Header Compression Where do we want to go in RIOT?

slide-2
SLIDE 2

MAIN GOAL

R I O T S U M M I T 2 0 2 0

Integrate libSCHC for

  • standard, IPv6-based connectivity to the smallest devices
  • reliable fragmentation at MAC layer
slide-3
SLIDE 3

OBJECTIVES

1. SCHC for end-to-end security

1. CoAP + OSCORE

2. RIOT on LoRaWAN gateway/network server 3. SCHC as a generic framework

1. HTTP, CoAP, MQTT 2. NDN?

4. SCHC for reliable fragmentation

R I O T S U M M I T 2 0 2 0

slide-4
SLIDE 4

COMPRESSION

R I O T S U M M I T 2 0 2 0

slide-5
SLIDE 5

LIBSCHC

Currently GNRC_NETTYPE_SCHC bypasses the gnrc_udp and gnrc_ipv6 layer

R I O T S U M M I T 2 0 2 0

ip->type = GNRC_NETTYPE_IPV6; ipv6_hdr_t *ip_hdr = (ipv6_hdr_t *)ip->data; ip_hdr->hl = 64; ip_hdr->nh = PROTNUM_UDP; ip_hdr->len = byteorder_htons(payload_size + udp->size); ip_hdr->src = src; udp_hdr_t *udp_hdr = (udp_hdr_t *)udp->data; udp_hdr->length = byteorder_htons(payload_size + udp->size); gnrc_udp_calc_csum(udp, ip); /* send packet */ if(!gnrc_netapi_dispatch_send(GNRC_NETTYPE_SCHC, GNRC_NETREG_DEMUX_CTX_ALL, ip)) { puts("Error: unable to locate SCHC thread"); gnrc_pktbuf_release(ip); return; }

slide-6
SLIDE 6

LIBSCHC

What it should be

  • Behave like gnrc_6lo

adaptation layer (fragmentation + compression)

  • Fragmentation w/o

compression

R I O T S U M M I T 2 0 2 0 gnrc_schc

slide-7
SLIDE 7

LIBSCHC

Layers can be identified by RIOT using GNRC_NETTYPE_x: no configuration Currently set at compile time inside compressor

R I O T S U M M I T 2 0 2 0

#define USE_COAP 1 #define USE_UDP 1 #define USE_IPv6 1

slide-8
SLIDE 8

LIBSCHC

Use a protocol parser per layer

  • detect protocol stack at

compile time

R I O T S U M M I T 2 0 2 0

struct schc_rule_t* schc_compress(uint8_t *data, uint16_t total_length, schc_bitarray_t* dst, uint32_t device_id, direction dir) { #if USE_IPv6 compress(dst, &src, (const struct schc_layer_rule_t*) ipv6_rule, dir); #endif #if USE_UDP compress(dst, &src, (const struct schc_layer_rule_t*) udp_rule, dir); #endif #if USE_COAP compress(dst, &coap_src, (const struct schc_layer_rule_t*) coap_rule, dir); #endif }

slide-9
SLIDE 9

LIBSCHC

Protocol parser per layer

  • What about OSCORE?

How can we offer SCHC (L2) + OSCORE (L5)?

  • Compression in 2 steps

R I O T S U M M I T 2 0 2 0

slide-10
SLIDE 10

FRAGMENTATION

R I O T S U M M I T 2 0 2 0

slide-11
SLIDE 11

LIBSCHC

Fragmentation

  • libSCHC requires
  • information about the

netif (MTU, duty cyle)

  • configuration per packet

for

  • reliability mode

R I O T S U M M I T 2 0 2 0

schc_conn.mtu = 8; // network driver MTU schc_conn.dc = 5000; // 5 seconds duty cycle schc_conn.device_id = device_id; // the device id of the connection schc_conn.bit_arr = &schc_bitbuff; schc_conn.schc_rule = schc_rule; schc_conn.RULE_SIZE = RULE_SIZE_BITS; schc_conn.MODE = ACK_ALWAYS; if (schc_rule == NULL) { DEBUG("schc: Can not retrieve rule.\n"); return; } /* release original headers and payload */ gnrc_pktbuf_release(pkt); /* start fragmentation loop */ schc_fragment(&schc_conn);

slide-12
SLIDE 12

CURRENT IMPLEMENTATION

Memory management

  • fragmented packet uses

pre-allocated chunk of memory, stored in a mbuf (network memory buffer) cha chain

  • contains a pointer to

headers and payload

R I O T S U M M I T 2 0 2 0

typedef struct schc_mbuf_t { ... /* the length of the fragment */ uint16_t len; /* pointer to the chunk of memory */ uint8_t* data; /* pointer to the next mbuf */ struct schc_mbuf_t next; } schc_mbuf_t;

slide-13
SLIDE 13

FRAGMENTATION MANAGEMENT

Abstraction required

  • differentiate between

end-devices

  • possibility to
  • reorder linked list (missing

fragments)

  • take a single payload byte

from the chain

  • to calculate MIC

R I O T S U M M I T 2 0 2 0

mbuf(0)

  • head

mbuf(1) mbuf(0)

  • head

mbuf(3) data(0) 0x20000 00 data(1) 0x20000 33 data(2) 2) 0x20000 66 data(3) 0x20000 CC mbuf(1) data(4) 0x20000 FF mbuf(2) 2) data(5) 0x200013 2

F R A G M E N T A T I O N M A N A G E M E N T i n l i b S C H C

slide-14
SLIDE 14

LIBSCHC

libSCHC works on a per fragment basis that relates to the original packet

  • Receiver can ask the

retransmission of a specific fragment

R I O T S U M M I T 2 0 2 0

slide-15
SLIDE 15

LIBSCHC

Receiver should be able to reconstruct the original packet (removing the fragmentation headers) to calculate the RCS (MIC)

  • mbuf

R I O T S U M M I T 2 0 2 0

slide-16
SLIDE 16

RIOT INTEGRATION

Currently poor memory management in libSCHC.

  • Separate memory and

mbuf logic and instead use pktsnip

R I O T S U M M I T 2 0 2 0

mbuf(0)

  • head

mbuf(1) mbuf(0)

  • head

… mbuf(n) mbuf(3) data(0) 0x20000 00 data(1) 0x20000 33 data(2) 2) 0x20000 66 … data(m) data(3) 0x20000 99

memory blocks mbuf entries

M E M O R Y M A N A G E M E N T : R I O T F R A G M E N T A T I O N M A N A G E M E N T : l i b S C H C

slide-17
SLIDE 17

RIOT INTEGRATION

  • RIOT as a SCHC network

gateway

  • pktqueue to queue

packets for multiple devices that are restricted in downlink communication

  • Configuration?

R I O T S U M M I T 2 0 2 0

slide-18
SLIDE 18

RIOT INTEGRATION

  • Device configuration

R I O T S U M M I T 2 0 2 0

/* combine compression and fragmentation parameters */ const struct schc_rule_t schc_rule_1 = { 0x01, &not_found_404, NOT_FRAGMENTED, 0, 0, 0, 0 }; const struct schc_rule_t schc_rule_3 = { 0x03, &not_found_404, ACK_ON_ERROR, 3, 6, 1, 0 }; /* save rules in flash */ const struct schc_rule_t* node1_schc_rules[] = { &schc_rule_1, &schc_rule_2, &schc_rule_3, &schc_rule_4, &schc_rule_5, &schc_rule_6, &schc_rule_7, &schc_rule_8, &schc_rule_9, &schc_rule_10, &schc_rule_11, &schc_rule_12, &schc_rule_13, &schc_rule_14, &schc_rule_15, &schc_rule_16, &schc_rule_17 }; /* rules for a particular device */ const struct schc_device node1 = { 0x06, 17, &node1_schc_rules }; const struct schc_device node2 = { 0x01, 17, &node1_schc_rules };

slide-19
SLIDE 19

RIOT INTEGRATION

  • Setting up the context
  • RIOT filesystem?

R I O T S U M M I T 2 0 2 0

#if USE_UDP const static struct schc_udp_rule_t udp_rule1 = { 1, 4, 4, 4, { { "src port", 2, 16, 1, BI, { 0x33, 0x16, 0x33, 0x17}, &mo_matchmap, MAPPINGSENT }, { "dest port", 2,16, 1, BI, {0x33, 0x16, 0x33, 0x17}, &mo_matchmap, MAPPINGSENT }, { "length", 0, 16, 1, BI, {0, 0}, &mo_ignore, COMPLENGTH }, { "checksum", 0, 16, 1, BI, {0, 0},&mo_ignore, COMPCHK } }}; #endif

slide-20
SLIDE 20

Ghent University – IDLab – imec bamoons.moons@ugent.be idlab.ugent.be

Static Context Header Compression [sjiek] in RIOT

BART MOONS.