1 of 132

IOT Protocols

2 of 132

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

3 of 132

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

4 of 132

What is the Link Layer?

  • It’s responsible for node-to-node data transfer.�
  • It handles framing, error detection, medium access control (MAC), and sometimes addressing.�
  • In IoT, link layer protocols are often designed for low power, low data rates, and short/long range communication.

5 of 132

1. IEEE 802.15.4

  • Foundation for many IoT wireless standards.�
  • Operates at 2.4 GHz, 915 MHz, and 868 MHz.�
  • Low data rates (~250 kbps at 2.4 GHz).�
  • Used by Zigbee, Thread, and 6LoWPAN( Low-Rate Wireless Personal Area Networks)�
  • Supports star and mesh topologies.�
  • Designed for low power, low complexity devices.�

6 of 132

2. Zigbee

  • Built on top of IEEE 802.15.4.�
  • Mesh networking capability.�
  • Focus on low-power, low-data-rate sensor and control devices.�
  • Popular for home automation and industrial IoT.�

7 of 132

3. Bluetooth Low Energy (BLE)

  • Operates at 2.4 GHz.�
  • Designed for very low power consumption.�
  • Data rates up to 2 Mbps (Bluetooth 5).�
  • Used in wearables, health monitoring, proximity sensors.�
  • Supports star topology and mesh networking (Bluetooth Mesh).

8 of 132

4. Wi-Fi (IEEE 802.11 variants)

  • Operates in 2.4 GHz and 5 GHz bands.�
  • Higher power consumption and data rates (up to several hundred Mbps).�
  • Used for IoT devices requiring high bandwidth.�
  • Newer standards like Wi-Fi HaLow (802.11ah) are designed for IoT:�
    • Operates sub-1 GHz.�
    • Longer range, lower power.�
    • Data rates around 150 kbps to several Mbps.�

9 of 132

5. LoRaWAN (Link Layer aspects)

  • Long Range (LoRa) operates at sub-GHz frequencies.�
  • Provides long-range communication (kilometers).�
  • Very low data rates (0.3 kbps to 50 kbps).�
  • Uses a proprietary physical layer but defines MAC layer for IoT.�
  • Designed for battery-operated devices needing wide area coverage.

10 of 132

6. NB-IoT (Narrowband IoT)

  • Cellular LPWAN technology standardized by 3GPP.�
  • Operates over licensed LTE spectrum.�
  • Supports link layer with reliable MAC.�
  • Suitable for massive IoT deployments with deep coverage and low power.

11 of 132

7. 6LoWPAN

  • IPv6 over Low power Wireless Personal Area Networks.�
  • Adapts IPv6 packets to IEEE 802.15.4 frames.�
  • Enables IP connectivity for low-power wireless networks.

12 of 132

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

13 of 132

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

14 of 132

15 of 132

Wi-Fi (IEEE 802.11 Variants) for IoT

16 of 132

1. Overview of Wi-Fi

  • • Family of wireless communication standards (IEEE 802.11)
  • • Operates mainly in 2.4 GHz, 5 GHz, and newer 6 GHz bands
  • • Originally designed for high-speed data (internet, video)
  • • Increasingly adapted for IoT needing higher bandwidth

17 of 132

2. Common IEEE 802.11 Variants

  • 802.11b (1999) – 11 Mbps, 2.4 GHz, 35-100m
  • 802.11g (2003) – 54 Mbps, 2.4 GHz, 35-100m
  • 802.11n (2009) – Up to 600 Mbps, dual-band, 70-250m
  • 802.11ac (2013) – Up to 6.9 Gbps, 5 GHz, beamforming
  • 802.11ax (2019) – Up to 9.6 Gbps, 2.4/5 GHz, IoT-friendly (OFDMA, MU-MIMO)

18 of 132

3. Wi-Fi for IoT — Challenges & Adaptations

  • Challenges:
  • • Power consumption
  • • Range limitations
  • • Stack complexity
  • • Module cost

  • Adaptations:
  • • Power Save Mode (PSM)
  • • Wi-Fi HaLow (802.11ah)
  • • Cloud-friendly IP integration

19 of 132

4. Wi-Fi HaLow (802.11ah)

  • • Sub-1 GHz (around 900 MHz)
  • • Range up to 1 km+
  • • Data Rate: 150 kbps – 347 Mbps
  • • Lower power, star topology
  • • Apps: Smart agri, cities, industry
  • • Benefits: Penetration, long battery, dense deployments

