MQTT experiment

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值