MQTT 101: Powering IoT Ecosystem
amit singh
Lead Architect Secure Networking | Cisco Validated. 3xCCIE, MS Computer Networks, MBA in Telecom Management, SM IEEE. MIET
Have you ever wondered what powers the resource-constrained tiny sensors, and IoT devices to connect to the internet? One of the most popular protocols powering the solution is MQTT (Message Queuing Telemetry Transport).
MQTT is a lightweight messaging protocol designed for constrained devices with low bandwidth and high latency, such as those found in the Internet of Things (IoT) and Machine-to-Machine (M2M) communication scenarios. This protocol is revolutionizing the way we communicate with our devices, and today I'm going to tell you all about it.
MQTT was invented by Andy Stanford-Clark and Arlen Nipper in 1999. At the time, they were looking for a protocol to create minimum battery loss and minimal bandwidth for oil pipelines and satellite connections. After using the protocol internally for some time, IBM decided to donate it as a royalty-free version in 2010. The latest standard is version five, and it is maintained by Oasis standards.
MQTT is an application layer protocol that runs over the well-known TCP/IP stack. It uses TCP port 1883 for an unsecured connection, and 8883 for a secure connection. To set up an MQTT connection, you need to know the broker's IP address and establish a TCP connection. After that, the MQTT protocol comes into play, and it connects based on application error messages.
MQTT uses a publishing/subscriber architecture, which is revolutionary. In most of the Internet arena, protocols are based on a server/client model. However, MQTT is asynchronous, which means that the sender and receiver don't have to be online at the same time. This is because there is an intermediary, called the MQTT broker, which listens to all topics published and relays the interested topics to the subscriber. The broker can also store published data if the subscriber is not online.
领英推荐
MQTT also provides Quality of Service (QoS) for messaging. This means that the sender and receiver don't have to be in the same environment, as they can communicate over the Internet or the cloud. There are three roles in MQTT: publisher, subscriber, and broker. The publisher - publishes topics and the subscriber - subscribes to topics. The broker listens to all topics published and relays the interested topics to the subscriber.
Topics are UTF-8 strings separated by backslashes. They can be nested and wildcards can be used for filtering. Clients can be publishers and subscribers at the same time or either one. The first message used to make a connection is the connect message, followed by publish, subscribe, unsubscribe, and disconnect messages.
MQTT is tailored for resource-constrained devices and runs on TCP, which makes it reliable at the transport layer. It also supports QoS to ensure delivery and avoid duplicates. The protocol is lightweight and minimal, making it great for constrained devices.
Getting started with MQTT is easy. You can install "Mosquitto" as a broker and use clients such as "Paho" for publishing and subscribing. There are also websites such as?mqtt.org?and?hivemq.com that provide online brokers and blogs to learn more about MQTT.
If you're interested in learning more about MQTT, I suggest checking out the resources at MQTT@SDN. Thank you!