20 of 132

5. Use Cases of Wi-Fi in IoT

  • • Smart home: cameras, speakers, appliances
  • • Security systems: IP cameras, sensors
  • • Industrial IoT: high-data sensors, monitoring
  • • Healthcare: patient monitoring
  • • Smart city: public Wi-Fi sensors, traffic

21 of 132

6. Advantages of Wi-Fi in IoT

  • • High bandwidth
  • • Ubiquitous infrastructure
  • • IP-based networking
  • • Mature security protocols (WPA3)
  • • Supports many devices (latest standards)

22 of 132

7. Disadvantages of Wi-Fi in IoT

  • • Higher power consumption
  • • Limited range (except HaLow)
  • • Congested 2.4 GHz band
  • • Higher hardware cost for sensors

23 of 132

8. Security Considerations

  • • Use WPA3 encryption
  • • Device authentication & secure onboarding
  • • Firmware updates
  • • VPNs or secure tunnels for sensitive data

24 of 132

9. Example Wi-Fi IoT Communication Flow

  • 1. Device powers on → connects to AP
  • 2. Authentication (WPA2/WPA3)
  • 3. DHCP → gets IP
  • 4. Data exchange (sensor/commands)
  • 5. Power save mode (idle)

25 of 132

10. Future Trends

  • • Wi-Fi 6 & Wi-Fi 7 → more IoT support
  • • AI & edge computing integration
  • • Growing adoption of Wi-Fi HaLow
  • • Security & privacy improvements

26 of 132

Messaging Protocols

27 of 132

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.

28 of 132

🔌 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

29 of 132

📡 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)

30 of 132

🧭 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)

31 of 132

🛠️ Example: IoT Device Using WebSocket

Let’s say you have a smart thermostat that sends temperature updates to a dashboard in real time.

  1. Thermostat connects to a WebSocket server.�
  2. Sends { "temp": 26.3 } every few seconds.�
  3. The dashboard receives updates instantly without polling.�

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);

});

32 of 132

🧩 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)

33 of 132

🧠 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

34 of 132

Messaging Protocols in IoT

  • Messaging protocols are very important for the transfer of data in terms of messages.
  • They are useful for send/receive of a message to/from the cloud in IoT applications.
  • In the section, two messaging protocols are discussed.
  • Message Queuing Telemetry Transport (MQTT)
  • Constrained Application Protocol (CoAP)

35 of 132

Message Queuing Telemetry Transport (MQTT)

  • As we know, IoT has one of the biggest challenges of resource constraints, the lightweight protocol is more preferred.
  • MQTT is widely used in IoT applications as it is a lightweight protocol.
  • Here, lightweight means, it can work with minimal resources and does not require any specific hardware architecture or additional resources.

36 of 132

MQTT

  • MQTT works with “publish – subscribe” pattern.
  • The MQTT working can be explained as follows.
  • The publisher (node) sends a message to the MQTT broker.
  • The MQTT broker transmits the message to the subscribed destinations.

Subscriber

MQTT Broker

Publisher

Subscriber

37 of 132

MQTT - Example

  • Suppose a temperature sensor is connected to any system and we want to monitor that temperature.
  • The controller connected to the temperature sensor publishes the temperature value to the MQTT broker with a topic name: “Temperature”. Hence, it is considered a publisher.
  • The MQTT broker transmits the temperature value to the subscribers.

Subscriber 1

Publisher

MQTT Broker

Subscribed to:

“Temperature”

Subscribed to:

“Temperature”

  • Note that the only nodes which have subscribed to the topic will capture the data and not the other nodes.

Subscriber 2

Subscriber 3

38 of 132

MQTT - Example

  • Can publisher and subscriber interchange their role?
  • Let us take an example of a Driverless car.
  • A GPS sensor is connected to the car which gives the current location of the car.
  • The system in car, publishes the location to MQTT broker with topic name – CurrentLocation.
  • The server/computer subscribes to the topic CurrentLocation and receives the current location of the car.

MQTT Broker

Subscriber: CurrentLocation

Publisher: CurrentLocation

39 of 132

MQTT - Example

  • Based on the currently selected destination, the server/computer computes the direction of the car.
  • This data is published to an MQTT broker with a topic named – Direction.
  • To get the command from the server, the system in the car has to subscribe to the topic named Direction.
  • According to the command received from the server, the car will run in a particular direction.

