On a Linux or OS X machine, install Mosquitto (http://mosquitto.org/).
You will need the server (broker) as well as the clients (publisher and subscriber).
You do NOT need to compile from sources
On Linux use your distribution’s standard package management front-end (apt, aptitude, synaptic, yum etc). You may need to install two separate packages (broker and clients).
On macOS install it with homebrew. You may need to install two separate packages (broker and clients).
Open Wireshark, start a live capture and set a filter to view MQTT messages only.
Open a terminal, start the broker and leave it running. You can do this by running:
mosquitto
In a different terminal, subscribe to a topic:
mosquitto_sub -t “topic/this”
Publish to a topic (command below is single line):
mosquitto_pub -h localhost -t “topic/this” -m “A Publish Message”
See how the message appeared on the console where you ran your subscriber
Experiment
Play around with publisher/subscriber command line arguments
You can enable broker and/or client debug mode for more info. Run the broker with -v to put it in verbose mode.
Add more subscribers
Use different subscription/publish topics
Experiment with topic wildcards
Play around with different QoS levels
Look at the wireshark capture
Have a look for CONNECT, CONACK, PUBLISH, PUBACK, SUBSCRIBE, SUBACK and other MQTT message types
Can you identify the bytes holding the topic and the message?
Can you see how the topic is human-readable?
If you live together (e.g. in the same student residence) and you can connect your computers to the same WiFi, you can also team-up in groups of 2 or 3 (or even more!)!
Agree on a topic structure
Run a broker on one computer
Run subscribers on all your PCs for topics with/without wildcards.
You will need to provide the address of the broker to your subscribe. Do this through the -h option of mosquitto_sub.
Start sending publish messages. See what happens!
Again, you will need to use the -h option of mosquitto_pub.
You can run Wireshark live captures on your computers to see what traffic goes in and out.