当前位置:网站首页>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 .
边栏推荐
猜你喜欢

Commodity seckill system

wm_concat()和group_concat()函数

Class inheritance of 25class

Tag dynamic programming - preliminary knowledge for question brushing -2 0-1 knapsack theory foundation and two-dimensional array solution template

In and exceptions, count (*) query optimization

Clion编译catkin_ws(ROS工作空间包的简称)加载CMakeLists.txt出现的问题

Create a time blocker yourself

Properties file garbled

零时科技 | 智能合约安全系列文章之反编译篇

微信小程序 自定义 弹框组件
随机推荐
Résumé des points de connaissance
Pinda general permission system (day 3~day 4)
(必须掌握的多线程知识点)认识线程,创建线程,使用Thread的常见方法及属性,以及线程的状态和状态转移的意义
项目实战五:搭建ELk日志收集系统
JVM入個門(1)
博云,站在中国容器潮头
Solidity - 合约继承子合约包含构造函数时报错 及 一个合约调用另一合约view函数收取gas费用
(树) 树状数组
Do you know how to compare two objects
ROS查询话题具体内容常用指令
Comparing the size relationship between two objects turns out to be so fancy
Clion编译catkin_ws(ROS工作空间包的简称)加载CMakeLists.txt出现的问题
Determine whether a sequence is a stack pop-up sequence
sql中的几种删除操作
SSO微服务工程中用户行为日志的记录
Tag dynamic programming - preliminary knowledge for question brushing -2 0-1 knapsack theory foundation and two-dimensional array solution template
DVD digital universal disc
成功解决之微服务@Value获取配置文件乱码问题
成功解决之idea引用Lombok的@Slf4j后无法正常使用log
物联网协议的王者:MQTT