At present, most IoT modules on the market support TCP, UDP, CoAP, LwM2M, MQTT and other protocols, including both transport layer protocols and application layer protocols. There are many protocols and different applicable scenarios. However, when designing a product, usually only one protocol is needed, so it is particularly important to choose a protocol that meets the application scenario of your product. This article will introduce the characteristics and differences of the five commonly used protocols TCP, UDP, CoAP, LwM2M, and MQTT, to provide a reference for the selection of protocols when designing products.
1. Transport layer protocols TCP and UDP TCP (Transmission Control Protocol) and UDP (User Data Protocol) are both transport layer protocols, providing the same level of communication reliability for upper-layer users. 1. Transmission Control Protocol (TCP): TCP (Transmission Control Protocol) defines the format of data and confirmation information exchanged for reliable transmission between two computers, as well as the measures taken by the computers to ensure the correct arrival of data. The protocol specifies how TCP software can identify multiple destination processes on a given computer and how to recover from errors such as packet duplication. The protocol also specifies how two computers can initiate a TCP data stream transmission and how to end the transmission. The biggest feature of TCP is that it provides a connection-oriented, reliable byte stream service. 2. User Datagram Protocol (UDP): UDP (User Datagram Protocol) is a simple datagram-oriented transport layer protocol. It provides non-connection-oriented, unreliable data stream transmission. UDP does not provide reliability, nor does it provide functions such as message arrival confirmation, sorting, and flow control. It only sends out the datagrams passed by the application to the IP layer, but it cannot guarantee that they can reach the destination. Therefore, the messages may be lost, duplicated, and out of order. However, since UDP does not need to establish a connection between the client and the server before transmitting the datagram, and there is no timeout retransmission mechanism, the transmission speed is very fast. 3. Differences between TCP and UDP
Second, is the transport layer protocol suitable for direct application to IoT device terminals? The transport layer, as the name implies, is only responsible for transmitting data, just like a truck that transports goods. However, if you want the goods to be transported to the destination intact, you need to pack, load, inspect, store, sign the receipt, etc. This requires more work, which is what the application layer protocol needs to do. Therefore, if the IoT device terminal wants to interact with data stably and reliably, it needs to use the application layer protocol instead of the transport layer protocol directly. The following will introduce MQTT, CoAP, and LwM2M, three application layer protocols suitable for use on IoT device terminals. 3. Application layer protocols MQTT and CoAP 1. MQTT Overview MQTT (Message Queuing Telemetry Transport) is an instant messaging protocol developed by IBM, which is likely to become an important part of the Internet of Things. The protocol supports all platforms and can connect almost all networked objects to the outside world. It is used as a communication protocol for sensors and actuators (such as connecting houses to the Internet through Twitter). 2. MQTT protocol features The MQTT protocol is designed for communication between a large number of remote sensors and control devices with limited computing power and working on low-bandwidth, unreliable networks. It has the following main features:
"At most once", message publishing is completely dependent on the underlying TCP/IP network. Message loss or duplication may occur. This level can be used in the following situations, such as environmental sensor data, where it does not matter if a read record is lost because a second send will be sent soon. "At least once", ensure that the message arrives, but message duplication may occur. "Exactly once", ensure that the message arrives once. This level can be used in the following situations, such as in the billing system, where message duplication or loss may lead to incorrect results. Small transmission, small overhead (fixed-length header is 2 bytes), and minimized protocol exchanges to reduce network traffic. 3. CoAP Overview Since many devices in the Internet of Things are resource-constrained, that is, they have only a small amount of memory space and limited computing power, the traditional HTTP protocol is too large and inapplicable to the Internet of Things. The CoRE working group of IETF proposed a CoAP protocol based on the REST architecture. CoAP works in the UDP protocol family and uses a binary format. Compared with the text format used by HTTP, CoAP is more compact than HTTP. 4. CoAP protocol characteristics
5. Differences between MQTT and CoAP 4. So which one is more suitable for IoT devices, MQTT or CoAP? In fact, both MQTT and CoAP are more suitable for IoT devices, but the choice of use still depends on the actual scenario. For example, if the device is running in a scenario where power consumption does not need to be considered but real-time control is required, such as charging piles, express cabinets, etc., it is more appropriate to use the MQTT protocol. If the device usually only reports data and is very sensitive to power consumption, such as water meters, gas meters, etc., it is more appropriate to use the CoAP protocol.
With the rise of the Internet of Things, the era of the Internet of Everything will eventually arrive. However, due to cost and performance considerations, the resources of devices are often limited, so a protocol designed specifically for resource-constrained IoT devices is needed to meet the needs of the Internet of Everything, which is the LwM2M protocol. 1. LwM2M Overview: OMA is an international organization that initially defined a set of OMA-DM protocols for remote management of mobile terminal devices, such as mobile phone account opening, version upgrades, etc. OMA-DM has a very wide range of applications. Many operators, such as Verizon Wireless and Sprint, have their own OMA-DM services and require mobile phones/modules to pass a customized OMA-DM network access test when they join the network. Due to the rise of the Internet of Things, OMA proposed the LwM2M protocol based on the traditional OMA-DM protocol. At the end of 2013, OMA released the LwM2M specification. The main motivation of OMA Lightweight M2M is to define a set of lightweight protocols suitable for various IoT devices, because M2M devices are usually embedded terminals with very limited resources, no UI, limited computing power and network communication capabilities. At the same time, due to the huge number of IoT terminals, saving network resources becomes very important. 2. LwM2M protocol logical entity and logical interface LwM2M defines three logical entities:
There are 4 logical interfaces between these three logical entities:
The relationship between these three logical entities and the four logical interfaces is as follows: 3. LwM2M protocol stack The LwM2M protocol stack structure is shown in the figure below: LwM2M Objects: Each object corresponds to a specific functional entity of the client. The LwM2M specification defines the following standard Objects, such as
Each object can have many resources. For example, a Firmware object can have resources such as Firmware version number, size, etc. Vendor can define its own object:
DTLS: is used to ensure security between the client and the server. 4. Relationship between LwM2M and CoAP LwM2M messages do not have symmetrical feedback messages. Since LwM2M is carried on the CoAP protocol, using CoAP's get, post, put, and delete methods, the feedback on the success or failure of the corresponding message is achieved through the interaction of the CoAP protocol itself. LwM2M payloads support four formats: plain text, Opaque, TLV, and JSON. These four protocols require the server to support them all, and the client must support the TLV format. |
<<: my country's first 5G satellite communication test was successful, and the future is promising
>>: WIFi 5 Final Madness 2019 Wireless Router Market Report
At present, among China's smart home brands, ...
[[426617]] After much anticipation, the long-awai...
CloudServer is a foreign hosting company founded ...
[The Hague, Netherlands, May 29, 2019] The Mobile...
The 2022 MWC Barcelona Conference kicked off rece...
Redis is an open source, network-based, memory-ba...
If you are a telecom broadband user, then you mus...
The tribe has shared information about RepriseHos...
On September 6, during HUAWEI CONNECT 2017, Huawe...
Why is low latency important for 5G? Latency is a...
Advances in technology are dramatically changing ...
Hospitals are the core of protecting the health a...
As 2017 draws to a close, IT industry leaders are...
The rapid development of information technology h...
Wen Ku, director of the Information and Communica...