Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
A Low-Power CoAP for Contiki
1. A Low-Power CoAP for Contiki
Matthias Kovatsch, Simon Duquennoy, and Adam Dunkels
kovatsch@inf.ethz.ch simonduq@sics.se adam@sics.se
Monday, 17 Oct 2011
2. Internet of Things Protocol Stack
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
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 2
3. ContikiMAC Radio on
D Data frame
A ACK frame
Sender D D D D A
Receiver D A
Channel check Transmission detected
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 3
4. Link-layer Bursts Radio on
D Data frame
A ACK frame
Sender D D D D A D A D A D A
Receiver D A D A D A D A
Channel check Transmission detected
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 4
5. Constrained Application Protocol (CoAP)
RESTful Web services for networked embedded devices
Idealized architectural style of the Web
HTTP for the Internet of Things
coap://sky2/
coap://sky1/
coap://sky3/
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 5
6. «Erbium» CoAP for Contiki
Implements draft-ietf-core-coap-07
Available in the Contiki repository on SourceForge
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 6
7. «Erbium» CoAP
Reliable UDP transport
Observing resources
Blockwise transfers
Resource discovery
Separate responses
Blocking client requests
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 7
8. «Erbium» REST Engine CoRE Link Format
title="Hello world";
rt="TemperatureC";
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
Observable
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 8
9. «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
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 9
10. Experimental Set-up
4 hops
Energy data over USB
100 Requests each
3 hops
Laptop with Static routing
border router
1 hop 2 hops
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 10
11. No duty cycling
ContikiMAC
Energy vs Latency for 64B Payload
8 Hz channel check rate
1.0
0.6% RDC
400
0.8
300
Energy [mJ]
Latency [s]
0.6
200
0.4
100
0.2
0
0
1 2 3 4 1 2 3 4
Number of hops Number of hops
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 11
12. 4 hops
2 hops
Transmitting Large Data 1 hop
70
65
2 3 4 5 6 1.8
Bursts avoid
60
1.6 steps in latency
55
1.4
50
45 1.2
Energy [mJ]
Latency [s]
40
1.0
35
30 Steps become 0.8
25 less noticable
0.6
20
15 0.4
10
0.2
5
0 0
0 128 256 384 512 0 128 256 384 512
Payload [Bytes] Payload [Bytes]
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 12
13. Transmitting Large Data Radio on
D Data frame
Number of frames sent depends on
link quality, not number of fragments A ACK frame
Sender D D D D A D D D A
Receiver D A D A
Channel check Transmission detected
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 13
14. Separate Responses
Client Server Client Server
Request Request
ACK
Retry
Request Request
processing processing
Retry
… Benchmark
and switch
Response automatically Response
ACK
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 14
15. Without
With
Separate Responses over 4 Hops
Savings marginal for CoAP’s default parameters
150
125
Energy [mJ]
100
75 Retransmissions after
2-3, 4-6, 8-12, and
50 16-24 seconds
25
0 5 10 15 20 25
Server processing time [s]
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 15
16. 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
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 16
17. 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
https://github.com/mkovatsc/Californium
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 17
19. 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);
Unaware: fill buffer up to Chunk-aware: use offset and
REST_MAX_CHUNK_SIZE fill buffer up to preferred_size
(update offset and set to -1 when finished)
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 19
20. 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);
}
Every x-th is CON to resolve orphans
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 20
21. «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)
Matthias Kovatsch – ETH Zürich A Low-Power CoAP for Contiki 21