Here is the Subscribe frame format from the MQTT protocol.
Refer to the end of the post for more information for various fields.
The official definition can be found here.

byte

content
(hexa)

content

 

1

8

MQTT Control Packet type

 

2

Reserved

 

2

?

Remaining Length

 

?

(2 + 3*nb_of_topics + sum_of_topics_lenght)

3

0

Packet Identifier
MSB

 

0

 

4

0

Packet Identifier
LSB

 

a

 

5

0

Length MSB

 

0

 

6

?

Length LSB

 

?

 

7

?

Topic Filter

 

?

 

 

 

?

0

qos

 

?

0, 1 or 2

 

?+1

0

Length MSB

 

0

 

?+2

?

Length LSB

 

?

 

?+3

?

Topic Filter

 

?

 

 

 

?+?

0

qos

 

?

0, 1 or 2

 

 

 

 

MQTT Control Packet type:
This is present for each frame, it announces the coming frame.

Remaining Length:
Length of the rest of the frame. “4 + topic_length + payload_length” is the formula used to calculate this length.

Packet Identifier:
(MSB and LSB = most significant byte and least significant byte)
SUBSCRIBE, UNSUBSCRIBE, and PUBLISH (in cases where QoS > 0) Control Packets MUST contain a non-zero 16-bit Packet Identifier [MQTT-2.3.1-1]. Each time a Client sends a new packet of one of these types it MUST assign it a currently unused Packet Identifier [MQTT-2.3.1-2]. If a Client re-sends a particular Control Packet, then it MUST use the same Packet Identifier in subsequent re-sends of that packet. The Packet Identifier becomes available for reuse after the Client has processed the corresponding acknowledgement packet. In the case of a QoS 1 PUBLISH this is the corresponding PUBACK; in the case of QoS 2 it is PUBCOMP. For SUBSCRIBE or UNSUBSCRIBE it is the corresponding SUBACK or UNSUBACK [MQTT-2.3.1-3]. The same conditions apply to a Server when it sends a PUBLISH with QoS > 0.

QoS:

QoS value

Bit 2

bit 1

Description

0

0

0

At most once delivery

1

0

1

At least once delivery

2

1

0

Exactly once delivery

1

1

Reserved – must not be used

Back Next

Subscribe
Tagged on:                             

3 thoughts on “Subscribe

Leave a Reply