The networking protocol was MQTT

1, the protocol defined MQTT

MQTT agreement translated into Chinese called the Message Queue Telemetry Transport, first from IBM, is a publish / subscribe messaging protocol type for the next poor hardware performance of remote equipment and poor network conditions designed case. It works on the TCP / IP protocol, with a lightweight, simple, open and easy to implement, widely used in the networking industry, such as in smart home equipment, agricultural wisdom, the wisdom of the community. 2014 published MQTT v3.1.1 is the latest version of the current MQTT agreement.

2, MQTT several features

1, using the publish / subscribe messaging model, providing many message distribution, to facilitate messaging between devices, effective decoupling.

2, the load transmission message content block;

3, using the TCP / IP provides a network connection, using standard version MQTT data push TCP connection, TCP provides reliable data transmission in the IP environment to ensure the reliability MQTT transmission.

4, there are three quality of service news release:

    • "Up to a" data transmission only once, it does not matter not received, the sensor used in the reported scenario, because the sensor information transmission is continuous, less than the closing, as well as the next
    • "At least one", the transmitting device may send a message a plurality of times, the receiving apparatus can receive at least once, may also receive a plurality of times.
    • "Only once" to ensure that a message arrives, the message no more, no less, is received by only one terminal device.

5, the transmission data amount is small, the amount of data exchange protocol MQTT very small, only a fixed 2 bytes;

6, with a will and testament mechanism mechanism for informing the parties with the client for a theme, sending the last words of the equipment has been disconnected.

3, the middleware message - a message broker (Broker)

MQTT work required during a protocol message server, also known as a message broker (Broker), a number of messages stored in the queue, and then forwards the message to the receiving device at the right time. When the receiving device receives a trigger event information corresponding to the operation is complete. It has four functions:

  1. [] Network connection, the network accepts a connection request from a client
  2. [] Queue buffer message data, save data published by the client
  3. [] Disconnected from the network, the processing subscribe and unsubscribe request from the client
  4. [News] data forwarding, forwarding information to the subscribed clients

4, MQTT protocol packet structure

MQTT packet consists of three parts: head, variable header, a message body

MQTT glands are present in all packets, the packet indicates the packet type and packet class identifier

Content of the variable header by packet type is different, more frequent application is as a packet identifier

Represents something the client receives, there are CONNECT, SUBSCRIBE, SUBACK, UNSUBSCRIBE four types

Published 100 original articles · won praise 120 · views 690 000 +

Guess you like