Messaging Protocols:
MQTT:
Message Queuing Telemetry Transport, or MQTT, is a communications protocol
designed for Internet of Things devices with extremely high latency and restricted
low bandwidth. Message Queuing Telemetry Transport is a perfect protocol for
machine-to-machine (M2M) communication since it is designed specifically for low-
bandwidth, high-latency settings.
What is Message Queue Telemetry Transport
Protocol(MQTT)?
MQTT is a simple, lightweight messaging protocol used to establish communication
between multiple devices. It is a TCP-based protocol relying on the publish-
subscribe model. This communication protocol is suitable for transmitting data
between resource-constrained devices having low bandwidth and low power
requirements. Hence this messaging protocol is widely used for communication in
the IoT Framework.
This model involves multiple clients interacting with each other, without having any
direct connection established between them. All clients communicate with other
clients only via a third party known as a Broker.
MQTT Client and Broker
Clients publish messages on different topics to brokers. The broker is the central
server that receives these messages and filters them based on their topics. It then
sends these messages to respective clients that have subscribed to those different
topics. The heart of any publish/subscribe protocol is the MQTT broker. A broker
can handle up to thousands of concurrently connected MQTT customers,
depending on how it is implemented. All communications must be received by the
broker, who will then sort them, ascertain who subscribed to each one, and deliver
the messages to the clients who have subscribed. All persistent customers'
sessions, including missed messages and subscriptions, are likewise kept by the
Broker. Hence client that has subscribed to a specific topic receives all messages
published on that topic.
Here the broker is central hub that receives messages, filters them, and distributes
them to appropriate clients, such that both message publishers, as well as
subscribers, are clients.
MQTT Architecture:
Working of MQTT
MQTT's publish/subscribe (pub/sub) communication style, which aims to maximise
available bandwidth, is an alternative to conventional client-server architecture that
communicates directly with an endpoint. In contrast, the client who transmits the
message (the publisher) and the client or clients who receive it (the subscribers) are
not connected in the pub/sub paradigm. Third parties—the brokers—manage the
relationships between the publishers and subscribers because they don't
communicate with one another directly.
Publishers and subscribers, which denote whether a client is publishing messages
or has subscribed to receive messages, are examples of MQTT clients. The same
MQTT client can be used to accomplish these two features. A publish occurs when a
client or device want to submit data to a server or broker.
The term "subscribe" refers to the reversal of the procedure. Several clients can
connect to a broker under the pub/sub paradigm and subscribe to subjects that
interest them.
When a broker and a subscribing client lose contact, the broker will store messages
in a buffer and send them to the subscriber whenever the broker is back up and
running. The broker has the right to cut off communication with subscribers and
send them a cached message containing publisher instructions if the publishing
client abruptly disconnects from the broker.
"Publishers send the messages, subscribers receive the messages they are
interested in, and brokers pass the messages from the publishers to the
subscribers," reads an IBM write-up describing the pub/sub paradigm. MQTT clients,
such as publishers and subscribers, can only speak with MQTT brokers. Any device
or programme that runs a MQTT library can be a MQTT client, ranging from
microcontrollers like the Arduino to entire application servers housed in the cloud.
MQTT Broker and its functions:
An MQTT broker in IoT is a central hub that manages message routing between
devices (publishers) and applications (subscribers) using a publish/subscribe model.
It enables real-time data transmission, such as a temperature sensor publishing data
to home/livingroom/temp, which a mobile app subscribes to. Common examples
include HiveMQ, EMQX, AWS IoT Core, and Mosquitto.
Eclipse Mosquitto: Widely used on Raspberry Pi, edge devices, and small-to-
medium deployments due to its lightweight nature.
EMQX: Designed for high-performance, massive scalability (millions of
connections), and enterprise needs.
VerneMQ: Known for high-performance distributed messaging.
HiveMQ Cloud: A managed broker designed for IoT data scaling.
Azure IoT Hub: Provides secure, bi-directional communication for IoT devices.
Characteristics of MQTT
Lightweight: MQTT is designed to be lightweight, making it suitable for use in
aid-restrained environments inclusive of embedded systems and low-strength
devices. The protocol minimizes bandwidth and processing overhead, enabling
green communication even on restricted networks.
Publish-Subscribe Model: In the publish-subscribe version, clients (publishers)
send messages to subjects, and different clients (subscribers) acquire messages
from subjects of interest. This decoupling of producers and purchasers permits
for flexible and dynamic conversation styles.
Quality of Service (QoS) Levels: MQTT supports exclusive stages of message
delivery warranty, referred to as Quality of Service (QoS). QoS levels range from
0 to 2, providing various stages of reliability and message transport guarantees,
relying at the utility necessities.
Retained Messages: MQTT lets in agents to store retained messages on topics,
making sure that new subscribers acquire the maximum latest message posted
on a subject right now after subscribing. This characteristic is beneficial for fame
updates and configuration settings.
Last Will and Testament (LWT): MQTT clients can specify a Last Will and
Testament message to be posted by way of the broker in the occasion of an
sudden consumer disconnect. This function affords a mechanism for detecting
patron failures and dealing with them gracefully.
Security: MQTT helps various protection mechanisms, consisting of Transport
Layer Security (TLS) encryption and authentication mechanisms which include
username/password and consumer certificates. These capabilities make certain
the confidentiality, integrity, and authenticity of messages exchanged over MQTT
connections.
Advantages of MQTT
This model is not restricted to one-to-one communication between clients. Although
the publisher client sends a single message on specific topic, broker sends multiple
messages to all different clients subscribed to that topic. Similarly, messages sent
by multiple such publisher clients on multiple different topics will be sent to all
multiple clients subscribed to those topics. Hence one-to-many, many-to-one, as
well as many-to-many communication is possible using this model. Also, clients can
publish data and at the same time receive data due to this two-way communication
protocol. Hence MQTT is considered to be bi-directional protocol. The default
unencrypted MQTT port used for data transmission is 1883. The encrypted port for
secure transmission is 8883.
Lightweight protocol that is quick to create and allows for efficient data transport
Minimal data packet usage, resulting in low network usage
Effective data dispersion
The effective use of remote sensing and control
Prompt and effective message delivery
Minimises power consumption, which is beneficial for the linked devices, and
maximises network capacity.
Data transmission is quick, efficient, and lightweight because MQTT messages
have small code footprint. These control messages have a fixed header of size 2
bytes and payload message up to size 256 megabytes.
Disadvantages of MQTT
When compared to Constrained Application Protocol (CoAP), MQTT has slower
send cycles.
Resource discovery in MQTT is based on flexible topic subscription, while
resource discovery in CoAP is based on a reliable system.
MQTT lacks encryption. Rather, security encryption is accomplished by TLS/SSL
(Transport Layer Security/Secure Sockets Layer).
Building an internationally scalable MQTT network is challenging.
XMPP Protocol:
The Extensible Messaging and Presence Protocol (XMPP) is an open-standard,
XML-based technology used in IoT for real-time, secure, and bidirectional
communication between devices, servers, and applications. Ideal for smart home
and industrial automation, it enables publish/subscribe, device discovery, and
status monitoring (presence).
Key Aspects of XMPP in IoT:
Real-Time Data Exchange: XMPP provides efficient, near-real-time
streaming of XML data, allowing for instant command and control.
Presence Awareness: It natively supports monitoring the state
(online/offline/busy) of connected IoT devices
PubSub (Publish/Subscribe): XMPP includes a robust PubSub extension that
allows sensors to publish data, which is then distributed to authorized
subscribers, ideal for data telemetry.
Security & Scalability: XMPP offers strong, built-in security features,
including TLS encryption, and supports decentralized architectures, making
it suitable for distributed IoT networks.
Addressing: Devices are identified using Jabber Identifiers (JIDs), which
resemble email addresses, facilitating easy routing.
XMPP architecture:
In IoT applications, the XMPP architecture enables real-time communication
between smart devices, servers, and users over the Internet. In this system, IoT
devices such as ESP8266, ESP32, or Raspberry Pi act as XMPP clients that
connect to an XMPP server through a network connection. The XMPP server
performs important functions such as device authentication, message routing, and
presence management (online/offline status). Sensor data, alerts, and status updates
are sent from the IoT device to the server, and control commands are sent back
from the server to the device. To support communication with other systems, an
XMPP gateway is used. This gateway acts as a protocol translator, allowing
integration with services like SMS and SMTP. For example, if a gas leakage or fire
is detected, the IoT device sends an alert to the XMPP server, which then forwards
it through the gateway to an SMS server or an email server so that the user receives
a notification via SMS or email. This multi-protocol integration ensures reliable
and flexible communication. Therefore, XMPP-based architecture is suitable for
IoT systems because it supports real-time messaging, remote monitoring,
interoperability, scalability, and secure communication over the Internet.
Transport Protocol:
BLE(Bluetooth Low Energy):
Bluetooth Low Energy (BLE) is a low-power, short-range wireless protocol operating in the 2.4
GHz ISM band, designed specifically for IoT devices to exchange small data amounts while
running on minimal battery (0.01–0.5 W). It features rapid connection/disconnection, high
interoperability, and supports mesh networking, making it ideal for wearables, smart homes, and
industrial sensors
BLE PROTOCOL STACK ARCHITECTURE:
Figure shows the Bluetooth low energy protocol stack architecture.
The Bluetooth low energy protocol stack (or protocol stack) consists of the controller and the
host. This separation of controller and host derives from the implementation of classic Bluetooth
BR/EDR devices, where the two sections are implemented separately. Any profiles and
applications sit on top of the GAP and GATT layers of the protocol stack.
The physical layer (PHY) is a 1-Mbps adaptive frequency-hopping GFSK (Gaussian frequency-
shift keying) radio operating in the unlicensed 2.4-GHz ISM (industrial, scientific, and medical)
band.
The Generic Access Profile (GAP) controls the RF state of the device, with the device in one of
five states:
Standby
Advertising
Scanning
Initiating
Connected
Advertisers transmit data without connecting, while scanners scan for advertisers. An initiator is
a device that responds to an advertiser with a request to connect. If the advertiser accepts the
connection request, both the advertiser and initiator enter a connected state. When a device is
connected, it connects as either master or slave. The device initiating the connection becomes the
master and the device accepting the request becomes the slave.
The HCI layer provides communication between the host and controller through a standardized
interface. This layer can be implemented either through a software API or by a hardware
interface such as UART, SPI, or USB. The Specification of the Bluetooth System describes
Standard HCI commands and events. TI’s proprietary commands and events are specified in TI
Bluetooth low energy Vendor-Specific HCI Reference Guide.
The L2CAP layer provides data encapsulation services to the upper layers, allowing for logical
end-to-end communication of data.
The Security Manager layer defines the methods for pairing and key distribution, and provides
functions for the other layers of the protocol stack to securely connect and exchange data with
another device.
The Generic Access Profile (GAP) layer directly interfaces with the application and/or profiles,
to handle device discovery and connection-related services for the device. GAP handles the
initiation of security features.
The ATT layer allows a device to expose certain pieces of data or attributes, to another device.
The Generic Attribute Profile (GATT) layer is a service framework that defines the sub-
procedures for using ATT. Data communications that occur between two devices in a Bluetooth
low energy connection are handled through GATT sub-procedures. The application and/or
profiles will directly use GATT.
Applications of Bluetooth Low Energy (BLE)
Wearable Technology
BLE has become a main protocol in the development of wearable devices, powering
smartwatches, fitness trackers, and health monitoring devices. Its low power consumption is
applied in ensuring these devices can operate for extended periods without frequent recharging.
Healthcare Devices
BLE finds maximum use in healthcare applications, connecting medical devices to smartphones
for real-time monitoring. This includes devices like blood glucose monitors, heart rate monitors,
and temperature sensors.
Smart Home System
BLE is a key enabler of smart home ecosystems. From smart bulbs and thermostats to door locks
and security systems, BLE provides seamless communication between devices, enhancing the
overall smart home experience.
Asset Tracking
BLE is used for asset tracking applications, and businesses to monitor the location of assets
within a limited space. This is valuable in industries such as logistics, where real-time tracking
can streamline operations.
Advantages of BLE in IoT
Ultra-Low Power Consumption: Designed for small devices, enabling them to operate for
months or years on a single coin-cell battery.
Low Cost & High Ubiquity: Inexpensive to implement and widely supported by
smartphones, tablets, and computers.
Scalability & Flexibility: Supports multiple topologies (point-to-point, broadcast, and
mesh).
Fast Connection Time: Connects and transfers data quickly, ideal for intermittent, low-
bandwidth data transfers.
Easy Integration: Simple development process for manufacturers and developers
Disadvantages of BLE in IoT
Limited Range: Typically effective within short distances (up to 100 meters in open
space), which is significantly reduced by obstacles like walls.
Low Data Throughput: Not suitable for large data transfers or streaming; it is optimized
for small, intermittent data packets.
Security Risks: Susceptible to eavesdropping and man-in-the-middle attacks if not
properly secured.
Interference Issues: Operates on the 2.4 GHz spectrum, which can suffer from
interference from Wi-Fi and other devices.
Dependency on Hubs: Often requires a central device (like a smartphone or gateway) to
connect to the internet.
Li-Fi(Light Fidelity):
The Li-Fi (light fidelity) technology was proposed by the German Scientist namely Harald Haas.
The main function of this technology is to transmit the data via light. This technology is idyllic
for high-speed wireless communication in a restricted region, and it offers many benefits over
Wi-Fi technology such as high bandwidth, ease of use, efficiency, and safety. These systems can
communicate from street lights to auto-piloted cars using their headlights. As the light speed is
superior hence the data communication speed is also faster in the existing system. Furthermore,
this technology can be implemented for speedy data access for the laptops, and gadgets that will
be transmitted during the beam in a room.
Architecture:
Transmitter (LED Driver/Lamp): The data source connects to an LED driver, which
modulates the intensity of the LED bulb to transmit data, typically using visible light,
infrared, or ultraviolet spectrum.
Transmission Medium: Visible light spectrum (400-800 THz), which is 10,000 times
larger than the radio spectrum, allows for high-speed, secure, and interference-free
communication.
Receiver (Photodetector/Dongle): A photodetector on the user device (laptop, phone)
detects the light fluctuations, amplifies them, and converts the signals back into digital
data.
Working:
The working of Li-Fi is very simple. There is a light emitter on one end i.e. an LED
transmitter, and a photo detector (light sensor) on the other. The data input to the LED
transmitter is encoded in to the light (technically referred to as Visible Light
Communication) by varying the flickering rate at which the LEDs flicker ‘on’ and ‘off’ to
generate different strings of 1s and 0s. The onoff activity of the LED transmitter which seems
to be invisible (The LED intensity is modulated so rapidly that human eye cannot notice, so
the light of the LED appears constant to humans), enables data transmission in light form in
accordance with the incoming binary codes: switching ON a LED is a logical '1', switching it
OFF is a logical '0'. By varying the rate at which the LEDs flicker on and off, information
can be encoded in the light to different combinations of 1s and 0s. In a typical setup, the
transmitter (LED) is connected to the data network (Internet through the modem) and the
receiver (photo detector/light sensor) on the receiving end receives the data as light signal
and decodes the information, which is then displayed on the device connected to the receiver.
The receiver (photo detector) registers a binary ‘1’ when the transmitter (LED) is ON and a
binary ‘0’ when the transmitter (LED) is OFF. Thus flashing the LED numerous times or
using an array of LEDs (perhaps of a few different colours) will eventually provide data rates
in the range of hundreds of Mbps.
Advantages:
High Speed: LiFi provides significantly faster data transfer rates than traditional Wi-Fi,
with potential speeds exceeding 100 Gbps.
Enhanced Security: Data transmission is restricted to the area illuminated by the light
source, meaning signals cannot be intercepted through walls
.No Electromagnetic Interference: Because it uses light waves instead of radio
frequencies, LiFi can be safely used in hospitals, airplanes, and other sensitive
environments.
Energy Efficiency: Utilizing existing LED lighting infrastructure for data transmission
reduces energy consumption.
Large Bandwidth: The visible light spectrum is 10,000 times larger than the radio
spectrum, allowing for higher capacity without overcrowding.
Key Disadvantages of LiFi
Line-of-Sight Requirement: A clear, unobstructed path is generally required between
the light source and the receiver.
Limited Range: LiFi signals have a limited range, typically covering only a few meters
from the light source.
Dependence on Light Source: The system requires lights to be on, or at least dimmed to
a low level, to maintain connectivity.
Interference from Ambient Light: Strong external light sources, such as sunlight, can
interfere with the signal.
High Initial Cost & Limited Compatibility: Currently, few devices have built-in LiFi
support, necessitating expensive adapters and causing high installation costs.
Comparison with Wi-fi:
Feature LiFi Wi-Fi
Medium Light (Visible/Infrared) Radio Frequency
Speed Extremely High (100 Gbps) Moderate (Up to 7 Gbps)
Range Short (5-10 meters) Long (Through walls)
Security High (Confined to room) Moderate (Can pass through walls)
Interference Low High
Basics of sensor networks:
Wireless Sensor Networks (WSNs) consist of spatially distributed, autonomous devices (nodes)
that monitor physical or environmental conditions—like temperature, sound, or pressure—and
cooperatively pass data through the network to a main location (sink/gateway). These networks
are self-organizing, low-power, and often use wireless communication to transmit data to a
central system for analysis.
Wireless Sensor Network Architecture
Sensor Nodes: Tiny, battery-powered devices consisting of a sensing unit (data
acquisition), processing unit, transceiver (communication), and power source.
Sink Node/Gateway: Collects data from sensor nodes and acts as an interface to the user,
often via the internet.
Topologies: Common structures include star (direct communication to base station),
mesh, and hybrid configurations.
A Wireless Sensor Network (WSN) architecture is structured into three main layers:
Physical Layer: This layer connects sensor nodes to the base station using technologies
like radio waves, infrared, or Bluetooth. It ensures the physical communication between
nodes and the base station.
Data Link Layer: Responsible for establishing a reliable connection between sensor
nodes and the base station. It uses protocols such as IEEE 802.15.4 to manage data
transmission and ensure efficient communication within the network.
Application Layer: Enables sensor nodes to communicate specific data to the base
station. It uses protocols like ZigBee to define how data is formatted, transmitted, and
received, supporting various applications such as environmental monitoring or industrial
control.
These layers work together to facilitate the seamless operation and data flow within a Wireless
Sensor Network, enabling efficient monitoring and data collection across diverse applications.
Point To Point Topology
Point-to-point topology is a type of topology that works on the functionality of the sender and
receiver. It is the simplest communication between two nodes, in which one is the sender and the
other one is the receiver. Point-to-Point provides high bandwidth.
Common Components in a P2P Link
Even in a simple P2P setup, each sensor node (or "mote") typically contains:
Sensing Unit: To capture physical data like temperature or pressure.
Processing Unit: A microcontroller to handle data and control tasks.
Communication Unit: A transceiver (using protocols like ZigBee or Bluetooth) to
send/receive signals.
Power Unit: Usually a battery, sometimes supported by solar cells.
Characteristics:
Direct Interaction: Each node can function as both a "client" and a "server" to the other
node in the pair.
Dedicated Link: The connection is a single, secure data communication channel
between exactly two points.
No Centralized Control: Unlike star topologies, there is no master node or
communications hub managing the traffic.
Simplicity: It is widely considered the most basic building block of any network
infrastructure.