0% found this document useful (0 votes)
16 views198 pages

IoT Class U1 U3 Premid

The document provides a comprehensive overview of the Internet of Things (IoT), including its definition, historical context, benefits, and key components. It discusses the evolution of IoT, its conceptual frameworks, and various technologies involved, such as embedded systems and communication protocols. Additionally, it contrasts IoT with Wireless Sensor Networks (WSN) and outlines major IoT architectures and developmental platforms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views198 pages

IoT Class U1 U3 Premid

The document provides a comprehensive overview of the Internet of Things (IoT), including its definition, historical context, benefits, and key components. It discusses the evolution of IoT, its conceptual frameworks, and various technologies involved, such as embedded systems and communication protocols. Additionally, it contrasts IoT with Wireless Sensor Networks (WSN) and outlines major IoT architectures and developmental platforms.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 198

Internet of

Things
Reference books:
[1]. Raj Kamal, “Internet of Things: Architecture and Design Principles”,
McGraw Hill
Textbook References:
[1] Internet of Things: Principles and paradigms, Edited by Rajkumar Buyya and
Amir Dastjerdi , Morgan Kaufmann
[2] Precision - Internet of Things Author: Timothy Chou ISBN: 9789352605385
[3] Designing the Internet of Things, Adrian McEwen and Hakim Cassimally,
Wiley.
Who introduced the term IoT?
The term "Internet of things" was likely coined by Kevin Ashton of Procter
& Gamble, later MIT's Auto-ID Center, in 1999.

He played a pivotal role in conceptualizing the vision of an interconnected


world of smart devices through his early work.

Definition of IoT as per Kevin Ashton:


It meant using the Internet to empower computers to sense the world for
themselves it still does.
What is IoT?
 Internet of Things (IoT) is the network of smart physical objects
 physical objects (e.g. devices, vehicles, buildings, etc.) embedded with sensors/actuators,
computation unit, memory unit, power source, and network connectivity,
 which enables the physical object to collect and exchange data,
 analyze the collected data to extract new insight and respond accordingly.

 Goal of IoT is to “connect the unconnected”


 “Things” or “objects” that were not supposed to be connected to the Internet

 IoT did the technology transition in traditional computer networks


Cont…
• Unifications of technologies:
• Embedded systems,
• Low power and low rate network,
• Internet,
• Big data,
• Data analytics,
• Cloud computing,
• Edge Intelligence
• Software defined networks,
• Network and data security
• Etc.

• Alternate Definition:
“The Internet of Things (IoT) is the network of physical objects that contain embedded
technology to communicate and sense or interact with their internal states or the external
environment.” – Gartner Research*
* https://www.gartner.com/en/information-technology/glossary/internet-of-things
Brief History of IoT
 Early 1980s at the Carnegie Melon University, a group of students created a way
to get their campus Coca-Cola vending machine to report on its contents
through a network in order to save them the track if the machine was out of
Coke.
 In 1990, John Romkey, developer of the first TCP/IP stack for IBM PC in 1983,
connected a toaster to the internet for the first time.
 In 1991, a group of students at the University of Cambridge used a web camera
to report on coffee available in their computer labs coffee pot.
 At the beginning of the 21st Century, LG Electronics introduced the
world’s first refrigerator connected to the internet

7
Cont…
 The popularity of the term IoT did not accelerate until 2010/2011 and reached mass
market in 2013-14.

 Definition of the IoT has evolved over time.


2010 onwards
Post 1993
1990 Early 2000

Evolutionary Phases of the Internet


Benefits of IoT
•Automation
• Machines can assemble parts with more precision and speed, resulting in fewer errors
during assembly
• Robots can very rapidly detect faults that may not be detected by the human eye
•Predictive Maintenance
• Continuous monitoring of systems and processes to identify key indicators of problems before they
result in downtime or system failure
•Process / Efficiency Improvement
• Process improvement affects every aspect of an operation’s bottom line
•Cost Reduction
• When an organization can improve system uptime, automate processes, reduce the risk of failure
gain insights that support better decision-making, and reduce resource usage, the result is
efficiency and cost savings
•Improved/ New Insights
• IoT systems often act as the eyes and ears on remote, hard-to-reach, or widely distributed
equipment and processes.
•Adaptability
• The ability to adapt to new business requirements, customer needs, and changing conditions or
scale the deployment in response to business growth or customer requirements
IoT vs. WSN
• Wireless Sensor Network (WSN):
– WSN refers to a group of specialized dedicated sensors with a
communications infrastructure.
– WSN is primarily used for monitoring and recording the physical
environment conditions like temperature, sound, pollution levels,
humidity, wind, and so on.
– It is designed to acquire, process, transfer, and provide data/information
extracted from the physical world.
– In a WSN, there is no direct connection to the internet. Instead, the
various sensors connect to some kind of router or central node.

•WSN: Resource constraint sensor nodes + wireless network to


connect the nodes + gather some data by sensing the environment.
•IoT: WSN + Internet + App + Cloud computing + Data Analytics + etc…
IoT CONCEPTUAL
FRAMEWORK
An IoT conceptual framework is a structured system that outlines the
interconnected components and processes involved in an IoT system. The
following equation describes a simple conceptual framework of IoT :
Physical Object + Controller, Sensor and Actuators + Internet = Internet of
Things
IoT Framework by Oracle
The equation below conceptually represents the actions and
communication of data at successive levels in IoT consisting of
internetworked devices and objects.
Gather + Enrich + Stream + Manage + Acquire + Organise and Analyse
= Internet of Things with connectivity to data center, enterprise or
cloud server
IoT Framework by Oracle
The steps are as follows:
1. At level 1, data of the devices (things) using sensors or the things gather the pre
data
from the internet.
2. A sensor connected to a gateway functions as a smart sensor (a smart sensor
refers to
A sensor with computing and communication capacity). The data then enriches at
Level 2, for example, by transcoding at the gateway. Transcoding means coding or
Decoding before data transfer between two entities.
3. A communication management subsystem sends or receives data streams at
level 3.
4. Device management, identity management, and access management subsystems
receive the device’s data at level 4.
5. A data store or database acquires the data at level 5.
6. Data routed from the devices and things organized and analyzed at level 6. For
example, data is analyzed to collect business intelligence in business processes.
IoT Framework by IBM
The equation conceptualizes the general framework for IoT using cloud
based services is:
Gather + Consolidate + Connect + Collect + Assemble + Manage and
Analyse = Internet of Things
IoT Framework by IBM
Equation represents a complex conceptual framework for IoT using cloud-platform
based processes and services. The steps are as follows:
1. Levels 1 and 2 consist of a sensor network to gather and consolidate the data.
The first level gathers the data of the things (devices) using sensor circuits. The
sensor connects to a gateway.
1. Data then consolidates at the second level, for example, transformation at
the gateway at level 2.
2. The gateway at level 2 communicates the data streams between levels 2 and the
system uses a communication-management subsystem at level 3.
3. An information service consists of connecting, collecting, assembling, and
managing subsystems at levels 3 and 4. The services are rendered from level 4.
4. Real-time series analysis, data analytics, and intelligence subsystems are also at
levels 4 and 5.
5. A cloud infrastructure, a data store, or a database acquires the data at level 5.
IoT ARCHITECTURAL VIEW
•An IoT system has multiple levels.
•These levels are also known as tiers.
•A model enables the conceptualization of a framework.
•A reference model can depict building blocks, successive interactions,
and integration.
•An example is CISCO, which presents a reference model comprising
seven levels.
IoT Architecture

Fig.: An IoT reference model suggested by CISCO that gives a conceptual


