Implementation of CoAP and its Application in Transport Logistics - - PowerPoint PPT Presentation

implementation of coap and its application in transport
SMART_READER_LITE
LIVE PREVIEW

Implementation of CoAP and its Application in Transport Logistics - - PowerPoint PPT Presentation

Implementation of CoAP and its Application in Transport Logistics Koojana Kuladinithi, Olaf Bergmann, Thomas Ptsch, Markus Becker, Carmelita Grg koo@comnets.uni-bremen.de bergmann@tzi.org tpoetsch@uni-bremen.de mab@comnets.uni-bremen.de


slide-1
SLIDE 1

Implementation of CoAP and its Application in Transport Logistics

Koojana Kuladinithi, Olaf Bergmann, Thomas Pötsch, Markus Becker, Carmelita Görg

koo@comnets.uni-bremen.de bergmann@tzi.org tpoetsch@uni-bremen.de mab@comnets.uni-bremen.de cg@comnets.uni-bremen.de

TZI, University Bremen, Germany

IP+SN2011, 11th of April 2011 Becker: CoAP , IP+SN 2011 1 / 23

slide-2
SLIDE 2

Outline

Introduction Machine-2-Machine Communication Implementation of CoAP libcoap libcoap & Contiki libcoap & TinyOS Evaluation of libcoap CoAP vs HTTP Conclusions & Outlook

Becker: CoAP , IP+SN 2011 2 / 23

slide-3
SLIDE 3

Introduction

◮ IETF CoRE Working Group ◮ Constrained Application Protocol (CoAP) ◮ RESTful protocol

Becker: CoAP , IP+SN 2011 3 / 23

slide-4
SLIDE 4

CoAP in a nutshell

◮ Methods: CON, NON, ACK, RST ◮ Pre-processed URI in different options ◮ Resource discovery built-in /.well-known/core ◮ Caching/Proxying ◮ HTTP like response codes ◮ Mapping to HTTP

Becker: CoAP , IP+SN 2011 4 / 23

slide-5
SLIDE 5

Machine-2-Machine Communication

◮ http://www.intelligentcontainer.com

Becker: CoAP , IP+SN 2011 5 / 23

slide-6
SLIDE 6

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

slide-7
SLIDE 7

CoAP Resources (2/2)

Resource GET PUT Comments /ni X Inform about node integration into 6LoWPAN/RPL network /warntemplow X Below Warning Temperature Low /warntemphi X Above Warning Temperature High

Table: CoAP Resources on the FSU

Becker: CoAP , IP+SN 2011 7 / 23

slide-8
SLIDE 8

libcoap

◮ http://libcoap.sourceforge.net ◮ Implements

◮ draft-ietf-core-coap-03 ◮ draft-ietf-core-link-format-01 ◮ draft-ietf-core-block-00 ◮ draft-ietf-core-observe-00 ◮ draft-bormann-coap-misc-06

◮ Provides

◮ Sample server ◮ Sample client

◮ Participated in several plug-fests of the CoRE working

group

Becker: CoAP , IP+SN 2011 8 / 23

slide-9
SLIDE 9

libcoap & Contiki

◮ CoAP for Sensinode N740 ◮ Based on uIP ◮ Contiki & libcoap stripped to fit into 3 memory banks of

32 KB each

◮ TCP removed ◮ Shared global variables ◮ libcoap: ∼ 12 KB ROM ◮ rest-coap shipped with Contiki: ∼ 26 KB ROM

Becker: CoAP , IP+SN 2011 9 / 23

slide-10
SLIDE 10

libcoap & TinyOS

◮ Installation instructions at

http://docs.tinyos.net/index.php/CoAP

◮ CoAP server and client ◮ Only GET + PUT support

(POST + DELETE do not fit component model)

◮ Based on TinyOS blip-1.0

(working on blip-2.0)

◮ Block & observe drafts not supported yet (time.h → Timer) ◮ Synchronous/asynchronous a.k.a immediate/deferred

a.k.a. piggy-backed/separate supported through TinyOS timers

◮ multiple end-points on different ports possible

Becker: CoAP , IP+SN 2011 10 / 23

slide-11
SLIDE 11

libcoap & TinyOS components

CoapBlipP MainC Boot LedsC Leds IPDispatchC SplitControl IPConnectivity CoapUdpServerC CoAPServer ConfigStorageC Mount Init Init LibCoapAdapterC LibCoAP CoapReadResourceC (CoapReadT empResource) R eadR esource[uint8_t] CoapReadResourceC (CoapReadHumResource) R eadR esource[uint8_t] CoapReadResourceC (CoapReadVoltResource) R eadR esource[uint8_t] CoapLedResourceC (CoapLedResource) R eadR esource[uint8_t] W riteR esource[uint8_t] CoapReadResourceC (CoapReadAllResource) R eadR esource[uint8_t] CoapFlashResourceC (CoapFlashResource) R eadR esource[uint8_t] W riteR esource[uint8_t] UdpSocketC (UdpServerSocket) UDP CoapBufferT empT ranslateC (CoapBufferT empT ranslate) R ead<uint16_t> SensirionSht11C (HumT empSensor) R ead<uint16_t> CoapBufferHumT ranslateC (CoapBufferHumT ranslate) R ead<uint16_t> R ead<uint16_t> CoapBufferVoltT ranslateC (CoapBufferVoltT ranslate) R ead<uint16_t> VoltageC (VoltSensor) R ead<uint16_t> Leds CoapResourceCollectorC R ead<val_all_t> CoapBufferT empT ranslateC (CoapBufferT empT ranslateAll) R ead<uint16_t> CoapBufferHumT ranslateC (CoapBufferHumT ranslateAll) R ead<uint16_t> CoapBufferVoltT ranslateC (CoapBufferVoltT ranslateAll) R ead<uint16_t> SensirionSht11C (HumT empSensorAll) R ead<uint16_t> R ead<uint16_t> R ead<uint16_t> ConfigStorage

