1.1Unit 1 (IoT)-1 (1)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 28

Unit 1 (IoT)

• Physical Design of IoT


• Logical Design of IoT
• IoT Communication Model
• IoT Communication APIs

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 1
Physical Design of IoT
Physical Design of IoT refers to
⮚ IoT Devices
⮚ IoT Protocols

1. IoT Devices
⚫ Things in IoT are IoT devices.
⚫ They have unique identifiers
⚫ They perform remote sensing, actuating and monitoring.
⚫ Types of IoT devices: sensing devices, smart watches, smart electronic devices, smart industrial
machines, wearable sensors etc.
⚫ Data generated by IoT devices processed by data analytics systems leads to useful information
to guide further actions locally or remotely.
⚫ IoT devices exchange data with other connected devices & applications directly or indirectly or
collect data from other devices.
⚫ For example, Temperature data generated by a Temperature Sensor in Home or other place,
when processed can help in determining temperature and take action according to users.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 2
Compiled By: Dr. Amita Gandhi, Assistant
Professor, GVMITM, Sonipat 3
An IoT device may consist of several interfaces for communication to other devices both wired and
wireless. These includes
(i) I/O interfaces for sensors & actuators,
(ii) Interfaces for internet connectivity,
(iii) memory and storage interfaces,
(iv) audio/video interfaces, and
(v) Process & graphic interface.

i. Input/Output interface
Sensors & actuators are connected to IoT devices using this interface. To give input and output signals
to sensors, and actuators we use things like
⚫ UART (Universal Asynchronous receiver and transmitter), simplest and oldest form of device to
device digital communication.
⚫ SPI (Serial Peripheral Interface), used in short distance communication.
⚫ I2C (Inter Integrated Circuit) used in video devices like monitor, TV, VCR.
⚫ CAN (Controller Area Network), Network of independent controllers.

ii. Audio/Video Interfaces


Audio connectors are used for audio frequencies. They can be analog or digital. Video connectors
carry video signals only.
An interface like HDMI (High Definition Multimedia Interface, used to transfer high quality audio
and video); 3.5 mm audio (used for headphones connection) and RCA (Radio Corporation of
America) devices is used to record audio and videos in a system.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 4
iii. Storage Interfaces
Things like SD (Secure Digital, used to store data of smart phones, video recorders, camera etc.), MMC
(Multimedia card), and SDIO (Secure Digital input output) are used to store the data generated from an
IoT device.
iv. Graphics
GPU (Graphic Processing Unit) are used to control the activity of an IoT system.
v. Memory
(Explain volatile & non volatile memory) (RAM & ROM)
NAND/NOR gates These are logic gates, found in memory cards, smart phones and USB devices.
vi. Connectivity
Devices like USB hosts and ETHERNET are used for connectivity between the devices and the server.
vii. Processor
A processor like a CPU and other units are used to process the data. these data are further used to improve
the decision quality of an IoT system.

2. IoT Protocols
These protocols are used to establish communication between a node device and a server over the internet.
It also helps to send commands to an IoT device and receive data from an IoT device over the internet.
We use different types of protocols that are present on both the server and client-side and these protocols are
managed by network layers like application, transport, network, and link layer.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 5
Compiled By: Dr. Amita Gandhi, Assistant
Professor, GVMITM, Sonipat 6
1. Application Layer Protocols:
In this layer, protocols define how the data can be sent over the network with
the lower layer protocols using the application interface. these protocols
include HTTP, WebSocket, XMPP, MQTT, DDS, and AMQP protocols.

HTTP:
⚫ Hyper Text Transfer Protocol that forms foundation of WWW.
⚫ a protocol that presents in an application layer for transmitting media
documents. It is used to communicate between web browsers and servers.
⚫ HTTP follows classical client-server model.
⚫ Follow request- response model (it makes a request to a server and then
waits till it receives a response and in between the request server does not
keep any data between two requests)
⚫ Stateless protocol.
⚫ Generally, use TCP connections to communicate with server.

