Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction of MQTT Industrial Internet of things message passing Protocol

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

MQTT message queue transmission has become one of the main ways of Internet of things message transmission across multiple industries in the Internet of things industry in recent years. Most existing cloud services or cloud platforms provide MQTT functions, and more and more device manufacturers, software and services are implementing MQTT-based products.

For example, MQTT gateway, MQTT router.

The adoption of MQTT by cloud service providers such as Aliyun, Baidu Cloud, Tencent Cloud, Huawei Cloud and many other companies in the information technology field makes people think that MQTT is aimed at cloud service solutions, and it is expected that MQTT originated from industrial communications.

A brief introduction to MQTT

MQTT is a client-server based message publish / subscribe transport protocol. MQTT protocol is lightweight, simple, open and easy to implement, which makes it suitable for a wide range of applications. In many cases, including constrained environments, such as machine-to-machine (M2M) communication and the Internet of things (IoT). It has been widely used in satellite link communication sensors, occasionally dialed medical devices, smart homes, and some miniaturized devices.

Main characteristics of MQTT

MQTT protocol is a protocol designed to communicate between remote sensors and control devices working in low-bandwidth, unreliable networks. It has the following main characteristics:

1. Use the publish / subscribe message pattern to provide one-to-many message publishing and decouple the application. This is similar to XMPP, but MQTT has much less information redundancy than XMPP, because XMPP uses XML-formatted text to pass data.

two。 Message transmission that masks payload content.

3. Use TCP/IP to provide network connectivity. The mainstream MQTT pushes data based on TCP connections, but there is also a UDP-based version called MQTT-SN. Because the two versions are based on different connection methods, their advantages and disadvantages are naturally different.

4. 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 in the case of environmental sensor data, it doesn't matter if you lose a read record, because there will be a second transmission soon. This method is mainly ordinary APP push, if your smart device is not connected to the Internet when the message is pushed, and the push is not received in the past, it will not be received when connected to the Internet again.

"at least once" to ensure that the message arrives, but message repetition may occur.

"only once", make sure the message arrives once. This level can be used in some more stringent billing systems. In the billing system, repetition or loss of messages can lead to incorrect results. This highest quality messaging service can also be used for instant messaging APP push, ensuring that users receive it and only receive it once.

5. Small transmission, low overhead (fixed-length header is 2 bytes), and protocol switching is minimized to reduce network traffic. This is why it is said in the introduction that it is very suitable for "in the field of the Internet of things, the communication between sensors and servers, the collection of information", knowing that the computing power and bandwidth of embedded devices are relatively weak, it is perfect to use this protocol to transmit messages.

6. A mechanism for notifying interested parties of abnormal client interruptions using the Last Will and Testament features.

Last Will: the last note mechanism, which is used to notify other devices under the same topic that the device that sent the last message has been disconnected.

Testament: a testamentary mechanism that functions like Last Will.

Implementation of MQTT protocol

The realization of MQTT protocol requires communication between client and server. In the process of communication, there are three identities in MQTT protocol: publisher (Publish), agent (Broker) (server) and subscriber (Subscribe). Among them, the publisher and subscriber of the message are both clients, the message broker is the server, and the message publisher can be the subscriber at the same time.

The message transmitted by MQTT is divided into two parts: topic (Topic) and load (payload):

(1) Topic, which can be understood as the type of message. After subscribing to (Subscribe), subscribers will receive the message content (payload) of the topic.

(2) payload, which can be understood as the content of the message, refers to the specific content that the subscriber wants to use.

Network transmission and application message

MQTT builds the underlying network transport: it establishes a client-server connection, providing an orderly, lossless, byte-stream-based two-way transport between the two.

When the application data is sent over the MQTT network, the MQTT will associate the quality of service (QoS) associated with it with the subject name (Topic).

MQTT client

An application or device that uses the MQTT protocol that always establishes a network connection to the server. The client can:

(1) publish information that other clients may subscribe to

(2) subscribe to messages published by other clients

(3) unsubscribe or delete messages from the application

(4) disconnect from server.

MQTT server

The MQTT server, known as a "message broker" (Broker), can be an application or a device. It is located between message publishers and subscribers, and it can:

(1) accept network connections from customers

(2) accept the application information released by the customer

(3) handle subscription and unsubscription requests from the client

(4) forward application messages to subscribed customers.

Subscriptions, topics, sessions in MQTT protocol

1. Subscription (Subion)

Subscriptions include topic filters (Topic Filter) and maximum quality of service (QoS). Subscription is associated with a session (Session). A session can contain multiple subscriptions. Each subscription in each session has a different topic filter.

II. Conversation (Session)

After each client establishes a connection with the server, there is a session and there is a stateful interaction between the client and the server. A session exists between a network and may span multiple consecutive network connections between the client and the server.

III. Topic name (Topic Name)

A label that connects to an application message that matches the subscription of the server. The server sends a message to each client that subscribes to the matching label.

Topic filter (Topic Filter)

A wildcard filter for topic names, used in subscription expressions, represents multiple topics to which the subscription matches.

5. Load (Payload)

The specific content received by the message subscriber.

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.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report