43
Building and Managing IoT Apps with Lightweight M2M Virtual IoT Meetup - Sept. 10, 2015 Julien Vermillard Sierra Wireless

Building and managing iot applications with Lightweight M2M

Embed Size (px)

Citation preview

Page 1: Building and managing iot applications with Lightweight M2M

Building and Managing IoT Apps with Lightweight M2M

Virtual IoT Meetup - Sept. 10, 2015

Julien Vermillard – Sierra Wireless

Page 2: Building and managing iot applications with Lightweight M2M

Building and Managing IoT Apps with Lightweight M2M

Virtual IoT Meetup - Sept. 10, 2015

Julien Vermillard – Sierra Wireless

Page 3: Building and managing iot applications with Lightweight M2M

Agenda● From M2M to Web-of -Things● Device management 101● Intro to Lightweight M2M● Security with LwM2M

○ End-to-End vs Gateways○ Secrets & Access control

● Get started with Leshan & Wakaama

Page 4: Building and managing iot applications with Lightweight M2M

Machine-to-Machine

Server

Machine A Machine B Machine C

Page 5: Building and managing iot applications with Lightweight M2M

Internet-of-Things

Page 6: Building and managing iot applications with Lightweight M2M

Web-of-Things

/walk/hand/left/raise/eye/picture

/on/red/green/blue/mtbf

/on/on

/buttons/buttons/1/push/bat-level

/engine/status/position/fuel /CO2

/noise/lights/on

Page 7: Building and managing iot applications with Lightweight M2M

Conquering the last mileLow power networks plugged to the Internet

● 6LowPAN● Bluetooth Smart 4.2● Thread

IPv6 MTU: 1280 bytes, 6LowPAN: ~100 bytes

TCP, HTTP,MQTT doesn’t fit

Page 8: Building and managing iot applications with Lightweight M2M

CoAP: a new protocol for the IoTClass 1 devices~100KiB Flash~10KiB RAM~$1

Low-power networks<100Bytes packets

Page 9: Building and managing iot applications with Lightweight M2M

CoAP in a nutshellRESTful protocol designed from scratch

URIs, Internet Media TypesGET, POST, PUT, DELETE

Transparent mapping to HTTPAdditional features for M2M scenarios

Observe

Page 10: Building and managing iot applications with Lightweight M2M

CoAP: Constrained Application ProtocolBinary protocol- Low parsing complexity

- Small message size

Options- Binary HTTP-like headers

0 – 8 Bytes TokenExchange handle for client

4-byte Base HeaderVersion | Type | T-len | Code | ID

OptionsLocation, Max-Age, ETag, …

Marker0xFF

PayloadRepresentation

Page 11: Building and managing iot applications with Lightweight M2M

Device management?Secure, monitor, manage a fleet of devices

● Configure the device ● Update the firmware (and maybe the app)● Monitor and gather connectivity statistics

Page 12: Building and managing iot applications with Lightweight M2M

Device managementYou don't know yet what hardware will power your IoT projects on the field,

But you MUST be able to do device management in a consistent way without vendor lock

Page 13: Building and managing iot applications with Lightweight M2M

OMA Lightweight M2M

An API on top of CoAP

Page 14: Building and managing iot applications with Lightweight M2M

Lightweight M2MREST API for:

Security, Device, Server

Connectivity monitoring, Connectivity statistics

Location, Firmware Upgrade, Software management,

Swipe & Lock

But objects have a numerical identifier

Page 15: Building and managing iot applications with Lightweight M2M

Lightweight M2M - CoAP URLs/{object}/{instance}/{resource}

Examples:● "/6/0" the whole location object (binary record)

● "/6/0/1" only the longitude (degree)

Page 16: Building and managing iot applications with Lightweight M2M

Example: Object DeviceManufacturerModel numberSerial numberFirmware versionRebootFactory resetPower sources

Power V/ABattery levelMemory freeError codeCurrent timeUTC offsetTimezone

Page 17: Building and managing iot applications with Lightweight M2M

Also with applicative objectsYou can define your own objects

Discoverable using CoAP Link Format

IPSO Alliance Smart Objects:

accelerometer, temperature, sensors,...

Page 18: Building and managing iot applications with Lightweight M2M

Demo!

Page 19: Building and managing iot applications with Lightweight M2M

Security with LwM2M

DTLS and secret management

Page 20: Building and managing iot applications with Lightweight M2M

Authentication and encryptionBased on DTLS 1.2 (TLS for Datagrams)

Focus on AES & Elliptic Curve Cryptography (ECC)

AES Hardware acceleration in IoT oriented SoC

Works on Low Power networks (~100bytes MTU)

Page 21: Building and managing iot applications with Lightweight M2M

TLS_PSK_WITH_AES_128_CCM_8Pre-Shared-Key:password for session authentication