framework for a
general IoT system
Fig.: Oracle’s IoT architecture
IoT Technologies examples
•Hardware (Arduino Raspberry Pi, Intel Galileo, Intel Edison, ARM mBed,
Bosch XDK110, Beagle Bone Black and Wireless SoC)
•Integrated Development Environment (IDE) for developing device software,
firmware and APIs
•Protocols [RPL, CoAP, RESTful HTTP, MQTT, XMPP (Extensible Messaging
and Presence Protocol)]
•Communication (Powerline Ethernet, RFID, NFC, 6LowPAN, UWB, ZigBee,
Bluetooth, WiFi, WiMax, 2G/3G/4G)
•Network backbone (IPv4, IPv6, UDP and 6LowPAN)
•Software (RIOT OS, Contiki OS, Thingsquare Mist firmware, Eclipse IoT)
•Internetwork Cloud Platforms/Data Centre (Sense, ThingWorx, Nimbits,
Xively, openHAB, AWS IoT, IBM BlueMix, CISCO IoT, IOx and Fog, EvryThng,
Azure, TCSCUP)presents a reference model comprising seven levels.
Major Components of IoT
System
Physical objects with embedded software into hardware.
Hardware comprises a microcontroller, firmware, sensors, control unit,
actuators, and communication module.
Communication module: Software consisting of device APIs and device
interface for communication over the network and communication
circuit/port(s), and middleware for creating communication stacks using
protocols
Software for actions on messages, information, and commands that the
devices receive and then output to the actuators, which enable actions
such as glowing LEDs, robotic hand movement, etc.
Sensors and Control Units
•Sensors are electronic devices that sense the physical environments.
•An actuator is a device that converts energy into mechanical motion,
such as rotation, bending, or linear movement.
•Sensor-actuator pairs are used in control systems.
•Sensors are of two types.
•Analog sensors give analog inputs to the control unit.
•Examples are thermistors, photoconductors, pressure gauges, and Hall
sensors.
•Digital sensors give digital inputs to the control unit. Examples are touch
sensor, proximity sensor, metal sensor, and traffic presence sensor.
Sensors and Control Units
• The control unit in IoT consists of a Microcontroller Unit (MCU) or a
custom chip.
•A microcontroller is an integrated chip or core in a VLSI or SoC.
•An MCU comprises a processor, memory, and several other interfaced
hardware units.
•It also has firmware, timers, interrupt controllers and functional IO units.
•Additionally, an MCU has application-specific functional circuits designed
as per the specific version of a given microcontroller family.
MCU/SoC
Communication Module
•A communication module consists of protocol handlers, message queue
and message cache.
•A device message-queue inserts the messages in the queue and deletes
the messages from the queue in a first-in first-out manner.
•A device message-cache stores the received messages.
Connectivity interface comprises communication APIs, device interfaces,
and processing units.
Software
•IoT software consists of two components—software at the IoT device and
software at the IoT server.
M2M Communication
•Machine-to-machine (M2M) refers to the process of communication of a
physical object or device at machine with others of the same type, mostly
for monitoring but also for control purposes.
•Each machine in an M2M system embeds a smart device.
•M2M must deploy device to device and carry out the coordination,
monitoring, and controlling of the devices and communication without the
usage of the Internet.
•Difference: IoT deploys the internet, server, internet protocols, and server
or cloud end applications, services, or processes.
M2M
Architecture
•M2M architecture
consists of three
domains:
• M2M device domain
• M2M network domain
• M2M application
domain
M2M Architecture
•The M2M device communication domain consists of three entities:
physical devices, communication interface, and gateway.
•The M2M network domain consists of an M2M server, device identity
management, data analytics, data management, and device
management.
•The M2M application domain consists of applications for services,
monitoring, analysis, and control of the device's networks.
U-II Embedded
System for IoT
What is an Embedded
System?
•An embedded system consists of a processor, memory, and
input/output units and has a specific function within a larger
system.
•At the core, it is an integrated circuit designed to carry out
computation for real-time operations.
•Embedded systems have four main factors that differentiate them from
a typical workstation or server: purpose, design, cost, and human
involvement.
Fundamental of Embedded
Systems
•Embedded System: A computer system designed for specific control
functions within a larger system, often with real-time computing constraints. It
is embedded as part of a complete device often including hardware and
mechanical parts.
•Embedded Device: A specific type of embedded system that performs
computational tasks within a dedicated function or system, typically involving
both processing and communication tasks.
•Microcontroller Unit (MCU): A compact integrated circuit designed to govern
specific operations in an embedded system through its processing power,
memory, and I/O interfaces.
•Timer: A component in an embedded system used to measure time intervals
for the purpose of scheduling activities or triggering events at preset times.
Fundamental of Embedded
Systems
•Port: An interface on a microcontroller or other device that facilitates I/O
communication between the MCU and external devices like sensors,
actuaries, or computers.
•USB Port: A specific type of port that allows data transfer between
devices and computers; it can also supply electrical power for devices,
often eliminating the need for a separate power source.
•GPIO Pins: General-purpose input/output pins on an MCU or other circuit
board that can be programmed to perform various functions, including
digital input/output and analog input, among others.
•Board: A physical piece of hardware that houses an MCU or SoC (System
on Chip), along with other circuits and connectors, used to create
electronic devices and systems.
Fundamental of Embedded
Systems
•Platform: A combination of hardware and software including an
operating system that supports development and operation of
applications.
•Module: A smaller hardware unit that can be integrated onto a board to
add functionality or reduce overall size, such as an RF module for
wireless communication.
•Shield: An add-on board that can be plugged into a standard electronic
board to provide additional functionalities, commonly used with platforms
like Arduino to add capabilities like network connectivity.
•Header: A connector that facilitates the attachment of additional
components or wires to a board without soldering.
•Jumper: A conductor used to establish a temporary electrical
connection between two points on a circuit board.
Fundamental of Embedded
Systems
•Interrupt: A signal that causes a processor to temporarily halt what it is
doing and execute a different program, such as handling an incoming
data request or responding to a timer.
•Integrated Development Environment (IDE): Software tools that
provide comprehensive facilities to computer programmers for software
development, including writing, modifying, testing, and debugging their
programs.
•Operating System (OS): Software that manages computer hardware,
software resources, and provides common services for computer
programs, facilitating tasks like memory management, process
allocation, and multitasking.
Developmental Board
Developmental Board
EMBEDDED COMPUTING
BASICS
•Embedded Software
• BootLoader
• RTOS
• OS

•Integrated Development Environment


• Simulator
• APIs and Device Interfaces
• Device Interfaces
•Embedded Hardware Units
EMBEDDED PLATFORMS FOR
PROTOTYPING
•Designing a product needs a prototype development first.
•A standard source board enables prototyping, an easy task for number
of IoT and M2M devices.
•Several standard popular boards, modules and supporting circuits
(shields) are available from a number of sources:
• Arduino
• Intel®Galileo
• Intel® Edison
• Raspberry Pi
• Beagle Bone
• mBed
Digital
Communication
Protocols
Types of Protocol
• Serial Peripheral Interface (SPI)

• Inter-Integrated Circuit (I2C)

•Recommended Standard 232 (RS232)

Note: I2C, SPI, and RS232 are digital communication protocols used to send
data between devices in embedded systems.
They are commonly used for short-distance device communication.
Fundamental of SPI
•SPI supports Half / Full Duplex serial communication.
•It is a synchronous communication protocol.
•It is a four-wire communication protocol.
•In most cases, one master multiple slave protocol, but it also supports
multiple master configurations.
•It is on board short-range communication protocol for embedded
systems.
•It supports maximum speed up to 10Mbps
•Master provides a clock for synchronization.
•SPI supports 8 & 16 bits data frame format.
SPI Communication

42
SPI clocking: there is no “standard way”
Four clocking “modes”
◦ Two phases (CPHA)
◦ Two polarities (CPOL)

Master and selected slave must be in the same mode


During transfers with slaves A and B, Master must
◦ Configure clock to Slave A’s clock mode
◦ Select Slave A
◦ Do transfer
◦ Deselect Slave A
◦ Configure clock to Slave B’s clock mode
◦ Select Slave B
◦ Do transfer
◦ Deselect Slave B

