A brief introduction to the MQTT-SN agreement

Source: Internet
Author: User

Objective

This period of time is looking at the MQTT-SN protocol, interested in the MQTT protocol, which does not rely on TCP transmission, and is always thinking about how the goods are defined. A series of articles are composed of MQTT-SN 1.2 protocol, the original document address: Mqtt-sn_spec_v1.2.pdf

The MQTT-SN document is divided into 7 parts, which I directly assemble into four pieces in the order of the former to the latter. Well, if you put it in an article, the text is too long, which makes typesetting difficult.

Non-literal translation, complete according to their own understanding of the collation, please know.

Version change history
    1. 2007-11-29 version 1.0
    2. 2008-6-5 1.1 version, increased sleep device support
    3. 2011-5-20 Version 1.2
    • Increased message length 255 byte support
    • Increased forwarding encapsulation support
    • Add return code "0X03 rejected, not supported"
    • ReturnCode added to WILLTOPICRESP and WILLMSGRESP messages
MQTT-SN name origin

The original name is Mqtt-s, but it will cause misunderstanding, and therefore renamed to MQTT-SN:

As part of the job of applying the same or similar license terms to the MQTT-S specification as those on the MQTT specific ation, we is proposing a small name change. The new name would is MQTT-SN, standing for exactly the same long name, and MQTT for Sensor Networks. Some people had assumed that the S in Mqtt-s stood for secure, so we hope this change would avoid that confusion. --Ian Craggs

MQTT-SN Purpose of existence

MQTT for Sensor Networks are aimed at embedded devices on NON-TCP/IP Networks, such as Zigbee. MQTT-SN is a Publish/subscribe messaging protocol for Wireless sensor networks (WSN), with the aim of extending the MQTT p Rotocol beyond the reach of TCP/IP infrastructure for Sensor and actuator solutions.

A specific version of the MQTT protocol for the Adaptive Sensing Device (abbreviated SA), typically running in an embedded battery-powered electronic component, transmits a wireless sensor network (WSN) based on the IEEE 802.15.4 specification wireless low-speed network The same enterprise-level features have a data-centric (data-centric) subscription/release feature.

In summary, customized for low-power, battery-driven, storage-constrained devices, and electronic devices that do not support TCP/IP protocol stack networks, such as common ZigBee (or Xbee), are unknown to the underlying transport network on which they depend, but as long as the network supports bidirectional data transmission and gateways, Can support the higher-level MQTT-SN protocol transmission. For example, the simple datagram service, as long as it supports a source endpoint to send data to a specific destination endpoint, is sufficient to support the MQTT-SN protocol. The Broadcast datagram transport service is also a must for gateways and endpoints for the automatic discovery process. To reduce broadcast storms, MQTT-SN defines the broadcast path depth (broadcast range or broadcast radius).

Some nouns and terms
    • Topic ID, subject identifier, natural number represented by two bytes 16 bits (Java language short type, 0-65535 range), corresponds to subject topic name
    • Gateway/server (Gateway/server), known as the Gateway in MQTT-SN, primarily handles and MQTT-SN client interactions, abbreviated as gateways
    • MQTT-SN terminal and client, unified call the client, in fact, is also embedded sensor equipment, or electronic components, limited resources, in the wireless area of the personal network to run
    • IEEE 802.15.4, full stack of the entire data limit is 128 bytes, generally select UDP (compared to 20 bytes of TCP protocol, UDP packet header only requires 8 bytes) Protocol Transfer data
    • Low-speed network/current network, refers to Lr-wpan (Low-rate Wireless personal area Network), low-speed wireless personal zone networks
MQTT-SN VS MQTT

Although MQTT-SN is designed to be as close to mqtt as possible, those with low-power, battery-driven, resource-constrained devices are at low-speed bandwidth, high-connection failures, and physical-layer packets coming online at 128 bytes. The document presents the following differences:

    1. The CONNECT message is split into three messages (Connect,willtipic, willmsg), both of which are used by the client to deliver a testamentary subject and a testamentary message, etc.
    2. In the publish message, the subject (topic name) is replaced with a two-byte-length natural number (topic ID), which requires the client to obtain the corresponding topic ID through the registration process.
    3. Predefined (pre-defined) Topic ID and topic name, eliminating the intermediate registration process, requiring clients and gateways to be specified in their firmware in advance
    4. The automatic discovery mechanism introduced by the Protocol helps clients to discover potential gateways. If there is more than one gateway, coordination is the primary slave or load balancer
    5. The "clean session" acts on subscription persistence and is also extended to the Wills feature (Wills subject and probate messages)
    6. Added support for offline keepalive for dormant devices, the proxy needs to be cached when there is a message, and the client is awakened when it is sent
MQTT-SN Architecture schematic

In the MQTT-SN architecture diagram, there are three types of components:

    1. MQTT-SN Client
    2. The Mqtt-sn gateway, which can exist separately or be integrated into an MQTT server. Need to assume the transition between the MQTT-SN and MQTT protocols
    3. MQTT-SN forwarder, responsible for forwarding the current client data to the gateway is not directly accessible, for the client, the gateway is not directly accessible, the role of forwarders is highlighted. The forwarder encapsulates the MQTT-SN message forwarded to the gateway, and the message from the gateway is sent to the client. The gateway is not able to tamper with the original data.
MQTT-SN Transport Gateway

MQTT-SN Gateway transmission mode, the picture below is at a glance.

    1. A transparent gateway establishes a channel for each client that TCP connects to the MQTT server, which consumes the gateway network resources, but the model is simple
    2. Aggregation gateway, only one TCP connection channel is established to the MQTT server, and all clients share a channel, which is very economical to say.

The gateway needs to decide which messages need to interact with the remote MQTT server, such as selecting only the publish, subscrible messages sent by the client.

Summary

The MQTT-SN is briefly described above, and the MQTT-SN message header and format are described below.

A brief introduction to the MQTT-SN agreement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.