Implementation of CoAP and its Application in Transport...
Transcript of Implementation of CoAP and its Application in Transport...
Implementation of CoAP andits Application in Transport Logistics
Koojana Kuladinithi, Olaf Bergmann, Thomas Pötsch,Markus Becker, Carmelita Görg
[email protected]@tzi.org
[email protected]@[email protected]
TZI, University Bremen, Germany
IP+SN2011, 11th of April 2011
Becker: CoAP, IP+SN 2011 1 / 23
Outline
Introduction
Machine-2-Machine Communication
Implementation of CoAP libcoaplibcoap & Contikilibcoap & TinyOSEvaluation of libcoapCoAP vs HTTP
Conclusions & Outlook
Becker: CoAP, IP+SN 2011 2 / 23
Introduction
I IETF CoRE Working GroupI Constrained Application Protocol (CoAP)I RESTful protocol
Becker: CoAP, IP+SN 2011 3 / 23
CoAP in a nutshell
I Methods: CON, NON, ACK, RSTI Pre-processed URI in different optionsI Resource discovery built-in /.well-known/core
I Caching/ProxyingI HTTP like response codesI Mapping to HTTP
Becker: CoAP, IP+SN 2011 4 / 23
Machine-2-Machine Communication
I http://www.intelligentcontainer.com
Becker: CoAP, IP+SN 2011 5 / 23
CoAP Resources (1/2)
Resource GET PUT Comments/st X Temperature/sh X Humidity/sv X Voltage/r X Temperature, humidity
and voltage together/l X X LEDs/ck (X) X AES Encryption Key
Table: CoAP Resources on Sensor Nodes
Becker: CoAP, IP+SN 2011 6 / 23
CoAP Resources (2/2)
Resource GET PUT Comments/ni X Inform about node
integration into6LoWPAN/RPL network
/warntemplow X Below WarningTemperature Low
/warntemphi X Above WarningTemperature High
Table: CoAP Resources on the FSU
Becker: CoAP, IP+SN 2011 7 / 23
libcoap
I http://libcoap.sourceforge.netI Implements
I draft-ietf-core-coap-03I draft-ietf-core-link-format-01I draft-ietf-core-block-00I draft-ietf-core-observe-00I draft-bormann-coap-misc-06
I ProvidesI Sample serverI Sample client
I Participated in several plug-fests of the CoRE workinggroup
Becker: CoAP, IP+SN 2011 8 / 23
libcoap & Contiki
I CoAP for Sensinode N740I Based on uIPI Contiki & libcoap stripped to fit into 3 memory banks of
32 KB eachI TCP removedI Shared global variablesI libcoap: ∼ 12 KB ROMI rest-coap shipped with Contiki: ∼ 26 KB ROM
Becker: CoAP, IP+SN 2011 9 / 23
libcoap & TinyOSI Installation instructions athttp://docs.tinyos.net/index.php/CoAP
I CoAP server and clientI Only GET + PUT support
(POST + DELETE do not fit component model)I Based on TinyOS blip-1.0
(working on blip-2.0)I Block & observe drafts not supported yet (time.h→ Timer)I Synchronous/asynchronous a.k.a immediate/deferred
a.k.a. piggy-backed/separate supported through TinyOStimers
I multiple end-points on different ports possible
Becker: CoAP, IP+SN 2011 10 / 23
libcoap & TinyOS components
CoapBlipP
MainC
Boot
LedsC
Leds
IPDispatchC
SplitControlIPConnectivity
CoapUdpServerC
CoAPServer
ConfigStorageC
Mount
Init
Init
LibCoapAdapterC
LibCoAP
CoapReadResourceC(CoapReadTempResource)
ReadResource[uint8_t]
CoapReadResourceC(CoapReadHumResource)
ReadResource[uint8_t]
CoapReadResourceC(CoapReadVoltResource)
ReadResource[uint8_t]
CoapLedResourceC(CoapLedResource)
ReadResource[uint8_t]WriteResource[uint8_t]
CoapReadResourceC(CoapReadAllResource)
ReadResource[uint8_t]
CoapFlashResourceC(CoapFlashResource)
ReadResource[uint8_t]WriteResource[uint8_t]
UdpSocketC(UdpServerSocket)
UDP
CoapBufferTempTranslateC(CoapBufferTempTranslate)
Read<uint16_t>
SensirionSht11C(HumTempSensor)
Read<uint16_t>
CoapBufferHumTranslateC(CoapBufferHumTranslate)
Read<uint16_t>
Read<uint16_t>CoapBufferVoltTranslateC(CoapBufferVoltTranslate)
Read<uint16_t>
VoltageC(VoltSensor)
Read<uint16_t>
Leds
CoapResourceCollectorC
Read<val_all_t>
CoapBufferTempTranslateC(CoapBufferTempTranslateAll)
Read<uint16_t>
CoapBufferHumTranslateC(CoapBufferHumTranslateAll)
Read<uint16_t>
CoapBufferVoltTranslateC(CoapBufferVoltTranslateAll)
Read<uint16_t>
SensirionSht11C(HumTempSensorAll)
Read<uint16_t>Read<uint16_t>Read<uint16_t>
ConfigStorage
Becker: CoAP, IP+SN 2011 11 / 23
libcoap & TinyOS call/signal
I LibCoAPAdapterC translates between callbacks andcall/signal
I LibCoAPAdapterC wired to UDPSocketC’sI Resources wired, but registered with URI at boot timeI Generic index calculated from URI
Becker: CoAP, IP+SN 2011 12 / 23
Interfaces (1/3)
interface LibCoAP {command error_t bind(uint16_t port);command coap_tid_t send(coap_context_t *ctx,
struct sockaddr_in6 *dst,coap_pdu_t *pdu,int free_pdu);
event void read(struct sockaddr_in6 *from,void *data,uint16_t len,struct ip_metadata *meta);
}
Becker: CoAP, IP+SN 2011 13 / 23
Interfaces (2/3)
interface ReadResource {command error_t get(coap_tid_t id);event void getDone(error_t result,
coap_tid_t id,uint8_t asyn_message,uint8_t* val,uint8_t buflen);
event void getPreAck(coap_tid_t id);}
I E.g. for Temperature, Humidity, VoltageI Default handlers catch not supported methods on
resources and return the appropriate error code
Becker: CoAP, IP+SN 2011 14 / 23
Interfaces (3/3)
interface WriteResource {command error_t put(uint8_t* val, uint8_t buflen);event void putDone(error_t result);
}
I Readable and writable resources implement bothinterfaces
I E.g. for Led, FlashStorage
Becker: CoAP, IP+SN 2011 15 / 23
libcoap & TinyOS Read/ReadResource interfaces
I CoapReadResourceC translates between val_t anduint8_t*
I CoAPBuffer{Volt|Hum|Temp}TranslateC transform bufferreading to SI units using fixed-point calculations
I Over-the-air only fixed point values (SI value * 100) aretransmitted
I The corresponding side does not need to know whichsensor and its characteristic line
I Characteristic line might be discoverable by resourcediscovery and resource description of link-format standard
Becker: CoAP, IP+SN 2011 16 / 23
Evaluation of libcoap (Time & Size)
Resource Type Retrieval Time Num. of Bytes Transmitted/st GET 297.04 ms 223 bytes/sh GET 143.57 ms 119 bytes/sv GET 92.69 ms 119 bytes/r GET 369.99 ms 229 bytes/l GET 69.55 ms 117 bytes/l PUT 71.12 ms 116 bytes/ck PUT 101.51 ms 142 bytes
I GET /st and /r are deferred/asynchronous/separate→higher retrieval time and number of transmitted bytes
I With coap-04 not necessary to be deferred,RESPONSE_TIMEOUT now 2 s
Becker: CoAP, IP+SN 2011 17 / 23
Evaluation of libcoap (ROM)
05000
100001500020000250003000035000400004500050000
ROM Usage in Bytes
I UDPEcho - CoAP without resources: 3708 ByteI Increase to CoAP with resources is mostly because of
additional components
Becker: CoAP, IP+SN 2011 18 / 23
CoAP vs HTTP (RTT)I Test on GPRS, not 802.15.4, because of
I HTTP not available on 802.15.4I CoAP wasn’t available for TinyOS at that timeI CoAP might be of interest for M2M on GPRS as wellI Similar RTT for multi-hop 6LoWPAN
Access Method Time (sec)Apache2-Firefox 38.774Apache2-Epiphany 31.972Apache2-wget 2.660Apache2-bareHTTP client 3.032bareHTTP(TCP) 3.076bareHTTP(UDP) 1.104CoAP 1.029
Becker: CoAP, IP+SN 2011 19 / 23
CoAP vs HTTP (#Bytes)
1928
1201 1186 1115885
132 1070
500
1000
1500
2000
2500
Total Number of Bytes Transmitted
I Firefox downloads faviconI Firefox, Epiphany, and
wget add user agentsI Apache2 adds
Content-Type etc.
I Bare server and clients areless chatty
I UDP reduces at lotI CoAP has retransmission
Becker: CoAP, IP+SN 2011 20 / 23
CoAP vs HTTP (#Bytes)
Header HTTP/TCP HTTP/UDP CoAP/UDPLink Layer 160 32 32IP 200 40 40TCP/UDP 340 16 16HTTP/CoAP 181 41 17Data 4 4 2
Table: Separation of Bytes at each Layer
I Note: IP without 6LoWPAN
Becker: CoAP, IP+SN 2011 21 / 23
Conclusions
I CoAP for M2M enabled logistic applicationsI libcoap for Contiki and TinyOSI libcoap is a generic library, specific custom-made
implementations might be smallerI Adaptations necessary, e.g. split-phase operationI More compact than HTTP/TCP, but reliable on UDPI JNI interface to libcoap for Java available, and possibly
other languages
Becker: CoAP, IP+SN 2011 22 / 23
Outlook
I Measurement of CoAP in deploymentsI Port to blip-2.0I Move to coap-05/06I Simulation with TOSSIM
Becker: CoAP, IP+SN 2011 23 / 23