Master reconfigures clock mode on-the-fly!


SPI Timing diagram

Timing Diagram – Showing Clock polarities and phases

44
SPI Pros and Cons
Pros:
◦ Fast and easy
◦ Fast for point-to-point connections
◦ Easily allows streaming/Constant data inflow
◦ No addressing/Simple to implement
◦ Everyone supports it

Cons:
◦ SS makes multiple slaves very complicated
◦ No acknowledgement ability
◦ No inherent arbitration
◦ No flow control

45
I2C Communication
Two lines
◦ Serial data line (SDA)
◦ Serial clock line (SCL)

Only two wires are needed to connect multiple devices.


Maximum 128 devices can be connected.
I2C(Inter-Integrated Circuit)
MASTER SLAVE
SDA SDA

SCL SCL

• I2C is a serial communication protocol that allows multiple devices to talk to each
other using only two wires - a clock (SCL) and a data line (SDA).
• Master: The master operates as the primary controller, initiating and managing data
transfers with a central role in controlling the communication flow.
• Slave: In contrast, the slave devices act as subordinate participants, responding to the
master's commands and actively engaging in the communication process.
• SDA (Serial Data): Transfer of data takes place through this pin.
• SCL (Serial Clock): It carries the clock signal.
KeyConcepts
Data Line Behavior: In I2C, data changes when the clock is low, remains stable
when high. Both lines are open drain, needing pull-up resistors for high levels, as
I2C devices often use active-low logic.
Packet Transmission: Data is transmitted in 9-bit packets.
Start Condition (1 bit) Slave Address (8 bits)
Acknowledgment bit (1 bit)

Start and Stop Conditions:


Start Condition: Initiated by transitioning SDA from high to low while keeping SCL high.
Stop Condition: Triggered by transitioning SDA from low to high while keeping SCL high.
Repeated Start Condition: Between each start-stop pair, if the master wants to initiate a
new transfer without releasing the bus, it issues a Repeated Start condition.
Addressing: I2C identifies slaves through addressing. The master sends the address
frame to all slaves, and the matched slave responds with a low voltage ACK bit.

Read/Write Bit: Included in the address frame, a low voltage level signals the master is
sending data, while a high level means it's requesting data.

Data Frame: After receiving an ACK bit, the master sends an 8-bit data frame, followed
by an ACK/NACK bit. The next frame waits for acknowledgment.

Stop Condition: The master concludes the transmission with a stop condition – a
voltage transition from low to high on SDA after a low to high transition on SCL,
keeping SCL high.

Acknowledge (ACK) and No-Acknowledge (NACK): After each frame, an ACK bit signals
successful reception, while a NACK bit indicates an unsuccessful one.
Single Master Controlling Multiple Slaves
MASTER SLAVE 1
SDA SDA

SCL SCL

SLAVE 2
SDA

RESISTORS
PULL-UP
SCL

SLAVE 3
VCC SDA
VCC

SCL

In I2C's Single Master, Multiple Slaves setup, one master communicates with several
slaves on a shared bus, addressing each for data exchange. This enables efficient
management and communication across multiple devices.
Multiple Masters with Multiple Slaves
MASTER 1 SLAVE 1
SDA SDA

SCL SCL
MASTER 2 SLAVE 2
SDA SDA

SCL
SCL
MASTER 3 SLAVE 3
SDA SDA

SCL SCL

RESISTORS
PULL-UP
VCC
VCC

Multiple Masters, Multiple Slaves in I2C allows several master devices to


communicate with multiple slaves on a shared bus.
Masters coordinate communication by addressing specific slaves, facilitating
efficient interactions across the network.
Key Features of I2C Communication
Half-duplex Communication: Bi-directional but not simultaneous communication.

Synchronous Transmission: Data is transferred in frames or blocks.

Multi-Master Configuration: Supports multiple masters in the system.

Clock Stretching: Slave can hold the clock low, preventing the master from raising it until
ready.

Arbitration: Supports multi-master but only one active master at a time.

Serial Transmission: Utilizes serial transmission for data exchange.

Low-Speed Communication: Primarily designed for low-speed communication.


Advantages
• Configurable in multi-master mode.
• Simplicity is achieved with only 2 bi-directional lines. Cost-efficient implementation.
• Improved error handling with the ACK/NACK feature.
• Supports multiple masters and slaves.
• Utilizes only two wires.

Limitations
• Slower speed compared to other protocols.

• Half-duplex communication is used.


• Limited data frame size to 8 bits.
RS232 Protocol
RS232
• RS232 is a standard protocol used for serial communication.
• It is used for connecting the computer and its peripheral devices to allow
serial data exchange between them.
• As it obtains the voltage for the path used for the data exchange between
the devices.
• It is used in serial communication up to 50 feet with a rate of 1.492kbps.
• As EIA defines, the RS232 connects Data Transmission Equipment (DTE) and
Data Communication Equipment (DCE).
RS-232 Signals
Working of RS232
•RS232 works on two-way communication that exchanges data with one another.
•There are two devices connected to each other, (DTE) Data Transmission
Equipment& (DCE) Data Communication Equipment which has the pins like TXD,
RXD, and RTS& CTS.
•Now, from the DTE source, the RTS generates the request to send the data.
•Then, DCE, the CTS, clears the path for receiving the data.
•After clearing a path, it will give a signal to RTS of the DTE source to send the
signal.
•Then the bits are transmitted from DTE to DCE.
•Now again from DCE source, the request can be generated by RTS and CTS of
DTE sources clears the path for receiving the data and gives a signal to send the
data.
•This is the whole process through which data transmission takes place.
U-II Embedded
System for IoT
What is an Embedded
System?
•An embedded system consists of a processor, memory, and
input/output units and has a specific function within a larger
system.
•At the core, it is an integrated circuit designed to carry out
computation for real-time operations.
•Embedded systems have four main factors that differentiate them from
a typical workstation or server: purpose, design, cost, and human
involvement.
Fundamental of Embedded
Systems
•Embedded System: A computer system designed for specific control
functions within a larger system, often with real-time computing constraints. It
is embedded as part of a complete device often including hardware and
mechanical parts.
•Embedded Device: A specific type of embedded system that performs
computational tasks within a dedicated function or system, typically involving
both processing and communication tasks.
•Microcontroller Unit (MCU): A compact integrated circuit designed to govern
specific operations in an embedded system through its processing power,
memory, and I/O interfaces.
•Timer: A component in an embedded system used to measure time intervals
for the purpose of scheduling activities or triggering events at preset times.
Fundamental of Embedded
Systems
•Port: An interface on a microcontroller or other device that facilitates I/O
communication between the MCU and external devices like sensors,
actuaries, or computers.
•USB Port: A specific type of port that allows data transfer between
devices and computers; it can also supply electrical power for devices,
often eliminating the need for a separate power source.
•GPIO Pins: General-purpose input/output pins on an MCU or other circuit
board that can be programmed to perform various functions, including
digital input/output and analog input, among others.
•Board: A physical piece of hardware that houses an MCU or SoC (System
on Chip), along with other circuits and connectors, used to create
electronic devices and systems.
Fundamental of Embedded
Systems
•Platform: A combination of hardware and software including an
operating system that supports development and operation of
applications.
•Module: A smaller hardware unit that can be integrated onto a board to
add functionality or reduce overall size, such as an RF module for
wireless communication.
•Shield: An add-on board that can be plugged into a standard electronic
board to provide additional functionalities, commonly used with platforms
like Arduino to add capabilities like network connectivity.
•Header: A connector that facilitates the attachment of additional
components or wires to a board without soldering.
•Jumper: A conductor used to establish a temporary electrical
connection between two points on a circuit board.
Fundamental of Embedded
Systems
•Interrupt: A signal that causes a processor to temporarily halt what it is
doing and execute a different program, such as handling an incoming
data request or responding to a timer.
•Integrated Development Environment (IDE): Software tools that
provide comprehensive facilities to computer programmers for software
development, including writing, modifying, testing, and debugging their
programs.
•Operating System (OS): Software that manages computer hardware,
software resources, and provides common services for computer
programs, facilitating tasks like memory management, process
allocation, and multitasking.
Developmental Board
Developmental Board
EMBEDDED COMPUTING
BASICS
•Embedded Software
• BootLoader
• RTOS
• OS