Becker: CoAP , IP+SN 2011 11 / 23

slide-12
SLIDE 12

libcoap & TinyOS call/signal

◮ LibCoAPAdapterC translates between callbacks and

call/signal

◮ LibCoAPAdapterC wired to UDPSocketC’s ◮ Resources wired, but registered with URI at boot time ◮ Generic index calculated from URI

Becker: CoAP , IP+SN 2011 12 / 23

slide-13
SLIDE 13

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

slide-14
SLIDE 14

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); }

◮ E.g. for Temperature, Humidity, Voltage ◮ Default handlers catch not supported methods on

resources and return the appropriate error code

Becker: CoAP , IP+SN 2011 14 / 23

slide-15
SLIDE 15

Interfaces (3/3)

interface WriteResource { command error_t put(uint8_t* val, uint8_t buflen); event void putDone(error_t result); }

◮ Readable and writable resources implement both

interfaces

◮ E.g. for Led, FlashStorage

Becker: CoAP , IP+SN 2011 15 / 23

slide-16
SLIDE 16

libcoap & TinyOS Read/ReadResource interfaces

◮ CoapReadResourceC translates between val_t and

uint8_t*

◮ CoAPBuffer{Volt|Hum|Temp}TranslateC transform buffer

reading to SI units using fixed-point calculations

◮ Over-the-air only fixed point values (SI value * 100) are

transmitted

◮ The corresponding side does not need to know which

sensor and its characteristic line

◮ Characteristic line might be discoverable by resource

discovery and resource description of link-format standard

Becker: CoAP , IP+SN 2011 16 / 23

slide-17
SLIDE 17

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

◮ GET /st and /r are deferred/asynchronous/separate →

higher retrieval time and number of transmitted bytes

◮ With coap-04 not necessary to be deferred,

RESPONSE_TIMEOUT now 2 s

Becker: CoAP , IP+SN 2011 17 / 23

slide-18
SLIDE 18

Evaluation of libcoap (ROM)

5000 10000 15000 20000 25000 30000 35000 40000 45000 50000

ROM Usage in Bytes

◮ UDPEcho - CoAP without resources: 3708 Byte ◮ Increase to CoAP with resources is mostly because of

additional components

Becker: CoAP , IP+SN 2011 18 / 23

slide-19
SLIDE 19

CoAP vs HTTP (RTT)

◮ Test on GPRS, not 802.15.4, because of

◮ HTTP not available on 802.15.4 ◮ CoAP wasn’t available for TinyOS at that time ◮ CoAP might be of interest for M2M on GPRS as well ◮ Similar RTT for multi-hop 6LoWPAN

Access Method Time (sec) Apache2-Firefox 38.774 Apache2-Epiphany 31.972 Apache2-wget 2.660 Apache2-bareHTTP client 3.032 bareHTTP(TCP) 3.076 bareHTTP(UDP) 1.104 CoAP 1.029

Becker: CoAP , IP+SN 2011 19 / 23

slide-20
SLIDE 20

CoAP vs HTTP (#Bytes)

1928 1201 1186 1115 885 132 107 500 1000 1500 2000 2500

Total Number of Bytes Transmitted

◮ Firefox downloads favicon ◮ Firefox, Epiphany, and

wget add user agents

◮ Apache2 adds

Content-Type etc.

◮ Bare server and clients are

less chatty

◮ UDP reduces at lot ◮ CoAP has retransmission

Becker: CoAP , IP+SN 2011 20 / 23

slide-21
SLIDE 21

CoAP vs HTTP (#Bytes)

Header HTTP/TCP HTTP/UDP CoAP/UDP Link Layer 160 32 32 IP 200 40 40 TCP/UDP 340 16 16 HTTP/CoAP 181 41 17 Data 4 4 2

Table: Separation of Bytes at each Layer

◮ Note: IP without 6LoWPAN

Becker: CoAP , IP+SN 2011 21 / 23

slide-22
SLIDE 22

Conclusions

◮ CoAP for M2M enabled logistic applications ◮ libcoap for Contiki and TinyOS ◮ libcoap is a generic library, specific custom-made

implementations might be smaller

◮ Adaptations necessary, e.g. split-phase operation ◮ More compact than HTTP/TCP

, but reliable on UDP

◮ JNI interface to libcoap for Java available, and possibly

  • ther languages

Becker: CoAP , IP+SN 2011 22 / 23

slide-23
SLIDE 23

Outlook

◮ Measurement of CoAP in deployments ◮ Port to blip-2.0 ◮ Move to coap-05/06 ◮ Simulation with TOSSIM

Becker: CoAP , IP+SN 2011 23 / 23