Wireshark#

Internet communication is great - until it fails. Frequently error messages are insufficient to diagnose the problem.

ide49 comes with Wireshark, an IP and Bluetooth package capture and analysis tool, that can help.

Let’s look at a simple example of capturing an MQTT conversation. Start Wireshark by clicking on the link in the iot49 home window. You will be greeted with a page similar to this one:

../../_images/wireshark_interfaces.png

The center shows all interfaces. We are interested in wireless (WiFi) traffic which is sent on wlp3s0. Click it to highlight it. Then press the blue shark fin to start a capture. Now run the code below to send some MQTT data. After the program finishes, click the red square next to the shark fin to stop the capture. The window now will look similar to this:

../../_images/wireshark_capture.png

Wireshark will have captured a large amount of traffic, most of which has nothing to do with MQTT. In “Apply a display filter”, type mqtt and hit return to get just the messages related to MQTT.

../../_images/wireshark_mqtt.png

Clicking on any of them shows details below. For example, details of the Publish message reval the topic and message sent. Note also that the ping request has been combind with publish to safe communication bandwidth. Ideal for small IoT devices like the ESP32.

%connect esp32 -q 

from mqtt_client import MQTTClient

client = MQTTClient('umqtt_client', '10.39.40.200', keepalive=5)
client.connect()
client.publish(b"testtopic", b"Hello from micropython!")

client.ping()

time.sleep(2)

client.disconnect()

Wireshark has many more features. If you are not familiar with the program you may want to look into one of the many online tutorials.