•Integrated Development Environment


• Simulator
• APIs and Device Interfaces
• Device Interfaces
•Embedded Hardware Units
EMBEDDED PLATFORMS FOR
PROTOTYPING
•Designing a product needs a prototype development first.
•A standard source board enables prototyping, an easy task for number
of IoT and M2M devices.
•Several standard popular boards, modules and supporting circuits
(shields) are available from a number of sources:
• Arduino
• Intel®Galileo
• Intel® Edison
• Raspberry Pi
• Beagle Bone
• mBed
Digital
Communication
Protocols
Types of Protocol
• Serial Peripheral Interface (SPI)

• Inter-Integrated Circuit (I2C)

•Recommended Standard 232 (RS232)

Note: I2C, SPI, and RS232 are digital communication protocols used to send
data between devices in embedded systems.
They are commonly used for short-distance device communication.
Fundamental of SPI
•SPI supports Half / Full Duplex serial communication.
•It is a synchronous communication protocol.
•It is a four-wire communication protocol.
•In most cases, one master multiple slave protocol, but it also supports
multiple master configurations.
•It is on board short-range communication protocol for embedded
systems.
•It supports maximum speed up to 10Mbps
•Master provides a clock for synchronization.
•SPI supports 8 & 16 bits data frame format.
SPI Communication

14
SPI clocking: there is no “standard way”
Four clocking “modes”
◦ Two phases (CPHA)
◦ Two polarities (CPOL)

Master and selected slave must be in the same mode


During transfers with slaves A and B, Master must
◦ Configure clock to Slave A’s clock mode
◦ Select Slave A
◦ Do transfer
◦ Deselect Slave A
◦ Configure clock to Slave B’s clock mode
◦ Select Slave B
◦ Do transfer
◦ Deselect Slave B

Master reconfigures clock mode on-the-fly!


SPI Timing diagram

Timing Diagram – Showing Clock polarities and phases

16
SPI Pros and Cons
Pros:
◦ Fast and easy
◦ Fast for point-to-point connections
◦ Easily allows streaming/Constant data inflow
◦ No addressing/Simple to implement
◦ Everyone supports it

Cons:
◦ SS makes multiple slaves very complicated
◦ No acknowledgement ability
◦ No inherent arbitration
◦ No flow control

17
I2C Communication
Two lines
◦ Serial data line (SDA)
◦ Serial clock line (SCL)

Only two wires are needed to connect multiple devices.


Maximum 128 devices can be connected.
I2C(Inter-Integrated Circuit)
MASTER SLAVE
SDA SDA

SCL SCL

• I2C is a serial communication protocol that allows multiple devices to talk to each
other using only two wires - a clock (SCL) and a data line (SDA).
• Master: The master operates as the primary controller, initiating and managing data
transfers with a central role in controlling the communication flow.
• Slave: In contrast, the slave devices act as subordinate participants, responding to the
master's commands and actively engaging in the communication process.
• SDA (Serial Data): Transfer of data takes place through this pin.
• SCL (Serial Clock): It carries the clock signal.
KeyConcepts
Data Line Behavior: In I2C, data changes when the clock is low, remains stable
when high. Both lines are open drain, needing pull-up resistors for high levels, as
I2C devices often use active-low logic.
Packet Transmission: Data is transmitted in 9-bit packets.
Start Condition (1 bit) Slave Address (8 bits)
Acknowledgment bit (1 bit)

Start and Stop Conditions:


Start Condition: Initiated by transitioning SDA from high to low while keeping SCL high.
Stop Condition: Triggered by transitioning SDA from low to high while keeping SCL high.
Repeated Start Condition: Between each start-stop pair, if the master wants to initiate a
new transfer without releasing the bus, it issues a Repeated Start condition.
Addressing: I2C identifies slaves through addressing. The master sends the address
frame to all slaves, and the matched slave responds with a low voltage ACK bit.

Read/Write Bit: Included in the address frame, a low voltage level signals the master is
sending data, while a high level means it's requesting data.

Data Frame: After receiving an ACK bit, the master sends an 8-bit data frame, followed
by an ACK/NACK bit. The next frame waits for acknowledgment.

Stop Condition: The master concludes the transmission with a stop condition – a
voltage transition from low to high on SDA after a low to high transition on SCL,
keeping SCL high.

Acknowledge (ACK) and No-Acknowledge (NACK): After each frame, an ACK bit signals
successful reception, while a NACK bit indicates an unsuccessful one.
Single Master Controlling Multiple Slaves
MASTER SLAVE 1
SDA SDA

SCL SCL

SLAVE 2
SDA

RESISTORS
PULL-UP
SCL

SLAVE 3
VCC SDA
VCC

SCL

In I2C's Single Master, Multiple Slaves setup, one master communicates with several
slaves on a shared bus, addressing each for data exchange. This enables efficient
management and communication across multiple devices.
Multiple Masters with Multiple Slaves
MASTER 1 SLAVE 1
SDA SDA

SCL SCL
MASTER 2 SLAVE 2
SDA SDA

SCL
SCL
MASTER 3 SLAVE 3
SDA SDA

SCL SCL

RESISTORS
PULL-UP
VCC
VCC

Multiple Masters, Multiple Slaves in I2C allows several master devices to


communicate with multiple slaves on a shared bus.
Masters coordinate communication by addressing specific slaves, facilitating
efficient interactions across the network.
Key Features of I2C Communication
Half-duplex Communication: Bi-directional but not simultaneous communication.

Synchronous Transmission: Data is transferred in frames or blocks.

Multi-Master Configuration: Supports multiple masters in the system.

Clock Stretching: Slave can hold the clock low, preventing the master from raising it until
ready.

Arbitration: Supports multi-master but only one active master at a time.

Serial Transmission: Utilizes serial transmission for data exchange.

Low-Speed Communication: Primarily designed for low-speed communication.


Advantages
• Configurable in multi-master mode.
• Simplicity is achieved with only 2 bi-directional lines. Cost-efficient implementation.
• Improved error handling with the ACK/NACK feature.
• Supports multiple masters and slaves.
• Utilizes only two wires.

Limitations
• Slower speed compared to other protocols.

• Half-duplex communication is used.


• Limited data frame size to 8 bits.
RS232 Protocol
RS232
• RS232 is a standard protocol used for serial communication.
• It is used for connecting the computer and its peripheral devices to allow
serial data exchange between them.
• As it obtains the voltage for the path used for the data exchange between
the devices.
• It is used in serial communication up to 50 feet with a rate of 1.492kbps.
• As EIA defines, the RS232 connects Data Transmission Equipment (DTE) and
Data Communication Equipment (DCE).
RS-232 Signals

Data Frame 1 Bit (Start) 7 or 8 bits (Data) Parity Bit 1 or 2 bit Stop bit
Bus arbitration
 Processor and controllers both need to initiate data
transfers on the bus and access main memory.
 The device that is allowed to initiate transfers on the
bus at any given time is called the bus master.
 When the current bus master relinquishes its status as
the bus master, another device can acquire this status.
 The process by which the next device to become the bus master is selected and
bus mastership is transferred to it is called bus arbitration.
 Centralized arbitration:
 A single bus arbiter performs the arbitration.
 Distributed arbitration:
 All devices participate in the selection of the next bus master.
Centralized Bus Arbitration

B BS Y

BR

Processor

Slave Slave
BG1 1 BG2 2