AES 128bits (or 256) - Counter CBC Mode:encryption and integrity (AEAD cipher)8 bytes for integrity in place of CCM usual 16

Page 22: Building and managing iot applications with Lightweight M2M

What? :DPSK: No certificates, just password

CCM8: compactness

Full DTLS-PSK-CCM8 handshake in ~1030 bytes

Ex: HTTPS TLS handshake ~6000bytes

Page 23: Building and managing iot applications with Lightweight M2M

More security: TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8

ECDHE: Perfect Forward Secrecy (PFS)Someone rob your private key: he can’t decrypt past communications

ECDSA: use public key in place of passwordYou can use X.509 certificates (like HTTPS)

Page 24: Building and managing iot applications with Lightweight M2M

Security with gateways

public network

Sensor network(ex: Zigbee)

Gateway:collect data and push to cloud

cable, 4G, etc..

Secure transportLow or no security

Page 25: Building and managing iot applications with Lightweight M2M

Security with gateways

public network

Sensor network(ex: Zigbee)

cable, 4G, etc..

Attack gatewayget access to all the network

Local wireless sniffing

Page 26: Building and managing iot applications with Lightweight M2M

Other gateway architecture flawsComplexity: mixing IP and non IP networks

Lack of flexibility compared to end-to-end IP

Hard to scale vs IP routing

Page 27: Building and managing iot applications with Lightweight M2M

End-to-end security

public network

Low power nodes:security starts here

Sensor network(ex: Thread)

Router

cable, 4G, etc..

See only encrypted communicationNot your Achilles heel

Page 28: Building and managing iot applications with Lightweight M2M

At scale?You will have a fleet of device

They needs secrets (key, password, etc..)

Unique across devices

You need to be able to change those secrets

You will probably don’t trust your factory

Page 29: Building and managing iot applications with Lightweight M2M

Lightweight M2M Bootstrap

Flash bootstrap credentials

Page 30: Building and managing iot applications with Lightweight M2M

I only have bootstrap credentials or I can’t reach final server

Lightweight M2M Bootstrap

Page 31: Building and managing iot applications with Lightweight M2M

Lightweight M2M Bootstrap

Give me key and my server(s)

Bootstrap Server

Page 32: Building and managing iot applications with Lightweight M2M

Lightweight M2M Bootstrap

New key and server(s) URLsand ACL

Bootstrap Server

Page 33: Building and managing iot applications with Lightweight M2M

Lightweight M2M Bootstrap

Registration

Bootstrap Server

Registration

Home AutomationServer

Device Manag.Server

Page 34: Building and managing iot applications with Lightweight M2M

Access Control ListsDefine which operation on a given object for a given server

One server for Over-The-Air upgrade: “/5/”+“/9/” read, write, exec

One server for application, maybe with: “/5” read only

Page 35: Building and managing iot applications with Lightweight M2M

Hands-On!

Getting started with Leshan & Wakaama

Page 36: Building and managing iot applications with Lightweight M2M

LeshanJava library for implementing servers & clients

Friendly for any Java developer

Simple (no framework, few dependencies)

But also a Web UI for discovering and testing

Build using “mvn install”

Based on Californium and Scandium

Page 37: Building and managing iot applications with Lightweight M2M

Public sandboxhttp://leshan.eclipse.org

Bleeding edge: deployed on master commit

IPv4 and IPv6

Press “CoAP messages” for low-level traces

Page 38: Building and managing iot applications with Lightweight M2M

WakaamaA C client and server implementation of LwM2M

Not a shared library (.so/.dll)

Embedded friendly but using malloc/free

Plug your own IP stack and DTLS implementation

Page 39: Building and managing iot applications with Lightweight M2M

Wakaama featuresRegister, registration update, deregister

Read, write resources

Read, write, create, delete object instances

TLV or plain text

Observe

Page 40: Building and managing iot applications with Lightweight M2M

Wakaama internalscore :internals.h liblwm2m.c liblwm2m.hlist.c management.c objects.c observe.cpacket.c registration.c tlv.c transaction.curi.c utils.c

core/er-coap-13 :er-coap-13.c er-coap-13.h

Page 41: Building and managing iot applications with Lightweight M2M

TinydtlsEclipse Proposal“Support session multiplexing in single-threaded applications and thus targets specifically on embedded systems.”

Examples for Linux, or Contiki OSTLS_PSK_WITH_AES_128_CCM_8TLS_ECDHE_ECDSA_WITH_AES128_CCM_8

Page 42: Building and managing iot applications with Lightweight M2M

In real hardware?Spark Core:Cortex-M3 STM32, RAM/ROM 20/128k, 72MHzWiFi

Arduino MegaAVR, ATmega2560,

RAM/ROM 8/256k, 16MHzEthernet