IOT-Unit V
IOT-Unit V
Deployment models
Deployment in cloud computing comprises four deployment models: private cloud, public cloud,
community cloud and hybrid cloud.
A cloud storage API is an application program interface that connects a locally-based application to a
cloud-based storage system, so that a user can send data to it and access and work with data stored in
it. To the application, the cloud storage system is just another target device, like tape or disk-based
storage. An application program interface (API) is code that allows two software programs to
communicate with each other. The API defines the correct way for a developer to write a program
that requests services from an operating system (OS) or other application. APIs are implemented by
function calls composed of verbs and nouns. The required syntax is described in the documentation
of the application beingcalled
Three basic types of APIs
APIs take three basic forms: local, web-like and program-like.
1. Local APIs are the original form, from which the name came. They offer OS or middleware
services to application programs. Microsoft's .NET APIs, the TAPI (Telephony API) for voice
applications, and database access APIs are examples of the local APIform.
2. Web APIs are designed to represent widely used resources like HTML pages and are accessed
using a simple HTTP protocol. Any web URL activates a web API. Web APIs are often called REST
(representational state transfer) or RESTful because the publisher of REST interfaces doesn't save
any data internally between requests. As such, requests from many users can be intermingled as they
would be on theinternet.
3. Program APIs are based on remote procedure call (RPC) technology that makes a remote
program component appear to be local to the rest of the software. Service oriented architecture
(SOA) APIs, such as Microsoft's WS-series of APIs, are programAPIs.
– Dealer: Dealer acts a router and routes RPC calls from the Caller to the Callee and routes results
from Callee to Caller.
• Application Code: Application code runs on the Clients (Publisher, Subscriber, Callee or Caller).
In RPC model client can have following roles: –
1. Caller: Caller issues calls to the remote procedures along with call arguments. – Callee: Callee
executes the procedures to which the calls are issued by the caller and returns the results back to the
caller. • Router: Routers are peers that perform generic call and event routing. In publish-subscribe
model Router has the role of a Broker: – Broker: Broker acts as a router and routes messages
published to a topic to all subscribers subscribed to thetopic.
In RPC model Router has the role of a Broker: –
1. Dealer: Dealer acts a router and routes RPC calls from the Caller to the Callee and routes results
from Callee toCaller.
2. Application Code: Application code runs on the Clients (Publisher, Subscriber, Callee or Caller).
• APIs provides services for logging, sharing and displaying sensor data of all
Xively Support
•The platform supports the REST, WebSockets and MQTT protocols and connects the devices to
Xively Cloud Services
• Native SDKs for Android, Arduino, ARM mbed, Java, PHP, Ruby, and Python languages
• Developers can use the workflow of prototyping, deployment and management through the
tools provided at Xively
Xively APIs
• Enable interface with Python, HTML5, HTML5 server, tornado
• Interface with WebSocket Server and WebSockets
• Interface with an RPC (Remote Procedure Call).
Xively PaaS services
• Enables services
• Business services platform which connects the products, including collaboration products
• Rescue, Boldchat, join.me, and operations to Internet
• Data collection in real-time over Internet
Xively Methods for IoT Devices Data
•Concept of users, feeds, data streams, data points and triggers
• Data feed typically a single location (e.g. a device or devices network),
• Data streams are of individual sensors associated with that location (for example, ambient
lights, temperatures, power consumption).
• Pull or Push (Automatic or Manual Feed)
Xively Data formats and Structures
• Number of data formats and structures enable the interaction, data collection and services
• Support exists for JSON , XML and CSV
• Structures: Tabular, spreadsheet, Excel, Data numbers and Text with a comma-separated values
in file
Xively Uses in IoT/M2M
• Private and Public Data Access
• Data streams, Data points and Triggers
• Creating and Managing Feeds
• Visualising Data
5.4 Django
Django is an open source web application framework for developing web applications in Python.
• A web application framework in general is a collection of solutions, packages and best practices
that allows development of web applications and dynamic websites.
• Django is based on the Model-Template-View architecture and provides a separation of the data
model from the business rules and the user interface.
• Django provides a unified API to a database backend.
• Thus web applications built with Django can work with different databases without requiring any
code changes.
• With this fiexibility in web application design combined with the powerful capabilities of the
Python language and the Python ecosystem, Django is best suited for cloud applications.
• Django consists of an object-relational mapper, a web templating system and a regular-expression
based URL dispatcher. Django is Model-Template-View (MTV) framework.
Model The Model represents the data structure and business logic of the application. It defines the
database schema and handles interactions with the database.
• The model acts as a definition of some stored data and handles the interactions with the database. In
a web application, the data can be stored in a relational database, non-relational database, an XML
file, etc. A Django model is a Python class that outlines the variables and methods for a particular
type of data.
The Template is responsible for the presentation and rendering of the user interface. It
Template defines how the data from the models should be displayed to the user.
• In a typical Django web application, the template is simply an HTML page with a few extra
placeholders. Django’s template language can be used to create various forms of text files (XML,
email, CSS, Javascript, CSV, etc.)
The View handles the logic of the application, processes user requests, and interacts with
View models to retrieve data. Views in Django are Python functions or classes that receive HTTP
requests, process them, and return HTTP responses, often rendered using templates.
• The view ties the model to the template. The view is where you write the code that actually
generates the web pages.
View determines what data is to be displayed, retrieves the data from the database and passes the
data to the template.
5.5 Designing a RESTful Web API
i) REST based communication APIs( Request-Response Based Model)
ii) WebSocket based Communication APIs(Exclusive Pair Based Model)
The REST architectural constraints are as follows: The below figure shows the
communication between client server with REST APIs
• Launch Configuration
• After connecting to AutoScaling service, a new launch configuration is created by calling
conn.create_launch_con f iguration. Launch configuration contains instructions on how to launch
new instances including the AMI-ID, instance type, security groups, etc.
AutoScaling Group
• After creating a launch configuration, it is then associated with a new AutoScaling group.
AutoScaling group is created by calling conn.create_auto_scaling_group. The
settings for AutoScaling group such as the maximum and minimum number of instances in the
group, the launch configuration, availability zones, optional load balancer to use with the group, etc.
AutoScaling Policies
• After creating an AutoScaling group, the policies for scaling up and scaling down are defined.
• In this example, a scale up policy with adjustment type Change In Capacity and scaling_ad
justment = 1 is defined.
• Similarly a scale down policy with adjustment type ChangeInCapacity and scaling_ad justment = -1
is defined.
CloudWatch Alarms
• With the scaling policies defined, the next step is to create Amazon CloudWatch alarms that trigger
these policies.
• The scale up alarm is defined using the CPUUtilization metric with the Average statistic and
threshold greater 70% for a period of 60 sec. The scale up policy created previously is associated
with this alarm. This alarm is triggered when the average CPU utilization of the instances in the
group becomes greater than 70% for more than 60 seconds.
• The scale down alarm is defined in a similar manner with a threshold less than 50%.
iii)Amazon S3:
• In this example, a connection to S3 service is first established by calling boto.connect_s3 function.
• The upload_to_s3_bucket_path function uploads the file to the S3 bucket specified at the specified
path.
iv)Amazon RDS
In this example, a connection to RDS service is first established by calling
boto.rds.connect_to_region function.
• The RDS region, AWS access key and AWS secret key are passed to this function.
• After connecting to RDS service, the conn.create_dbinstance function is called to launch a
new RDS instance.
• The input parameters to this function include the instance ID, database size, instance type, database
username, database password, database port, database engine (e.g. MySQL5.1), database name,
security groups, etc.
v) Amazon Dynamo DB
In this example, a connection to DynamoDB service is first established by calling
boto.dynamodb.connect_to_region.
• After connecting to DynamoDB service, a schema for the new table is created by calling
conn.create_schema.
• The schema includes the hash key and range key names and types.
• A DynamoDB table is then created by calling conn.create_table function with the table schema,
read units and write units as input parameters.
5.7 SkyNetIoT Messaging Platform.
SkyNet is running on a dozen Amazon EC2 servers and has nearly 50,000 registered
smart devices including: Arduinos, Sparks, Raspberry Pis, Intel Galileos, and BeagleBoards,
Matthieu said. SkyNet runs as an IoT platform-as-a-service (PaaS) as well as a private cloud
through Docker, the new lightweight container technology. The platform is written in Node.js
and released under an MIT open source license on GitHub.
The single SkyNet API supports the following IoT protocols: HTTP, REST,
WebSockets, MQTT (Message Queue Telemetry Transport), and CoAP (Constrained
Application Protocol) for guaranteed message delivery and low-bandwidth satellite
communications, Matthieu said. Every connected device is assigned a 36 character UUID and
secret token that act as the device’s strong credentials. Security permissions can be assigned to
allow device discoverability, configuration, and messaging.
[ Separately discussed ]
Part B- 7 Marks
Part C- 16 Marks