Daisy-Chain Approach
Centralized Bus Arbitration(cont.,)
• Bus arbiter may be the processor or a separate unit
connected to the bus.
• Normally, the processor is the bus master, unless it grants
bus membership to one of the controllers.
• Controller requests the control of the bus by asserting the
Bus Request (BR) line.
• In response, the processor activates the Bus-Grant1 (BG1)
line, indicating that the controller may use the bus when it
is free.
• BG1 signal is connected to all controllers in a daisy chain
fashion.
• BBSY signal is 0, it indicates that the bus is busy. When BBSY
becomes 1, the controller which asserted BR can acquire
control of the bus.
Centralized arbitration (contd..)
Controller 2
asserts the BR signal. Time
Processor asserts
BR
the BG1 signal

BG1 BG1 signal propagates


to Controller#2.
BG2

BBSY

Bus
master
Processor Controller 2 Processor

Processor relinquishes control


of the bus by setting BBSY to 1.
Distributed arbitration
 All devices waiting to use the bus share the
responsibility of carrying out the arbitration process.
 Arbitration process does not depend on a central arbiter and hence distributed
arbitration has higher reliability.
 Each device is assigned a 4-bit ID number.
 All the devices are connected using 5 lines, 4
arbitration lines to transmit the ID, and one line for the
Start-Arbitration signal.
 To request the bus a device:
 Asserts the Start-Arbitration signal.
 Places its 4-bit ID number on the arbitration lines.
 The pattern that appears on the arbitration lines is the
logical-OR of all the 4-bit device IDs placed on the
arbitration lines.
Distributed arbitration
Distributed arbitration(Contd.,)
• Arbitration process:
• Each device compares the pattern that appears on the
arbitration lines to its own ID, starting with MSB.
• If it detects a difference, it transmits 0s on the
arbitration lines for that and all lower bit positions.
• The pattern that appears on the arbitration lines is the
logical-OR of all the 4-bit device IDs placed on the
arbitration lines.
Distributed arbitration (contd..)
•Device A has the ID 5 and wants to request the bus:
- Transmits the pattern 0101 on the arbitration lines.
•Device B has the ID 6 and wants to request the bus:
- Transmits the pattern 0110 on the arbitration lines.
•Pattern that appears on the arbitration lines is the logical OR of the patterns:
- Pattern 0111 appears on the arbitration lines.

Arbitration process:
•Each device compares the pattern that appears on the arbitration lines to its own
ID, starting with MSB.
•If it detects a difference, it transmits 0s on the arbitration lines for that and all lower
bit positions.
•Device A compares its ID 5 with a pattern 0101 to pattern 0111.
•It detects a difference at bit position 0, as a result, it transmits a pattern 0100 on the
arbitration lines.
•The pattern that appears on the arbitration lines is the logical-OR of 0100 and 0110,
which is 0110.
•This pattern is the same as the device ID of B, and hence B has won the arbitration.
IEEE Standards
Shared Access Networks are Different
• Shared Access Networks assume multiple nodes on the
same physical link
• Bus, ring, and wireless structures
• Transmission sent by one node is received by all others
• No intermediate switches
• Need methods for moderating access (MAC protocols)
• Fairness
• Performance
• How can this be done?

41
Project 802 (IEEE 802 standards)
Ethernet
• Ethernet was first developed in the 1970s and was later standardized as IEEE
802.3.
• Ethernet is the group of LAN products covered by IEEE 802.3 that define a
wired Ethernet media access control's physical layer and data link layer.
• These standards also describe the rules for configuring an Ethernet network
and how the network elements work with one another.
• Ethernet allows computers to connect over one network—without it,
communication between devices in today’s modern world would not be
possible.
• Ethernet is the global standard for a system of wires and cables to conjoin
multiple computers, devices, machines, etc., over an organization’s single
network so that all the computers can communicate with one another.
• Ethernet began as a single cable, making it possible for multiple devices to
be connected on one network.
Ethernet evolution through four generations
802.3 MAC frame

Preamble + SFD:
• Added by the physical layer.
• Not a part of the frame.
• It is a series of bits as per 10101010 ...... 101011
Source & Destination Address:
• MAC Address of the source & destination node.
• Size of MAC is 6B = 48bits = 12 digit Hex number
Length/Type:
• It gives the length of the frame-Exclude: Preamble & SOF
Minimum and maximum lengths

Frame length:
Minimum: 64 bytes (512 bits)
Maximum: 1518 bytes (12,144 bits)
Example of an Ethernet address in hexadecimal notation
Unicast and multicast addresses

The least significant bit of the first byte defines the type of address.
If the bit is 0, the address is unicast; otherwise, it is multicast.
The broadcast destination address is a special case of the multicast address
in which all bits are 1s.
Categories of Standard Ethernet
Encoding in a Standard Ethernet implementation
10Base5 implementation
10Base2 implementation
10Base-T implementation
10Base-F implementation
Summary of Standard Ethernet implementations
CSMA/CD
Ethernet vs. Industrial Ethernet

Purpose & Environments


Ethernet:
•Used in offices, homes, and data centers.
•Designed for commercial and non-industrial applications.
•Commonly used for internet access, file sharing, and communication.
Industrial Ethernet:
•Designed for industrial applications and harsh environments.
•Used in manufacturing, automation, and process control.
•Supports real-time control, monitoring, and data exchange.
Ethernet vs. Industrial Ethernet

Reliability & Robustness


Ethernet:
•Not designed for extreme conditions.
•Sensitive to temperature, moisture, vibration, and electromagnetic
interference (EMI).
Industrial Ethernet:
•Engineered for harsh environments.
•Resistant to temperature changes, humidity, dust, and EMI.
•Devices are more rugged and durable.
Ethernet vs. Industrial Ethernet
Speed, Performance & Protocols
•Ethernet: Supports 10/100/1000 Mbps (Gigabit Ethernet, 10 Gbps, etc.).
•Industrial Ethernet: Similar speeds but optimized for real-time low-latency
communication (e.g., PROFINET, EtherCAT).
Protocols
•Ethernet: Uses TCP/IP and other standard networking protocols.
•Industrial Ethernet: Uses real-time industrial protocols like PROFINET, Modbus
TCP, and Ethernet/IP.
Modbus
Modbus
 Modbus is a widely used communication protocol designed for industrial
automation systems.
 Developed in 1979 by Modicon (now Schneider Electric).
 An open protocol, meaning many industrial devices can communicate using it.
 Modbus allows electronic devices to exchange data over a network, such as
PLCs (Programmable Logic Controllers), sensors, actuators, and industrial
equipment.
 It is simple, reliable, and commonly used in SCADA (Supervisory Control and
Data Acquisition) and DCS (Distributed Control Systems).
How Modbus work
• Modbus follows a master-slave (client-server) architecture.
• Master (Client): Initiates communication, requests data, and sends commands.
• Slave (Server): Responds to master’s requests and performs actions.
• The master device (e.g., a PLC or SCADA system) can communicate with multiple
slave devices (e.g., sensors, actuators).

Slave Function Data CRC


Address Code
Frame Format for Modbus
Modbus Data Structure
Register Type Function Size Access Type Address Range

Coils (0X) Digital Output (On/Off) 1-bit Read/Write 00001 – 09999

Discrete Inputs (1X) Digital Input (On/Off) 1-bit Read-Only 10001 – 19999

Input Registers (3X) Analog Input (Sensor Data) 16-bit Read-Only 30001 – 39999

Holding Registers (4X) Analog Output/Configuration 16-bit Read/Write 40001 – 49999

Function Code Description


