IOT Protocols
UNIT 3
Content
Link layer protocols, Network/internet layer protocols, Transport layer protocols,
Application layer protocols:
Hypertext transfer protocol (HTTP), Systematic HTTP access methodology, Web Socket, Constrained application protocol CoAP), Message Queue, Telemetry Transport Protocol (MQTT), XMPP, DDS, AMQP
IoT Link Layer Protocols
1. IEEE 802.15.4
2. Zigbee
3. Bluetooth Low Energy (BLE)
4. Wi-Fi (IEEE 802.11 variants)
5. LoRaWAN (Link Layer aspects)
6. NB-IoT (Narrowband IoT)
7. 6LoWPAN
What is the Link Layer?
1. IEEE 802.15.4
2. Zigbee
3. Bluetooth Low Energy (BLE)
4. Wi-Fi (IEEE 802.11 variants)
5. LoRaWAN (Link Layer aspects)
6. NB-IoT (Narrowband IoT)
7. 6LoWPAN
Summary Table:
Protocol | Frequency | Data Rate | Range | Power Consumption | Topology | Notes |
IEEE 802.15.4 | 2.4 GHz, 868/915 MHz | ~250 kbps | 10-100 m | Low | Star, Mesh | Base for Zigbee, Thread, 6LoWPAN |
Zigbee | 2.4 GHz | ~250 kbps | 10-100 m | Low | Mesh | Widely used in automation |
BLE | 2.4 GHz | Up to 2 Mbps | ~10-50 m | Very Low | Star, Mesh | Wearables, sensors |
Wi-Fi | 2.4/5 GHz | Mbps - Gbps | 50-100 m | High | Star | Wi-Fi HaLow for IoT (sub-1 GHz) |
LoRaWAN | Sub-GHz | 0.3 - 50 kbps | 2-15 km | Very Low | Star | Long range, low power |
NB-IoT | Licensed LTE | Up to 250 kbps | Several km | Low | Cellular | Massive IoT deployments |
6LoWPAN | Depends on PHY | Adapted IPv6 | Same as PHY | Low | Mesh, Star | IP connectivity over 802.15.4 |
What works most in practice?
Use Case | Most Used Protocol(s) |
Home automation | Zigbee, Thread, BLE |
Wearables & personal devices | BLE |
Smart appliances & cameras | Wi-Fi |
Industrial IoT (IIoT) | IEEE 802.15.4 variants, LoRaWAN, NB-IoT |
Smart agriculture & cities | LoRaWAN, NB-IoT |
Large-scale IP IoT | 6LoWPAN + Thread |
Wi-Fi (IEEE 802.11 Variants) for IoT
1. Overview of Wi-Fi
2. Common IEEE 802.11 Variants
3. Wi-Fi for IoT — Challenges & Adaptations
4. Wi-Fi HaLow (802.11ah)
5. Use Cases of Wi-Fi in IoT
6. Advantages of Wi-Fi in IoT
7. Disadvantages of Wi-Fi in IoT
8. Security Considerations
9. Example Wi-Fi IoT Communication Flow
10. Future Trends
Messaging Protocols
Web Socket,
"WebSocket as IoT" is a concept that refers to using WebSockets as a communication protocol for Internet of Things (IoT) devices. It's not a standard approach like MQTT or CoAP, but it can be useful in certain cases. Let's break this down and explain how WebSockets can be used in IoT.
🔌 What is WebSocket?
WebSocket is a full-duplex, bi-directional communication protocol that runs over a single TCP connection. It allows real-time data exchange between a client (like a web browser or IoT device) and a server.
✅ Persistent connection (unlike HTTP, which is request-response)
✅ Low latency, efficient real-time updates
✅ Built into most browsers and many languages
❌ Overhead compared to lightweight IoT protocols
📡 Why Use WebSocket in IoT?
While protocols like MQTT and CoAP are more popular in IoT for being lightweight and optimized for constrained devices, WebSocket can be a viable choice when:
✅ Use Cases:
You have a web interface that needs real-time updates from IoT devices
Your IoT devices are not very constrained (have enough CPU/memory/network)
You need low-latency, bi-directional communication
You’re running over Wi-Fi or Ethernet, not low-power radios (e.g., Zigbee)
🧭 Comparison: WebSocket vs MQTT in IoT
Feature | WebSocket | MQTT |
Protocol Type | Full-duplex over TCP | Publish/Subscribe over TCP |
Overhead | Higher | Lower |
Use Case | Web apps, real-time updates | Sensor data, telemetry |
Security | WSS (WebSocket over TLS) | TLS |
Native Browser | Yes | No |
QoS Levels | No | Yes (0, 1, 2) |
🛠️ Example: IoT Device Using WebSocket
Let’s say you have a smart thermostat that sends temperature updates to a dashboard in real time.
Example code snippet (Node.js client):
const WebSocket = require('ws');
const ws = new WebSocket('wss://iot-server.example.com');
ws.on('open', function open() {
setInterval(() => {
const temp = 25 + Math.random();
ws.send(JSON.stringify({ temp }));
}, 5000);
});
🧩 When Not to Use WebSocket
In power- or bandwidth-constrained environments (e.g., battery-operated sensors)
When using low-power protocols like LoRaWAN or Zigbee
If you need guaranteed delivery with low bandwidth (MQTT is better)
🧠 Conclusion
WebSocket is not the traditional IoT protocol, but it’s useful in certain real-time, web-integrated, or higher-powered device scenarios.
Use WebSocket in IoT when:
You need real-time updates
You're working with browsers or interactive dashboards
Devices can handle more complex protocols
Messaging Protocols in IoT
Message Queuing Telemetry Transport (MQTT)
MQTT
Subscriber
MQTT Broker
Publisher
Subscriber
MQTT - Example
Subscriber 1
Publisher
MQTT Broker
Subscribed to:
“Temperature”
Subscribed to:
“Temperature”
Subscriber 2
Subscriber 3
MQTT - Example
MQTT Broker
Subscriber: CurrentLocation
Publisher: CurrentLocation
MQTT - Example
Publisher: Direction
Publisher: CurrentLocation
MQTT Broker
Subscriber: CurrentLocation
Subscriber: Direction
MQTT - Working -Video
Client_Address
MQTT - Working
MQTT – Node(s)
Publisher
Subscriber
MQTT
Broker
Topic:SensData
QoS in MQTT
MQTT Publisher – Code Implementation
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
�const char* ssid = "OnePlusTJ";
const char* pwd = "Tjm12347";
const char* mqtt_server =
"broker.mqtt-dashboard.com";
�WiFiClient espClient;
PubSubClient client(espClient);
int value = 0;
unsigned long lastMsg = 0;
#define MSG_BUFFER_SIZE (50)
char msg[MSG_BUFFER_SIZE];
1
2
3
4
5
6
7
8
9
10
11
12
13
MQTT_publisher.ino
Including the “ESP8266WiFi” library for enabling Wi-Fi connection with protocols.
Including the “PubSubClient” library for use of MQTT protocol and their functions.
Defining MQTT server/broker for publishing the message on particular topic.
Defining parameters for Wi-Fi connection.
MQTT Publisher – Code Implementation
void setup_wifi() {
delay(10);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, pwd);
� while(WiFi.status()!=WL_CONNECTED) {
delay(500);
Serial.print(".");
}� Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
MQTT_publisher.ino
Initializing Wi-Fi module as station mode.
Connecting Wi-Fi module with given SSID and Password
Try until Wi-Fi is not connected to given SSID with delay of half second.
MQTT Publisher – Code Implementation
void setup() {
Serial.begin(115200);
setup_wifi();
client.setServer(mqtt_server,1883);
while (!client.connected()) {
Serial.print("Attempting MQTT");
String clientId="ESPClient1234";
if (client.connect(
clientId.c_str())) {
Serial.println("connected");
client.publish("darshan/6thsem /ce", “You are in Darshan");
}
}
}
31
32
33
34
35
36
37
38
39
40
41
42
43
MQTT_publisher.ino
Execute the syntax in loop until ESP is not connected to MQTT broker.
Defining a clientId for MQTT server/broker.
Publishing announcement message after connecting to the MQTT broker with Topic name : darshan/6thsem/ce
Returns the pointer of string clientId to the array.
Connects the client to the MQTT Server stored in mqtt_server with port number 1883.
MQTT Publisher – Code Implementation
void loop() {
� client.loop();
unsigned long now = millis();
if (now - lastMsg > 2000)
{
lastMsg = now;
++value;
snprintf (msg, MSG_BUFFER_SIZE, "hello world #%ld", value);
Serial.print("Publish message:");
Serial.println(msg);
client.publish("darshan/6thsem/
ce", msg);
}
}
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
MQTT_publisher.ino
This function allows client to process incoming messages, publish data and refresh the connection.
Creating a string in msg with given buffer size and assigning the value “hello world” with concatenation of integer named value.
Publishes the msg in the given topic name: darshan/6thsem/ce
MQTT Subscriber – Code Implementation
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
�const char* ssid = "OnePlusTJ";
const char* pwd = "Tjm12347";
const char* mqtt_server =
"broker.mqtt-dashboard.com";
�WiFiClient espClient;
PubSubClient client(espClient);
1
2
3
4
5
6
7
8
9
MQTT_subscriber.ino
Including the “ESP8266WiFi” library for enabling Wi-Fi connection with protocols.
Including the “PubSubClient” library for use of MQTT protocol and their functions.
Defining MQTT server/broker for publishing the message on particular topic.
Defining parameters for Wi-Fi connection.
MQTT Subscriber – Code Implementation
void setup_wifi() {
delay(10);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, pwd);
� while(WiFi.status()!=WL_CONNECTED) {
delay(500);
Serial.print(".");
}� Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
MQTT_subscriber.ino
Initializing Wi-Fi module as station mode.
Connecting Wi-Fi module with given SSID and Password
Try until Wi-Fi is not connected to given SSID with delay of half second.
MQTT Subscriber – Code Implementation
void callback(char* topic,
byte* payload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < length; i++)
{
Serial.print((char)payload[i]);
}
Serial.println();
}
27
28
29
30
31
32
33
34
35
36
37
MQTT_subscriber.ino
A callback function for receiving messages every time when client.loop( ) executes.
Executing the for loop until all the characters of the payload are printed.
This function accepts the arguments char* of topic, char* of payload and the length of payload.
Typecasting of payload[i] into equivalent character and then printing on serial monitor.
MQTT Subscriber – Code Implementation
void setup() {
Serial.begin(115200);
setup_wifi();
client.setServer(mqtt_server,1883);
client.setCallback(callback);
while (!client.connected()) {
Serial.print("Attempting MQTT");
String clientId="ESPClient1234";
if (client.connect(
clientId.c_str())) {
Serial.println("connected");
client.subscribe("darshan/Msg");
}
}
}
void loop() {
client.loop(); }
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
MQTT_subscriber.ino
This is built-in function client.setCallback( ) in PubSubClient library and it calls a function callback( ) every time when client.loop( ) function is executed.
Subscribing to the Topic named “darshan/Msg”
Constrained Application Protocol (CoAP)
CoAP Architecture
CoAP Layers
UDP
Messages
Request/Response
Application
Message Layer in CoAP
Client
Server
CON (ADDR)
Message Layer in CoAP (Contd.)
Client
Server
NON [Message ID]
Message Layer in CoAP (Contd.)
Client
Server
CON (ADDR)
ACK (ADDR)
Message Layer in CoAP (Contd.)
Client
Server
CON (ADDR)
Timeout
RST
Request-Response Layer in CoAP
Client
Server
CON (ADDR)
GET/Humidity
(Token Number)
ACK (ADDR)
(Token Number)
72%
Client
Server
CON (ADDR)
GET/Humidity
(Token Number)
ACK (ADDR)
(Token Number)
NOT FOUND
Request-Response Layer in CoAP (Contd.)
Client
Server
CON (ADDR)
GET/Humidity
(Token Number)
ACK
ACK
CON (ADDR)
(Token Number)
60%
.
.
.
.
Request-Response Layer in CoAP (Contd.)
Client
Server
NON (Message ID)
GET/Humidity
(Token Number)
NON (Message ID)
(Token Number)
72%
CoAP Message Format
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Token (if any, with TKL bytes length) |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | Payload |
V | T | TKL | Code | Message ID |
Options (if any) |
CoAP Message Format (Contd.)
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Token (if any, with TKL bytes length) |
Options (if any) |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | Payload |
V | T | TKL | Code | Message ID |
XMPP Protocol
XMPP denotation
Messenger Requirements
XMPP Architecture
XMPP
Client
XMPP
Client
XMPP
Client
XMPP
Server
XMPP
Server
XMPP
Client
XMPP
Client
XMPP
Client
XMPP Architecture (Contd.)
XMPP
Client
XMPP
Client
XMPP
Client
XMPP
Server
XMPP
Server
XMPP
Client
XMPP
Client
XMPP
Client
XMPP Architecture (Contd.)
Data Distribution Service (DDS)
DDS Architecture
Data Distribution Service
(DDS)
Publisher
Publisher
Publisher
Subscriber
Subscriber
Subscriber
DDS Architecture (Contd.)
Data Distribution Service
(DDS)
Publisher
Publisher
Publisher
Subscriber
Subscriber
Subscriber
Transport Protocols
Section - 2
Bluetooth 4.0 (BLE)
Bluetooth 4.0 (BLE) (Cont.)
Features of BLE
BLE Architecture
Application
Host
Controller
BLE
Application
Generic Access Profile
(GAP)
Link Layer (LL)
Physical Layer (PHY)
Generic Attribute Profile
(GATT)
Attribute Protocol
(ATT)
Logical Link Control and Adaptation Protocol
(L2CAP)
Security Management Protocol
(SMP)
--------------------------------------Host Controller Interface --------------------------------------
(HCI)
Host
Application
Controller
BLE Architecture
Link Layer (LL)
Physical Layer (PHY)
--------------------------------------Host Controller Interface --------------------------------------
(HCI)
Controller
BLE Architecture
Generic Access Profile
(GAP)
Generic Attribute Profile
(GATT)
Attribute Protocol
(ATT)
Logical Link Control and Adaptation Protocol
(L2CAP)
Security Management Protocol
(SMP)
Host
BLE Architecture
Generic Access Profile
(GAP)
Generic Attribute Profile
(GATT)
Attribute Protocol
(ATT)
Logical Link Control and Adaptation Protocol
(L2CAP)
Security Management Protocol
(SMP)
Host
BLE Architecture
Application
Application
BLE Topology
Bluetooth
Broadcaster
Observer
Observer
Observer
Observer
Observer
Observer
BLE Topology
Bluetooth
Broadcaster
Observer
Observer
Observer
Observer
Observer
Observer
BLE Topology
Master
Slave
(Peripheral)
Slave
(Peripheral)
Slave
(Peripheral)
Slave
(Peripheral)
Slave
(Peripheral)
Slave
(Peripheral)
BLE Topology
Master
Slave
(Peripheral)
Slave
(Peripheral)
Slave
(Peripheral)
Slave
(Peripheral)
Slave
(Peripheral)
Slave
(Peripheral)
Light Fidelity (Li-Fi)
Li-Fi Working
Receiver dongle
Receiver dongle
Photo
Detector
Amplification & Processing
Received App Data
Photo
Detector
Amplification & Processing
Received App Data
Internet
Server
Streaming
Content
Power
LED
Lamp
LED
Lamp
Lamp
Driver
Li-Fi Working
Receiver dongle
Receiver dongle
Photo
Detector
Amplification & Processing
Received App Data
Photo
Detector
Amplification & Processing
Received App Data
Internet
Server
Streaming
Content
Power
LED
Lamp
LED
Lamp
Lamp
Driver
Li-Fi – Advantages & Disadvantages
Addressing & Identification Protocols
Section - 3
Internet Protocol Version 4 (IPv4)
10101100
00010000
11111110
00000001
172
16
254
1
IP addresses are divided into 2 parts:
Network ID & Host ID
<NID> <HID> = IP Address
Classification of IP Address
0 | | | | |
Class: A
Fix
7 Bit Network ID
24 Bit Host ID
1 | 0 | | | | |
Class: B
Fix
14 Bit Network ID
16 Bit Host ID
1 | 1 | 0 | | | | |
Class: C
Fix
21 Bit Network ID
8 Bit Host ID
1 | 1 | 1 | 0 | | | | |
Class: D
Fix
Multicast address
1 | 1 | 1 | 1 | | | | |
Class: E
Fix
Reserved address
Class A
0 | | | | |
7 Bit Network ID
24 Bit Host ID
0.0.0.0 | Special IP Address |
00000001.0.0.1 1.0.0.2 1.0.0.3 . . . 126.255.255.254 | 224 – 2 are Host IP |
127.255.255.255 | Special IP Address – Loopback |
Class B
1 | 0 | | | | |
Fix
14 Bit Network ID
16 Bit Host ID
128.0.0.0 | Special IP Address |
10000001.0.0.1 130.0.0.2 130.0.0.3 . . . 190.255.255.254 | 216 – 2 are Host IP |
10111111.255.255.255 | Special IP Address – Loopback |
Class C
1 | 1 | 0 | | | | |
Fix
21 Bit Network ID
8 Bit Host ID
192.0.0.0 | Special IP Address |
11000001.0.0.1 194.0.0.2 194.0.0.3 . . . 222.255.255.254 | 28 – 2 are Host IP |
11011111.255.255.255 | Special IP Address – Loopback |
Class D
11100000 – 11101111
224 – 239
Class E
IPv4 Format
Identification (16) | Flags(3) | Fragment Offset (13) |
Time to Live (8) | Protocol (8) | Header Checksum (16) |
Source Address (32) |
Destination Address (32) |
Options (if any) |
VER (4) | IHL (4) | Types of Service (8) | Total Length (16) |
IPv4 Format
Time to Live (8) | Protocol (8) | Header Checksum (16) |
Source Address (32) |
Destination Address (32) |
Options (if any) |
VER (4) | IHL (4) | Types of Service (8) | Total Length (16) |
Identification (16) | Flags(3) | Fragment Offset (13) |
Precedence
Delay
T
R
Reserved Bits
IPv4 Format
Time to Live (8) | Protocol (8) | Header Checksum (16) |
Source Address (32) |
Destination Address (32) |
Options (if any) |
VER (4) | IHL (4) | Types of Service (8) | Total Length (16) |
Identification (16) | Flags(3) | Fragment Offset (13) |
IPv4 Format
Time to Live (8) | Protocol (8) | Header Checksum (16) |
Source Address (32) |
Destination Address (32) |
Options (if any) |
VER (4) | IHL (4) | Types of Service (8) | Total Length (16) |
Identification (16) | Flags(3) | Fragment Offset (13) |
IPv4 Format
Time to Live (8) | Protocol (8) | Header Checksum (16) |
Source Address (32) |
Destination Address (32) |
Options (if any) |
VER (4) | IHL (4) | Types of Service (8) | Total Length (16) |
Identification (16) | Flags(3) | Fragment Offset (13) |
IPv6 Addressing
Features of IPv6 Addressing
IPv6 Header Format
Payload Length (16) | Next Header (8) | Hop Limit (8) |
Source Address (128) |
Destination Address (128) |
IP Version Number (4) | Traffic Class (8) | Flow Label (20) |
IPv6 Header Format
IP Version Number (4) | Traffic Class (8) | Flow Label (20) |
Payload Length (16) | Next Header (8) | Hop Limit (8) |
Source Address (128) |
Destination Address (128) |
IPv6 Header Format
IP Version Number (4) | Traffic Class (8) | Flow Label (20) |
Payload Length (16) | Next Header (8) | Hop Limit (8) |
Source Address (128) |
Destination Address (128) |
IPv6 Header Format
IP Version Number (4) | Traffic Class (8) | Flow Label (20) |
Payload Length (16) | Next Header (8) | Hop Limit (8) |
Source Address (128) |
Destination Address (128) |
Uniform Resource Identifier (URI)
Universal Resource Name (URN)
E.g.: ISBN:0451450523
Universal Resource Identifier (URI)
Universal Resource Locator (URL)
E.g.: https://darshan.ac.in/ce/material
Uniform Resource Locator (URL)
http://www.darshan.ac.in/CE/Study-material/IoT/Syllabus.html
HTTP Protocol
World Wide Web
Domain Name
Path
File name
Systematic HTTP access methodology,
It's a structured approach to accessing resources or services over the HTTP protocol. The methodology ensures consistent, reliable, and efficient communication between clients (like browsers, apps, IoT devices) and servers.
Key elements of a systematic HTTP access methodology:
1. Understanding HTTP Methods
HTTP defines several request methods — each with a specific purpose.
GET: Retrieve data from the server.
POST: Send data to the server (usually creates a new resource).
PUT: Update or replace an existing resource.
PATCH: Partially update a resource.
DELETE: Remove a resource.
HEAD: Retrieve metadata without the body.
OPTIONS: Discover supported methods on a resource.
Using these methods correctly is fundamental to a good HTTP access strategy.
2. Endpoint Structuring and Naming
Design URLs (endpoints) to be clear, meaningful, and consistent.
Use nouns for resources, e.g., /users, /devices/123.
Avoid verbs in URLs (instead, use HTTP methods to describe actions).
Support versioning in URLs like /api/v1/....
3. Request and Response Standards
Use appropriate HTTP status codes:
200 OK (success)
201 Created (resource created)
400 Bad Request (client error)
401 Unauthorized (auth error)
404 Not Found (missing resource)
500 Internal Server Error (server error)
Define clear request and response payloads (usually JSON or XML).
Include metadata in headers (like content-type, auth tokens, caching).
4. Authentication & Authorization
Use secure methods: OAuth, API keys, JWT tokens.
Enforce HTTPS to encrypt traffic.
Implement access control based on user roles or device permissions.
5. Error Handling and Retries
Provide meaningful error messages with error codes and details.
Implement retry mechanisms with exponential backoff to handle transient failures.
Log errors for monitoring and troubleshooting.
6. Rate Limiting and Throttling
Protect servers from overload by limiting request rates.
Inform clients when limits are reached with status 429 Too Many Requests.
Implement fair usage policies.
7. Caching
Use HTTP caching headers (Cache-Control, ETag, Last-Modified) to improve performance.
Decide which resources can be cached and for how long.
8. Testing & Documentation
Document APIs clearly (Swagger/OpenAPI, Postman).
Test endpoints thoroughly (unit tests, integration tests).
Monitor usage and performance.
Summary of a systematic HTTP access flow example:
Step | Description |
Client sends GET /devices | Retrieve list of devices |
Server returns 200 OK with JSON data | Successfully returns data |
Client sends POST /devices with payload | Creates a new device resource |
Server returns 201 Created with resource URL | Resource successfully created |
Client sends PUT /devices/123 to update | Updates existing device info |
Server returns 200 OK or 204 No Content | Update successful, no body returned |
Client sends DELETE /devices/123 | Deletes the device resource |
Server returns 204 No Content | Successfully deleted |
| |
AMQP
AMQP stands for Advanced Message Queuing Protocol. It’s an open standard protocol for message-oriented middleware that enables the exchange of messages between systems or devices in a reliable, secure, and interoperable way.
Key Characteristics of AMQP:
Message-oriented: Focuses on sending messages (data packets) between producer and consumer.
Reliable delivery: Guarantees message delivery through acknowledgments and transactions.
Flexible routing: Supports complex routing logic like pub/sub, direct, topic, and fanout exchanges.
Interoperable: Works across different platforms and languages.
Open standard: Defined by the OASIS group.
How does AMQP work?
AMQP defines:
Messages — packets of data with properties and body.
Producers — entities that send messages.
Queues — where messages are stored.
Consumers — entities that receive messages.
Exchanges — route messages to queues based on rules (bindings).
AMQP in IoT?
AMQP is widely used in enterprise messaging but also has applications in IoT, especially in:
Industrial IoT (IIoT) scenarios where reliability and complex routing are important.
Systems requiring transactional messaging.
Environments where devices or gateways are resource-rich (not low-power sensors).
Cases needing interoperability across diverse platforms.
AMQP vs MQTT for IoT
Feature | AMQP | MQTT |
Protocol type | Advanced, binary, with many features | Lightweight, publish-subscribe |
Complexity | High — supports queues, transactions | Low — simple pub/sub model |
Overhead | Higher | Very low |
QoS | Very strong (acknowledgments, transactions) | Supports QoS levels (0,1,2) |
Use cases | Enterprise messaging, complex routing | IoT sensor telemetry, constrained devices |
Broker support | RabbitMQ, Apache Qpid, ActiveMQ | Mosquitto, EMQX, HiveMQ |
AMQP Architecture (Example)
Producer: An IoT device or gateway publishes sensor data as AMQP messages.
Exchange: Routes messages to different queues based on rules.
Queue: Stores messages until consumed.
Consumer: Backend services or databases consume the data.
Why use AMQP in IoT?
When you need complex routing (e.g., route sensor data based on type or priority).
If you want transactional guarantees on message delivery.
When devices/gateways have sufficient resources.
In enterprise IoT, where AMQP brokers integrate with existing systems.
Example of AMQP use in IoT:
Imagine an industrial plant with multiple sensors:
Temperature sensors send data.
Humidity sensors send data.
Alerts and commands are routed to specific systems.
AMQP exchanges can route temperature data to one queue and alerts to another, ensuring reliable and organized messaging.