This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:communications_and_communicating_sut:high_level_communication [2017/12/05 22:05] – pczekalski | en:iot-open:communications_and_communicating_sut:high_level_communication [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | === Host layers | + | ===== ===== |
| - | The host layers protocols include session (SES), presentation (PRES) and application (APP) level, particularly APP (application) layer in the regular Internet communication is dominated by the HTTP protocol and XML-related derivatives | + | <box # |
| + | <box # | ||
| + | ===== Host Layer Protocols | ||
| + | <box # | ||
| + | <box # | ||
| + | |||
| + | The host layers protocols include session (SES), presentation (PRES) and application (APP) level, particularly APP (application) layer in the regular Internet communication is dominated by the HTTP protocol and XML-related derivatives, e.g. SoAP. Also, FTP protocol for file transfer is ubiquitous; | ||
| Some IoT designed protocols are reviewed below. | Some IoT designed protocols are reviewed below. | ||
| - | == MQTT == | + | ==== MQTT ==== |
| - | MQTT protocol ((https:// | + | MQTT protocol ((https:// |
| - | MQTT uses TCP connection so requires open connection channel (this is in opposite to UDP connections, | + | |
| + | MQTT uses TCP connection so requires open connection channel (this is in opposite to UDP connections, | ||
| - | The standard MQTT Message header is composed of just two bytes only (table {{ref> | + | The standard MQTT Message header is composed of just two bytes only (Table {{ref> |
| <table MQTT_header> | <table MQTT_header> | ||
| - | < | + | < |
| ^bit ^ 7 ^ 6 ^ 5 ^ 4 ^ 3 ^ 2 ^ 1 ^ 0 ^ | ^bit ^ 7 ^ 6 ^ 5 ^ 4 ^ 3 ^ 2 ^ 1 ^ 0 ^ | ||
| |byte 1 | Message Type |||| DUP flag | Qos level || RETAIN | |byte 1 | Message Type |||| DUP flag | Qos level || RETAIN | ||
| Line 21: | Line 28: | ||
| MQTT requires for its operation a centralized MQTT broker that is located outside of firewalls and NATs, where all clients connect, send and receive messages via **publish/ | MQTT requires for its operation a centralized MQTT broker that is located outside of firewalls and NATs, where all clients connect, send and receive messages via **publish/ | ||
| <figure mqtt_broker> | <figure mqtt_broker> | ||
| - | {{: | + | {{ : |
| - | < | + | < |
| </ | </ | ||
| - | **MQTT Message**\\ | + | ===MQTT Message=== |
| - | MQTT is text-based protocol and is data-agnostic. | + | MQTT is a text-based protocol and is data-agnostic. |
| A message is composed of a Topic (text) and a Payload (data). | A message is composed of a Topic (text) and a Payload (data). | ||
| - | The topic is a directory-like string with / "slash" delimiter. Thus all topics | + | The topic is a directory-like string with slash ("/" |
| - | The subscriber can subscribe to specific, single | + | The subscriber can subscribe to specific, single |
| - | * # stands for entire branch | + | * # stands for the entire branch, |
| - | * + stands for single level | + | * + stands for the single level. |
| + | |||
| + | //Example Scenario// | ||
| - | __Example scenario__.\\ | ||
| Publishers deliver some air quality information data in separate MQTT messages and for various rooms at the department Inf of the Universities (SUT, RTU, ITMO) to the Broker: | Publishers deliver some air quality information data in separate MQTT messages and for various rooms at the department Inf of the Universities (SUT, RTU, ITMO) to the Broker: | ||
| ^ Topic (publishers): | ^ Topic (publishers): | ||
| Line 45: | Line 53: | ||
| | RTU/ | | RTU/ | ||
| - | The subscriber 1 wants to get all sensor data for SUT university, Inf (informatics) department only, for any space: | + | The subscriber 1 wills to get all sensor data for SUT university, Inf (informatics) department only, for any space: |
| ^ Topic (subscription): | ^ Topic (subscription): | ||
| | SUT/ | | SUT/ | ||
| - | The subscriber 2 wants to get Temperature data only from any sensor and in any location in ITMO: | + | The subscriber 2 wills to get only Temperature data virtually |
| ^ Topic (subscription): | ^ Topic (subscription): | ||
| | ITMO/#/ | | ITMO/#/ | ||
| - | The subscriber 3 wants to get any information | + | The subscriber 3 wills to get any information from the sensors, but only for the RTU |
| ^ Topic (subscription): | ^ Topic (subscription): | ||
| | RTU/# | | | RTU/# | | ||
| - | The payload (data) of the message is text as well, so in case one need to send binary data, it is necessary to encode it (i.e. Base64). | + | The payload (data) of the message is text as well, so in case one need to send binary data, it is necessary to encode it (e.g. Base64). |
| - | **MQTT Broker**\\ | + | ===MQTT Broker=== |
| - | MQTT Broker is a server for both publishers and subscribers. The connection is initiated from client to the Broker, so assuming it is located outside of a firewall, it breaks firewall its boundaries. | + | MQTT Broker is a server for both publishers and subscribers. The connection is initiated from the client to the Broker, so assuming it is located outside of a firewall, it breaks firewall its boundaries. |
| - | The Broker provides QoS (Quality of Service) and it can retain message payload. There are three levels of MQTT Broker QoS (provided on the message level): | + | The Broker provides QoS (Quality of Service), and it can retain message payload. There are three levels of MQTT Broker QoS (supplied in the message level). |
| * Unacknowledged service: Ensures that MQTT message is delivered at most once to each subscriber. | * Unacknowledged service: Ensures that MQTT message is delivered at most once to each subscriber. | ||
| - | * Acknowledged service: Ensures delivery of the message at least once to every subscriber. The broker expects acknowledgement to be sent from the subscriber, otherwise, it retransmits data. | + | * Acknowledged service: Ensures delivery of the message at least once to every subscriber. The broker expects acknowledgement to be sent from the subscriber. Otherwise, it retransmits data. |
| * Assured service: This is two-step delivery of the message, and ensures the message is delivered exactly once to every subscriber. | * Assured service: This is two-step delivery of the message, and ensures the message is delivered exactly once to every subscriber. | ||
| For Acknowledged and Assured services it is vital to provide unique packet IDs in MQTT frame.\\ | For Acknowledged and Assured services it is vital to provide unique packet IDs in MQTT frame.\\ | ||
| - | The DUP flag (byte 1, bit 3) represents | + | The DUP flag (byte 1, bit 3) represents information sent by the publisher if the message is a "first try" (0) or a retransmitted one (1). It is mostly for internal purposes, and this flag is never propagated to the subscribers. |
| MQTT offers some limited set of features (options): | MQTT offers some limited set of features (options): | ||
| - | * Clean session flag for durable connections: | + | * clean session flag for durable connections: |
| - | * If set True, Broker removes all of the client subscriptions on client disconnect. | + | * if set //TRUE//, Broker removes all of the client subscriptions on client disconnect; |
| - | * Otherwise | + | * otherwise |
| - | * MQTT " | + | * MQTT " |
| - | * Message | + | * message |
| Interestingly MQTT is a protocol used by Facebook Messenger ((https:// | Interestingly MQTT is a protocol used by Facebook Messenger ((https:// | ||
| - | MQTT security is rather | + | MQTT security is rather |
| - | A short comparison of MQTT and HTTP protocols are presented in the table {{ref> | + | A short comparison of MQTT and HTTP protocols are presented in the Table {{ref> |
| <table http_vs_mqtt> | <table http_vs_mqtt> | ||
| < | < | ||
| | ^ MQTT ^ HTTP ^ | | ^ MQTT ^ HTTP ^ | ||
| ^ Design | ^ Design | ||
| - | ^ Pattern | + | ^ Pattern |
| ^ Complexity | ^ Complexity | ||
| ^ Message size | Small, with 2 byte binary header | ^ Message size | Small, with 2 byte binary header | ||
| - | ^ Service levels | + | ^ Service levels |
| - | ^ Implementation | + | ^ Implementation |
| ^ Data distribution models | ^ Data distribution models | ||
| </ | </ | ||
| - | == CoAP == | + | ==== CoAP ==== |
| - | CoAP protocol (RFC7252) originates from the REST (Representational State Transfer). CoAP does not use a centralized | + | CoAP protocol (RFC7252) originates from the REST (Representational State Transfer). CoAP does not use a centralised |
| - | * %%" | + | * %%" |
| * a secure, encrypted version uses " | * a secure, encrypted version uses " | ||
| It supports various content types, can work with proxy and can be cached.\\ | It supports various content types, can work with proxy and can be cached.\\ | ||
| - | The protocol is designed to be compact and simple to implement. The stack implementation takes only about 10kB or RAM and 100kB of storage. The header is only 4 bytes.\\ | + | The protocol is designed to be compact and simple to implement. The stack implementation takes only about 10 kB of RAM and 100 kB of storage. The header is only 4 bytes. |
| CoAP protocol has a binary header to decrease overhead but payload depends on the content type. Initial, non-exclusive list of the payload types include: | CoAP protocol has a binary header to decrease overhead but payload depends on the content type. Initial, non-exclusive list of the payload types include: | ||
| * text/plain (charset=utf-8) (ID=0, RFC2046, RFC3676, RFC5147), | * text/plain (charset=utf-8) (ID=0, RFC2046, RFC3676, RFC5147), | ||
| Line 105: | Line 114: | ||
| * application/ | * application/ | ||
| - | CoAP endpoint services are identified by unique IP and port number, however, they operate on the UDP instead of TCP (like i.e. HTML does). The transfer in CoAP is made using non-reliable UDP network, so a message can appear duplicated, disappear or it can be delivered in other order than initially sent. Because of the nature of datagram communication, | + | CoAP endpoint services are identified by unique IP and port number. However, they operate on the UDP instead of TCP (like, e.g. HTML does). The transfer in CoAP is made using non-reliable UDP network so that a message can appear duplicated, disappear or it can be delivered in other order than initially sent. Because of the nature of datagram communication, |
| CoAP messages can be (non-exhaustive list): | CoAP messages can be (non-exhaustive list): | ||
| * CON (Confirmable, | * CON (Confirmable, | ||
| - | * NON (Non-Confirmable, | + | * NON (Non-Confirmable, |
| * ACK (an acknowledgement message), | * ACK (an acknowledgement message), | ||
| - | * RESET (sent if CON or NON was received, but the receiver cannot understand the context, | + | * RESET (sent if CON or NON was received, but the receiver cannot understand the context, e.g. part of the communication is missing because of device restart, messages memory loss, etc.). Empty RESET messages can be used to " |
| - | Because of the UDP network characteristics, | + | Because of the UDP network characteristics, |
| * stop and wait for retransmission with exponential back-off for CON messages, | * stop and wait for retransmission with exponential back-off for CON messages, | ||
| - | * duplicate message detection for CON and NON messages. | + | * duplicate message detection for CON and NON-messages. |
| Request-reponse pair is identified by a unique " | Request-reponse pair is identified by a unique " | ||
| - | Sample request-response scenarios are presented | + | Sample request-response scenarios are presented |
| - | Sample CoAP message exchange scenarios between client and server are presented | + | Sample CoAP message exchange scenarios between client and server are presented (two per image) |
| <figure CoAP1> | <figure CoAP1> | ||
| - | {{: | + | {{ : |
| - | < | + | < |
| </ | </ | ||
| <figure CoAP2> | <figure CoAP2> | ||
| - | {{: | + | {{ : |
| - | < | + | < |
| </ | </ | ||
| - | The scenario | + | The scenario |
| - | The scenario | + | The scenario |
| - | The scenario | + | The scenario |
| - | The scenario | + | The scenario |