TBMQ Lite (beta): a self-contained MQTT broker with zero external dependencies
776 Try for free Menu

TBMQ live demo

Try TBMQ in your browser

A free account on our public broker. Open the TBMQ UI and connect your MQTT clients. No credit card required.

Rather run it yourself? Install on your own servers

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load the site search from Google. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics).

Remember the campaign or partner link you arrived from, so we know which campaign or partner brought you when you sign up or contact us (partner program). We do not use it to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

MQTT GUIDE

3 min read

MQTT Packets: Control Packet Types

Quick answer

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.

Every MQTT control packet Fixed header ≥ 2 bytes · always present packet type + flags+ remaining length Variable header optional packet ID, properties (MQTT 5)… Payload optional your message bytes (opaque) Smallest packets are just the 2-byte fixed header — e.g. PINGREQ, PINGRESP
An MQTT packet: a tiny fixed header, plus an optional variable header and payload

The control packet types

PacketDirectionPurpose
CONNECT / CONNACKC→B / B→COpen a session and acknowledge it
PUBLISHeither wayDeliver an application message on a topic
PUBACK / PUBREC / PUBREL / PUBCOMPeither wayAcknowledge a PUBLISH per its QoS level
SUBSCRIBE / SUBACKC→B / B→CSubscribe to topic filters and confirm
UNSUBSCRIBE / UNSUBACKC→B / B→CCancel subscriptions and confirm
PINGREQ / PINGRESPC→B / B→CKeep-alive heartbeat
DISCONNECTeither wayClose the session gracefully (MQTT 5 adds a reason)
AUTHeither wayEnhanced 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.