01 Read Coil Status (Digital Output)
02 Read Discrete Inputs (Digital Input)
03 Read Holding Registers (Analog Output)
04 Read Input Registers (Analog Input)
05 Write Single Coil
06 Write Single Holding Register
16 Write Multiple Holding Registers
Modbus Communication
Models
Modbus can operate over different physical communication layers:
1. Modbus RTU (Remote Terminal Unit) (Serial Communication)
•Uses RS-232, RS-485, or RS-422 for communication.
•Data is sent in binary format for efficiency.
•Requires a checksum (CRC) for error checking.
•Suitable for real-time applications in industrial environments.
2. Modbus ASCII (Serial Communication)
•Similar to Modbus RTU but uses human-readable ASCII characters.
•Easier to debug but less efficient than RTU.
•Also uses RS-232, RS-485, or RS-422.
3. Modbus TCP/IP (Ethernet Communication)
•Uses TCP/IP over Ethernet instead of serial communication.
•Allows communication over modern industrial networks.
•Can integrate with cloud-based and IoT applications.
•No need for a checksum (since TCP handles error checking).
Advantages of Modbus
✅ Simple and Open Standard – Easy to implement and widely supported.
✅ Multiple Communication Types – Works with serial (RS-485) and Ethernet
(TCP/IP).
✅ Interoperability – Can be used across different manufacturers' devices.
✅ Reliable and Efficient – Well-suited for industrial environments.

Limitations of Modbus
❌ Limited Security – No encryption, making it vulnerable to cyber threats.
❌ Slow Communication – Serial Modbus RTU has lower speeds compared to
modern protocols.
❌ Limited Data Size – Can only handle small data packets.
BACnet
BACnet Protocol
•A data communication protocol used to build an automated control network: Building
Automation and Control Network.
•Protocol is an ISO & ANSI standard for interoperability between cooperating building
automation devices.
•Bacnet Protocol includes a set of rules for governing the data exchange on a computer network
that covers all the types of cables to utilize and form a particular command or request.
•BACnet specification includes three major parts. Primary, Secondary, and tertiary.
•Primary part defines a technique to represent any kind of building automation apparatus
normally.
•Secondary part describes messages that can be transmitted across a network of computers to
check and manage such equipment.
• Tertiary part describes a set of suitable LANs that are used for conveying BACnet
communications.
Why BACnet?
•Open Standard for Building Automation –An open, vendor-neutral protocol that allows
seamless integration of different devices and systems.
•Interoperability Across Devices – Supports HVAC, lighting, fire detection, security
systems, and more, enabling devices from different manufacturers to communicate.
•Flexible Communication Options – Works over multiple transport layers, including
Ethernet (BACnet/IP), RS-485 (MS/TP), and Zigbee (wireless BACnet) for versatile
connectivity.
•Supports Distributed Control Systems – Enables decentralized control, reducing
dependency on a single central controller for improved reliability and efficiency.
•Scalability & Future-Proofing – Designed to support small to large-scale automation
systems, making it ideal for modern smart buildings and IoT integration.
•Efficient Data Sharing & Monitoring – Uses standardized object-oriented data to simplify
data exchange and remote monitoring.
•Energy Management & Cost Savings – Helps optimize energy consumption, automate
controls, and improve efficiency, leading to lower operational costs.
BACnet Architecture
BACnet Objects
• BACnet objects are the fundamental components of the BACnet protocol.
• Objects represent specific pieces of information or control mechanisms
within a BACnet system.
• Each object in BACnet has a defined structure that includes properties such
as present value, status flags, and reliability status.
BACnet Objects
Point-like objects: Scheduling/Logging Control
BACnet Object Properties
Feature Modbus vs. BACnet
Full Name Modbus: Modular Communication Bus
BACnet: Building Automation and Control Network
Developed By Modbus: Modicon, 1979
BACnet: ASHRAE, 1987
Primary Use Modbus: Industrial automation
BACnet: Building automation
Protocol Type Modbus: Master-Slave
BACnet: Peer-to-Peer
Communication Mediums Modbus: RS-232, RS-485, Ethernet
BACnet: Ethernet, RS-485, Zigbee, ARCNET
Data Structure Modbus: Register-based
BACnet: Object-oriented
Interoperability Modbus: Limited
BACnet: High
Scalability Modbus: Up to 247 devices
BACnet: Thousands of devices
Feature Modbus vs. BACnet
Speed Modbus: Up to 115.2 kbps (RTU), 10 Mbps+ (TCP)
BACnet: 10 Mbps - 1 Gbps
Complexity Modbus: Simple
BACnet: Complex but flexible
Error Handling Modbus: CRC, TCP/IP error detection
BACnet: Built-in error detection
Security Modbus: Minimal
BACnet: Enhanced with authentication, encryption
Real-Time Performance Modbus: Lower latency, slower RTU response
BACnet: Real-time, event-driven
Application Examples Modbus: SCADA, industrial control
BACnet: Smart buildings, HVAC
Advantages
• BACnet protocol is particularly designed for building automation as well as
control networks.
• Doesn’t depend on present LAN or WAN technologies.
• It is an American National Standard & a European pre-standard.
• It is scalable completely from small single building applications to universal
networks of devices.
• Implementers of BACnet can securely include non-standard extensions as well
as enhancements without influencing existing interoperability.
• In real building control applications, this protocol has a proven track record.
Disadvantages
•Interoperability Issues
•Security concerns
•Scalability challenges
•Complexity
•Dependence on Network Infrastructure
IoT COMMUNICATION
PROTOCOLS
Functional block
Communication Models of IoT
A communication model defines how device interact and share
data. It outlines the rules and methods used for device to send or
receive information.
• Client-Server

• Publisher-Subscriber

• Push-Pull

• Exclusive Pair Communication Model


Client Server Model

Request

SERVER Database
CLIENT
Response
PUBLISH SUBSCRIBE MODEL

PUBLISHER
Message BROKER
published
CONSUMER 1
to topic 1
SEND TOPIC 1
MESSAGES CONSUMER 2
TO TOPICS TOPIC 2
Message
published CONSUMER 3
to topic 2
Push Pull Model
EXCLUSIVE PAIR COMMUNICATION
MODEL

Request to Setup connection

Response accepting the request

Message from Client to Server


CLIENT Message from Server to Client SERVER
Connection close request

Connection Close Response


IoT COMMUNICATION PROTOCOLS

• loT communication protocols form the backbone of IoT systems and enable
network connectivity and coupling to applications.
• Communication protocols allow devices to exchange data over the network.
• These protocols define the data exchange formats, data encoding
addressing schemes for devices, and routing of packets from source to
destination.
Layers of IoT Protocols
Application layer
HTTP: Hypertext
Transfer Protocol
HTTP CoAP WebSockets

CoAP: Constrained
Application Protocol MQTT XMPP DDS AMQP
MQTT: Message
Queuing Telemetry
Transport
XMPP: Extensible Transport layer
Messaging and
Presence Protocol TCP UDP
DDS: Data Distribution
Service
AMQP: Advanced
Message Queuing
Protocol
Network layer
TCP: Transmission IPv4 IPv6 6LoWPAN
Control Protocol
UDP: User
Datagram Protocol
Link layer
802.3 802.16
2G/3G/LTE-
Cellular
802.11 802.15.4
HTTP

▸ Hypertext transfer protocol.

▸ GET, PUT, POST, DELETE, HEAD, TRACE, OPTIONS, etc commands.

▸ Stateless (each request is different from others.)

▸ HTTP client can be a browser or application running on the client.

▸ Multiple headers (MIME).


HTTP Objects

• Protocol for transfer of various data formats between server and


client
• Plaintext
• Hypertext
• Images
• Video
• Sound
• Meta-information also transferred
Uniform Resources Identifier

• URL
• Uniform Resource Locator
• Refers to an existing protocol
• http:, wais:, ftp:, mailto:, gopher:, news:
• Points to a document on a specific server
• URN
• Uniform Resource Name
• Globally unique, persistent identifier
• Independent of location
HTTP Server Message
HTTP Request Message HTTP Response Message

GET /dir/page.html HTTP/I.I HTTP/I.1 200 OK


