当前位置:网站首页>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 .
边栏推荐
- Eigen库计算两个向量夹角
- Temporarily turn off MySQL cache
- 一些基本错误
- MySQL download and configuration MySQL remote control
- Decompilation of zero time technology smart contract security series articles
- SQL中的并、交、差运算
- tag动态规划-刷题预备知识-2. 0-1背包理论基础和二维数组解法模板
- 如何创建并强制使用索引
- Ethereum技术架构介绍
- Union, intersection and difference operations in SQL
猜你喜欢

In and exceptions, count (*) query optimization

项目实战四:用户登录及token访问验证(reids+jwt)

Numpy's Matplotlib

Tree array

Solidity - contract inheritance sub contract contains constructor errors and one contract calls the view function of another contract to charge gas fees

品达通用权限系统(Day 1~Day 2)

限流设计及实现

Image binarization

图像二值化处理

JVM入个门(1)
随机推荐
Comparing the size relationship between two objects turns out to be so fancy
Using recursion to find all gray codes with n bits
转:实事求是
ARM裸板调试之串口打印及栈初步分析
Crawl Douban to read top250 and import it into SqList database (or excel table)
图像二值化处理
字符串String转换为jsonArray并解析
Commodity seckill system
Properties file garbled
Union, intersection and difference operations in SQL
CD-CompactDisk
预编译处理指令中的条件编译
零时科技 | 智能合约安全系列文章之反编译篇
LeetCode 面试题29 顺时针打印矩阵
Ethereum技术架构介绍
PC end records 515 ground sweeping robot /scan data
你了解如何比较两个对象吗
输入n个整数,输出出现次数大于等于数组长度一半的数
Publish message publishers and subscribe message subscribers of ROS
Résumé des points de connaissance