Lab Assignment 14
Lab Assignment 14
Lab Assignment 14
Note: The MQTT protocol establishes a connection between clients through a broker. A CONNECT
command is sent to initiate a connection from the client to the broker. After the connection is
established, it remains active until a disconnect command is sent from the client. Some of the
headers of the CONNECT command are given below:
a. Header Flags: Contains information regarding the MQTT control packet type.
b. Connect Flags: Contains parameters specifying the behavior of the MQTT
connection.
c. Clean Session: Indicates whether the client wants to establish a persistent
connection with the broker or not.
d. Client ID: Indicates a unique identifier for each MQTT client connecting to an
MQTT broker.
Select a Connect Ack packet from the Packet List pane. In the Packet Details pane at the
middle of the window, expand the Transmission Control Protocol, MQ
Telemetry Transport Protocol, and Header Flags nodes.
Under the MQ Telemetry Transport Protocol nodes, you can observe details such as Header
Flag and Return Code.
Note: The broker sends the Connect Ack packet on receiving a Connect command request from
the client. Some of the headers in the Connect Ack packet are given below:
e. Header Flags: Contains information regarding the MQTT control packet type.
f. Session Present: Indicates the session between the broker and client; Bit 0 is the
Connection Ack bit in the session present flag.
Select a Subscribe Request packet from the Packet List pane. In the Packet Details pane at
the middle of the window, expand the Transmission Control Protocol, MQ Telemetry
Transport Protocol, and Header Flags nodes.
Under the MQ Telemetry Transport Protocol nodes, you can observe details such as Msg
Len, Message Identifier, and Topic Length.
Note: To receive a relevant message, a client sends a SUBSCRIBE message to an MQTT broker.
Some of the headers in the Subscribe Request packet are given below:
Header Flags: Contains information regarding the MQTT control packet type.
Message Identifier: Identifies a message in a message flow between a client and
a broker.
Topic and QoS Level: A subscription is a pair of a topic filter and a QoS level; the
topic defines a subject of interest on which the client would like to get messages.
Payload: Contains a list of subscriptions.
Select a Subscribe Ack packet from the Packet List pane. In the Packet Details pane at the
middle of the window, expand the Tran Note: The MQTT broker confirms subscription by
sending an acknowledgment back to the client using a SUBACK message. Some of the headers in
the Subscribe Acknowledgement packet are given below:
g. Header Flags: Contains information regarding the MQTT control packet type.
h. Message Identifier: Identifies a message in a message flow between a client and
a broker.
i. Payload: Contains a list of return codes.
j. Return Code: For each Topic/QoS pair received, a return is sent by the MQTT
broker in the SUBSCRIBE message; the return code is in line with the QoS level in
the case of a success.
smission Control Protocol, MQ
Telemetry Transport Protocol, and Header Flags nodes.
Under the MQ Telemetry Transport Protocol nodes, you can observe details such as Msg
Len and Message Identifier.
Select any Publish Message packet from the Packet List pane. In the Packet Details pane at
the middle of the window, expand the Transmission Control Protocol, MQ Telemetry
Transport Protocol, and Header Flags nodes.
Under the MQ Telemetry Transport Protocol nodes, you can observe details such as Msg
Len, Topic Length, Topic, and Message.
Publish Message can be used to obtain the message sent by the MQTT client to the broker.
Note: After establishing a successful connection with the MQTT broker, the MQTT client can
publish messages. The headers in the Publish Message packet are given below:
k. Header Flags: Contains information regarding the MQTT control packet type.
l. DUP flag: If the DUP flag is 0, it indicates the first attempt at sending this
PUBLISH packet; if the flag is 1, it indicates a possible re-attempt at sending the
message.
m. QoS: Determines the assurance level of a message.
n. Retain Flag: If the retain flag is set to 1, the server must store the message and
its QoS, so it can cater to future subscriptions matching the topic.
o. Topic Name: Contains a UTF-8 string that can also include forward slashes when
it needs to be hierarchically structured.
p. Message: Contains the actual data to be transmitted.
q. Payload: Contains the message that is being published.
Select any Publish Release packet from the Packet List pane. In the Packet Details pane at
the middle of the window, expand the Transmission Control Protocol, MQ Telemetry
Transport Protocol, and Header Flags nodes.
Under the MQ Telemetry Transport Protocol nodes, you can observe details such as Msg
Len, Message Type, Message Identifier.
Note: A Publish Release (PUBREL) packet is the response to a Publish Received (PUBREC) packet.
Now, scroll down, look for the Publish Complete packet from the Packet List pane, and click
on it. In the Packet Details pane at the middle of the window, expand the Transmission
Control Protocol, MQ Telemetry Transport Protocol, and Header Flags nodes.
Under the MQ Telemetry Transport Protocol nodes, you can observe details such as Msg
Len and Message Identifier.
Note: The Publish Complete (PUBCOMP) packet is the response to a Publish Release (PUBREL)
packet.
This concludes the demonstration of capturing and analyzing MQTT protocol packets. Here, we
analyzed different processes involved in the communication between an MQTT client and an
MQTT broker using Wireshark. Understanding these metrics as well as the workflow can help you
in quickly identifying the MQTT-related issues.