Host: www.xyz.com Connection: close
Connection: close Date: Fri, 18 February GMT
User-agent: Chrome/132.0.6834.160 Server: Apache/%.2.3
Accept-language: ENG (CentOS)
Last Modified: Tug18Aug
2023
15.11.03 GMT
Content-Length: 6821
Content-Type: text/html
(data data data data data)
HTTP Server Message
HTTP Response Message

HTTP/I.1 200 OK
Connection: close
Date: Tue,18 August GMT
Server: Apache/%.2.3 (CentOS)
Last Modified: Tug18Aug
202315.•11.03GMT
Content-Length: 6821
Content-Type: text/html
(data data data data data)

200 0K
301 Moved Permanently
400 Bad Request
404 Not Found
505 HTTP Version Not Supported
HTTP Methods

• GET
• Web browser request an object from a web server.
• POST
• Submit data to the server for operation
• HEAD
• Used for debugging(Developers)
• PUT
• Upload an object to specific directory
• DELETE
• Remove object from the server
URL

• <scheme> : //<host> :<port> /<path> ;<parameters> ?<query>


#<fragment>
• scheme
• The protocol you are using
• host
• Host name or IP number
• Port
• TCP port number that the protocol server is using
• Path
• Path and filename reference of the object on the server
• Parameters
• Any specific parameters that the object needs
• query
• Query string for a CGI program
• fragment
• Reference to a subset of an object
MQTT: Message Queuing
Telemetry Transport
• MQTT is a machine-to-machine (M2M)/"Internet of Things" connectivity protocol.

• It was designed as an extremely lightweight publish/subscribe messaging transport.

• It is useful for connections with remote locations where a small code footprint is
required and/or network bandwidth is at a premium.

• Message brokers are the communication nodes.

• Limited devices, High Latency.


Components of MQTT

• Brokers:
• Is a server that receives and sends messages to subscribers,
• an Intermediate between Publisher and subscriber
• Topic:
• Is the virtual channel in which the Publisher and Subscriber send and receive message
• Message
• Client
• Publisher
• Subscriber

Publisher-Is a Client which publishes message to Mqtt Broker with a particular topic
Subscriber-Is the Client which receives message from the broker on subscription of a particular topic
MQTT-IOT-Example

Webserver
MQTT MQTT MQTT
Client Broker
MQTT Protocol Details -
Headers
 MQTT protocol control packets:
• Fixed header (2 bytes)
• Variable header (optional, length varies)
• Message payload (optional, length encoded, up to 256MB)

Fixed Variable Payload

 Fixed header indicates the packet type, the length of the


payload, and Quality of Service
 Variable header contents depend on packet type
• Message ID, Topic name, client identifier, and so on.
 Each bit in each byte is important!

 Disconnect and Pings include only the 2-byte fixed header


 Remaining Length allows for a
256MB payload
MQTT protocol flows/Methods

 Most control packets have a Connection


Management
CONNECT
corresponding acknowledgment CONNACK

• e.g. CONNECT/CONNACK DISCONNECT


PINGREQ
 CONNECT
PINGRESP
• Can restart a previous session
• Can specify a message and topic Subscription SUBSCRIBE
Management
SUBACK
 SUBSCRIBE can specify multiple topics
UNSUBSCRIBE
 PUBLISH flows
UNSUBACK
• Sent from client → server to publish a Message PUBLISH
message, or Server → client to send Delivery
PUBACK
messages
PUBREC
• Flow depends on the QoS level
PUBREL
PUBCOMP
MQTT client
CONNECT
MQTT
client MQTT server
CONNACK

SUBSCRIBE
Is connected, and
is awaiting Has a subscriber
messages SUBACK connected on a topic

Is the connection PINGREQ


still active?
Yes! PINGRESP
MQTT Qualities of Service
• Delivery guarantees between
Sender and Receiver
QoS 0: At most once delivery (non-
persistent)
– No retry semantics are defined in the protocol.
– The message arrives either once or not at all.

QoS 1: At least once delivery


(persistent, duplicates are possible)
– Sender sends message with Message ID in the message header
– Receiver acknowledges with a PUBACK control packet
– Message is resent with DUP bit set if the PUBACK is not received

QoS 2: Exactly once delivery


(persistent)
– Two stage process to ensure that message is not duplicated
– Server acknowledges with a PUBREC control packet
– Client releases message with a PUBREL control packet
– Server acknowledges completion with a PUBCOMP control packet
COAP
• Constrained Application Protocol

• For M2M/IoT

• Request response model

• Runs on UDP instead of TCP

• GET , PUT, POST, DELETE, etc.

• Low bandwidth-restricted network


CoAP – Request Response

CoAP Server 1
(Thermostat in Bedroom)

CoAP Client
CoAP Server 2
(Thermostat in Living room)

Name of
Port (5683 is the parameter
Name of the the default port Name of device controls
protocol CoAP uses) the device (temperature here)

coap://myhome.in:5683/nest_bedroom/temp
CoAP Layers

▶ Mostly it is divided in two layers.


 Upper Layer (Request and Response) Application

 Lower Layer (Message)


Request/Response
▶ There are 4 types of message
 Confirmable (CON) Messages
 Non Confirmable (NON)
 Acknowledgement (ACK) UDP

 Reset (RST)
▶ Reset (RST) – RST message is sent when recipient fails to send
response in time.
CoAP Message Types
CON / Confirmable message
A confirmable message requires a response, either a positive acknowledgement or
a negative acknowledgement. In case acknowledgement is not received, retransmissions
are made until all attempts are exhausted.
NON / Non-confirmable message
A non-confirmable request is used for unreliable transmission (like a request for a
sensor measurement made in periodic basis. Even if one value is missed, there is not too
much impact). Such a message is not generally acknowledged.
ACK / Acknowledgement
Sent to acknowledge a confirmable (CON) message.
RST / Reset
This represents a negative acknowledgement and means “Reset”. It generally
indicates, some kind of failure (like unable to parse received data)
COAP Header

• VER (2 bits) – CoAP version.


• Type (2 bits) – Type of messages [CON (0), NON (1), ACK (2), RST (3)]
• Token Length (4 bits) – Indicates the length of the variable token field.
• CoAP Request/Response Code (8 bits) – It has a Request/Response code.
• Class: 0(Request), 2 (Success response), 4(Client Error Response), 5(Server Error Response)
• Message ID (16 bits) – Stores message ID, which is used to detect message duplication.
CoAP Status Codes
CoAP Status Code Description HTTP Status Code Description
2.01 Created 1xx Informational
2.02 Deleted
Successful
2.03 Valid
2.04 Changed
200 – OK
2xx 201 – Created
2.05 Content 202 – Accepted
2.31 Continue 204 – No Content
4.00 Bad Request
Redirection
4.01 Unauthorized
3xx 301 - Moved Permanently
4.02 Bad Option
305 - Use Proxy
4.03 Forbidden 307 - Temporary Redirect
4.04 Not Found Client Error
4.05 Method Not Allowed
400 – Bad Request
4.06 Not Acceptable
401 – Unauthorized
4.08 Request Entity Incomplete 4xx 403 – Forbidden
4.12 Precondition Failed 404 - Not Found
4.13 Request Entity Too Large 405 – Method Not Found
4.15 Unsupported Content-Format 408 – Request Timeout
5.00 Internal Server Error 500 – Internal Server Error
5.01 Not Implemented 501 – Not Implemented
5xx
5.02 Bad Gateway 503 – Service Unavailable
5.03 Service Unavailable 504 - Gateway Timeout
5.04 Gateway Timeout Only mostly used HTTP Status Codes are listed here
5.05 Proxying Not Supported
CoAP Methods
• GET
• POST
• PUT
• DELETE
• OBSERVE (Not present in Http, New in CoAP)

• Method calls can be made using confirmable & non-confirmable message services
• When a confirmable message is received, receiver always returns an acknowledgement.
The sender resends messages if an acknowledgement is not returned within a given time.

• When a non confirmable message is received, receiver does not return an