CoAP:
⚫ Constrained Application Protocol for machine-to-machine(M2M)
applications with constrained devices, constrained environment and
constrained n/w. Uses client-server architecture.
⚫ It enables devices to communicate over the internet.
⚫ It is used for constrained devices such as 8 bit microcontroller, low power
sensors that can’t run on HTTP.
⚫ It is simplification of HTTP protocol running on UDP instead of TCP, that
helps save bandwidth.
Compiled By: Dr. Amita Gandhi, Assistant
Professor, GVMITM, Sonipat 7
WebSocket:
● It is a low level web friendly communication mechanism (FB, messenger etc)
● allows full duplex communication i.e this protocol enables two-way communication between a client and a
host that can be run on an untrusted code in a controlled environment. this protocol is commonly used by web
browsers.

MQTT: (Message Queue Telemetry Transport)


● M2M/IoT Connectivity Protocol.
● is light weight messaging protocol based on publish-subscribe model.
● Uses client server architecture.
●Well suited for constrained environment.
● It runs over TCP/IP.

XMPP:
● Extensible Message and Presence Protocol for real time communication and streaming XML data between
network entities.
●Support client-server and server-server communication.
● It is suitable for voice/video calls, chats, messaging, gaming, multiparty chat, social networking etc.

DDS:
● Data Distribution Service is data centric middleware standards for device-to-device or machine-to-machine
communication.
● IoT protocol developed for M2M communication by object management group communication.
● Uses publish-subscribe model.

AMQP:
● Advanced Message Queuing Protocol is open standard application layer protocol for business messaging.
● Supports both point-to-point and publish-subscribe model.
Compiled By: Dr. Amita Gandhi, Assistant
Professor, GVMITM, Sonipat 8
2. Transport Layer Protocols:
This layer is used to control the flow of data segments and handle the error control. also, these layer
protocols provide end-to-end message transfer capability independent of the underlying network.
TCP
The transmission control protocol is a protocol that defines how to establish and maintain a network that can
exchange data in a proper manner using the internet protocol.

UDP
a user datagram protocol is a part of an internet protocol called the connectionless protocol. this protocol is
not required to establish the connection to transfer data.

3. Network Layer Protocols:


This layer is used to send datagrams from the source network to the destination network. We use IPv4 and
IPv6 protocols as host identification that transfers data in packets.
IPv4
This is a protocol address that is a unique and numerical label assigned to each device connected to the
network. an IP address performs two main functions host and location addressing. IPv4 is an IP address that
is 32-bit long.

IPv6
It is a successor of IPv4 that uses 128 bits for an IP address. it is developed by the IETF task force to deal
with long-anticipated problems.
6LOWPAN
(IPv6 over Low Power Wireless Personal Area Network) operates in 2.4 GHz frequency range and data
transfer 250 kb/s.
This protocol allows smallest devices with limited processing ability to transmit information wirelessly using
an internet protocol.
6LOWPAN can communicate with 802.15.4 devices as well as other types of devices on an IP network link
like WiFi.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 9
4. Link Layer Protocols:
Link-layer protocols are used to send data over the network's physical layer. it also determines how
the packets are coded and signaled by the devices.
Ethernet
It is a set of technologies and protocols that are used primarily in LANs. it defines the physical layer
and the medium access control for wired ethernet networks.
WiFi
It is a set of LAN protocols and specifies the set of media access control and physical layer protocols
for implementing wireless local area networks (WLANs).
WiMax
● Is a standard for wireless MANs.
● Specialized in point to multipoint broadband wireless access.
● WiMax can provide at home or mobile internet access across whole cities or countries.
LR-WPAN
(Low Rate Wireless Personal Area Network) eg. ZigBee
LR-WPAN focuses on low cost, low speed communication between devices.

2G/3G/4G-Mobile Communication
● IoT devices based on these standards can communicate over cellular networks.
● Supports data rates from 9.6kb/s(2G) to up to100Mb/s(4G).

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 10
Logical Design of IoT

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 11
Logical Design of IoT
The logical design of an IoT system refers to an abstract
representation of entities and processes without going into
the low-level specification of implementation.
That is, A logical design for an IoT system is the actual
design of how its components (computers, sensors, and
actuators) should be arranged to complete a particular
function. It doesn’t go into the depth of describing how
each component will be built with low-level programming
specifics.
To implement a system, IoT logical design includes
1. Functional Blocks,

2. Communication Models, and

