A Low-Power CoAP for Contiki

21
Monday, 17 Oct 2011 A Low-Power CoAP for Contiki Matthias Kovatsch, Simon Duquennoy, and Adam Dunkels [email protected] [email protected] [email protected]

description

Presentation at the IEEE Workshop on Internet of Things Technology and Architectures (IoTech 2011), Valencia, Spain. http://iotech-ws.com/

Transcript of A Low-Power CoAP for Contiki

Page 1: A Low-Power CoAP for Contiki

Monday, 17 Oct 2011

A Low-Power CoAP for Contiki

Matthias Kovatsch, Simon Duquennoy, and Adam Dunkels [email protected] [email protected] [email protected]

Page 2: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Internet of Things Protocol Stack

2

Layer Protocol

Application CoAP / REST Engine (Erbium)

Transport UDP

Network IPv6 / RPL

Adaption 6LoWPAN

MAC CSMA / link-layer bursts

Radio Duty Cycling ContikiMAC

Physical IEEE 802.15.4

/ link-layer bursts

Page 3: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

ContikiMAC

3

A

D

A

D A

ACK frame

Data frame

Radio on

Sender

Receiver

Transmission detected

D D D D

Channel check

Page 4: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Link-layer Bursts

4

A

A D

Sender

Receiver

Transmission detected

D D D D

Channel check

A

A D

D A

A D

D A

A D

D

D

A ACK frame

Data frame

Radio on

Page 5: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Constrained Application Protocol (CoAP)

RESTful Web services for networked embedded devices

Idealized architectural style of the Web

HTTP for the Internet of Things

5

coap://sky3/

coap://sky2/

coap://sky1/

Page 6: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Implements draft-ietf-core-coap-07

Available in the Contiki repository on SourceForge

«Erbium» CoAP for Contiki

6

Page 7: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

«Erbium» CoAP

Reliable UDP transport

Observing resources

Blockwise transfers

Resource discovery

Separate responses

Blocking client requests

7

Page 8: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

«Erbium» REST Engine

Resource abstraction

RESOURCE(handle, METHODs, URI-Path, Web Linking info);

Resource handler

PERIODIC_RESOURCE(handle, METHODs, URI-Path, info, period);

Additional periodic handler

EVENT_RESOURCE(handle, METHODs, URI-Path, info);

Additional event handler

8

Observable

CoRE Link Format

title="Hello world"; rt="TemperatureC";

Page 9: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

«Erbium» Memory Footprint

ROM [kB] RAM [kB]

CoAP REST Engine total 8.5 1.5

Measured stack usage – 0.1

REST Engine 0.7 0

CoAP-07 base 4.5 0

CoAP-07 server 1.9 0.3

CoAP-07 transport 0.4 0.9

CoAP-07 observing 0.9 0.2

CoAP-07 separate 0.1 0

9

Page 10: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Experimental Set-up

10

3 hops

2 hops 1 hop

Energy data over USB

100 Requests each

Laptop with

border router

Static routing

4 hops

Page 11: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Energy vs Latency for 64B Payload

11

Number of hops Number of hops

Energ

y [m

J]

Late

ncy [s]

No duty cycling

ContikiMAC

1 2 3 4

0

100

200

300

400

1 2 3 4

0

0.2

0.4

0.6

0.8

1.0 8 Hz channel check rate

0.6% RDC

Page 12: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Transmitting Large Data

12

0 128 256 384 5120

5

10

15

20

25

30

35

40

45

50

55

60

65

70

0 128 256 384 5120

0.2

0.4

0.6

0.8

1.0

1.2

1.4

1.6

1.8

Payload [Bytes] Payload [Bytes]

Energ

y [m

J]

Late

ncy [s]

Bursts avoid

steps in latency

2 3 4 5 6

Steps become

less noticable

4 hops

2 hops

1 hop

Page 13: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Transmitting Large Data

13

A

A D

Sender

Receiver

Transmission detected

D D D D

Channel check

D D A

A D

D

D

A ACK frame

Data frame

Radio on

Number of frames sent depends on

link quality, not number of fragments

Page 14: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Separate Responses

14

Client Client Server Server

Request

processing

Request

Retry

Retry

Response

Request

processing

Response

ACK

Request

ACK

Benchmark

and switch

automatically

Page 15: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Separate Responses over 4 Hops

15

Without

With

0 5 10 15 20 25

25

50

75

100

125

150

Energ

y [m

J]

Server processing time [s]

Savings marginal for CoAP’s default parameters

Retransmissions after

2-3, 4-6, 8-12, and

16-24 seconds

Page 16: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Conclusion

Internet of Things stack

Isolated layers with different goals work together

Layered architecture lowers complexity

Optimize for single fragments

No need to optimize payload size once fragmented

CoAP

Draft 07 implementation for Contiki

Block size most important parameter for memory-constrained devices:

Exponential sizes too coarse-grained

16

Page 17: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Future Work

Extend «Erbium» CoAP

Blocking resource handler for UART

Hierarchical resources / URI-Path handling

Improve observer handling (only one buffer)

Study RESTful approach

Long-term deployment with smart appliances

Separate application logic from device firmware

and combine with «Californium»-based App Server

17

https://github.com/mkovatsc/Californium

Page 18: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

THANK YOU

Questions?

18

Page 19: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Blockwise Transfers

Automatic or controlled by handler

RESOURCE(handle, METHODs, URI-Path, Web Linking info);

Resource handler

handle_handler(void* request, void* response, uint8_t *buffer, uint16_t preferred_size, int32_t *offset);

19

Unaware: fill buffer up to REST_MAX_CHUNK_SIZE

Chunk-aware: use offset and

fill buffer up to preferred_size

(update offset and set to -1 when finished)

Page 20: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

Observing Resources

Post-handler registers observers automatically

PERIODIC_RESOURCE(handle, METHODs, URI-Path, info, period);

Additional periodic handler

EVENT_RESOURCE(handle, METHODs, URI-Path, info);

Additional event handler

int handle_event_handler(resource_t *r) {

... REST.notify_subscribers(r->url, CON/NON, seqno, buf, len);

}

20

Every x-th is CON to resolve orphans

Page 21: A Low-Power CoAP for Contiki

A Low-Power CoAP for Contiki Matthias Kovatsch – ETH Zürich

«Erbium» REST Engine

Manipulate messages with REST API REST.set_header_etag(response, etag_buf, etag_len);

REST.get_query_variable(request, name, value_buffer);

Link implementation coap-03

coap-06

coap-07

HTTP (not yet implemented for Erbium)

21