当前位置:网站首页>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 .
边栏推荐
- VCD-影音光碟
- Usage and difference between ros:: spinonce() and ros:: spin()
- 微服务版单点登陆系统(SSO)
- [unity] use C in unity to execute external files, such as Exe or bat
- 利用递归实现求n位所有格雷码
- SSO微服务工程中用户行为日志的记录
- Jsonutils tool class (based on Alibaba fastjson)
- JVM入个门(1)
- Paging query and join Association query optimization
- Feign远程调用
猜你喜欢
随机推荐
wm_ Concat() and group_ Concat() function
Class inheritance of 25class
元宇宙链游开发案例版 NFT元宇宙链游系统开发技术分析
Usage and difference between ros:: spinonce() and ros:: spin()
判断某个序列是否为栈的弹出序列
JVM entry Door (1)
gdb安装
xlua获取ugui的button注册click事件
50 lines of code to crawl TOP500 books and import TXT documents
VCD-影音光碟
手机影像内卷几时休?
LeetCode 128最长连续序列
ISO documents
GDB installation
Clion编译catkin_ws(ROS工作空间包的简称)加载CMakeLists.txt出现的问题
Several delete operations in SQL
Development principle analysis and source code of dapp-lp single and dual currency liquidity pledge mining system
Convex hull problem
sql 中的alter操作总结
Decompilation of zero time technology smart contract security series articles