3. Communication APIs.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 12
1. IoT Functional Blocks
An IoT system comprises of a number of functional blocks that provide the system
the capabilities for identification, sensing, actuation, communication and
management.
Functional blocks are:

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 13
Functional blocks are:
Device: An IoT system comprises of devices that provide sensing, actuation,
monitoring and control functions.
Communication: Handles the communication for the IoT system.
Services: services for device monitoring, device control service, data publishing
services and services for device discovery.
Management: this blocks provides various functions to govern the IoT system.
Security: this block secures the IoT system and by providing functions such as
authentication , authorization, message and content integrity, and data security.
Application: This is an interface that the users can use to control and monitor various
aspects of the IoT system. It also allow users to view the system status and view or
analyze the processed data.

2. IoT Communication Models


There are multiple kinds of models available in an Internet of Things system that is used
for communicating between the system and server, such as:
 Request-response model
 Publish-subscribe model
 Push-pull model
 Exclusive pair model Compiled By: Dr. Amita Gandhi, Assistant
Professor, GVMITM, Sonipat 14
i. Request-Response Communication Model
Request-response model is communication model in which the client sends requests to
the server and the server responds to the requests.
The request may be transfer of data or upload of data.
The server may be remote or local and can handle request of many clients.
When the server receives a request, it decides how to respond, fetches the data,
retrieves resource representation, prepares the response, and then sends the response to
the client.
Request-response is a stateless communication model and each request-response pair is
independent of others.
HTTP works as a request-response protocol between a client and server. A web
browser may be the client, and an application on a computer that hosts a web site may be
the server.
Example: A client (browser) submits an HTTP request to the server; then the server
returns a response to the client. The response contains status information about the
request and may also contain the requested content.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 15
ii. Publish-subscribe communication model
⚫Publish-Subscribe is a communication model that involves publishers, brokers and
consumers.
⚫Publishersare the source of data. Publishers send the data to the topics which are
managed by the broker. Publishers are not aware of the consumers.
⚫Consumers subscribe to the topics which are managed by the broker.
⚫Broker receive data for a topic from the publisher, it sends the data to all the
subscribed consumers. This means that broker responsibility is to accept data from
publishers and send it to the appropriate consumer.
⚫Example
In youtube it is happening like this only, like I am a creator, and I am publishing my
vedios, there can be subscribers, right, so youtube is a broker and you are a
subscriber and you are watching my vedio based on subscription on the youtube.
or
On the website many times we subscribed to their newsletters using our email
address. these email addresses are managed by some third-party services and when
a new article is published on the website it is directly sent to the broker and then the
broker sends these new data or posts to all the subscribers.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 16
17
iii. Push-pull communication model
Push-Pull is a communication model in which the data producers push the data to
queues and the consumers Pull the data from the Queues.
Producers do not need to be aware of the consumers.
Queues also act as a buffer which helps in situations when there is a mismatch between
the rate at which the producers push data and the rate at which the consumer pull data.
Example
When we visit a website we saw a number of posts that are published in a queue and
according to our requirements, we click on a post and start reading it.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 18
iv. Exclusive-Pair communication model
Exclusive Pair is a bidirectional, fully duplex communication model that uses
a persistent connection between the client and server.
Connection is setup (or persistent), it remains open until the client sends a
request to close the connection. Client and server can send messages to each
other after connection setup.
Exclusive pair is stateful communication model and the server is aware of all
the open connections.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 19
3. IoT Communication APIs
 An API is a set of definitions and protocols for building and integrating application
software. It’s sometimes referred to as a contract between an information provider
and an information user—establishing the content required from the consumer (the
call) and the content required by the producer (the response). For example, the API
design for a weather service could specify that the user supply a zip code and that
the producer reply with a 2-part answer, the first being the high temperature, and
the second being the low.
 In other words, if you want to interact with a computer or system to retrieve
information or perform a function, an API helps you communicate what you want
to that system so it can understand and fulfill the request.
 You can think of an API as a mediator between the users or clients and the
resources or web services they want to get. It’s also a way for an organization to
share resources and information while maintaining security, control, and
authentication—determining who gets access to what.
 Another advantage of an API is that you don’t have to know the specifics of
caching—how your resource is retrieved or where it comes from.

