Understanding the MQTT protocol packet structure
MQTT control packets are how the data is managed within an MQTT network. For instance, as discussed in the previous section, when a client wants to connect to a broker, it sends a connect packet and, in response, gets a connack packet from the broker.
Similarly, when a client wants to publish something on a given topic, it sends a publish packet. When a client wants all the data arriving on a particular topic, it achieves that by subscribing to the specific topic using the subscribe packet.
In this section, we will provide a detailed discussion of each of the packets. Please note that we will be discussing MQTT v3.1.
Connect packet
The previous section mentions that parameters need to be passed along with a connect packet. The attributes of this message are as follows.
- Fixed headers:
The fixed headers only contain the MQTT control packet type (which is the code for CONNECT); the remaining length will have...