IoT protocol overview

Table of contents

foreword

content

CoAP (Constrained Application Protocol)

MQTT (Message Queuing Telemetry Transport Message Queue Telemetry Transmission)

Which protocol? Analyze how to choose from the level of application scenario requirements

1. The timeliness of the data (anti-control) actively sent by the server to the client (such as controlling hardware actions through APP)

2. Requirements or limitations of the device environment on the underlying protocol

3. Does it need to be adjusted in the NAT network environment?

4. To achieve many-to-many communication or one-to-one communication

5. Service quality level and automatic reconnection and resend

6. Requirements for network stability

7. Impact on power consumption of hardware devices


foreword

The Internet of Things is a network that extends and expands on the basis of the Internet. Its client end extends and expands to any item, and exchanges information and communicates with each other. The purpose is to realize the connection between all items and the network, so as to facilitate identification and management. and control.

The characteristics of the wireless Internet of Things include: comprehensive perception, real-time and accurate transmission of item information, and the use of intelligent computing technology to analyze and process massive data to achieve intelligent control.

Since many devices in the Internet of Things are resource-constrained, that is, only a small amount of memory space and limited computing power , the application of the traditional HTTP protocol in the Internet of Things is too large and inapplicable.

Both the MQTT protocol and the CoAP protocol are relatively popular protocols in the Internet of Things, and both have greatly simplified the transmission volume, and the transmission overhead is small to adapt to the network environment of the physical network.

content

CoAP (Constrained Application Protocol)

CoAP is an application layer protocol in the 6LowPAN protocol stack. The network transport layer of the COAP protocol is changed from TCP to UDP.
COAP is in binary format, HTTP is in text format, and COAP is more compact than HTTP.
Lightweight, the minimum length of COAP is only 4B, and an HTTP header is dozens of B.
Support reliable transmission, data retransmission, block transmission. Make sure data arrives reliably.
Supports IP multicast, that is, requests can be sent to multiple devices at the same time.
Non-persistent connection communication, suitable for low-power IoT scenarios.

MQTT (Message Queuing Telemetry Transport Message Queue Telemetry Transmission)

A publish/subscribe messaging protocol designed for remote devices with low hardware performance and poor network conditions . Lightweight, simple, open and easy to implement.
1. Use the publish/subscribe message mode to provide one-to-many message publishing and decoupling applications.
2. Use TCP/IP to provide network connections.
3. Small transmission with low overhead (fixed-length header is 2 bytes), Protocol exchanges are minimized to reduce network traffic.


These features make it suitable for constrained environments. For example, but not limited to:
Especially suitable for expensive network, low bandwidth, unreliable environment
・Can run in embedded devices with limited processor and memory
resources Publish messages to release application coupling
. Use TCP/IP to provide network connections
. Provide Last Will and Testament features to notify relevant parties. A mechanism for abnormal client interruption


Which protocol? Analyze how to choose from the level of application scenario requirements

1. The timeliness of the data (anti-control) actively sent by the server to the client (such as controlling hardware actions through APP)
 

       Because the MQTT protocol keeps the connection , the timeliness is relatively good; the CoAP protocol is a connectionless response communication , so it cannot be actively pushed, and it can be carried back only after the client accesses, and the timeliness is relatively poor.

2. Requirements or limitations of the device environment on the underlying protocol


  The MQTT protocol is based on  the TCP  protocol, so it also has the advantages and disadvantages of the TCP protocol; the CoAP protocol is based on the  UDP  protocol, so it also has the advantages and disadvantages of the UDP protocol.

3. Does it need to be adjusted in the NAT network environment?


  Because the MQTT protocol maintains a long-term connection, there is no problem under NAT (Network Address Translation). The CoAP protocol needs to use NAT penetration because it is a connectionless method.

NAT NAT (Network Address Translation, Network Address Translation) was proposed in 1994. When some hosts in the private network have been assigned local IP addresses (that is, private addresses used only in the private network), but now want to communicate with hosts on the Internet (no encryption is required), NAT can be used method. This method requires NAT software to be installed on the router that connects the private network to the Internet. A router with NAT software installed is called a NAT router, and it has at least one valid external global IP address. In this way, when all hosts using local addresses communicate with the outside world, their local addresses must be converted into global IP addresses on the NAT router in order to connect to the Internet.

4. To achieve many-to-many communication or one-to-one communication


  Because the message model of the MQTT protocol is publish/subscribe, it can communicate many-to-many ; the message model of the CoAP protocol is request/response, so it is one-to-one communication.

5. Service quality level and automatic reconnection and resend


  Because the MQTT protocol has QoS configuration, it supports service quality level and automatic reconnection and retransmission mechanism; CoAP itself does not have it, and the application layer needs to write this logic by itself.

  

6. Requirements for network stability


  The MQTT protocol uses the automatic reconnection and retransmission mechanism to solve the problem of network instability, and reconnection will be triggered when the network is disconnected; the CoAP protocol only needs to ensure that the network connection is normal when the client sends, and does not need to be connected during other periods.

7. Impact on power consumption of hardware devices


  The power consumption of the MQTT protocol is slightly higher than that of the CoAP protocol because of the keep-alive.

Guess you like

Origin blog.csdn.net/flyTie/article/details/126186579