In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what are the differences between MQTT-SN and MQTT". In daily operation, I believe many people have doubts about the differences between MQTT-SN and MQTT. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what are the differences between MQTT-SN and MQTT?" Next, please follow the editor to study!
MQTT-SN (Sensor Networks) is the sensor version of the MQTT protocol, which was first used in zigBee wireless networks, mainly for devices with battery power, limited processor capacity and storage capacity. MQTT based on TCP protocol is still too heavy for some sensors, these sensors may only have dozens of bytes of memory, can not run TCP protocol.
The differences between MQTT-SN and MQTT
1. Different levels of protocol operation
MQTT runs on top of the TCP layer, while MQTT-SN can run on the MAC layer, IP layer, and UDP. The scenarios of MQTT-SN applications are mainly a variety of low-power sensor networks, which need battery power and are very sensitive to power consumption. TCP virtual long connections need to maintain a timing heartbeat, which is not a good solution for batteries. In sensor networks, the link may be interrupted at any time, and the TCP connection has to be constantly re-established, which is a big consumption of power consumption.
2. QOS increased by-1 or 3
When the QOS-1 level is set, QOS flag still needs to set 3 ("0b11").-1 is just a title. This level is only suitable for very simple applications. There is no need to establish or disconnect the connection, and there is no need to register or subscribe. In this case, the client simply sends a public message to the gateway. The published news does not need to be confirmed by the message.
3. Subscribe to topics
MQTT-SN can use MQTT's subscription topic format, long-name topics such as "/ beijing/sen1", short-name topics such as "S1" with only two characters, and predefined topics such as "1". If you do not use long-name topics, you cannot use wildcards.
4. Publish a message
As with subscription topics, you can use a two-character short-name topic or a defined topic ID.
Note: the content of the theme ID may or may not be the same for different clients. For example, A sensor subscribes to the topic ID1 content is / beijing/sen1,B sensor is also subscribed to the topic ID1 content is / beijing/sen2, their content is different.
5. Network architecture
MQTT-SN has one more node, which is the MQTT-SN gateway. The main function of the gateway is to convert the underlying MQTT-SN protocol into the protocol format of MQTT.
As shown in the figure above, there are two kinds of gateways, one is transparent gateways, which simply unpack packets through transmission, and the other is aggregation gateways, which aggregate multiple nodes and transmit them to message agents.
6. Gateway Discovery
In MQTT-SN, the client does not have to remember the address of the gateway. The gateway regularly broadcasts ADVERTISE information with its own address, which is received by the client. When there are multiple gateways, the gateway needs to bring its own gateway ID, and it is up to the client to decide which one to connect to. At any time, a client can only connect to one gateway. The client can also send a gateway query (SEARCHGW information), in which case the gateway will respond to the GWINFO
information. There are two parameters to prevent broadcast storm. The transmission of gateway query messages needs to wait for a random time. The number of gateway queries sent is generally set to 1, that is, SEARCHGW information cannot be transmitted across gateways. In this way, the gateway can be configured flexibly, and there is no need to fix a gateway.
7. Support device sleep
If the device sleeps, the MQTT-SN gateway stores the message first, and then sends it when the device wakes up. This is a bit like SMS. After the phone is turned off, the SMS is stored in the operator's SMS exchange center, and then sent after the phone is turned on.
At this point, the study of "what are the differences between MQTT-SN and MQTT" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.