4401053 #0
ves}
Internet
* Things
A HANDS-ON APPROACH
Arshdeep Bahga e Vijay Madisetti
Universities Press
REFERENCE BOOK[UNIVERSITIES PRESS (INDIA) PRIVATE LIMITED.
Registered Office
3-6-1478 & 3-6-754/1, Himayatnagar, Hyderabed 500 029 (Telangana), India
E-mail info@anivestespresscom; wowwcuniversitespress.com
Distributed by
Orient Blacks wan Private Limited
Registered Office
5+6-752 Himayainagar, Hyderebad 500 029 (Telangana), India
Other Offices
‘Bengaluru, Bhopal. Chennai, Guwahati, Hyderatac, Jaipur, Kolkata
Lucknow, Mumbai, New Delhi, Noida, Paina, Vijayawada
© Arskdeep Bahen & Vijay Madiseti 2015
All sights reserved. No part ofthis publication may be reproduced, stored ina retrieval system, or transmitted,
in any form or by any means, electronic, mechanical, photocopying, or otherwise, without prior written
permission of the authors Arshdeep Bahga (
[email protected]) and Vijsy Madiseti (vim@
rmadisett.com).
‘First published in India by soiz12
Universities Prese (Indi) Private Limited 2015 x
Reprinted 2016
ISBN 978 81 7371 054.7
ook Website: www internet-ofthings-bock com
23082016
For alin South Asin andthe Mile Fas ony =m
Printed in India at
Seth Informatics, Kolkata 700035
‘Hyderabad $00 029 (Telangana), India
Limit of LiailioyDisclaimer of Warrany auihors have used thelr best efor in
‘preparing tha book, they make no representations with respect to the accuracy or completeness
fof the confents of this book and specifically disclaim any implied warranties of merchantability or fess
for particule purpose. No warranty may be created or extended by sales representatives or written sales
rmaterials, The advice ané strategies contained herein may not be suitable for your situation. You should consult
1 professional where appeepriate. Neither the pubisber nor the authors shall be lable for any los of profi or
ny other commercial éamages, including butnot imited to special, incidental, consequential, cr other damages.
“The publisher and the authorsmakemo representationsor wa:rantes withrespect othe sccuracy or completeness
of the contents of this work and specifically disclaim all warranties including without limitation any implied
‘warrantles of finess for « particular purpose. The fact that an organization or web site i refered toi this wore
8 citation andlor potential source of further infermation does not mean thatthe authors or the publisher
‘endorse the information the organization o: web site may provide or recommendations it may make. Purr,
readers should be aware that Interet web sits listed inthis work may have changed or disappeared between
‘when this work was writen and ihen itis read, No waranty may be created or extended by any promotional
statements for this work. Neither th publisher nor the authors shal be liable for ary damages arising herefiom.I INTRODUCTION & CONCEPTS
1
11
aa
12
124
1.22
13
13.4
182
1.33
14
144
142
Introduction to Internet of Things ..
Introduction
Definition & Characteristics of loT
Physical Design of loT
Things in loT
oT Protocols
Logical Design of loT
JoT Functional Blocks
JoT Communication Models ..
loT Communication APIs ....
loT Enabling Technologies
Wireless Sensor Networks ......
Cloud Computing
QeeReRBs
88eee
1143
144
145
15
154
152
153
154
155
158
25.2
25.3
Big Data Analytics
Communication Protocols
Embedded Systems .
loT Levels & {Deport Template
loT Lovel-t
loT Levet-2
loT Level-3.
loT Level-4
loT Level-5.
loT Lovel-6
ee
Domain Specific loTs ....
Introduction
Home Automation
‘Smart Lighting
‘Smart Appliances
Intrusion Detection . .
‘Smoke/Gas Deteciors ..
Cities
Smart Parking . .
‘Smart Lighting .
‘Smart Roads . ..
Screen Morten
Surveillance . 3 i
Emergency Response.
Environment
Weather Monitoring .
Air Pollution Monitoring
Noise Pollution Monitoring. .
Forest Fire Detection
River Fioods Detection .......
Energy 61
‘Smart Grids 2 1 oa
Renewable Energy ytoms 62
Prognostics. Bas 62At
3.4.2
at
42
424
Retail
Inventory Management . .
‘Smart Payments...
‘Smart Vending Machines
Logistics
Route Generation & Scheduling
Fleet Tracking Rut
Shipment Monitoring»... +++
Remote Vehicle Diagnostics ......
Agriculture
‘Smart Irrigation
Green House Control
Industry
Machine Diagnosis & Prognosis
Indoor Air Quality Monitoring... . % :
Health & Lifestyle n
Health & Fitness Monitoring . . 7
SSSBrSSRR Lees
Wearable Electronics 6.6.66. ee eee neste eer teen ren nne tener eee 72
loT and M2M . 6
Introduction 76
m2 76
Difference between loT and M2M n
SDN and NFV for loT 80
‘Software Defined Networking . 8t
Network Function Virtualization . 85
loT System Management with NETCONF-YANG ... ”
Need for loT Systems Management 92
‘Simple Network Management Protocol (SNMP) 3
Limitations of SNMP... sche ie peace . 9%43 Network Operator Requirements 94
4,4 NETCONF 96
4.8 YANG 97
4.6 _loT Systems Management with NETCONF-VANG 106
4.6.1 NETOPEER . Tee eS Po + 107
It DEVELOPING INTERNET OF THINGS im
5 _loT Platforms Design Methodology ... 113
5.1 Introduction 114
5.2 loT Design Methodology 114
5.2.1 Step 1: Purpose & Requirements Specification al weet
5.2.2 Step 2: Process Specification 7 ' ve 2116
5.2.3 Step 3: Domain Model Specification . sede . 217
5.2.4 Step 4: Information Model Specification . . . . 119
5.25 Step 5: Service Specifications eae . tees * 119
5.26 Step 6: loT Level Specification ...... +--+ a 121
5.27 Step 7: Functional View Specification ma SOP
5.28 Step 8: Operational View Specification . we 125
5.29 Step 9: Device & Component Integration . ie
5.210 Step 10: Application Development . . . anne 127
5.3 Case Study on loT System for Weather Monitoring 127
54 Motivation for Using Python: 131
6 loT Systems - Logical Design using Python .
64 Introduction
6.2 _ Installing Python 141
6.3 Python Data Types & Data Structures 142
63.1 Numbers ....- sascicancha Gani 142
6.3.2 Strings . ooo ee se eeeecr cess 143
633 Lists . 145
634 Tuples... 148635
636
64
644
oa2
643
644
645
646
65
66
67
63
6.10
61
6414
e112
6113
6.114
TA
Tad
12
73
Ta
8
715A
782
753
‘Type Conversions
Control Flow
pass ..
Functions:
Modules:
Packages
File Handling
Date/Time Operations
Classes
Python Packages of Interest for loT
JSON
XML.
HTTPLib & URLLib
SMTPLib . .
loT Physical Devices & Endpoints
‘What Is an loT Device
Basic building blooks of an loT Device
Exemplary Device: Raspberry Pl
‘About the Board
Linux on Respberry PI
Raspberry PI interfaces
Serial wn wei fac F
‘SPI
2c76
76.1
782
783
Ww
774
172
77.8
86.1
o4
92.1
922
Programming Raspberry Pi with Python 196
Controling LED with Raspberry PI. : :
Interfacing an LED and Switch wih Raspbery Pi
Interfacing a Light Sensor (LDR) with Raspberry Pi...
Other loT Devices 193
peDuino......
BeagleBone Black .
Cubleboard ..
loT Physical Servers & Cloud Offerings
Introduction to Cloud Storage Models & Communication APIs 198
WAMP - AutoBahn for loT 198
Xively Cloud for loT 202
Python Web Application Framework Dlengo
Django Architecture
‘Starting Development with Django:
Designing a RESTTul Web API
‘Amazon Web Services for loT
208
218
Amazon EC2 . 225
zr
230
231
284
237
240
249
206
Case Studies Illustrating loT Design . . 253
Introduction Cd
Home Automation 254
‘Smart Lighting 254
268
Home Intrusion Detection93 Cities a7
9:04: Gyre Parting oc: 1S jas.. vas eeeewe Bers
‘specifications for high level communication protocols such as ZigBee. LR-WPAN,
|». standards provide data rates from 40 Kb/s 250 Kb/s. These standards provide low-cost
‘and low-speed communication for power ee ee eee:
‘vw the 802154 standards ae available on the IEEE, 802,15 working group website
1» 2GI3G/4G - Mobile Communication : There are different
- generations of 1
+ Sommunication standards including second generation 2G including GSM and
“is, CDMA), tied generation (3G - including LIMTS and CDMAZ000) and fourth generation
_, GG - inclading LTE), 1oT devices based on these. standards can ‘over
|» /ellular networks, Data rates for these standards range from 9.6 :2G) 10 upto
© "100 Mis (for 4G) and are available from the 3GPP. websites,28 Int
juction to Internet of Things
Network/internet Layer
The network layers are responsible for sending of IP datagrams from the source network.
to the destination network. This layer performs the host addressing and packet routing.
‘The datagrams contain the source and destination addresses which are used to route them
from the source to destination across multiple networks. Host identification is done using
hierarchical IP addressing schemes such as IPv4 or IPV6.
‘¢ IPv4:: Imemet Protocol version 4 (IPy4) is the most deployed Internet protacol tha is
used to identify the devices on @ network using a hiecarchical addressing scheme. [Pv
uses @ 32-bit address scheme that allows total of 2°” or 4,294,967,296 addresses. As
‘more and more devices got connected to the Intemet, these addresses got exhausted
in the year 2011, TPv4 has been succeeded by IPv6. The IP protocols establish
connections on packet networks, but do not guarantee delivery of packets. Guaranteed
delivery and data integrity are handled by the upper layer protocols (such as TCP).
IPv4 is formally described in RFC 791 [6].
‘* IPv6 + Internet Protocol version 6 (IPv6) is the newest version of Intemet protocol
and successor to IPv4. IPv6 uses 128-bit address scheme that allows total of 2!78 or
3.4 x 10°8 addresses. IPv4 is formally described in RFC 2460 (7].
© GLOWPAN : 6LoWPAN (IPv6 over Low power Wireless Personal Area Networks)
brings IP protocol to the low-power devices which have limited processing capability.
GLoWPAN operates in the 2.4 GHz frequency range and provides data transfer rates
of 250 Kb/s. 6LoWPAN works with the 802.15.4 link layer protocol and defines
compression mechanisms for IPV6 datagrams over IEEE 802.15.4-based networks
(81.
Transport Layer
‘The transport layer protocols provide end-to-end message transfer capability independent
of the underlying network. The tnessage transfer capability can be set up on connections,
«either using handshakes (as in TCP) of without handshakea/acknowledgements (as in UDP).
‘The transport layer provides functions such as error control, segmentation, flow control and
congestion control
© ‘TCP : Transmission Control Protocol (TCP) is the most widely used transport layer
‘Protocol, that is used by web browsers (along with HTTP. HTTPS application layer
protocols), email programs (SMTP application layer protocol) and file transfer (FTP).
‘TCP is a connection oriented and stateful protocol. While IP protocol deals with
sending packets, TCP onsures reliable transmission of packets in-order. TCP also
‘provides error detection capability so that duplicate packets can bbe discarded and
lost packets are retransmitted. The flow control capability of TCP ensures that
Bahga & Madisett, © 20151.2: Physical Design of loT 29
rate at which the sender sends the data is not too high for the receiver to process.
‘The congestion control capability of TCP helps in avoiding network congestion and
congestion collapse which can lead to degradation of network performance, TCP is
escribed in RFC 793 [9].
© UDP: Unlike TCP, which requires carrying out an initial setup procedure, UDP is a
connectionless protocol. UDP is useful for time-sensitive applications that have very
smal] data units to exchange and do not want the overhead of connection setup. UDP
is a transaction oriented and stateless protocol. UDP does not provide guaranteed
delivery, ordering of messages and duplicate elimination. Higher levels of protocols
can ensure reliable delivery or ensuring connections created are reliable. UDP is
Gescribed in RFC 768 [10].
Application Layer
Application layer protocols define how the applications interface with the lower layer
protocols to send the data over the network. The application data, typically in files, is
encoded by the application layer protocol and encapsulated in the transport layer protocol
‘which provides connection or transaction oriented communication over the network. Port
numbers are used for application addressing (for example port 80 for HTTP, port 22 for SSH,
ctc.). Application layer protocols enable process-to-process connections using ports.
+ HTTP : Hypertext Transfer Protocol (HTTP) is the application layer protocol that
forms the foundation of the World Wide Web (WWW). HTTP includes commands
such as GET, PUT, POST, DELETE, HEAD, TRACE, OPTIONS, etc. The protocol
follows a request-response model where a client sends fequests to @ server using the
HTTP commands. HTTP is a stateless protocol and each HTTP request is independent
of the other requests, An HTTP client can be a browser or an application running
‘on the client (.g., at application running on an IoT device, a mobile application or
‘other software). HTTP protocol uses Universal Resource Identifiers (URIs) to identify
HTTP resources. HTTP is described in RFC 2616 (11).
'» CoAP : Constrained Application Protocol (CoAP) is an application layer protocol for
‘machine-to-machine (M2M) applications, meant for constrained environments with
constrained devices and constrained networks. Like HTTP, CoAP is a web tansfer
‘protocol and uses a request-respnse model, however it runs on top of UDP insiead of
‘TCR. CoAP uses a client-server architecture where clients communicate with servers
Using connectionless datagrams, CoAP is designed to casily interface with HTTP.
Like HTTP, CoAP supports methods such as GET, PUT, POST, and DELETE. CoAP
‘draft specifications are available on IEFT Constrained environments (CoRE) Working
Group website (12).
intemot of Things “A Hands-On ApproachIntroduction to internet of Things
© WebSocket : WebSocket protocol allows full-duplex communication over a single
socket connection for sending messages between client and server. WebSocket is
‘based on TCP and allows streams of messages to be sent back and forth between the
client and server while keeping the TCP connection open. The client can be a browser,
a mobile application or an ToT device. WebSocket is described in RFC 6435 (13).
‘¢ MOTT : Message Queue Telemetry Transport (MQTT) is a light-weight messaging
‘protocol based on the publish-subscribe model. MQTT uses a client-server architecture
where the client (such as an IoT device) connects to the server (also called MOTT
Broker) and publishes messages to topics on the server. The broker forwards the
‘messages to the clients subscribed to topics. MQTT is well suited for constrained
environments where the devices have limited processing and memory resources
and the network bandwidth is low. MQTT specifications are available on IBM.
¢ XMPP : Extensible Messaging and Presence Protocol (XMPP) is « protocol for
real-time communication and streaming XML data between network entities. XMPP
powers wide range of applications including messaging, presence, data syndication,
‘gaming, multi-party chat and voice/video calls. XMPP allows sending small chunks
of XML data from one network entity to another in near real-time. XMPP is a
decentralized protocol and uses a client-server architecture, XMPP supports both
Client-to-server and server-o-server communication paths. In the context of IoT,
"XMPP allows real-time communication between loT devices. XMPP is described in
REC 6120 [i5}.
‘* DDS : Data Distribution Service (DDS) is a data-centric middleware standard for
device-to-device or machine-to-machine communication. DDS uses a publis
model where publishers (e.g. devices that generate data) create topics to which
subscribers (¢.g.. devices that want to consume data) can subscribe. Publisher is an
‘object responsible for data distribution and the subscriber is responsible for receiving
published data, DDS provides quality-of-service (QoS) contzol and configurable
‘clability. DDS is described in Object Management Group (OMG) DDS specification {16).
cither delivered by the broker to the consumers which have subscribed to the quewes
‘or the consumers can pull the messages from the queues. AMQP specification is
Bahga & Madiset, © 20151.8 Logical Design of loT 31
available on the AMQP working group website [17]
1.3 Logical Design of loT
Logical design of an oT system refers to an abstract representation of the entities and
processes without going into the low-level specifics of the implementation. In this section
‘we describe the functional blocks of an ToT system and the communication APIs that are
used for the examples in this book, The steps in logical design are described in additional
detail in Chapter-5.
1.3.1. loT Functional Blocks
‘An IoT sysiem comprises of a number of functional blocks that provide the system the
capabilities for identification, sensing, actuation, communication, and management as shown
in Figure 1.6. These functional blocks are described as follows:
‘¢ Device : An IoT system comprises of devices that provide sensing, actuation, monitoring
and control functions. You learned about IoT devices in section 1.2,
‘© Communication : The communication block handles the communication for the IoT
system, You learned about various protocols used for communication by ToT systems
in section 1.2,
‘© Services : An IoT system uses various types of IoT services such as services for
device monitoring, device control services, data publishing services and services for
device discovery.
‘+ Management : Management functional block provides various functions to govern
the [oT system.
© Security Security functional block secures the 1oT system and by providing functions
such as authentication, authorization, message and content integrity, and dete security.
© Application : [oT applications provide an interface that the users can use to control
‘and monitor various aspects of the IoT system. Applications also allow users to view
the system status and view or analyze the processed data.
1.3.2. loT Communication Models
‘« Request-Response : Request-Response is a communication model in which the
client sends requests to the server and the server responds to the requests. When
the server receives a request, it decides how to respond, ferches the data, retrieves
resource representations, prepares the response, and then sends the response to
the client. Request-Response model is a statcless communication model and each
request-response pair is independent of others. Figure 1.7 shows the client-server
Bn
Internet of Things ~ A Hands-On ApproachFigure 1.6: Functional Blocks of oT
Figure 1.7: Request-Response communication model
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.
‘When the broker reccives data for a topic from the publisher, it sends the data to all the
subscribed consumers. Figure 1.8 shows the publisher-broker-consumer interactions
‘Bahga & Madisetti, © 2015Logical Design of loT
Figure 1.9: Push-Pull communication model
in the publish-subseribe model.
« Push-Pull : Push-Pall is a communication model in which the data producers push the
‘data to queues and the consumers pull the data fromthe queues. Producers do not need
to be aware of the consumers. Queues help in decoupling the messaging between the
producers and 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 rate
at which the consumers pull data. Figure 19 shows the publses-queuesconsumer
interactions in the push-pull model.
¢- Bxchusive Pair: Exclusive Pairs a bi-iectonal, fully duplex communication model
Intgmet of Things - A Hands-On ApproachIntroduction to Internet of Things
Response accepting the request
‘Message from Clent to Server
Connection close response
Figure 1.10: Exchisive Pair communication model
‘that uses a persistent connection between the client and server, Once the connection is
setup it remains open until the client sends a request to close the connection. Client
and server can send to each other after connection setup. Exclusive pair is
‘a stateful communication model and the server is aware of all the open connections.
Figure 1.10 shows the client-server interactions in the exclusive pair model.
1.3.3 loT Communication APIs
In the previous section you leamed about various communication models, In this section
you will learn about two specific communication APIs which are used in the examples in
this book.
REST-based Communication APIs.
Representational State Transfer (REST) [88] is a set of architectural principles by which
you can design web services and web APIs that focus on a system's resources and how
resource states are addressed and transferred. REST APIs follow the request-response
communication model described in previous section. The REST architectural constraints
apply to the components, connectors, and data clements, within a distributed hypermedia
system, The REST architectural constraints are as follows
eee
‘Behga & Madisett. © 2015Figure 1.11; Communication with REST APIs
» 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 a concern of the server. Similarly, the server should not be concemed about the user
interface, which is a concer of the client. Separation allows client and server to be
‘independently developed and updated.
Stateless: Each request from client to server must contain all the information necessary
to understand the request, and cannot take advantage of any stored context on the
server, The session state is kept entirely on the client,
+ Cache-able: Cache constraint requires that the data within a response to a request
bbe implicitly or explicitly labeled as cache-able or non-cache-able. If a response is
ccache-able, then a client cache is given the right to reuse that response data for later,
equivalent requests. Caching can partially or completely eliminate some interactions
and improve efficiency and scalability.
# Layered System: Layered system constraint, constrains the behavior of components
such that each component cannot see beyond the immediate layer with which they are
interacting, For example, a client cannot tell whether it is connected directly to the
end server, or to an intermediary along the way. System scalability can be improved
Internet of Things -36 Introduction to Intemet of Things
REST
(gen a]
Request (GET, PUT, UPDATE or DELETE)
‘with payload (SON or XML)
Response SON or XM)
—— eee
Request (GET, PUT, UPDATE or DELETE)
‘with peyloud (SON or VL)
Response USON or xi)
| mee ee
re
Figure 1.12: Request-response model used by REST
by allowing intermediaries to respond to requests instead of the end server, without
the client having to do anything different.
‘© Uniform Interface: Uniform Interface constraint requires that the methed of
‘communication between a client and a server mast be uniform, Resources are identified
in the requests (by URIs in web based systems) and are themselves separate from the
‘representations of the resources that are returned to the client. When a client holds
a representation of a resource 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 or scripts for clients to execute
in their context, This constraint is the only one that is optional.
‘A RESTYul web service is a "web API” implemented using HTTP and REST principles.
Figure 1.1 shows the communication between client and server using REST APIs. Figure 1.12
shows the interactions in the request-response model used by REST, RESTful web service
is a collection of resources which are represented by URIs. RESTful web API has a base
URI (eg, htipi//example.com/api/tasks/). The clients send requests to these URIs using the
ee Se re
Banga & Ni ©20151.3 Logical Design of loT 7
Get information | http:/cxample.com/api/tasks/1/
fer mem | Sart tamara
feet lowe Ee
used
‘hutp://example.com/apiftasks/1/
Blement URI | UPdate | (update task-1 with data
oe provided in the request)
Delete a | hitp://example.com/api/tasks/1/
eee lew De Soe|
‘Table 1.1: HTTP request methods and actions
methods defined by the HTTP protocol (e.g.. GET, PUT, POST. or DELETE), as shown in
‘Table 1.1, A RESTIul web service can support various Interne: media types (ISON being the
‘most popular media type for RESTful web services) IP for Smart Objects Alliance (IPSO
‘Alliance) has published an Application Framework that defines a RESTful design for use in
IP smart object systems [18].
‘WebSocket-based Communication APIs
‘WebSocket APIs allow bi-directional, full duplex communication between clients and servers,
WebSocket APIs follow the exclusive pair communication model described in previous
seetion and as shown in Figure 1.13. Unlike request-response APIs such os REST, the
Internet of Things - A Hands-On Approach38 Introduction to Internet of Things
‘WebSocket Protocol
Request to setup wetsochet Connection
nil Handshake
Response accepting the reaues (over)
Date fame
‘idrectoral emmunication
{over persistent
iebSodet cormecton)
tH |
jf comecoctn
Figure 1.13: Exclusive pair model used by WebSocket APIs
‘WebSocket APIS allow full duplex communication and do not require a new connection to
be setup for each message to be sent. WebSocket communication begins with a connection
setup request sent by the client to the server. This request (called a WebSocket handshake)
is sent over HTTP and the server interprets it as an upgrade request. If the server supports
‘WebSocket protocol, the server responds to the WebSocket handshake response. After the
connection is setup, the client and server can send data/messages to each other in full-duplex
‘mode, WebSocket APIs reduce the network traffic and latency as there is no overhead for
connection setup and termination requests for each message. WebSocke! is suitable for ToT
applications that have low latency or high throughput requirements.
1.4 loT Enabling Technologies
Io is enabled by several technologies including wireless sensor networks, cloud computing,
big data analytics, embedded systems, security protocols and architectures, communication
protocols, web services, mobile Internet, and semantic search engines. This section provides
‘an overview of some of these technologies which play a key-role in IoT.
eee
Bahge & Macisetl, © 20131.4 loT Enabling Technologies:
Wiroless Sensor Networks
[A Wireless Sensor Network (WSN) comprises of distributed devices with sensors which are
used to monitor the environmental and physical conditions. A WSN consist of a number
of end-nodes and routers and a coordinator. End nodes have several sensors attached to
them; End nodes can also act as routers, Routers are responsible for routing the data packets
from end-nodes to the coordinator. The coordinator collects the data from all the nodes.
Coordinator also acts as a gateway that connects the WSN to the Internet, Some examples of
WSNS used in IoT systems are described as follows:
‘© Weather monitoring systems use WSNs in which the nodes collect temperature,
humidity and other data, which is aggregated and analyzed.
‘» Indoor air quality monitoring systems use WSNs to collect data on the indoor air
{quality and concentration of various gases.
‘ Soil moisture monitoring systems use WSNs to monitor soil moisture at various
locations.
‘# Surveillance systems use WSNs for collecting surveillance data (such as motion
detection data)
‘© Smart grids use WSNs for monitoring the grid at various points.
‘» Structural health monitoring systems use WSNs to monitor the health of structures
(buildings, bridges) by collecting vibration data from sensor nodes deployed at various
points in the structure,
WSN are enabled by wireless communication protocols such as IEEE 802.15.4. ZigBee
{sone of the most popular wireless technologies used by WSNs. ZigBee specifications are
based on IEEE 802.15.4. ZigBee operates at 2.4 GHz frequency and offers data rates upto
280 KB/s and range from 10 to 100 meters depending on the power output and environmental
conditions. The power of WSNS lies in their ability to deploy large number of low-cost
and low-power sensing nodes for continuous monitoring of environmental and physical
conditions. WSNs are self-organizing networks. Since WSNs have large number of nodes,
‘manual configuration for each node is not possible, The self-organizing capability of WSN
makes the network robust. In the event of failure of some nodes or addition of new nodes to
the network, the network can reconfigure itself.
1.42 Cloud Computing
Cloud computing is a transformative computing paradigm that involves delivering applications
and services over the Internet. Cloud computing involves provisioning of computing.
networking and storage resources on demand and providing these resources as metered:
services to the users, ina "pay as you go” model, Cloud computing resources can be
provisioned on-demand by the users, without requiring interactions with the cloud service
Inieenet of Things ~ A Hands-On Approach40 Introduction to Internet of Things
provider. The process of provisioning resources is automated. Cloud computing resources
ccan be accessed over the network using standard access mechanisms that provide
platform-independent access through the use of heterogeneous client platforms such as
‘workstations, laptops, tablets and smart-phoncs. The computing and storage resources
provided by cloud service providers are pooled to serve multiple users using multi-tenancy.
Multi-tenant aspects of the cloud allow multiple users to be served by the same physical
hardware. Users are assigned virtual resources that run on top of the physical resources.
Cloud computing services are offered to users in different forms (see the authors’
‘companion book on Cloud Computing, for instance):
¢# Infrastructure-as-a-Service (laaS) : IaaS provides the users the ability to provision
computing and storage resources. These resources are provided to the users as virtual
machine instances and virtual storage. Users can start, stop, configure and manage
the virtual machine instances and virtual storage. Users can deploy operating systems
and applications of their choice on the virtual resources provisioned in the cloud.
‘The cloud service provider manages the underlying infrastructure, Virtual resources
provisioned by the users are billed based on a pay-per-use paradigm.
« Platform-as-#-Service (PaaS) : PaaS provides the users the ability to develop and
deploy application in the cloud using the development tools, application programming
interfaces (APIs), software libraries and services provided by the cloud service
provider. The cloud service provider manages the underlying cloud infrastructure
including servers, network, operating systems and storage. The users, themselves, are
responsible for developing, deploying, configuring and managing applications on the
cloud infrastructure,
+ Software-as-a-Service (SaaS) : SaaS provides the users a complete software application
or the user interface to the application itself. The cloud service provider manages
the underlying cloud infrastructure including servers, network, operating systems,
storage and application software, and the user is unaware of the underlying architecture
of the cloud. Applications are provided to the user through @ thin client interface
(e.g., a browser). SaaS applications are platform independent and can be accessed
from various client devices such as workstations, laptop, tablets and smart-phones,
running different operating systems. Since the cloud service provider manages both
the application and data, the users are able to access the applications from anywhere.
Big data is defined as collections of data sets whose volume, velocity (in terms of its temporal
variation), or variety, is so large that it is difficult to store, manage, process and analyze
the data using traditional databases and data processing tools. Big data analytics involves
Bahga & Madsett, © 2015,|
|
1.4 loT Enabling Technologies 44
several steps staring from data cleansing, data munging (or wrangling), data processing and
visualization. Some examples of big data generated by IoT systems are described as follows:
‘¢ Sensor data generated by IoT systems such as weather monitoring stations.
‘¢ Machine sensor data collected from sensors embedded in industrial and energy systems
for monitoring their health and detecting failures,
¢ Health and fitness data generated by IoT devices such as wearable ftness bands,
Data generated by IoT systems for location and tracking of vehicles.
‘¢ Data generated by retail inventory monitoring systems.
‘The underlying charecteristics of big data include:
‘* Volume: Though there is no fixed threshold for the volume of data to be considered
as big data, however, typically, the term big data is used for massive scale data that is
difficult to store, manage and process using traditional databases and data processing
architectures. The volumes of data generated by modem IT, industual, and health-care
systems, for example, is growing exponentially driven by the lowering costs of data
Stomage and processing architectures and the need to extract valuable insights from the
data to improve business processes, efficiency and service to consumers.
# Velocity: Velocity is another important characteristic of big data and the primary
reason for exponential growth of data. Velocity of data refors to how fast the data is
generated and how frequently it varies. Modern IT, industrial and other systems are
generating dara at increasingly higher speeds.
© Variety: Variety refers to the forms of the data. Big data comes in different forms
such as structured or unstructured data, including text data, image, audio, video and
sensor data,
4.44 Communication Protocols
‘Communication protocols form the backbone of IoT systems and cnable network connectivity
and coupling to applications. Communication protocols allow devices to exchange data
cover the network. In section 1.2.2 you learned about various link, network, transport
and application layer protocols. These protocols define the data exchange formats, data
‘encoding, addressing schemes for devices and routing of packets from source to destination.
Other functions of the protocols include sequence control (that helps in ordering packets,
etermining lost packets) flow control (that helps in controlling the rate at which the sender
is sending the data so that the receiver or the network is not overwhelmed) and retransmission
of lost packets.
Internet of Things - A Hands-On Approach42 Introduction to Intemet of Things
1.4.5 Embedded Systems
‘An Embedded System is a computer system that has computer hardware and software
embedded to perform specific tasks. In contrast to general purpose computers or personal
computers (PCs) which can perform various types of tasks, embedded systems are designed
to perform a specific set of tasks. Key components of an embedded system include,
microprocessor or microcontroller, memory (RAM, ROM, cache), networking units (Ethernet,
WiFi adapters), inpuoutput units (display, keyboard, etc.) and storage (such as flash
memory). Some embedded systems have specialized processors such as digital signal
processors (DSPs), graphics processors and application specific processors, Embedded
systems run embedded operating systems such as real-time operating systems (RTOS).
Embedded systems range from low-cost miniaturized devices such as digital watches to
devices such as digital cameras, point of sale terminals, vending machines, appliances (such
as washing machines), etc, In the next chapter we describe how such devices form an integral
part of IoT systems.
1.5 loT Levels & Deployment Templates
[In this section we define various levels of IoT systems with increasing completely. An loT
system comprises of the following components:
‘« Device: An IoT device allows identification, remote sensing, actuating and remote
‘monitoring capabilities. You leamed about various examples of IoT devices in section
124.
‘* Resource: Resources are software components on the IoT device for accessing,
processing, and storing sensor information, or controlling actuators connected to the
device. Resources also include the software components that enable network access
for the device
‘« Controller Service: Controller service is a native service that runs on the device
and interacts with the web services. Controller service sends data from the device to
the web scrvice and receives commands from the application (via web services) for
controlling the device,
+ Database: Database can be either local or in the cloud and stores the data generated
by the [oT device.
«Web Service: Web services serve as a link between the IoT device, application,
database and analysis components. Web service can be either implemented using
HTTP and REST principles (REST service) or using WebSocket protocol (WebSocket
service), A comparison of REST and WebSocket is provided below:
Bahga & Madisett, ©20151.5 loT Levels & Deployment Templates 43
= Stateless/Stateful: REST services are statcless in nature. Each request contains
all the information needed to process it. Requests are independent of each other
‘WebSocket om the other hand is stateful in nature where the server maintains the
state and is aware of all the open connections,
~ Uni-directional/Bi-directional: REST services operate over HTTP and are
uni-directional, Request is always sent by a client and the server responds 10 the
requests. On the other hand, WebSocket is a bi-directional protocol and allows
both client and server to send messages to each other,
~ Request-Response/Full Duplex: REST services follow a request-response
‘communication model where the client sends requests and the seryer responds
to the requests, WebSocket on the other hand allow full-duplex communication
between the client and server, ie., bath client and server can send messages to
each other independently.
~ TCP Connections: For REST services, cach HTTP request involves setting up
‘a new TCP connection. WebSocket on the other hand inyolyes a single TCP
‘connection over which the elient and server communicate in a full-duplex mode.
~ Header Overhead: REST services operate over HTTP, and each request is
independent of others. Thus each request carries HTTP headers which is an
‘overhead. Due the overhead of HTTP headers, REST is not suitable for real-time
applications. WebSocket on the other hand does not involve overhead of headers.
‘After the initial handshake (that happens over HTTP), the client and server
exchange messages with minimal frame information, Thus WebSocket is suitable
for real-time applications,
= Scalability: Scalability is casier in the case of REST services as requests are
independent and no state information needs to be maintained by the server.
‘Thus both horizontal (scaling-out) and vertical scaling (scaling-up) solutions
“ are possible for REST services. For WebSockets, horizontal scaling can be
cumbersome due to the stateful nature of the communication. Since the server
‘maintains the state of a connection, vertical scaling is easier for WebSockets
than horizontal scaling.
‘Analysis Component: The Analysis Component is responsible for analyzing the ToT
‘daia and generate resulis in a form which are easy for the user to understand. Analysis
of 1dT data can be performed either locally or in the cloud. Analyzed results ae stored
iin the local or cloud databases.
_@ Application: IoT applications provide an interface that the users can use to control
and monitor various aspects of the JoT system. Applications also allow users to view
the system status and view the processed data.
jf Things A Hands-On Approach1.5.1. loT Level-t
{A Ievel-1 JOT system has a single node/device that performs sensing and/or actuation, stores
data, performs analysis and hosts the application as shown in Figure 1.14, Level-1 ToT
systems are suitable for modeling low-cost and low-complexity solutions where the data
involved is not big and the analysis requirements are not computationally intensive.
Let us now consider an example of 4 level-1 Jo system for home automation. "The
system consists of a single node that allows controlling the lights and appliances in a home
remotely. The device used in this system interfaces with the lights and appliances using
electronic relay switches. The status information of each light or appliance is maintained in
«local database, REST services deployed locally allow retrieving and updating the state of
cach light or appliance in the status database. The controller service continuously monitors,
the state of each light or appliance (by retrieving state from the database) and triggers the
relay switches accordingly. The application which is deployed locally has a user interface
for controlling the lights or appliances. Since the device is connected to the Intemet, the
application can be accessed remotely as well.
15.2 loT Level-2
‘A level-2 IoT system has a single node that performs sensing and/or actuation and local
analysis as shown in Figure 1.15. Data is stored in the cloud and application is usually
cloud-based. Level-2 IoT systems are suitable for solutions where the data involved is big,
however, the primary analysis requirement is not computationally intensive and can be done
locally itselt.
Let us consider an example of a Ievel-2 IoT system for smart irrigation, The system
consists of a single node that monitors the soil moisture level and controls the irrigation
system. The device used in this sysiem collects soil moisture data from sensors. The
controller service continuously monitors the moisture levels. If the moisture level drops
below a threshold, the irrigation system is tumed on, For controlling the irrigation system
actuators such as solenoid valves can be used, The controller also sends the moisture data to
the computing cloud. A cloud-based REST web service is used for storing and retricving.
moisture data which is stored in the cloud database, A cloud-based application is used for
visualizing the moisture levels over a period of time, which can help in making decisions
about irrigation schedules.
1.5.3 loT Level-3
A level-3 IoT system has a single node. Data is stored and analyzed in the cloud and
application is cloud-based as shown in Figure 1.16. Level-3 ToT systems are suitable for
Bahga & Madisott, © 2015Cloud
‘REST/Websocket
Communication
Monitorirg Node
perforrs analysis, stores cata
Figure 1.14: IoT Level“
ns where the data involved is big and the analysis requirements are computationally
Let us consider an example of a level-2 ToT system for tracking package handling. The
‘consists of a single node (for a package) that monitors the vibration levels for a
‘being shipped. The device in this system uses accelerometer and gyroscope sensors
itoring vibration levels. The controller service sends the senisor data to the cloud
using a WebSocket service. The data is siored in the cloud and also visualized
based application. The analysis components in the cloud can trigger alerts if
pet of Things - A Hands-On Approach46 Introduction to Internet of Things
loT Level-2
Cloud
Local
REST/Websocket
Communication
Monitoring Node |
Figure 1.15: ToT Level-2
the vibration levels become greater than a threshold. The benefit of using WebSocket service
instead of REST service in this example is that, the sensor data can be sent in real time to the
cloud. Moreover, cloud based applications ean subscribe to the sensor data feeds for viewing
the real-time data.
1.5.4 loT Level-4
A level-4 IoT system has multiple nodes that perform local analysis. Data‘is stored in the
load and application is cloud-based as shown in Figure 1.17. Level-4 contains local and
‘Bahga & Madisoti, © 20154,5 loT Levels & Deployment Templates 47
loT Level-3
Local Cloud
1
REST/WebSocket
Communication
REST/WebSocket
Communication
‘Monitoring Node
loud storage & Analysis
Figure 1.16: lof Level-3
cloud-based obsecver nodes which can subscribe to and receive information collected in
the cloud from IoT devices. Observer nodes can process information. and use it for various
applications, however, observer nodes do not perform any control functions. Leyel-4 ToT
systems are suitable for solutions where multiple nodes are required, the data involved is big
and the analysis requirements are computationally intensive.
Let us consider an example of a level-4 [oT system for noise monitoring. The system
consists of multiple nodes placed in different locations for monitoring noise levels in an area.
Internet of Things ~ A Hands-On Approach48 Introduction to Internet of Things:
‘The nodes in this example are equipped with sound sensors. Nodes are independent of each
other. Each node runs its own controller service that sends the data to the cloud. The data is
‘stored in a cloud database. The analysis of data collected from a number of nodes is done in
the cloud. A cloud-based application is used for visualizing the aggregated data.
155 loT Level-5
‘A levels [oT system has multiple end nodes and one coordinator node as shown in
Figure 1.18. The end nodes that perform scasing end/or actuation. Coordinator node
collects data from the end nodes and sends to the cloud. Data is stored and analyzed in the
‘loud and application is cloud-based. Level-5 ToT systems are suitable for solutions based
‘on wireless sensor networks, in which the data involved is big and the analysis requirements
are computationally intensive.
Lot us consider an example of a level-5 1oT system for forest fire detection. The system
‘consists of multiple nodes placed in different locations for monitoring temperature, humidity
and carbon dioxide (COs) levels in « forest. The end nodes in this example are equipped with
ee
Bags & Maciget, © 2013!
eeor
15 loT Levels & Deployment Templates 49
‘various sensors (such as temperature, humidity and CO). The coordinator node collects
the data from the end nodes and acts as a gateway that provides Internet connectivity to the
ToT system. The controller service on the coordinator device sends the collected datato the
cloud. The data is stored in a cloud database. The analysis of data is done in the computing
cloud to aggregate the data and make predictions. A cloud-based application is used for
visualizing the data.
loT Level-5
Local
Figure 1.18: IoT Level-S
15.6 loT Level-é
‘A Jevel-6 JoT system has multiple independent end nodes that perform sensing and/or
‘actuation and send data to the cloud, Datais stored in the cloud and application is eloud-based
‘as shown in Figure 1.19. The analytics component analyzes the data and stores the results
inthe cloud database. The results are visualized with the cloud-based application. ‘The
‘centralized controller is aware of the status of all the end nodes and sends control commands
Internet of Things - A Hands-On ApproachIntroduction to Internet of Things
to the nodes.
Let us consider an example of a Jevel-6 IoT system for weather monitoring: "The
system consists of multiple nodes placed in different locations for monitoring temperature,
‘humicity and pressure in an area. ‘The end nodes are equipped with various sensors (such 4s,
‘temperature, pressure and humidity). The end nodes send the data to the cloud in real-time
using a WebSocket service. The data is stored in a cloud database. The analysis of data is
done in the cloud to aggregate the data and make predictions. A cloud-based application is
used for visualizing the data,
loT Level-5
Local Cloud
ee
~~ content
Cowoler, oud trae
nae
Figure 1.19: loT Level-6
Summary
Internet of Things (IoT) refers to physical and virtual objects that have unique identities
and are connected to the Internet. This allows the development of intelligent applications
that make energy, logistics, industrial control, revail, agriculture and many other domains of
Bahga'& Madisati, © 2015