MQTT GUIDE
3 min readMQTT Packets: Control Packet Types
MQTT control packets are the messages exchanged between client and broker. Each has a fixed header of at least 2 bytes (packet type, flags and remaining length), an optional variable header, and an optional payload. The types include CONNECT/CONNACK, PUBLISH with its acknowledgements, SUBSCRIBE/SUBACK, UNSUBSCRIBE/UNSUBACK, PINGREQ/PINGRESP, DISCONNECT and — in MQTT 5.0 — AUTH.
Everything two MQTT peers say to each other is an MQTT control packet. There are only about a dozen types, and they all share the same compact structure — which is what keeps the protocol light enough for constrained devices.
Anatomy of a packet
Every packet starts with a fixed header of at least two bytes. Some packets add a variable header, and some carry a payload; both are optional depending on the packet type.
The control packet types
| Packet | Direction | Purpose |
|---|---|---|
CONNECT / CONNACK | C→B / B→C | Open a session and acknowledge it |
PUBLISH | either way | Deliver an application message on a topic |
PUBACK / PUBREC / PUBREL / PUBCOMP | either way | Acknowledge a PUBLISH per its QoS level |
SUBSCRIBE / SUBACK | C→B / B→C | Subscribe to topic filters and confirm |
UNSUBSCRIBE / UNSUBACK | C→B / B→C | Cancel subscriptions and confirm |
PINGREQ / PINGRESP | C→B / B→C | Keep-alive heartbeat |
DISCONNECT | either way | Close the session gracefully (MQTT 5 adds a reason) |
AUTH | either way | Enhanced authentication (MQTT 5.0 only) |
C→B = client to broker · B→C = broker to client
Why MQTT is lightweight
Because the fixed header is as small as two bytes and control packets carry only what they need, MQTT’s per-message overhead is tiny compared to text protocols like HTTP. That is a big part of why it suits low-bandwidth, battery-powered devices — see MQTT vs HTTP.
MQTT packets in TBMQ
TBMQ implements the full MQTT 3.1 / 3.1.1 / 5.0 control-packet set, including the MQTT 5.0 AUTH packet used for enhanced (SCRAM) authentication. For the exact protocol support, see the
MQTT protocol guide.
Frequently asked questions
How many MQTT packet types are there?
MQTT 3.1.1 defines 14 control packet types. MQTT 5.0 adds one more, AUTH, for enhanced authentication — for 15 in total.
What is the smallest MQTT packet?
Two bytes. PINGREQ and PINGRESP are just a fixed header with no variable header or payload, so they are the minimal 2-byte packets — which is part of why MQTT is so lightweight.
What is in the fixed header?
The control packet type and a set of type-specific flags in the first byte, followed by the Remaining Length — a variable-length integer giving the number of bytes left in the packet (variable header plus payload).
What is the AUTH packet?
AUTH is an MQTT 5.0 packet used for enhanced authentication — a challenge/response exchange (for example SCRAM) that can happen during connection or be re-issued later. It does not exist in MQTT 3.1.1.
Is there a limit on MQTT packet size?
The Remaining Length field caps a packet at about 256 MB (268,435,455 bytes). MQTT 5.0 also lets each side advertise a smaller Maximum Packet Size, and brokers typically enforce their own limit well below the protocol maximum.
Run it yourself
TBMQ is a free, open-source MQTT broker built to scale. Spin it up in minutes or try the live demo — no install required.