Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
MQTT TCP/IP port 1883 is reserved with IANA for use with MQTT. TCP/IP
port 8883 is also registered, for using MQTT over SSL.
You can pass a user name and password with an MQTT packet in
V3.1 of the protocol.
Application Message
Client
Server
MQTT Subscription
Terminology Topic Name
Topic Filter
Session
• Fixed Header
• Variable Header
• Payload
• CONNECT, Client request to connect to Server
• CONNACK, Connect acknowledgment
• PUBLISH, Publish message
• PUBACK , Publish acknowledgment
• PUBREC , Publish received
• PUBREL , Publish release
• PUBCOMP, Publish complete
MQTT Control Packet • SUBSCRIBE, Client subscribe request
• SUBACK , Subscribe acknowledgment
• UNSUBSCRIBE, Unsubscribe request
• UNSUBACK, Unsubscribe acknowledgment
• PINGREQ, PING request
• PINGRESP, PING response
• DISCONNECT, Client is disconnecting
Fixed Header
MQTT Control Packet Type
Name Value Name Value
CONNECT 1 SUBSCRIBE 8
CONNACK 2 SUBACK 9
PUBLISH 3 UNSUBSCRIBE 10
PUBACK 4 UNSUBACK 11
PUBREC 5 PINGREQ 12
PUBREL 6 PINGRESP 13
PUBCOMP 7 DISCONNECT 14
MQTT Flag Bit
Control Packet Fixed header flags Bit 3 Bit 2 Bit 1 Bit 0
CONNECT Reserved 0 0 0 0
CONNACK Reserved 0 0 0 0
PUBACK Reserved 0 0 0 0
PUBREC Reserved 0 0 0 0
PUBREL Reserved 0 0 1 0
PUBCOMP Reserved 0 0 0 0
SUBSCRIBE Reserved 0 0 1 0
SUBACK Reserved 0 0 0 0
UNSUBSCRIBE Reserved 0 0 1 0
UNSUBACK Reserved 0 0 0 0
PINGREQ Reserved 0 0 0 0
PINGRESP Reserved 0 0 0 0
DISCONNECT Reserved 0 0 0 0
The Remaining Length is the
number of bytes remaining
within the current packet,
including data in the variable
Remaining header and the payload.
Length The Remaining Length does not
include the bytes used to
encode the Remaining Length.
Some types of MQTT Control Packets
contain a variable header component. It
resides between the fixed header and
the payload
The content of the variable header
Variable varies depending on the Packet type.
Header
The Packet Identifier field of variable
header is common in several packet
types.
Packet Identifier