Something about
Protocols used in Constrained Environments
Vidhya Gholkar @vgholkar

CONSTRAINED ENVIRONMENT
http://tools.ietf.org/html/draft-ietf-lwig-terminology-06| Class | Rough translation |
| 0 | Can't run IP stack securely |
| 1 | Integrated Security but can't employ full stack using HTTP over TLS |
| 2 | Small but benefit from efficient protocols that free resources for application or reduce op costs. Arduino image |
Constrained Application Protocol
- Binary Protocol
- Request-response, RESTful
- does not sit on TCP
- Can proxy to and from HTTP
- NOT HTTP Compression
- draft-ietf-core-coap-18
- draft-ietf-core-observe-11
- RFC 6690
Features
- URI support
- Discovery
- Observation
- Security - DTLS
URI
coap+sms://+441234567/garden/peas/watercoap://building.uk:5633/~room/occ.xml
Request/Response

CoAP message

| Ver | Version |
| T | Transaction Type |
| OC | Option Count |
| Code | Request Method |
| Message ID | Identifier |
CoAP Methods
| Message | Code |
|---|---|
| GET | 0.01 |
| POST | 0.02 |
| PUT | 0.03 |
| DELETE | 0.04 |
Resource Discovery
- CoAP servers provide list of all known resources.
GET /.well-known/core
rt
ct
if
sz
GET /.well-known/core?rt=radiation
2.05 Content
</sensors/radiation>;rt="geiger";if="sensor"
Observe
draft-ietf-core-observe-11
Security
- Datagram TLS
- Records are independent so that if i'th record is lost i+1'th can still be decrypted.
- Handshake messages queued.
- Application is responsible for dealing with loss, reordering and so on.
Code to play with
- Cantcoap https://github.com/staropram/cantcoap
- C COAP Erbium git://github.com/contiki-os/contiki.git
- NodeJS https://github.com/morkai/h5.coap
- Firefox plugin (!) https://addons.mozilla.org/en-US/firefox/addon/copper-270430/
- libcoap http://sourceforge.net/projects/libcoap/
- Arduino implementation https:// github.com/ dgiannakop/ Arduino-CoAP.
Light Weight Device Management
© 2013 Open Mobile Alliance Ltd. All Rights Reserved.
technical.openmobilealliance.org/Technical/release_program/docs/LightweightM2M/V1_0-20131210-C/OMA-TS-LightweightM2M-V1_0-20131210-C.pdf
MQ Telemetry Transport
- Light weight, Binary protocol.
- Topic based Publish - Subscribe.
- For "Q" cf. AMQP, STOMP etc.
- Most recent message can be stored by broker and a Last Will can be set.
- TCP with concomitant TLS/SSL Security.
- 3 levels of Quality of Service (QoS).
- CONNECT, PUBLISH, SUBSCRIBE, UNSUBSCRIBE and DISCONNECT (others).
- MQTT-S addresses TCP constraint to be standardised.
- IBM driven, now at OASIS.
PubSub

Topics and Wild cards
Topic Publish:
/Lille/nord/BldA/hallway/temperature
/Lille/sud/BldB/meetingroom/pressure
Wildcard subscribe:
/Lille/+/+/temperature
/Lille/sud/#
Header and Payload
Core MQTT messages
| Message | Code | Description |
|---|---|---|
| CONNECT | 1 | Client request to connect to Server |
| PUBLISH | 3 | Publish message |
| SUBSCRIBE | 8 | Client Subscribe request |
| UNSUBSCRIBE | 10 | Client Unsubscribe |
| DISCONNECT | 14 | Client is Disconnecting |
Quality of Service

for many constrained devices likely that only QoS 0 available.
Interesting Flags
| PUBLISH | Retain so broker remembers the last published value. |
| CONNECT | CleanSession - Forget sessions/subscriptions. |
Code to play with
- (C, JS, Python etc) http://git.eclipse.org/c/paho/
- Lots of client libraries including .NET, Erlang and Lua! Some are device specific e.g. Netduino. See mqtt.org
- Broker http://mosquitto.org/ http://mqtt.org/wiki/doku.php/public_brokers
Summary
- MQTT is binary PubSub based messaging protocol that requires TCP/IP.
- CoAP is a binary HTTP-like P2P protocol that can also emulate the PubSub pattern.
- Both can be used today.
- Beware of Apples to Oranges comparisons.
- Work with both protocols to see what is right for your application.
END
Something about protocols used in constrained environments
By Vidhya Gholkar
Something about protocols used in constrained environments
CoAP and MQTT - M2M, Internet of things protocols for low power devices.
- 1,619