In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to choose the communication protocol for the IoT terminal equipment of the Internet of things". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to choose the communication protocol for IoT terminal devices of the Internet of things.
1. Transport layer protocols TCP and UDP
TCP (Transmission Control Protocol, Transport Controll Protocol) and UDP (user Datagram Protocol, User Data Protocol) belong to the transport layer protocols, which provide the upper layer users with a level of communication reliability.
1. Transmission Control Protocol (TCP):
TCP (Transmission Control Protocol) defines the format of data and confirmation information exchanged between two computers for reliable transmission, as well as the measures taken by the computer to ensure the correct arrival of the data. The protocol specifies how TCP software identifies multiple destination processes on a given computer and how to recover errors such as packet repetition. The protocol also specifies how the two computers initialize an TCP data stream transmission and how to end the transmission. The most important feature of TCP is that it provides connection-oriented and reliable byte streaming service.
two。 User Datagram Protocol (UDP):
UDP (user Datagram Protocol) is a simple Datagram-oriented transport layer protocol. Non-connection-oriented, unreliable data stream transmission is provided. UDP does not provide reliability, nor does it provide packet arrival confirmation, sorting, flow control and other functions. It just sends the datagrams that the application sends to the IP layer, but there is no guarantee that they will reach their destination. As a result, messages may be lost, duplicated and out of order. However, because UDP does not need to establish a connection between the client and the server before transmitting the Datagram, and there is no mechanism such as timeout retransmission, the transmission speed is fast.
3. The difference between TCP and UDP
TCP is connection-oriented (for example, dial-up to establish a connection); UDP is connectionless, that is, there is no need to establish a connection before sending data
TCP provides reliable service. In other words, the data transmitted through the TCP connection is error-free, not lost, not repeated, and arrives in sequence; UDP does its best to deliver, that is, reliable delivery is not guaranteed.
TCP is oriented to byte flow, in fact, TCP regards data as a series of unstructured byte streams; UDP is a message-oriented UDP without congestion control, so network congestion will not slow down the transmission rate of the source host (useful for real-time applications, such as IP phones, real-time video conferencing, etc.)
Each TCP connection can only be point-to-point; UDP supports one-to-one, one-to-many, many-to-one and many-to-many interactive communication
TCP header overhead is 20 bytes; UDP header overhead is small, only 8 bytes 6. The logical communication channel of TCP is full-duplex reliable channel, while UDP is unreliable channel.
Second, is the transport layer protocol suitable for direct application to the terminal of the Internet of things?
The transport layer, as the name implies, is only responsible for transmitting data, just like a freight truck, but if you want the goods to be transported to the destination intact, you still need to do the work of packing, loading, inspection, storage, signing back, and so on. This requires more work, which is what the application layer protocols do. Therefore, if the terminal of the Internet of things wants to exchange data stably and reliably, it needs to use the protocol of the application layer, but not the protocol of the transport layer directly. The following will introduce three application layer protocols, MQTT, CoAP and LwM2M, which are suitable to be used on the device terminals of the Internet of things.
Application layer protocols MQTT and CoAP
1. Overview of MQTT
MQTT (Message Queuing Telemetry Transport, message queuing Telemetry Transmission) is an instant messaging protocol developed by IBM, which may become an important part of the Internet of things. The protocol supports all platforms, connects almost all connected objects to the outside, and is used as a communication protocol for sensors and brakes, such as connecting houses through Twitter.
2. Characteristics of MQTT protocol
MQTT protocol is designed for the communication of a large number of remote sensors and control devices with limited computing power and working in low-bandwidth, unreliable networks. It has the following main characteristics:
Use the publish / subscribe message pattern to provide one-to-many message publishing and uncoupling the application
Message transmission masking payload content
Use TCP/IP to provide network connection
There are three quality of service for message publishing:
"at most once," the release of messages depends entirely on the underlying TCP/IP network. Messages can be lost or duplicated. This level can be used for environmental sensor data, it doesn't matter if you lose a read record, because there will be a second send soon. "at least once", make sure the message arrives, but message repetition may occur. "only once", make sure the message arrives once. This level can be used in situations where duplicate or lost messages can lead to incorrect results in a billing system. Small transmission, low overhead (fixed-length header is 2 bytes), and protocol switching is minimized to reduce network traffic.
3. Overview of CoAP
Because many devices in the Internet of things are resource-constrained, that is, there is only a small amount of memory space and limited computing power, the traditional HTTP protocol application on the Internet of things appears to be too large and not applicable. IETF's CoRE working group proposed a CoAP protocol based on REST architecture. CoAP works in the UDP protocol family and uses a binary format. Compared to the text format used by HTTP, CoAP is more compact than HTTP.
4. Characteristics of CoAP protocol
The message model takes the message as the data communication carrier and realizes the data communication between devices by exchanging network messages.
Operations on cloud device resources are done through request and response mechanisms. Similar to HTTP, devices can operate on server-side resources through four request methods (GET, PUT, POST, DELETE).
The protocol package is lightweight and the minimum length is only 4B.
Support reliable transmission, data retransmission, block transmission to ensure reliable data arrival.
Support for IP multicasting, that is, requests can be sent to multiple devices at the same time
Non-long-connection communication, suitable for low-power Internet of things scenarios
5. The difference between MQTT and CoAP
4. Which is more suitable for Internet of things devices, MQTT or CoAP?
Both MQTT and CoAP are suitable for Internet of things devices, but they still have to be used according to the actual scenario. For example, if the device runs in a scenario that does not need to consider power consumption, but needs to be controlled in real time, such as charging posts, express cabinets and so on, it is more appropriate to use MQTT protocol. If the equipment usually only reports data and is sensitive to power consumption, such as water meter, gas meter and so on, it is more appropriate to use CoAP protocol.
With the rise of the Internet of things, the era of the Internet of everything will eventually come. However, due to the consideration of cost and performance, the resources of devices are often limited, so a protocol specially designed for resource-constrained devices of the Internet of things is needed to meet the needs of the Internet of everything, which is the LwM2M protocol.
1. Overview of LwM2M:
OMA is an international organization that initially defined a set of OMA-DM protocols for remote management of mobile devices, such as mobile phone accounts, version upgrades, and so on. 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 the custom OMA-DM access test when they connect to the network. Because of the rise of the Internet of things, OMA proposed the LwM2M protocol on the basis of 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 all kinds of Internet of things devices, because M2M devices are usually embedded terminals with very limited resources, no UI, limited computing power and network communication capacity. At the same time, because of the huge number of terminals of the Internet of things, it is very important to save network resources.
2. LwM2M protocol logic entity and logic interface
LwM2M defines three logical entities:
LwM2M Server server
The LwM2M client client is responsible for executing the server's commands and reporting the execution results.
The LwM2M boot server Bootstrap server is responsible for configuring the LwM2M client.
There are four logical interfaces between these three logical entities:
Device Discovery and Registration: this interface allows the client to register with the server and inform the server of the capabilities supported by the client (in short, which resource Resource and object Object are supported
Bootstrap:Bootstrap server: configure Clinet through this interface-for example, the URL address of LwM2M server Device Management and Service Enablement: this is the main business interface. LwM2M Server sends instructions to Client and receives a response.
Information Reporting: this interface is used by LwM2M Client to report its resource information, such as sensor temperature. The reporting method can be event-triggered or periodic.
The relationship between these three logical entities and four logical interfaces is shown in the following figure:
3. LwM2M protocol stack
The LwM2M protocol stack structure is shown in the following figure:
LwM2M Objects: each object corresponds to a specific functional entity of the client. The LwM2M specification defines a standard Objects, such as
Urn:oma:lwm2m:oma:2; (LwM2M Server Object) urn:oma:lwm2m:oma:3; (LwM2M Access Control Object)
There can be many resource under each object. For example, Firmware object can have Firmware version number, size and other resource.
Vendor can define object on its own:
LwM2M Protocol: defines some logical operations, such as Read, Write, Execute, Create or Delete.
CoAP: Constrained Application Protocol defined by IETF is used as the transport layer of LwM2M. The lower layer can be UDP or SMS. UDP must be supported, and SMS is optional. CoAP has its own message header, retransmission mechanism, and so on.
DTLS: is used to ensure security between the client and the server.
4. The relationship between LwM2M and CoAP
The message of LwM2M has no symmetrical feedback message. Because LwM2M is carried on CoAP protocol and uses CoAP's get, post, put and delete methods, the feedback of the success or failure of the corresponding message is realized through the interaction of CoAP protocol itself. LwM2M payload supports four formats: plain text, Opaque, TLV, and JSON. These four protocols require that all of them be supported on the server side and TLV format on the client side.
At this point, I believe you have a deeper understanding of "how to choose the communication protocol for the IoT terminal equipment of the Internet of things". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.