acknowledgement.

• No of response code has also been reduced (to make implementation simpler)

• CoAP also broke away from the Internet Media Type scheme used in HTTP and
other protocols and replaced this with a reduced set of Content.
Web Service Protocol

• A protocol designed for communication between applications


over the web using standardized formats (e.g., SOAP, REST).
• Facilitates interoperability between different applications and
services over the internet.
• SOAP, Representational State Transfer (REST), XML-RPC,
JSON-RPC
• Application Layer Protocols handle data transfer in IoT
networks.
• Web Service Protocols ensure structured and interoperable
communication with external systems.
• Both work together for seamless IoT data exchange between
devices, cloud platforms, and applications.
SOAP

• SOAP (Simple Object Access Protocol) is a web service


communication protocol.
• Uses XML-based messaging to enable communication between
applications over a network.
• Works over HTTP, SMTP, TCP, and UDP.
• Designed for platform-independent and language-independent
communication.
SOAP Communication Process

• Client Sends a SOAP Request


• XML-formatted request sent to the server.
• Server Processes the Request
• Reads the request and performs the required action.
• Server Sends a SOAP Response
• Returns the result in XML format.
• Client Receives the Response
• Processes the response for further action.
SOAP Components

• SOAP Message: XML-based request/response message


structure.
• SOAP Envelope: Defines the start and end of a SOAP
message.
• SOAP Header (Optional): Contains metadata like authentication
or routing info.
• SOAP Body: Contains the actual request or response data.
• SOAP Fault: Handles error messages.
Soap-Message format
Soap example-SOAP request
Soap example-SOAP response
SOAP fault example
SOAP Binding

• The SOAP specification defines the structure of the SOAP


messages, not how they are exchanged.
• SOAP bindings are mechanisms that allow SOAP messages to
be effectively exchanged using a transport protocol.
• Most SOAP implementations provide bindings for common
transport protocols, such as HTTP or SMTP.
SOAP HTTP Bindings
SOAP: advantages and disadvantage

Advantages

• Human readable XML


• Easy to debug
• SOAP runs over HTTP
• Firewalls not affected
• Services can be written in any language, platform or operating system

Disadvantages

• XML produces much overhead for small messages


• Web Services speed relies on Internet traffic conditions
• Not strictly-typed XML
REST

• Representational State Transfer

• Architectural style (technically not a standard)

• Idea: a network of web pages where the client progresses through an


application by selecting links

• When client traverses link, accesses new resource (i.e., transfers state)

• Uses existing standards, e.g., HTTP

• REST is an architecture all about the Client-Server communication.


REST
• REST is about resources and how to represent resources in
different ways.

• REST is about client-server communication.

• REST is about how to manipulate resources.

• REST offers a simple, interoperable and flexible way of writing


web services that can be very different from other techniques.

• Comes from Roy Fielding’s Thesis study.


REST: Architectural Style

• REST is the architecture of the Web as it works today and, so it is already


used in the web!

• It is an software architectural model which is used to describe distributed


systems like WWW (World Wide Web).

• It has been developed in parallel with HTTP protocol.

• Not a protocol.

• Not a standard.

• Not a replacement for SOAP.


RESTful Web Services
• RESTful web services are web services which are REST based.

• Stateless & cacheable.

• Uses URI & HTTP methods.

• Moderate light, extensible and simple services.

• The reason behind the popularity of REST is that the applications we use
are browser-based nowadays and top it all, REST is built on HTTP.

• Main idea: Providing the communication between client and server over
HTTP protocol rather than other complex architectures like SOAP and RPC
etc.
RESTful Web Services

• You can do anything you already do with normal web services.

• No severe restrictions on how the architectural model will be and what properties
it will have.

• Models like SOAP have severe rules, REST does not.

• Inspite of the low bandwidth, large data have been transfered with methods even
inflating the size of the data, like XML with SOAP. Why?

• Nowadays, the bandwidth is amazingly large, but we still use JSON and it shrinks
the size of our data.
RESTful Web Services
• Platform independent.

• Language independent.

• Work on HTTP protocol.

• Flexible and easily extendible.

• They also have some constraints or principles.

▪ Client-Server
▪ Stateless
▪ Cacheable
▪ Uniform Interface/Contract
▪ Layered System
▪ Code on Demand
Client-Server
• Seperation of concerns.
• Client and server are independent from eachother.
• Client doesn’t know anything about the resource which is
kept in the server.
• Server responds as long as the right requests come in.
• Goal: Platform independency and to improve scalability.
Stateless
• Each request is independent from other requests.
• No client session data or any context stored on the server.
• Every request from client stores the required information, so
that the server can respond.
• If there are needs for session-specific data, it should be held
and maintained by the client and transferred to the server with
each request as needed.
• A service layer which doesn’t have to maintain client sessions
is much easier to scale.
• Of course there may be cumbersome situations:
• The client must load the required information to every request. And
this increases the network traffic.
• Server might be loaded with heavy work of «validation» of requests.
Cacheable

• HTTP responses must be cacheable by the clients.


• Important for performance.
• If a new request for the resources comes within a while, then
the cached response will be returned.
Uniform Interface
• All resources are accessed with a generic interface (HTTP-based).

• This makes it easier to manage the communication.

• By the help of a uniform interface, client and server evolve


independently from eachother.
Layered System

• There can be many intermediaries between you and the server you are
connecting to.

• Actually, a client does not know if it is connected to the last server or an


intermediary server.

• Intermediaries may improve performance by caching and message


passing.

• Intermediary servers can increase scalability by load-balancing and can


force clients to form some sort of security policies.

• This structure can be used when encapsulation is needed.


Code on Demand

• Servers can send some kind of executable scripts to the


client-side in order to increase or change the functionality on
the client side.
• This may cause low visibility, so it is the only optional
constraint.
• EXAMPLE
...
<head>
<script src="utility.js"
type="text/javascript">
</script>
...
Benefits

Network Performance Other Benefits


• Efficiency ► Simplicity
• Scalability ► Evolvability
• User Perceived ► Reuseability
Performance ► Visibility
► Extensibility
► Configuration
► Customizability
REST vs SOAP

• SOAP is a XML-based message protocol, while REST is an


architectural style.
• SOAP uses WSDL for communication between consumer and
provider, whereas REST just uses XML or JSON to send and
receive data.
• SOAP invokes services by calling RPC method, REST just
simply calls services via URL path.
• SOAP doesn't return human readable result, whilst REST result
is readable with is just plain XML or JSON.
• SOAP is not just over HTTP, it also uses other protocols such as
SMTP, FTP, etc, REST is over only HTTP.
Example of HTTP

• POST /smartlight/control HTTP/1.1


• Host: smarthome.com
• Content-Type: application/x-www-form-urlencoded
• action=turn_on&device_id=123

• HTTP/1.1 200 OK
• Content-Type: text/plain
• Light 123 turned ON
RESTFull HTTP

• PUT /smartlights/123/state HTTP/1.1


• Host: smarthome.com
• Content-Type: application/json
{
"state": "on“
}

• HTTP/1.1 200 OK
• Content-Type: application/json
{
"device_id": 123, "state": "on", "message": "Light turned ON“
}
WebSocket

• WebSocket is a technology for providing bi-directional full duplex communication


channels over a single TCP socket.

• Enable real-time interaction between a client and a server

• Stateful protocol

• Supports only TCP protocol

• Low Overhead: Unlike HTTP polling, WebSocket reduces network traffic.

• Efficient for IoT: Ideal for real-time IoT systems, such as smart home automation
and industrial monitoring.
Websocket Architecture
Example

Client sends:

Server
responds:
Limitations of WebSocket

• Not all browsers support them


• No support in Firefox 4, IE9, Opera
• So you need to fallback to something that works
• See Socket.IO: client and server library for graceful fallback

• Security vulnerabilities with transparent proxies


• Not caused by WebSockets, but they expose issue

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy