Internet of Things
Lecture 5 - CoAP & MQTT
CoAP
Constrained Application Protocol
CoAP:The Web of Things Protocol
3
Source: https://www.iab.org/wp-content/IAB-uploads/2011/04/Shelby.pdf
Lecture 5 - CoAP & MQTT
When to use CoAP?
4
Lecture 5 - CoAP & MQTT
CoAP Design Requirements
5
Source: https://www.iab.org/wp-content/IAB-uploads/2011/04/Shelby.pdf
Lecture 5 - CoAP & MQTT
CoAP Design Requirements
6
CoAP Design Requirements
7
CoAP Design Requirements
8
What CoAP is (and is not)
9
Lecture 5 - CoAP & MQTT
CoAP Features
10
Lecture 5 - CoAP & MQTT
CoAP Features
11
Lecture 5 - CoAP & MQTT
CoAP Features
12
Lecture 5 - CoAP & MQTT
Transaction Model
13
Lecture 5 - CoAP & MQTT
Method | CRUD | Action |
GET | read | returns requested data |
POST | create | creates a new record |
PUT | update | updates an existing record |
DELETE | delete | deletes an existing record |
CoAP Message Header (4 bytes)
14
Ver: CoAP version - 2 bits
T: message type - 2 bits
TKL: Token Length - 4 bits
Code: method or response code - 8 bits
Message ID: 16 bits
Token: 0-8 bytes
Message type:
CoAP Message Header (4 bytes)
15
Confirmable Request Example
16
Confirmable Request
Piggy-backed Response
Source: https://www.iab.org/wp-content/IAB-uploads/2011/04/Shelby.pdf
Message ID
Response code
Type
Lecture 5 - CoAP & MQTT
IoT node
Non-confirmable Request Example
17
Source: https://www.iab.org/wp-content/IAB-uploads/2011/04/Shelby.pdf
Message ID
Type
Lecture 5 - CoAP & MQTT
Dealing with Packet Loss
18
Source: https://www.iab.org/wp-content/IAB-uploads/2011/04/Shelby.pdf
Message ID
Type
Response code
Lecture 5 - CoAP & MQTT
Separate Response
19
Source: https://www.iab.org/wp-content/IAB-uploads/2011/04/Shelby.pdf
Same token
Lecture 5 - CoAP & MQTT
Message ID
Type
Bits and bytes...
20
CoAP - Caching Model
21
Lecture 5 - CoAP & MQTT
Proxying and caching
22
Source: https://www.iab.org/wp-content/IAB-uploads/2011/04/Shelby.pdf
RFC 7641: Observing Resources (Subscription)
23
Source: https://www.iab.org/wp-content/IAB-uploads/2011/04/Shelby.pdf
RFC 7959: Block-wise transfer
24
Source: https://www.iab.org/wp-content/IAB-uploads/2011/04/Shelby.pdf
Getting Started with CoAP
25
Lecture 5 - CoAP & MQTT
Getting Started with CoAP
26
Lecture 5 - CoAP & MQTT
MQTT
Message Queueing Telemetry Transport
MQTT
28
Lecture 5 - CoAP & MQTT
MQTT Features
29
Lecture 5 - CoAP & MQTT
MQTT Features
30
Lecture 5 - CoAP & MQTT
MQTT Features
31
Lecture 5 - CoAP & MQTT
MQTT Features
32
Lecture 5 - CoAP & MQTT
Publish/Subscribe
33
Image source: https://www.paessler.com/it-explained/mqtt
Lecture 5 - CoAP & MQTT
Publish/Subscribe
34
Image source: https://www.twilio.com/en-us/blog/what-is-mqtt
Topics
35
Lecture 5 - CoAP & MQTT
Topics - Wildcards
36
Lecture 5 - CoAP & MQTT
Actions in MQTT
37
Lecture 5 - CoAP & MQTT
Actions in MQTT
38
Lecture 5 - CoAP & MQTT
QoS Levels
39
Lecture 5 - CoAP & MQTT
Image source: https://emqx.medium.com/introduction-to-mqtt-5-0-protocol-qos-quality-of-service-e6d9b0aaf9fb
QoS Levels
40
Lecture 5 - CoAP & MQTT
Image source: https://emqx.medium.com/introduction-to-mqtt-5-0-protocol-qos-quality-of-service-e6d9b0aaf9fb
QoS Levels
41
Lecture 5 - CoAP & MQTT
MQTT Messages
42
Image source: https://www.techtarget.com/iotagenda/definition/MQTT-MQ-Telemetry-Transport
QoS Levels
43
Lecture 5 - CoAP & MQTT
MQTT Options
44
Lecture 5 - CoAP & MQTT
MQTT Options
45
Lecture 5 - CoAP & MQTT
https://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament/
MQTT vs. CoAP
46
Image Source: https://www.trendmicro.com/vinfo/es/security/news/internet-of-things/mqtt-and-coap-security-and-privacy-issues-in-iot-and-iiot-communication-protocols
Lecture 5 - CoAP & MQTT
MQTT vs. CoAP
47
Features | MQTT | CoAP |
Base protocol | TCP | UDP |
Model used for communication | Publish-Subscribe | Request-Response Publish-Subscribe (observing resources) |
Communication node | many-to-many | one-to-one |
Power consumption | Higher than CoAP | Lower than MQTT |
RESTful | No | Yes |
Number of messages type used | 16 | 4 |
Header size | 2 Bytes | 4 Bytes |
Messaging | Asynchronous | Asynchronous & Synchronous |
Reliability | 3 Quality of service levels | Confirmable messages |
Caching | On Broker | On Proxy |
Security | Username/Password Can use TLS/SSL | Can use DTLS or IPSec |
Bibliography
48
Lecture 5 - CoAP & MQTT
Bibliography
49
Lecture 5 - CoAP & MQTT