Publisher: Direction

Publisher: CurrentLocation

MQTT Broker

Subscriber: CurrentLocation

Subscriber: Direction

40 of 132

MQTT - Working -Video

  • In MQTT, clients do not have any address like a typical networking scheme.
  • The broker filters the messages based on the subscribed topics.
  • The messages will then be circulated to respective subscribers.
  • The topic name can be anything in string format.
  • The MQTT working can be explained with an example of the television broadcast.

Client_Address

41 of 132

MQTT - Working

  • Television broadcaster station broadcasts all the channels.
  • The viewers subscribe to their favorite channels only.
  • Similarly, in MQTT, the publisher node publishes data with the topic name and interested subscribers subscribe to the topic.
  • Note that there can be multiple subscribers of a same topic as well as a single subscriber can subscribe to multiple topics.

42 of 132

MQTT – Node(s)

  • Node(s) in MQTT collects the information from sensors or other i/p devices in case of the publisher.
  • Connects it to the messaging server known as the MQTT broker.
  • A specific string – Topic is used to publish the message and let other nodes understand the information. These nodes are considered subscribers.
  • Any node can be publisher or subscriber and node is also referred to as client.

Publisher

Subscriber

MQTT

Broker

Topic:SensData

43 of 132

QoS in MQTT

  • MQTT supports different QoS (Quality of Service) levels.
  • There are 3 layers of QoS supported by MQTT.
  • Level 0 = At most once (Best effort, No Acknowledgement)
  • Level 1 = At least once (Acknowledged, retransmitted if ack not received)
  • Level 2 = Exactly once (Requested to send, clear to send)

44 of 132

MQTT Publisher – Code Implementation

  • The code for MQTT publisher is as shown in below.

#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.

45 of 132

MQTT Publisher – Code Implementation

void setup_wifi() {

  delay(10);

  Serial.println();

  Serial.print("Connecting to ");

  Serial.println(ssid);

  WiFi.mode(WIFI_STA);

  WiFi.begin(ssidpwd);

�  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.

46 of 132

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.

47 of 132

MQTT Publisher – Code Implementation

void loop() {

�  client.loop();

  unsigned long now = millis();

  if (now - lastMsg > 2000)

{

    lastMsg = now;

    ++value;

    snprintf (msgMSG_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

48 of 132

MQTT Subscriber – Code Implementation

  • The code for MQTT subscriber is as shown in below.

#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.

49 of 132

MQTT Subscriber – Code Implementation

void setup_wifi() {

  delay(10);

  Serial.println();

  Serial.print("Connecting to ");

  Serial.println(ssid);

  WiFi.mode(WIFI_STA);

  WiFi.begin(ssidpwd);

�  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.

50 of 132

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 = 0i < 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.

51 of 132

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”

52 of 132

Constrained Application Protocol (CoAP)

  • CoAP is designed by IETF (Internet Engineer Task Force) to work in constrained environment.
  • It is a one to one communication protocol.
  • CoAP is also light weight like MQTT protocol and it uses less resources than HTTP.
  • HTTP runs over TCP and is connection oriented while CoAP runs over UDP and it is connection less.

53 of 132

CoAP Architecture

  • CoAP is based on the RESTful architecture (Representational State Transfer).
  • REST approach ensures the secure, fault tolerant and scalable system.
  • The CoAP optimizes the length of the datagram.
  • CoAP is connectionless protocol and it requires retransmission support.

54 of 132

CoAP Layers

  • CoAP has four layers:
  • UDP
  • Messages
  • Request-Response
  • Application
  • The message layer is designed to deal with UDP and asynchronous switching.
  • The request/response layer concerns communication method and deal with request/response messages.
  • In the request/response layer, clients may use GET/PUT/DELET methods to transmit the message.

UDP

Messages

Request/Response

Application

55 of 132

Message Layer in CoAP

  • CoAP message layer supports four types of messages:
  • Confirmable – Reliable Messaging (CON):
    • This is reliable approach because the retransmission of message occurs until the acknowledgement of the same message ID is received.
    • If there is a timeout or fail of acknowledgement, the RST message will be sent from the server as a response.
    • Hence, the client will retransmit the message, this resolves the retransmission and it is considered a reliable approach.

Client

Server

CON (ADDR)

56 of 132

Message Layer in CoAP (Contd.)

  1. Non-confirmable – Non-reliable Messaging (NON):
    • In this message transmission style, there is no reliability is ensured.
    • The acknowledgement is not issued by the server.
    • The message has ID for supervision purpose, if the message is not processed by the server it transmits the RST message.

Client

Server

NON [Message ID]

57 of 132

Message Layer in CoAP (Contd.)

  1. Acknowledgement (ACK):
    • In this messaging, the traditional acknowledgement message sent as usual protocol.
    • We can compare this with regular handshaking scheme.
    • The handshake is automated process that establishes a link for communication before actual data transfer begins.

Client

Server

CON (ADDR)

ACK (ADDR)

58 of 132

Message Layer in CoAP (Contd.)

  1. Reset (RST):
    • The receiver is expecting the message from sender of a particular message ID.
    • If no message is processed or received before specific amount of time (called timeout), the message called RESET is transmitted from receiver.
    • This message informs the sender that there is a trouble in transmission of messages.

Client

Server

CON (ADDR)

Timeout

RST

59 of 132

Request-Response Layer in CoAP

  • There are three modes in CoAP request-response layer.
  • Piggy-Backed:
    • In this mode, the client sends the data with particular method (GET, PUT etc.) with token number and CON messaging method.
    • The ACK is transmitted by server immediately with corresponding token number and message.
    • If the message is not received by server or data is not available then the failure code is embedded in ACK.

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

60 of 132

Request-Response Layer in CoAP (Contd.)

  1. Separate Response:
    • In this mode, the client sends the data with particular method (GET, PUT etc.) with token number and CON messaging method.
    • If the server is unable to respond immediately, an empty ACK will be reverted.
    • After some time, when the server is able to send the response, it sends a CON message with data.
    • In response to that, ACK is sent back from client to server.

Client

Server

CON (ADDR)

GET/Humidity

(Token Number)

ACK

ACK

CON (ADDR)

(Token Number)

60%

.

.

.

.

61 of 132

Request-Response Layer in CoAP (Contd.)

  1. Non-Confirmable Request and Response:
    • In this mode, the client sends the data with particular method (GET, PUT etc.) with token number and NON messaging method.
    • The server does not give ACK in NON messaging method, so it will send a NON type response in return with token number and its data.

Client

Server

NON (Message ID)

GET/Humidity

(Token Number)

NON (Message ID)

(Token Number)

72%

62 of 132

CoAP Message Format

  • The CoAP message format is of 16 Bytes consisting various fields.
  • V : It refers to version of CoAP. It is two bit unsigned integer.
  • T : It refers to message type. It is also two bit unsigned integer.
    • Confirmable (0)
    • Non-Confirmable (1)
    • ACK (2)
    • RESET (3)
  • TKL : It refers to the token length and is four bit unsigned integer.
  • Code: It refers to the response code.

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)

63 of 132

CoAP Message Format (Contd.)

  • Message ID: It is identifier of the message and to avoid duplication.
  • Token : Optional field whose size is indicated by the Token Length field.
  • Options : This field is used if any options available and having length of 4 Bytes.
  • Payload : This field refers to the payload data where actual data is transmitted.

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

64 of 132

XMPP Protocol

  • The full form of XMPP is Extensible Messaging and Presence Protocol.
  • It is designed for messaging, chat, video, voice calls and collaboration.
  • The fundamental base of this protocol is XML and it is used for messaging services such as WhatsApp.
  • The XMPP was originally named as Jabber and later known as XMPP.

65 of 132

XMPP denotation

  • The denotation for XMPP can be given as following:
  • X – X denotes eXtensible.
    • It is considered extensible as it is designed to accept and accommodate any changes.
    • The protocol is defined in open standard and it is extensible because of open standard approach.
  • M – M denotes Messaging.
    • XMPP supports sending message to the recipients in real time.
  • P – P denotes Presence.
    • It is helpful to identify the status such as “Offline” or “Online” or “Busy”.
    • It also helps in understanding if the recipient is ready to receive the message or not.
  • P – P denotes Protocol.
    • The set of standards together acting as a protocol.

66 of 132

Messenger Requirements

  • Any messenger requires the following features inbuilt :
  • Message sending and receiving features.
  • Understanding the presence/absence status.
  • Managing subscription details.
  • Maintaining the contact list.
  • Message blocking services.
  • Note that all the listed features are built in XMPP.

67 of 132

XMPP Architecture

  • The architecture of XMPP protocol is shown in the figure :
  • The XMPP clients communicate with XMPP server bidirectional.
  • There can be any numbers of clients connected to XMPP server.
  • The XMPP servers may be connected to the other clients or other XMPP servers.

XMPP

Client

XMPP

Client

XMPP

Client

XMPP

Server

XMPP

Server

XMPP

Client

XMPP

Client

XMPP

Client

68 of 132

XMPP Architecture (Contd.)

  • The initial version of the XMPP was with TCP using open ended XML.
  • After certain period of time, the XMPP was developed based on HTTP.
  • The XMPP can work with HTTP is through two different methods Polling and Binding.
  • What is Polling and Binding?

XMPP

Client

XMPP

Client

XMPP

Client

XMPP

Server

XMPP

Server

XMPP

Client

XMPP

Client

XMPP

Client

69 of 132

XMPP Architecture (Contd.)

  • In polling method, the messages stored in the server are pulled or fetched.
  • The fetching is done by XMPP client through HTTP GET and POST requests.
  • In binding method, Bidirectional-streams Over Synchronous HTTP (BOSH) enables the server to push the messages to the clients when they are sent.

  • The binding approach is more effective than polling.
  • Also both method uses HTTP, hence the firewall allows the fetch and post activity without any difficulties.

70 of 132

Data Distribution Service (DDS)

  • Data Distribution Service (DDS) is one of the protocol being used in the Internet of Things (IoT) applications.
  • DDS is brokerless service and the protocol was developed by the Object Management Group (OMG).
  • The purpose behind development of DDS is to get better machine to machine communication.
  • Like MQTT, DDS is also using publish-subscribe approach.

71 of 132

DDS Architecture

  • DDS is basically a publish – subscribe model based architecture.
  • Everything including sending and receiving data, event updates, command within and among the nodes are all accomplished through the publish – subscribe approach.
  • The publisher sends the data to DDS cloud with particular Topic.
  • The interested nodes (Subscribers) subscribes the particular Topic and receives data from DDS Cloud.

Data Distribution Service

(DDS)

Publisher

Publisher

Publisher

Subscriber

Subscriber

Subscriber

72 of 132

DDS Architecture (Contd.)

  • Here, DDS Cloud has to handle all the attributes of data transfer like addressing, marshalling data, control of delivery, control of flow, etc.
  • The marshalling of data means to convert any data or objects into a byte-stream, while unmarshalling is exactly the reverse process.
  • This enables the communication between publisher and subscriber working on multiple different platforms.

Data Distribution Service

(DDS)

Publisher

Publisher

Publisher

Subscriber

Subscriber

Subscriber

73 of 132

74 of 132

Transport Protocols

Section - 2

75 of 132

Bluetooth 4.0 (BLE)

  • BLE – Bluetooth Low Energy
  • BLE is open low energy short range radio communication technology.
  • The BLE is also known as Bluetooth Smart.
  • This protocol is designed by Bluetooth Special Interest Group (SIG).
  • BLE also works same al Bluetooth in wireless Personal Area Network (PAN).
  • It can be considered the advanced version of Bluetooth.

76 of 132

Bluetooth 4.0 (BLE) (Cont.)

  • BLE is superior to classic Bluetooth because of following reasons:
    • It is power saving.
    • It is supported by Android, IOS, Blackberry, etc.
    • It is also supported by computer OS like Windows 8/10, MAC-OS, and Linux variants.
  • Because of certain advantages of BLE over classic Bluetooth, it is widely used in the areas like:
    • Healthcare
    • Entertainment
    • Fitness (in form of wearable devices)
    • Proximity related applications
    • Tracking devices

77 of 132

Features of BLE

  • The key features of BLE are as following:
  • It is licence free and does not add any overhead costing.
  • There is no restrictions to Manufacturer.
  • BLE modules are inexpensive and affordable.
  • The size of BLE modules are small. So it can be accommodated in any system easily.
  • The power consumption for BLE modules is very less and hence suitable for IoT applications.
  • The range of BLE has very high range compared to classic Bluetooth.

78 of 132

BLE Architecture

  • The BLE architecture has three components.
  • Application Block
    • The user application is accommodated in this block.
    • It interacts directly with Bluetooth stack.
  • Host Block
    • It is upper layer of the Bluetooth stack.
  • Controller Block
    • It is lower layer of the Bluetooth stack.

Application

Host

Controller

BLE

79 of 132

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

80 of 132

BLE Architecture

  1. Controller : It has three components.
    1. Host Controller Interface (HCI) : is used to enable interoperability between hosts and controllers assembled by different manufacturers
    2. Link Layer (LL) : It defines the packet structure
    3. Physical Layer (PHY) : It takes care of the transmission/reception, modulation/demodulation and analog-to-digital conversion.

Link Layer (LL)

Physical Layer (PHY)

--------------------------------------Host Controller Interface --------------------------------------

(HCI)

Controller

81 of 132

BLE Architecture

  1. Host : It has following components with functionalities
    1. Generic Access Profile (GAP) : It takes care of the device discovery, connection establishment, connection management and security.
    2. Generic Attribute Profile (GATT) : It is responsible for the data exchange process. Whenever there is a need to push data and to read or write data, the generic guidelines with respect to the process are governed by GATT.
    3. Attribute Protocol (ATT) : It is the protocol for accessing data.

Generic Access Profile

(GAP)

Generic Attribute Profile

(GATT)

Attribute Protocol

(ATT)

Logical Link Control and Adaptation Protocol

(L2CAP)

Security Management Protocol

(SMP)

Host

82 of 132

BLE Architecture

  1. Host : It has following components with functionalities
    1. Logical Link Control and Adaptation Protocol (L2CAP) : It is responsible for fragmentation and de-fragmentation of the application data. Also, it is responsible for the multiplexing and de-multiplexing of channels over the shared logical link.
    2. Security Manager (SM) : It takes care of pairing, authentication, and encryption. Everything related to security is taken care here.
    3. Host Controller Interface (HCI) : The functionality remains the same as that in the controller. It is used to enable interoperability between hosts and controllers assembled by different manufacturers.

Generic Access Profile

(GAP)

Generic Attribute Profile

(GATT)

Attribute Protocol

(ATT)

Logical Link Control and Adaptation Protocol

(L2CAP)

Security Management Protocol

(SMP)

Host

83 of 132

BLE Architecture

  1. Application Layer :
    • The working of application layer in BLE is same as in OSI model. It is the top most layer in BLE and this layer is responsible for user interface (UI), logic and data handling.

Application

Application

84 of 132

BLE Topology

  • Broadcasting
    • The meaning of broadcasting is to send a message to more than one recipient. The same concept is followed in BLE.
    • The broadcast method will send the data in “one way” only.

Bluetooth

Broadcaster

Observer

Observer

Observer

Observer

Observer

Observer

    • The receiver in the vicinity of the broadcaster will receive the message or data.
    • There are two parts in broadcasting topology. Broadcaster and Observer.

85 of 132

BLE Topology

  • Broadcasting
    • Broadcaster : The broadcaster sends a "non-connectable" advertising packets in frequent intervals to all those who are willing to collect which is similar to a radio broadcast.
    • Observer : The observer will keep scanning predefined frequency to receive any non-connectable packets..

Bluetooth

Broadcaster

Observer

Observer

Observer

Observer

Observer

Observer

86 of 132

BLE Topology

  • Connections
    • The connections topology works on the concept of master-slave configuration.
    • The master will try to find out the connectable advertising packets. Once the advertisement is found, it will initiate the connection to the slave.

Master

Slave

(Peripheral)

Slave

(Peripheral)

Slave

(Peripheral)

Slave

(Peripheral)

Slave

(Peripheral)

Slave

(Peripheral)

    • The master will take care of periodic data exchange.
    • The slave(s) continuously sends the connectable advertising packets at regular interval.

87 of 132

BLE Topology

  • Connections
    • Once the slave is connected, the event is called connection event.
    • In this topology, the device will work whenever required. For the remaining time the device is in sleep mode.
    • This provides power saving during the communication.

Master

Slave

(Peripheral)

Slave

(Peripheral)

Slave

(Peripheral)

Slave

(Peripheral)

Slave

(Peripheral)

Slave

(Peripheral)

    • However, during the sleep mode also the connection remains present.
    • But the data will be transferred after the device invokes.

88 of 132

Light Fidelity (Li-Fi)

  • The Li-Fi is fastest communication protocol right now among all existing protocols.
  • The symbol of Li-Fi is as shown in the figure.
  • It gives the following solutions to the problems which one can face during the use of the Wi-Fi.
    • More security than Wi-Fi.
    • More available bandwidth to the connected devices or equipments.
    • Less/No congestion when more number of devices connected.
  • Note that the Li-Fi has phenomenal speed of 224GBps which is fastest among all.

89 of 132

Li-Fi Working

  • The server wants to transmit the data to the receiver with very high speed. The server is either connected to internet or intranet.

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

  • The server connected to the internet generates a data which is converted into streaming content.
  • The streaming content is given to Lamp driver which is powered by external source.

90 of 132

Li-Fi Working

  • The LED lamp is turned on and off at very high speed that human eyes can not capture it.

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

  • The light is received by the photo detector and it is passed for demodulation process and amplification to generate the data stream sent by transmitter.
  • The received data stream is further given to receiver (e.g. mobile, PC etc.) via receiver app. All components working for receiving the data combined known as receiver dongle.

91 of 132

Li-Fi – Advantages & Disadvantages

  • Advantages
    • Li-Fi is extremely secure as the light can not penetrate through walls and no data hijacking is possible.
    • Li-Fi is fastest and effective.
    • It is an effective alternate to RF communication.
    • It is inexpensive as the light is generated through LED lamps.

  • Disadvantages
    • It can be implemented in short range as the presence of walls or any other object will become the interruption in communication.
    • The required time for set up is higher.
    • There is no clarity of bidirectional communication means how to send data from mobile or PC back to server.

92 of 132

Addressing & Identification Protocols

Section - 3

93 of 132

Internet Protocol Version 4 (IPv4)

  • IP addresses are useful in identifying a specific host in a network.
  • IP addresses are 32 bit numbers which are divided into 4 octets. Each octet represents 8 bit binary number.
  • Below is an example of an IP address:

10101100

00010000

11111110

00000001

172

16

254

1

IP addresses are divided into 2 parts:

Network ID & Host ID

<NID> <HID> = IP Address

94 of 132

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

95 of 132

Class A

  • Only 126 addresses are used for network address.
  • All 0’s and 1’s in Network-ID are dedicated for special IP address. So, total number of IP address in class A can be represented as following.
  • The range of Class A is 0.0.0.0 to 127.255.255.255

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

96 of 132

Class B

  • No special network address here. All are usable.
  • The total number of hosts connected in network can be given as following:
  • It is used in medium size network.
  • The range of Class B is 128.0.0.0 to 191.255.255.255

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

97 of 132

Class C

  • This class is used in small networks.
  • The calculation for number of hosts can be given as following:
  • Normally, the LANs are configured with Class C.
  • The range for Class C is given as 192.0.0.0 to 223.255.255.255

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

98 of 132

Class D

  • Very first four bits of the first octet in Class D IP addresses are set to 1110, giving a range of:

  • Class D has IP address rage from 224.0.0.0 to 239.255.255.255.
  • Class D is reserved for Multicasting.
  • In multicasting data is not destined for a particular host, that is why there is no need to extract host address from the IP address, and Class D does not have any subnet mask.

11100000 – 11101111

224 – 239

99 of 132

Class E

  • This IP Class is reserved for experimental purposes only for R&D or Study.
  • IP addresses in this class ranges from 240.0.0.0 to 255.255.255.254.
  • Like Class D, this class too is not equipped with any subnet mask.

100 of 132

IPv4 Format

  • Figure shows the format for IPv4.
  • VER (Version):
    • It is a 4 bits field which indicates the version of IP.
  • IHL (Internet Header Length):
    • It specifies the Internet Header Length in 32 bits word length and points the beginning of data.
  • Types of Service:
    • It is a 8 bit field which specifies the Quality of Service (QoS). The format for these 8 bits are given here.

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)

101 of 132

IPv4 Format

  • Types of Service:
    • Precedence (3) : They are used for future options.
    • Delay (1): It indicates the delay of either normal or lower.
    • Throughput (1): Indicates the speed of throughput of either normal or higher rate.
    • Reliability (1): It indicates normal reliability or high reliability.

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

102 of 132

IPv4 Format

  • Total Length:
    • This is a 16 bit field defining the length of IPv4 datagram. The minimum length of datagram is 20 bytes and maximum is 65535.
  • Identification:
    • This field is of 16 bits which helps in assembling the fragments and added by the senders.
  • Flags:
    • There are3 bits in flags. First is always ‘1’. Second is DF (Don’t Fragment) and third is MF (More Fragment).

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)

103 of 132

IPv4 Format

  • Fragment Offset:
    • When fragmentation is done, this specifies the offset or position of overall message.
  • Time to Live:
    • This is 8 bit field that indicates the time period of datagram to survive.
  • Protocol:
    • This field identifies the protocol for higher layer in the IP datagram.

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)

104 of 132

IPv4 Format

  • Header Checksum:
    • It is 16 bit field to provide basic protection in transmission of header via checksum.
  • Source Address:
    • This is 32 bit IP address of the source of the datagram.
  • Destination Address:
    • This is 32 bit IP address of the destination of the datagram.
  • Options:
    • There are many optional header available for debug and test purpose.

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)

