当前位置:网站首页>The king of Internet of things protocol: mqtt
The king of Internet of things protocol: mqtt
2022-06-26 18:38:00 【Network technology alliance station】
Hello , This is the network technology alliance station .
Today, I'd like to talk about the famous Internet of things protocols :MQTT.
Let's go straight to !
What is? MQTT?
- English full name :Message Quueuing Telemetry Transport
- Chinese term : Message queuing telemetry transmission protocol
- A simple messaging protocol for communication between IOT devices
- Specially designed for Limited bandwidth Designed for the equipment
- use Release / subscribe Communication mode
- be used for machine Yes machine ( M2M ) signal communication
- MQTT Based on the agreement OASIS Under standard TCP/IP
- It is widely used in wireless network communication , It has a wide coverage , Health care coverage 、 Automotive and other industries that use IOT applications .
MQTT The history of
MQTT By the first Andy Stanford-Clark Doctor and Arlen Nipper Doctor Yu 1999 Created in , For connecting oil pipeline telemetry system via satellite .
The two inventors specified several requirements for future protocols :
- Simple implementation
- Service quality data delivery
- Lightweight and bandwidth efficiency
- The data is not known
- Persistent session
MQTT On 2013 Organization for the promotion of structured information standards (OASIS) Is standardized as open source ,OASIS Still manage MQTT standard .
MQTT The advantages of
MQTT There are the following advantages :
Simple
Use MQTT It's fast and easy to start and run .
It only needs a few commands to build , The startup is also very fast , There is also a special management interface .
reliable
Many IOT devices rely on radio Connect to transmit and collect data , This means that the connection is not always reliable .
MQTT By providing built-in QoS Features to reduce connectivity issues , This function can queue messages , Keep them in MQTT The agent of , And let them wait until the target device is all set to accept it , This reduces the chance of message misplacement , So the message is destined to reach its destination .
Two way messaging
Any device 、 Things or applications can be published or subscribed by MQTT Any topic handled by the agent .
This is not one-way , For example, you can only publish or subscribe , It can publish and subscribe , Be similar to full duplex signal communication .
Mass messaging
because Broker The existence of , So whether it's 100 Wan Tai equipment , still 100 device , about MQTT It's all the same , No pressure , Because the final message is delivered to Broker in , No matter how many clients listen for messages , Also from the Broker Take in .
MQTT working principle
MQTT framework
MQTT Use PUSH/SUBSCRIBE( Publish subscribe ) Model in TCP/IP Run on , stay MQTT Architecture , There are two types of systems :
- client
- agent
A proxy is a server with which clients communicate , The agent receives communications from the client and sends them to other clients , There is no direct communication between clients , It's connected to agent , Each client can be a publisher 、 Subscribers or both .
MQTT It's a kind of Event driven The agreement , There is no regular or continuous data transmission , This keeps transmission to a minimum . The client only publishes when there is information to send , The agent only sends information to subscribers when new data arrives .
Release / subscribe
In publish and subscribe systems , The device can post messages on a topic , You can also subscribe to specific topics to receive messages .
Pictured , equipment 1 Post a message on a topic , equipment 2 Subscribed to and devices 1 The published topic is the same topic , Subsequent equipment 2 You can receive messages .
news
Messages are information exchanged between devices , For example, some instructions , Or some information about the equipment , Or other information that needs to be exchanged .
The theme
As shown in the figure , Let me explain in one sentence with a picture : The topic is the type of official account you subscribe to through wechat .
Take the official account as an example. , Creators are publishers , The server of the official account is Broker, Readers are subscribers , Publishers in different fields are working on different topics ( field ) Publish articles , For example, Rego usually publishes articles in the field of science and technology , So all readers ( subscriber ) Anyone who has subscribed to the technology field can see my article .
This field can be roughly understood as the theme .
For theme Forward slash Separated strings represent , Each forward slash represents a Subject level .
As shown in the picture on the official account The topic of creating network type in the field of science and technology in the article type :
Be careful : Topics are case sensitive , The two themes are different :
If readers want to read articles on the Internet :
- The publisher is
article/technology/networkTheme release OSPF Related articles - The subscriber subscribed to the topic
article/technology/network - The publisher is on the topic
article/technology/networkWhen there is new news on the , Subscribers can subscribe to .
Broker agent
An agent is actually agent .
MQTT The agent is responsible for receiving all messages , Filtering messages , Decide who is interested in them , Then publish the message to all subscribed clients .
MQTT subscribe
MQTT Clients are not directly connected to each other , Instead, subscribe to topics to receive messages .
To subscribe to a topic , The client must first send a subscription request to the proxy ,SUBSCRIBE The request can contain multiple topics , Proxy usage SUBACK( confirm subscription ) Respond to SUBSCRIBE request , Subscriptions also have QoS Set up , Can be used to downgrade published messages QoS. under these circumstances , The message is always in a lower QoS Set Publishing .
Subscribe to wildcards
There are two types of subscription wildcards :
Single stage
Single level wildcard replaces one topic level :
This wildcard will cover the following topics :
- article / entertainment / The Internet
- article / Technology / The Internet
- article / Agriculture, rural areas and farmers / The Internet
- article / Journalism / The Internet
multistage
Multi level wildcards replace multiple topic levels :
This wildcard will cover the following topics :
- article / entertainment / The Internet
- article / Technology /java
- article / Agriculture, rural areas and farmers / food
- article / Journalism / space flight
Service quality QoS
- QoS 0( At most once ): The client's message is sent only once , Whether or not it has reached the agent .
- QoS 1( At least once ): Client messages are sent over and over again , Until the agent responds with an acknowledgement of receipt , This may cause messages to arrive at the broker multiple times .
- QoS 2( Exactly Once ): The client sends a message , Also make sure that it has reached the agent ,QoS 2 Communication needs more than quality of service 0 or 1 More bandwidth .
MQTT Several important websites
- mqtt Official website :
https://mqtt.org/
- emqx Official website :
https://www.emqx.com/
summary
MQTT Is a lightweight open messaging protocol , It provides a simple method for resource constrained network clients to distribute telemetry information in a low bandwidth environment , Adopt release / Subscription communication mode , For machine to machine ( M2M ) signal communication .
边栏推荐
- [unity] use C in unity to execute external files, such as Exe or bat
- wm_concat()和group_concat()函数
- Enter n integers and output the number of occurrences greater than or equal to half the length of the array
- Résumé des points de connaissance
- JVM入个门(1)
- 读书笔记:《过程咨询 III》
- Solidity - contract inheritance sub contract contains constructor errors and one contract calls the view function of another contract to charge gas fees
- 预编译处理指令中的条件编译
- Vscode 基础必备 常用插件
- ROS query topic specific content common instructions
猜你喜欢
随机推荐
MySQL download and configuration MySQL remote control
Decompilation of zero time technology smart contract security series articles
【Mysql系列】工作常用sql集锦(持续更新)
CLion断点单步调试
Summary of alter operation in SQL
9. Intelligent transportation project (2)
将字符串B插入字符串A,有多少种插入办法可以使新串是一个回文串
JVM入个门(1)
Some basic mistakes
Temporarily turn off MySQL cache
ROS的发布消息Publishers和订阅消息Subscribers
Example of using QPushButton style (and method of adding drop-down menu to button SetMenu)
【Kubernetes】Kubernetes 原理剖析与实战应用(更新中)
知識點總結
自己创建一个时间拦截器
成功解决之Jenkins报错:The goal you specified requires a project to execute but there is no POM
成功解决之微服务@Value获取配置文件乱码问题
Tree array
LeetCode 面试题29 顺时针打印矩阵
输入n个整数,输出出现次数大于等于数组长度一半的数









