This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:iot-open:networking2:applicationnetworkprotocols [2023/11/23 16:12] – pczekalski | en:iot-open:networking2:applicationnetworkprotocols [2024/08/28 15:56] (current) – pczekalski | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | |||
====== Application Protocols ====== | ====== Application Protocols ====== | ||
{{: | {{: | ||
The host layers protocols include session (SES), presentation (PRES) and application (APP) levels. In particular, the APP (application) layer in regular Internet communication is dominated by the HTTP protocol and XML-related derivatives, | The host layers protocols include session (SES), presentation (PRES) and application (APP) levels. In particular, the APP (application) layer in regular Internet communication is dominated by the HTTP protocol and XML-related derivatives, | ||
Although advanced and more powerful IoT devices frequently use these protocols, this is problematic to implement in the constrained IoT devices world: even the simplest HTTP header occupies at least 24 + 8 + 8 + 31 bytes without payload! \\ | Although advanced and more powerful IoT devices frequently use these protocols, this is problematic to implement in the constrained IoT devices world: even the simplest HTTP header occupies at least 24 + 8 + 8 + 31 bytes without payload! \\ | ||
- | There is also a problem | + | There is also a problem |
\\ | \\ | ||
Some IoT-designed protocols are reviewed below. | Some IoT-designed protocols are reviewed below. | ||
Line 24: | Line 23: | ||
MQTT requires a centralised MQTT Broker located outside firewalls and NATs, where all clients connect, send and receive messages via the **publish/ | MQTT requires a centralised MQTT Broker located outside firewalls and NATs, where all clients connect, send and receive messages via the **publish/ | ||
<figure mqtt_broker> | <figure mqtt_broker> | ||
- | {{ : | + | {{ : |
< | < | ||
</ | </ | ||
Line 59: | Line 58: | ||
| RTU/# | | | RTU/# | | ||
- | The payload (data) | + | The message' |
**MQTT Broker**\\ | **MQTT Broker**\\ | ||
MQTT Broker is a server for both publishers and subscribers. The connection is initiated from the client to the Broker, so assuming the Broker is located outside a firewall, it breaks its boundaries.\\ | MQTT Broker is a server for both publishers and subscribers. The connection is initiated from the client to the Broker, so assuming the Broker is located outside a firewall, it breaks its boundaries.\\ | ||
- | The Broker provides QoS (Quality of Service) and can retain message payload. | + | The Broker provides QoS (Quality of Service) and can retain message payload. MQTT Broker QoS (supplied |
* 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 message delivery at least once to every subscriber. The Broker expects acknowledgement to be sent from the subscriber. Otherwise, it retransmits data. | + | * Acknowledged service: Ensures message delivery |
- | * Assured service: This is a two-step delivery | + | * Assured service: This two-step |
Providing unique packet IDs in the MQTT frame is vital for Acknowledged and Assured services.\\ | Providing unique packet IDs in the MQTT frame is vital for Acknowledged and Assured services.\\ | ||
- | The DUP flag (byte 1, bit 3) represents information sent by the publisher | + | The DUP flag (byte 1, bit 3) represents information sent by the publisher, indicating whether |
MQTT offers a limited set of features (options): | MQTT offers a limited set of features (options): | ||
Line 80: | Line 79: | ||
Interestingly, | Interestingly, | ||
- | MQTT security is relatively weak. MQTT Broker can offer user and password verification sent in plain text. However, all communication between client and Broker may be encapsulated in SSL, encrypted stream. | + | MQTT security is relatively weak. The MQTT Broker can offer user and password verification sent in plain text. However, all communication between |
A short comparison of MQTT and HTTP protocols is presented in table {{ref> | A short comparison of MQTT and HTTP protocols is presented in table {{ref> | ||
Line 97: | Line 96: | ||
== CoAP == | == CoAP == | ||
- | CoAP protocol (RFC7252) originates from the REST (Representational State Transfer). CoAP does not use a centralised server as MQTT does, but every single device " | + | CoAP protocol (RFC7252) originates from the REST (Representational State Transfer). CoAP does not use a centralised server as MQTT does, but every single device " |
CoAP uses URIs to address services: | CoAP uses URIs to address services: | ||
* %%coap://< | * %%coap://< | ||
Line 126: | Line 125: | ||
Sample CoAP message exchange scenarios between client and server are presented (two per image) in figure {{ref> | Sample CoAP message exchange scenarios between client and server are presented (two per image) in figure {{ref> | ||
<figure CoAP1> | <figure CoAP1> | ||
- | {{ : | + | {{ : |
< | < | ||
</ | </ | ||
<figure CoAP2> | <figure CoAP2> | ||
- | {{ : | + | {{ : |
< | < | ||
</ | </ | ||
Line 139: | Line 138: | ||
== AMQP == | == AMQP == | ||
- | In its principles, the AMQP (Advanced Message Queuing Protocol) somehow recalls MQTT: it is message-oriented and uses a central broker. There are data publishers and consumers (that, in the case of the MQTT, are called subscribers). Messages are routed from publishers to the Broker, where they hit so-called exchanges, and then they are copied to the queues (0, 1 or more) that the consumer can later read from. A diagram of the message' | + | In its principles, the AMQP (Advanced Message Queuing Protocol) somehow recalls MQTT: it is message-oriented and uses a central broker. There are data publishers and consumers (that, in the case of the MQTT, are called subscribers). Messages are routed from publishers to the Broker, where they hit so-called exchanges, and then they are copied to the queues (0, 1 or more) from which the consumer can later read. A diagram of the message' |
<figure amqp1> | <figure amqp1> | ||
- | {{ : | + | {{ : |
< | < | ||
</ | </ | ||
- | |||
AMQP uses TCP/IP. AMQP is intended to work in non-reliable networks; thus, the protocol has a message acknowledgement mechanism to ensure delivery. A message is removed from the queue only if it has been acknowledged. Besides acknowledged delivery, it is also possible to use an unacknowledged one that does not involve acknowledgements. If a message cannot be routed (for any reason), it can be returned to the publisher, dropped or placed in the "dead letter queue" | AMQP uses TCP/IP. AMQP is intended to work in non-reliable networks; thus, the protocol has a message acknowledgement mechanism to ensure delivery. A message is removed from the queue only if it has been acknowledged. Besides acknowledged delivery, it is also possible to use an unacknowledged one that does not involve acknowledgements. If a message cannot be routed (for any reason), it can be returned to the publisher, dropped or placed in the "dead letter queue" | ||
**Queues**\\ | **Queues**\\ | ||
AMQP is a programmable protocol, so bindings are not defined by the Broker but rather by the publisher. Queues are also created on-demand via external actors (mostly consumers). Routing via bindings is provided with a message, and the Broker analyses it to provide correct message handling and delivery.\\ | AMQP is a programmable protocol, so bindings are not defined by the Broker but rather by the publisher. Queues are also created on-demand via external actors (mostly consumers). Routing via bindings is provided with a message, and the Broker analyses it to provide correct message handling and delivery.\\ | ||
- | Consumers can subscribe to the exchange and define a queue. Bindings then act as filters so they receive only selected messages. A single queue is intended to handle one consumer, but there does exist a possibility | + | Consumers can subscribe to the exchange and define a queue. Bindings then act as filters so they receive only selected messages. A single queue is intended to handle one consumer, but there is a possibility |
As in the protocol version 0.9, queues have the following properties: | As in the protocol version 0.9, queues have the following properties: | ||
* Name, | * Name, |