105 of 132

IPv6 Addressing

  •  

106 of 132

Features of IPv6 Addressing

  • It has better and efficient routing than IPv4.
  • The additional flow label is added in header of IPv6 for improvement in QoS.
  • IPv6 has new application like IP telephony, video/audio, interactive games etc. with ensured QoS.
  • The plug and play abilities have been improved in IPv6.
  • IPv6 has eliminated the need of Network Address Translation due to the huge availability of IP addresses.

107 of 132

IPv6 Header Format

  • IPv6 header format has less fields than IPv4 header format.
  • IPv6 header is 40 bytes which is twice than IPv4 header.
  • The figure shows IPv6 header format.
  • The IPv6 has simple packet handling and improved forwarding efficiency.
  • The fields of IPv6 header can be explained as following:

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)

108 of 132

IPv6 Header Format

  • IP version :
    • It is 4 bit field to represent the IP version being used.
  • Traffic Class :
    • It is 8 bit field to identify the different classes or priorities of IPv6 packets.
    • It replaces the type of services in IPv4.
    • Upper 6 bits are used for type of services lower 2 bits are used for Explicit Congestion Notification.
  • Flow Label :
    • It is 20 bit field used to identify the sequence of packets.
    • It is also useful for prioritizing the delivery of packet and providing real time service.
    • The higher priority packets can be delivered ahead of lower priority packets.

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)