APIs are used to communicate between the server and system in IoT. Some API’s
include:
 REST-based communication APIs
 Websocket based communication API

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 20
i. REST-based communication APIs
Representational state transfer (REST) API (also known as RESTful API) is a set of
architectural principles that used to design web services.
These APIs focus on the systems' resources that how resource states are addressed
and transferred.
REST APIs follow the request-response communication model.
This API uses some architectural constraints. The rest architectural constraint apply
to the components, connector and data elements, within a distributed hypermedia
system.
The rest architectural constraints are as follows (or In order for an API to be
considered RESTful, it has to confirm to these criteria):
 Client-server –

The principle behind the client-server constraint is the separation of concerns.


For example clients should not be concerned with the storage of data which is
concern of the server. Similarly the server should not be concerned about the
user interface, which is concern of the client.
Separation allows client and server to be independently developed and
updated.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 21
Stateless –
Each communication should be independent of others.
Each request from client to server must contain all the information necessary to
understand the request, and (because of stateless) cannot take advantage of any
stored context on the server. The session state is kept entirely on the client.

Cache-able –
Cache constraints requires that the data within a response to a request be implicitly
or explicitly leveled as cache-able or non cache-able.
If a response is cache-able, then a client cache is given the right to reuse that
response data for later, equivalent requests.

Layered system –
Layered system constraints, constrains the behavior of components such that each
component cannot see beyond the immediate layer with they are interacting.
For example, the client cannot tell whether it is connected directly to the end server
or to an intermediary along the way.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 22
Uniform interface –
Uniform interface constraints requires that the method of communication between client and
server must be uniform. It indicates that the server transfers information in a standard format.
The formatted resource is called a representation in REST.
This format can be different from the internal representation of the resource on the server
application. For example, the server can store data as text but send it in an HTML
representation format or Resources are identified in the requests [by URIs (Uniform Resource
Identifiers) in web based systems] and are themselves is separate from the representations of
the resources data returned to the client.
When a client holds a representation of resources it has all the information required to update
or delete the resource (provided the client has required permissions). Each message includes
enough information to describe how to process the message.

Code on demand –
Servers can provide executable code for clients to execute in their context.
this constraint is the only one that is optional.
A RESTful web service is a “Web API ” implemented using HTTP and
REST principles. REST is most popular IoT Communication APIs.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 23
Communication b/w client & server using Rest API

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 24
Request-Response model used by REST:

RESTful webservice is a collection of resources which are represented by URIs.


The clients send requests to these URIs using the methods defined by the HTTP protocol(e.g: GET,
PUT, POST or DELETE). A RESTful web service can support various internet media types.
(JSON - JavaScript Object Notation, Light weight format for storing and transmitting data. It often
used when data is sent from server to webpage.)

When a client request is made via a RESTful API, it transfers a representation of the state of
the resource to the requester or endpoint. This information, or representation, is delivered in
one of several formats via HTTP: JSON (Javascript Object Notation), HTML, Python, PHP,
or plain text. JSON is the most generally popular file format to use because, despite its name,
it’s language-agnostic, as well as readable by both humans and machines.
Compiled By: Dr. Amita Gandhi, Assistant
Professor, GVMITM, Sonipat 25
ii. Websocket-based communication APIs
WebSocket APIs allow bi-directional, full duplex communication between
clients and servers.
WebSocket APIs follow the exclusive pair communication model.
This API uses full-duplex communication so it does not require a new
connection setup every time when it requests new data.
WebSocket API begins with a connection setup between the server and client
and if the WebSocket is supported by the server then it responds back to the
client with the successful response, After the setup of a connection server and
the client can send data to each other in full-duplex mode.
This type of API reduces the traffic and latency of data (as there is no
overhead for connection setup and termination requests for each message) and
makes sure that each time when we request new data it cannot terminate the
request.
Websocket suitable for IoT applications that have low latency or high
throughput requirements.
So Web socket is most suitable IoT Communication APIs for IoT System.

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 26
Compiled By: Dr. Amita Gandhi, Assistant
Professor, GVMITM, Sonipat 27
Difference b/w REST API & Websocket based API

Compiled By: Dr. Amita Gandhi, Assistant


Professor, GVMITM, Sonipat 28

You might also like