109 of 132

IPv6 Header Format

  • Payload Length :
    • It is a 16 bit field which identifies the length of payload of IPv6.
  • Next Header :
    • It is a 8 bit field which is similar to protocol field in IPv4 header.
    • It represents the type of extension header that follows the primary IPv6 header.
  • Hop Limit :
    • It is 8 bit field equivalent to Time to Live in IPv4 Header.
    • The value is decremented by 1 every time when it is forwarded by the host.
    • When this value reaches 0, the packet is discarded.

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)

110 of 132

IPv6 Header Format

  • Source Address :
    • It represents the 128 bit IP address of source or sender.
  • Destination Address :
    • It represents the 128 bit IP address of destination or receiver.

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)

111 of 132

Uniform Resource Identifier (URI)

  • Uniform Resource Identifier (URI) is used to identify the resources with the help of sequence of characters.
  • The URI protocol was developed by IETF.
  • The URI can be URL or URN.
  • The sample for URL and URN can be as following:

  • URN mostly provides information of unique name without locating or retrieving the resource information.
  • URL provides locating and retrieving information on a network.

Universal Resource Name (URN)

E.g.: ISBN:0451450523

Universal Resource Identifier (URI)

Universal Resource Locator (URL)

E.g.: https://darshan.ac.in/ce/material

112 of 132

Uniform Resource Locator (URL)

  • The URL contains the information of how to fetch a resource information from its location.
  • URL always begin with a protocol like HTTP/HTTPS
  • A URL is used when client request the server for the service.
  • The sample URL and its fields are explained below:

http://www.darshan.ac.in/CE/Study-material/IoT/Syllabus.html

HTTP Protocol

World Wide Web

Domain Name

Path

File name

113 of 132

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.

114 of 132

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.

115 of 132

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/....

116 of 132

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).

117 of 132

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.

118 of 132

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.

119 of 132

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.

120 of 132

7. Caching

Use HTTP caching headers (Cache-Control, ETag, Last-Modified) to improve performance.

Decide which resources can be cached and for how long.

121 of 132

8. Testing & Documentation

Document APIs clearly (Swagger/OpenAPI, Postman).

Test endpoints thoroughly (unit tests, integration tests).

Monitor usage and performance.

122 of 132

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

123 of 132

124 of 132

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.

125 of 132

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.

126 of 132

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).

127 of 132

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.

128 of 132

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

129 of 132

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.

130 of 132

131 of 132

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.

132 of 132

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.