SlideShare a Scribd company logo
IoT(Internet of Things)
Dr. Rupam kr sharma
Asst. Professor(Sr), Dept. of Computer Applications
Course Outline
• Ovirview of Embedded system
• Overview vof IoT
• Components of IoT
• Introduction to Pi
• Basic operations of Pi
• Connecting Pi in a network
• Controlling a basic LED from Pi
• Introduction to python
• Controlling GPIO using python
• Understanding Basic Network
model(TCP)
• Communication between two
pi using sockets
• Understanding IoT broker
• Installing MQTT and using it
with Pi.
• Communication using MQTT
and CloudMQTT (Internet)
• Controlling sensors using Pi
• Introduction to Android app
development
• Controlling sensors using
Android app
Overview of Embedded system
Embedded system is a microcontroller based ,
software driven reliable real time control system
designed for performing a specific task.
What is a System?
All units assembled work together according to
certain set of rules.
What is Embedded?
Something attached to another. Computer
Hardware system with software embedded in it.
Components of Embedded
system
• Hardware
• Application software
• Real Time Operating System
Basic structure of an Embedded system
Basic types of processors..
• General Purpose Processor
• Microprocessor
• Microcontroller
• Embedded processor
• Digital signal processor
• Application specific system processor
Computer System
Block diagram of 8051
Rough register stack of x86
Your First Few Instructions
mov x, y x ← y
and x, y x ← x and y
or x, yx ← x or y
xor x, y x ← x xor y
add x, y x ← x + y
sub x, y x ← x – y
inc x x ← x + 1
dec x x ← x – 1
syscallInvoke an operating system routine
db A pseudo-instruction that declares bytes that will be in
memory when the program runs
Structure of a NASM Program
What is IoT?
Internet of Things (IoT) is an ecosystem of
connected physical objects that are
accessible through the internet.
The ‘thing’ in IoT could be a person with
a heart monitor or an automobile with
built-in-sensors, i.e. objects that have been
assigned an IP address and have the
ability to collect and transfer data over a
network without manual assistance or
intervention.
IoT ELEMENTS
• Identification
• Naming
• Addressing
• Sensing:
• Collected information is sent to storage media
• actuators, RFID tags, smart sensors, wearable sensing devices, etc.
• Computation
• Used to remove unnecessary information that is not needed.
• Services
• Four types of services
• identity-related service. It is used to get the identity of objects that have sent the
request.
• Information aggregation is another service whose purpose is to collect all the
information from objects.
• The third service is a collaborative service that makes decisions according to the
collected information and sends appropriate responses to the devices.
• The last service is ubiquitous service, which is used to respond the devices immediately
without rigidity about time and place.
Three layered architecture
Common security threats of perception layer are:
Eavesdropping: Eavesdropping is an unauthorized real-time attack where private communications, such as phone calls,
text messages, fax transmissions or video conferences are intercepted by an attacker. It tries to steal information that is
transmitted over a network.
It takes advantage of unsecure transmission to access the information being sent and received.
Node Capture: It is one of the hazardous attacks faced in the perception layer of IoT. An attacker gains full control over a
key node, such as a gateway node. It may leak all information including communication between sender and receiver, a
key used to make secure communication and information stored in memory
Fake Node and Malicious: It is an attack in which an attacker adds a node to the system and inputs fake data. It aims to
stop transmitting real information. A node added by an attacker consumes precious energy of real nodes and potentially
control in order to destroy the network.
Replay Attack: It is also known as a play back attack. It is an attack in which an intruder eavesdrops on the conservation
between sender and receiver and takes authentic information from the sender
Network Layer:
Common security threats and problems to network layers are:
Denial of Service (DoS) Attack: A DoS attack is an attack to prevent authentic users from accessing devices or other
network resources. It is typically accomplished by flooding the targeted devices or network resources with redundant
requests in an order to make it impossible or difficult for some or all authentic users to use them
Main-in-The-Middle (MiTM) Attack: MiTM attack is an attack where the attacker secretly intercepts and alters the
communication between sender and receiver who believe they are directly communicating with each other
Storage Attack: The information of users is stored on storage devices or the cloud. Both storage devices and cloud can
be attacked by the attacker and user’s information may be changed to incorrect details. The replication of information
associated with the access of other information by different types of people provides more chances for attacks.
Exploit Attack: An exploit is any immoral or illegal attack in a form of software, chunks of data or a sequence of
commands. It takes advantage of security vulnerabilities in an application, system or hardware. It usually comes with the
aim of gaining control of the system and steals information stored on a network [
Application Layer
Common security threats and problem of application layer are:
Cross Site Scripting: It is an injection attack. It enables an attacker to insert a client-side script, such as java script in a
trusted site viewed other users. By doing so, an attacker can completely change the contents of the application according to
his needs and use original information in an illegal way.
Malicious Code Attack: It is a code in any part of software intended to cause undesired effects and damage to the system. It
is a type of threat that may not be blocked or controlled by the use of anti-virus tools. It can either activate itself or be like a
program requiring a user’s attention to perform an action.
The ability of dealing with Mass Data: Due to a large number of devices and a massive amount of data transmission
between users, it has no ability to deal with data processing according to the requirements. As a result, it leads to network
disturbance and data loss.
Support Layer:
The support layer has two responsibilities.
• It confirms that information is sent by the authentic users and protected from threats. There are many ways
to verify the users and the information. The most commonly used method is the authentication. It is
implemented by using pre-shared secrets, keys and passwords.
• The second responsibility of the support layer is sending information to the network layer. The medium to
transmit information from the support layer to network layer can be wireless and wire based.
• Common threats and problems of the support layer are
• DoS Attack: The DoS attack in a support layer is related to the network layer. An attacker sends a large
amount of data to make network traffic inundated. Thus, the massive consumption of system resources
exhausts the IoT and makes the user not capable of accessing the system.
• Malicious Insider Attack: It occurs from the inside of an IoT environment to access the personal
information of users. It is performed by an authorized user to access the information of other user. It is a
very different and complex attack that requires different mechanisms to prevent the threat
It is the responsibility of IoT to facilitate users by performing their tasks. It is the most important
element of IoT to fulfill its responsibilities. It acts like the brain of IoT. It gets all information and makes
appropriate decisions to send responses to the devices.
Five-layered Architecture
IoT stack
CLIENT
SENDS
REQUEST
TO SERVER
SERVER
Receives request
from client,
process request,
looks up/fetches
resources
prepares responds
and sends respondns
to client
Resources
Request
Response
Request - Response Communication Model
Publish and Subscribe Model
PUSH-PULL Communication Model
EXCLUSIVE PAIR COMMUNICATION MODEL
M2M System Architecture
M2M Gateway
Difference between M2M and IoT
Area IoT M2M
Communication Protocols Focus of communication in IoT is usually
on the protocols above the network
layer such as HTTP,CoAP,MQTT, etc.
Uses propreitary on non IP based
communication protocols for
communication within M2M networks.
eg. ZIGBEE,6LoWPAN,Bluetooth etc.
Machines in M2M vs things in IoT Things in IoT referes to physical objects
that have unique identifiers and can
sense and communicate with their
external environment or their internal
physical states. The unique identifiers
are the IP(or MAC). Things have software
components for accessing,processing
and storing sensor information.
Area IoT M2M
Hardware vs Software emphasis More on software More on Hardware
Data Collection and Analysis data collected on cloud Data collected in point solutions
COMMUNICATION WITH REST API
IoT Communication API
REST-Based Communication API (Representational State Transfer)
• Set of architectural principlas by which web services/API can be designed that focus
on system resources and how resources states are addressed and transferred.
• Follows the REQUEST-RESPONSE communication model.
• REST architectural constraints :
• Client-Server:
• Stateless
• Cache-able
• Layered System
• Uniform Interface
• Code on Demand
Client-Server:
Constraint of seperation of concerns.
Clients should not be concerned with storage of data which is a concern of server.
Server should not be concerned about the user interface which is a concern of client.
Seperation allows client and server to be independently developed
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.
Cache-able:
Cache constraint requires that the data within a response to a request be implicitly or explicitly be
labeled as cache-abled or non-cache-abled.
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:
constraints the behaviour of components such that each component cannot see beyond the
immediate layer with which they are interacting. For eg. a client cannot say if it is directly
connected to the end server or through an intermediate.
Uniform Interface:
Requires that the method of communication between a client and server is uniform.
Resources are identified in the requests.
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 contexts.
REQUEST/RESPONSE MODEL USED IN REST
HTTP Request methods and actions
WEBSOCKET API
SDN and NFV for IoT
SDN Architecture
SDN Layers
Centralized Network Controller(CNC): With decoupled control and data planes and centralized
network controller , the network controller can rapidly configure the network.
SDN applications can be deployed through programmable open API.
Programmable Open API: SDN support programmable open API. for interface between SDN
application and control layers. With the open API various network services such as routing, QoS,
access control can be implemented.
Standard Communication Interface(OpenFlow): SDN uses a standard communication interface
between the control and infrastructure layers. OpenFLow which is defined by Open Networking
Foundation(ONF) is the broadly accepted protocol for the southbound interface.
With OpenFlow, the forwarding plane of the networking device can be directly accessed and
manipulated. OpenFlow uses the concept of flow to define network traffic based on pre-defined rules.
Flows can be programmed statically or dynamically by the SDN software.
Open Flow Switch
OPEN FLOW TABLE: Open FLow protocol is implemented on both sides of the interface between the controller
and the network device. The controller manages the switch via the open flow switch protocol. The controller can
add, update, delete flow entries in table.
Each flow table contains a set of flow entries. Each flow entries consists of match fields , counters and a set of
instructions to apply to matching packets.
Network Function Virtualization
NFV is a technology that leverages virtualization to consolidate the heterogenous network devices
onto industry standard high volume servers, switches and storage.
NFV is complimentay to SDN as NFV can provide infrastructure on which it runs. They are
mutually beneficial for each other but not dependent.
VNF: VNF is the software implementation of a network function which is capable of running over
the NVF Infrastructure(NVFI).
NVF Infrastructure(NVFI): NFVI includes compute,network and storage that are virtualized.
NFV Management and Orchestration:Focuses on all virtualization-specific management tasks and
covers the orchestration and life cycle management of physical and /or software resources that
support the infrastructure virtualization and the life cycle management of VNF.
Conventional Home Network Architecture
Home network with virtualized home gateway
IoT Platforms design methodology
• Important to design a generic design methodology independent of
specific product ,service or programming language.
• STEP 1: Purpose and Requirements specification:
• Define the purpose and requirements of the system(such as data collection
requirements,data analysis requirements,system management requirements,
data privacy and security requirements,user interface requirements).
Fig: Steps involved in the IoT system
design methodology
Process Specification: Here USE CASE of the system is formally described based and derived from purpose and
requirements specification.
Fig: Process specification for home
automation system
STEP 3:DOMAIN MODEL SPECIFICATION:
The domain model describes the main concepts, entities and objects in the domain of IoT system to be designed.
Domain model defines the attributes of the objects and the relationships between objects.
Defines the attributes of the objects and the relationships between objects.
Physical Entity: Identifiable entity in physical environment(eg. a room, a light, a car etc.) IoT system provides
information about physical entity using sensors. In home automation system two physical entities - one is the room
(of which lighting conditons to be monitored and other is the light appliance to be controlled.
Virtual Entity: Representation of physical entity in the digital world. For each physical entity there is a virtual entity
in the domain model.
Device: Provides a medium for interactions between physical entities and virtual entities. They are used to gather
information about physical entities.
Resource: Software components which can be either on device or network resources.
Service: Provides an interface for interacting with physical entities.
In HOME AUTOMATION there are three services:
1) Service that sets mode to auto or manual or retreives the current mode.
2) Service that sets the light appliance state to ON/OFF or retreives the current light state.
3) A controller service that runs as a native service on the device.
In AUTO Mode the controller service monitors the light level and swithches the light
ON/OFF and updates the status in the status database. In MANUAL mode,the controller
service retreives the current state from the database and switches the light ON/OFF.
STEP 4: Information model specification: Here Information model defines the structure of all information in
the IoT system. Eg. attributes of virtual entities , relations etc.
First the virtual entities are listed defined in the DOMAIN model. Later more details are added to the virtual
entities by adding attributes and relations.
In home automation there are two virtual entities - a virtual entity for light appliance ( with attribute light
and state) and a virtual entity for the room( with attribute light level)
Connecting to Pi connected locally
• ssh pi@raspberrypi.local
Making ready the working environment
Basic Circuit
GND
OUT of
PI
Putting the LED 'ON & OFF'
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BOARD)
blinkCount=3
count=0
LEDPin=22
#setup the pin the Led is connected to
GPIO.setup(LEDPin,GPIO.OUT)
while count < blinkCount:
GPIO.output(LEDPin,True)
print("LED ON")
sleep(3)
GPIO.output(LEDPin,False)
print("LED off")
sleep(1)
count +=1
Download Link:https://www.arduino.cc/en/software
For uploading error: Cannot write to serial port
windows
In the lower-right part of the Arduino board, you’ll see six pins marked “Analog In”; these are special pins
that can tell us not only whether there is a voltage applied to them, but if so, also its value. By using the
analogRead() function, we can read the voltage applied to one of the pins. This function returns a number
between 0 and 1023, which represents voltages between 0 and 5 volts. For example, if there is a voltage of
2.5 V applied to pin number 0, analogRead(0) returns 512.
delay takes parameter in milliseconds i.e 1000ms=1sec
Connecting through a PUSH Button
We connect three wires to the Arduino board. The first goes from one leg of the pushbutton through a pull-up
resistor (here 2.2 KOhms) to the 5 volt supply. The second goes from the corresponding leg of the pushbutton to
ground. The third connects to a digital i/o pin (here pin 7) which reads the button's state.
When the pushbutton is open (unpressed) there is no connection between the two legs of the pushbutton, so
the pin is connected to 5 volts (through the pull-up resistor) and we read a HIGH. When the button is closed
(pressed), it makes a connection between its two legs, connecting the pin to ground, so that we read a LOW. (The
pin is still connected to 5 volts, but the resistor in-between them means that the pin is "closer" to ground.)
ULTRASONIC SENSOR
For example, if the object is 20 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034
cm/µs the sound wave will need to travel about 588 microseconds. But what you will get from the Echo
pin will be double that number because the sound wave needs to travel forward and bounce backward. So
in order to get the distance in cm we need to multiply the received travel time value from the echo pin by
0.034 and divide it by 2.
1. First do the wiring as shown in the picture
2. Open Arduino IDE Software and write down your code, or download the code below and open it
3. Choose your own Arduino board (in this case Arduino Uno), by selecting Tools > Board > Arduino/Geniuno Uno
4. Choose your COM Port (usually it appears only one existing port), Tools > Port > COM.. (If there are more than
one ports, try it one by one)
5. Upload your code by pressing Ctrl + U or Sketch > Upload
6. To display the measurement data you can use Serial Monitor by pressing Ctrl + Shift + M (make sure that the
baudrate speed is 9600)
pulsein():Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to
go from LOW to HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the
pulse in microseconds or gives up and returns 0 if no complete pulse was received within the timeout.
#define echoPin 2 // attach pin D9 Arduino to pin Echo of HC-SR04
#define trigPin 3 //attach pin D8 Arduino to pin Trig of HC-SR04
// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
Serial.begin(9600); // // Serial Communication is starting with 9600 of baudrate speed
Serial.println("Ultrasonic Sensor HC-SR04 Test"); // print some text in Serial Monitor
Serial.println("with Arduino UNO R3");
}
void loop() {
// Clears the trigPin condition
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin HIGH (ACTIVE) for 10 microseconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
// Displays the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
}
int sensorPin = A0;
int sensorValue;
int limit = 300;
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.println("Analog Value : ");
Serial.println(sensorValue);
if (sensorValue<limit) {
digitalWrite(13, HIGH);
}
else {
digitalWrite(13, LOW);
}
delay(1000);
}
Connecting moisture sensor to arduino
waterproof temperature sensor
Installing Library For DS18B20
This Dallas Temperature library is a hardware-specific library which handles lower-level functions. It needs to
be paired with One Wire Library to communicate with any one-wire device not just DS18B20. Install this
library as well.
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into digital pin 2 on the Arduino
#define ONE_WIRE_BUS 2
// Setup a oneWire instance to communicate
with any OneWire device
OneWire oneWire(ONE_WIRE_BUS);
// Pass oneWire reference to DallasTemperature library
DallasTemperature sensors(&oneWire);
void setup(void)
{
sensors.begin(); // Start up the library
Serial.begin(9600);
}
void loop(void)
{
// Send the command to get temperatures
sensors.requestTemperatures();
//print the temperature in Celsius
Serial.print("Temperature: ");
Serial.print(sensors.getTempCByIndex(0));
Serial.print((char)176);//shows degrees character
Serial.print("C | ");
//print the temperature in Fahrenheit
Serial.print((sensors.getTempCByIndex(0) * 9.0) / 5.0 +
32.0);
Serial.print((char)176);//shows degrees character
Serial.println("F");
delay(500);
}
Arduino IR sensor
int IRSensor = 2; // connect ir sensor to arduino pin 2
int LED = 13; // conect Led to arduino pin 13
void setup()
{
pinMode (IRSensor, INPUT); // sensor pin INPUT
pinMode (LED, OUTPUT); // Led pin OUTPUT
}
void loop()
{
int statusSensor = digitalRead (IRSensor);
if (statusSensor == 1)
digitalWrite(LED, LOW); // LED LOW
}
else
{
digitalWrite(LED, HIGH); // LED High
}
}
4 digit 7 -segment display
import serial
import time
# Define the serial port and baud rate.
# Ensure the 'COM#' corresponds to what was seen in the Windows Device Manager
ser = serial.Serial('/dev/ttyACM2', 9600)
def led_on_off():
user_input = input()
user_input.strip()
if user_input =="on":
print("LED is on...")
time.sleep(0.1)
ser.write(b'H')
led_on_off()
elif user_input =="off":
print("LED is off...")
time.sleep(0.1)
ser.write(b'L')
led_on_off()
elif user_input =="quit" or user_input == "q":
print("Program Exiting")
time.sleep(0.1)
ser.write(b'L')
ser.close()
else:
print("Invalid input. Type on / off / quit.")
led_on_off()
time.sleep(2) # wait for the serial connection to initialize
led_on_off()
Python Ardudino Interaction to control LED
int data;
int LED=13;
String x;
int y;
void setup() {
Serial.begin(9600); //initialize serial COM at 9600 baudrate
pinMode(LED, OUTPUT); //declare the LED pin (13) as output
digitalWrite (LED, LOW); //Turn OFF the Led in the beginning
Serial.println("Hello!,How are you Python ?");
}
void loop() {
while (!Serial.available());
x = Serial.readString();
x.trim();
Serial.print(x[0]);
Serial.print("before if x");
Serial.print(x);
//Turn On the Led
if (x[0]=='H')
{
digitalWrite (LED, HIGH); //Turn
On the Led
Serial.print("true");
}
else if (x[0] =='L')
digitalWrite (LED, LOW);
//Turn OFF the Led
}
To Do Task
sand
7-segment
display
temperature
sensor
moisture
IR
ultrasonic
MQTT
sudo apt-get update sudo apt-get install mosquitto; sudo apt-get install mosquitto-clients
The architecture MQTT BROKER(MAY
ALSO RUN ON A
CLOUD SERVER)
MQTT PUBLISHER(Commands ON or
OFF
MQTT SUBSCRIBER
LED
CIRCUIT
ssh pi@raspberrypi.local
MQTT SUBSCRIBER
import paho.mqtt.client as mqtt
from blink2 import blin
broker_url="192.168.60.252"
broker_port=1883
def on_connect(client, userdata, flags, rc):
print("Connected With Result Code ", rc)
def on_disconnect(client, userdata, rc):
print("Client Got Disconnected")
def on_message(client, userdata, message):
strng=message.payload.decode()
print("Message received" + strng)
blin(strng)
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(broker_url, broker_port)
client.subscribe("LED", qos=1)
client.loop_forever()
MQTT PUBLISHER
import paho.mqtt.client as mqtt
import sys
broker_url="192.168.60.252"
broker_port=1883
def on_connect(client, userdata, flags, rc):
print("Connected With Result Code " (rc))
def on_disconnect(client, userdata, rc):
print("Client Got Disconnected")
client=mqtt.Client()
client.connect(broker_url,broker_port)
#If the connection is successful, you will see it output 0 on
the screen.
client.publish(topic="LED", payload=sys.argv[1], qos=0,
retain=False)
#client.loop_forever()
Running the code:
python mqttpub.py ON
Modified blink to blink2
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BOARD)
LEDPin=22
#setup the pin the Led is connected to
GPIO.setup(LEDPin,GPIO.OUT)
def blin(param):
if param=="ON":
GPIO.output(LEDPin,True)
sleep(3)
elif param=="OFF":
GPIO.output(LEDPin,False)
print("LED off")
sleep(1)
MQTT & moisture sensor
Testing water content from PI
5v
GND
DO
import RPi.GPIO as GPIO
import time
#GPIO SETUP
channel = 16
GPIO.setmode(GPIO.BOARD)
GPIO.setup(channel, GPIO.IN)
def callback(channel):
if GPIO.input(channel):
print "Water Detected!"
GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime=300) # let us know when the pin goes HIGH
or LOW
GPIO.add_event_callback(channel, callback) # assign function to GPIO PIN, Run function on change
Interfacing with MQTT
5v
GND
DO
Mqtt publisher
output
output
mqtt
subscriber
MQTT MOIST_PUBLISHER
import paho.mqtt.client as mqtt
import sys
import RPi.GPIO as GPIO
channel=16
msg="N"
broker_url="192.168.60.252"
broker_port=1883
def on_connect(client, userdata, flags, rc):
print("Connected With Result Code " (rc))
def on_disconnect(client, userdata, rc):
print("Client Got Disconnected")
client=mqtt.Client()
client.connect(broker_url,broker_port)
#If the connection is successful,
you will see it output 0 on the screen.
GPIO.setmode(GPIO.BOARD)
GPIO.setup(channel,GPIO.IN)
def mycallback(channel):
global msg
if GPIO.input(channel):
msg="ON"
client.publish(topic="MOIST",payload=msg,qos=0,retain=Fa
lse)
print("ON")
else:
msg="OFF"
client.publish(topic="MOIST",payload=msg,qos=0,retain=Fa
lse)
print("OFF")
GPIO.add_event_detect(channel,GPIO.BOTH)
GPIO.add_event_callback(channel,mycallback)
#client.publish(topic="MOIST", payload=msg, qos=0,
retain=False)
client.loop_forever()
MQTT MOIST_SUBSCRIBER
import paho.mqtt.client as mqtt
from blink3 import blin
broker_url="192.168.60.252"
broker_port=1883
def on_connect(client, userdata, flags, rc):
print("Connected With Result Code ", rc)
def on_disconnect(client, userdata, rc):
print("Client Got Disconnected")
def on_message(client, userdata, message):
strng=message.payload.decode()
print("Message received" + strng)
blin(strng)
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect(broker_url, broker_port)
client.subscribe("MOIST", qos=1)
client.loop_forever()
CloudMqtt
• From subscriber ubuntu terminal
• mosquitto_sub -h postman.cloudmqtt.com -p 14798 -t LED -u
xejupbki -P ReeIdW8jsAv0
Android Studio
Understanding Activity and Layout
Understanding Permissions
The first App- Hello world
Interacting App with Pi.
• https://medium.com/@gaikwadchetan93/android-real-time-
communication-using-mqtt-9ea42551475d
• except the service version in the build gradle
MQTT: Message Queuing Telemetry Transport
At any time, clients can subscribe to and unsubscribe from one or more topics by connecting to a broker. So if a new
industrial device is installed (e.g., a new reactor, “reactorX” ), the IT operations will have to configure its IoT node with
the Internet Protocol (IP) address and connection details of the broker. When booting up, the new IoT node will
announce its presence to the broker and subscribe to the requested topics. MQTT subscribers and publishers are
transient and can come and go at any time, and could receive old, queued messages when they come back online.
CoAP: Constrained Application Protocol
CoAP is a client-server protocol, which means that the data exchange is initiated by a client node with a
request sent to a server node, which will answer with a response.
CoAP does not require the client to open or keep a connection to a server because it’s based on User
Datagram Protocol (UDP). At any time, a client can send one CoAP packet to a server.
Each request has a few options, with the most important one being the Uniform Resource Identifier (URI),
which indicates the “path” to the requested resource — much like Uniform Resource Locators (URLs) for
websites.
Note that a node could be both server and client at the same time, implementing a point-to-point, full-
duplex data layer.
Following the same example used in the MQTT description above, a client node could command
another node to, say, “turn on” or “execute a given task,” by sending a CoAP packet such as
“/station1/substation3/reactor3” with payload “on” . The CoAP server will interpret the URI, extract
the “on” payload, and decide what to do according to its logic. Depending on the request, the server could
reply with an acknowledgment, or just remain silent: Not all requests must be acknowledged.
Vulenerability in MQTT Implementation
• MQTT Vulnerability
Design Issues (MQTT)
Previous versions of the standard contained vulnerable pseudocode examples as a reference for
developers. For example, the code example to parse the “remaining length” field in packets changed
between versions 3.1 8 and 3.1.1 9 + errata, 10 going from a “no check” to “wrong check” and then
to “correct check”. This turned out to be an interesting pattern to look for, leading us to discover a
memory error (exploitable to obtain a remote code execution primitive) in real MQTT
implementations.
On top of this, the MQTT version 5.0 specification 11 is not entirely compatible with previous
versions, which could delay its future adoption despite the security improvements that it brings.
Unicode Handling in Topic Strings
Another interesting venue prone to error is the handling of topic strings. The first issue is that the
standard leaves it up to the developers’ choice to close the connection upon failing validation of
disallowed UTF-8 code points.
Internet of things , presentation, rajiv gandhi university
Internet of things , presentation, rajiv gandhi university

More Related Content

Similar to Internet of things , presentation, rajiv gandhi university

Presentation about IoT in media and communication.pdf
Presentation about IoT in media and communication.pdfPresentation about IoT in media and communication.pdf
Presentation about IoT in media and communication.pdf
ezzAyman1
 
Network Attacks - (Information Assurance and Security)BS in Information Techn...
Network Attacks - (Information Assurance and Security)BS in Information Techn...Network Attacks - (Information Assurance and Security)BS in Information Techn...
Network Attacks - (Information Assurance and Security)BS in Information Techn...
SyvilMaeTapinit
 
Ak03402100217
Ak03402100217Ak03402100217
Ak03402100217
ijceronline
 
IOT_UNIT-1.pptx
IOT_UNIT-1.pptxIOT_UNIT-1.pptx
IOT_UNIT-1.pptx
ssuser4f5d2a
 
Detecting and Confronting Flash Attacks from IoT Botnets
Detecting and Confronting Flash Attacks from IoT BotnetsDetecting and Confronting Flash Attacks from IoT Botnets
Detecting and Confronting Flash Attacks from IoT Botnets
Farjad Noor
 
Malware Hunter: Building an Intrusion Detection System (IDS) to Neutralize Bo...
Malware Hunter: Building an Intrusion Detection System (IDS) to Neutralize Bo...Malware Hunter: Building an Intrusion Detection System (IDS) to Neutralize Bo...
Malware Hunter: Building an Intrusion Detection System (IDS) to Neutralize Bo...
Editor IJCATR
 
IoT-Device-Security-DRAFT-slide-presentation
IoT-Device-Security-DRAFT-slide-presentationIoT-Device-Security-DRAFT-slide-presentation
IoT-Device-Security-DRAFT-slide-presentation
AuliaArifWardana
 
unit 2 IT security solution.pptx
unit 2 IT security solution.pptxunit 2 IT security solution.pptx
unit 2 IT security solution.pptx
lochanrajdahal
 
IoT-Device-Security.pptx
IoT-Device-Security.pptxIoT-Device-Security.pptx
IoT-Device-Security.pptx
ZahidHussainqaisar
 
Network-security-ppt.pptx...............
Network-security-ppt.pptx...............Network-security-ppt.pptx...............
Network-security-ppt.pptx...............
AkilSayyad2
 
Aca presentation arm_
Aca presentation arm_Aca presentation arm_
Aca presentation arm_
Mudassar Mehmud
 
Chapter 4.ppt
Chapter 4.pptChapter 4.ppt
Chapter 4.ppt
girmawodajo
 
Ehical Hacking: Unit no. 1 Information and Network Security
Ehical Hacking: Unit no. 1 Information and Network SecurityEhical Hacking: Unit no. 1 Information and Network Security
Ehical Hacking: Unit no. 1 Information and Network Security
prachi67
 
Internet of Things Forensics
Internet of Things ForensicsInternet of Things Forensics
Internet of Things Forensics
Aakashjit Bhattacharya
 
IoT Honeypots: State of the Art
IoT Honeypots: State of the ArtIoT Honeypots: State of the Art
IoT Honeypots: State of the Art
Biagio Botticelli
 
Chapter 2 konsep dasar keamanan
Chapter 2 konsep dasar keamananChapter 2 konsep dasar keamanan
Chapter 2 konsep dasar keamanan
newbie2019
 
Physical Layer Essay
Physical Layer EssayPhysical Layer Essay
Physical Layer Essay
Jenny Richardson
 
G011123539
G011123539G011123539
G011123539
IOSR Journals
 
Assign 1_8812814ctm.pptx
Assign 1_8812814ctm.pptxAssign 1_8812814ctm.pptx
Assign 1_8812814ctm.pptx
pdevang
 
The Sharp Increase in Unmasking of Obtrusion into Internet of Things (IoT) IP...
The Sharp Increase in Unmasking of Obtrusion into Internet of Things (IoT) IP...The Sharp Increase in Unmasking of Obtrusion into Internet of Things (IoT) IP...
The Sharp Increase in Unmasking of Obtrusion into Internet of Things (IoT) IP...
IJCSIS Research Publications
 

Similar to Internet of things , presentation, rajiv gandhi university (20)

Presentation about IoT in media and communication.pdf
Presentation about IoT in media and communication.pdfPresentation about IoT in media and communication.pdf
Presentation about IoT in media and communication.pdf
 
Network Attacks - (Information Assurance and Security)BS in Information Techn...
Network Attacks - (Information Assurance and Security)BS in Information Techn...Network Attacks - (Information Assurance and Security)BS in Information Techn...
Network Attacks - (Information Assurance and Security)BS in Information Techn...
 
Ak03402100217
Ak03402100217Ak03402100217
Ak03402100217
 
IOT_UNIT-1.pptx
IOT_UNIT-1.pptxIOT_UNIT-1.pptx
IOT_UNIT-1.pptx
 
Detecting and Confronting Flash Attacks from IoT Botnets
Detecting and Confronting Flash Attacks from IoT BotnetsDetecting and Confronting Flash Attacks from IoT Botnets
Detecting and Confronting Flash Attacks from IoT Botnets
 
Malware Hunter: Building an Intrusion Detection System (IDS) to Neutralize Bo...
Malware Hunter: Building an Intrusion Detection System (IDS) to Neutralize Bo...Malware Hunter: Building an Intrusion Detection System (IDS) to Neutralize Bo...
Malware Hunter: Building an Intrusion Detection System (IDS) to Neutralize Bo...
 
IoT-Device-Security-DRAFT-slide-presentation
IoT-Device-Security-DRAFT-slide-presentationIoT-Device-Security-DRAFT-slide-presentation
IoT-Device-Security-DRAFT-slide-presentation
 
unit 2 IT security solution.pptx
unit 2 IT security solution.pptxunit 2 IT security solution.pptx
unit 2 IT security solution.pptx
 
IoT-Device-Security.pptx
IoT-Device-Security.pptxIoT-Device-Security.pptx
IoT-Device-Security.pptx
 
Network-security-ppt.pptx...............
Network-security-ppt.pptx...............Network-security-ppt.pptx...............
Network-security-ppt.pptx...............
 
Aca presentation arm_
Aca presentation arm_Aca presentation arm_
Aca presentation arm_
 
Chapter 4.ppt
Chapter 4.pptChapter 4.ppt
Chapter 4.ppt
 
Ehical Hacking: Unit no. 1 Information and Network Security
Ehical Hacking: Unit no. 1 Information and Network SecurityEhical Hacking: Unit no. 1 Information and Network Security
Ehical Hacking: Unit no. 1 Information and Network Security
 
Internet of Things Forensics
Internet of Things ForensicsInternet of Things Forensics
Internet of Things Forensics
 
IoT Honeypots: State of the Art
IoT Honeypots: State of the ArtIoT Honeypots: State of the Art
IoT Honeypots: State of the Art
 
Chapter 2 konsep dasar keamanan
Chapter 2 konsep dasar keamananChapter 2 konsep dasar keamanan
Chapter 2 konsep dasar keamanan
 
Physical Layer Essay
Physical Layer EssayPhysical Layer Essay
Physical Layer Essay
 
G011123539
G011123539G011123539
G011123539
 
Assign 1_8812814ctm.pptx
Assign 1_8812814ctm.pptxAssign 1_8812814ctm.pptx
Assign 1_8812814ctm.pptx
 
The Sharp Increase in Unmasking of Obtrusion into Internet of Things (IoT) IP...
The Sharp Increase in Unmasking of Obtrusion into Internet of Things (IoT) IP...The Sharp Increase in Unmasking of Obtrusion into Internet of Things (IoT) IP...
The Sharp Increase in Unmasking of Obtrusion into Internet of Things (IoT) IP...
 

Recently uploaded

Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
mahaffeycheryld
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
ycwu0509
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
Prakhyath Rai
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
PIMR BHOPAL
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
upoux
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
nedcocy
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
mahaffeycheryld
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
PriyankaKilaniya
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 

Recently uploaded (20)

Generative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdfGenerative AI Use cases applications solutions and implementation.pdf
Generative AI Use cases applications solutions and implementation.pdf
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
VARIABLE FREQUENCY DRIVE. VFDs are widely used in industrial applications for...
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 

Internet of things , presentation, rajiv gandhi university

  • 1. IoT(Internet of Things) Dr. Rupam kr sharma Asst. Professor(Sr), Dept. of Computer Applications
  • 2. Course Outline • Ovirview of Embedded system • Overview vof IoT • Components of IoT • Introduction to Pi • Basic operations of Pi • Connecting Pi in a network • Controlling a basic LED from Pi • Introduction to python • Controlling GPIO using python • Understanding Basic Network model(TCP) • Communication between two pi using sockets • Understanding IoT broker • Installing MQTT and using it with Pi. • Communication using MQTT and CloudMQTT (Internet) • Controlling sensors using Pi • Introduction to Android app development • Controlling sensors using Android app
  • 3. Overview of Embedded system Embedded system is a microcontroller based , software driven reliable real time control system designed for performing a specific task. What is a System? All units assembled work together according to certain set of rules. What is Embedded? Something attached to another. Computer Hardware system with software embedded in it.
  • 4. Components of Embedded system • Hardware • Application software • Real Time Operating System
  • 5. Basic structure of an Embedded system
  • 6. Basic types of processors.. • General Purpose Processor • Microprocessor • Microcontroller • Embedded processor • Digital signal processor • Application specific system processor
  • 10. Your First Few Instructions mov x, y x ← y and x, y x ← x and y or x, yx ← x or y xor x, y x ← x xor y add x, y x ← x + y sub x, y x ← x – y inc x x ← x + 1 dec x x ← x – 1 syscallInvoke an operating system routine db A pseudo-instruction that declares bytes that will be in memory when the program runs
  • 11. Structure of a NASM Program
  • 12. What is IoT? Internet of Things (IoT) is an ecosystem of connected physical objects that are accessible through the internet. The ‘thing’ in IoT could be a person with a heart monitor or an automobile with built-in-sensors, i.e. objects that have been assigned an IP address and have the ability to collect and transfer data over a network without manual assistance or intervention.
  • 14. • Identification • Naming • Addressing • Sensing: • Collected information is sent to storage media • actuators, RFID tags, smart sensors, wearable sensing devices, etc. • Computation • Used to remove unnecessary information that is not needed. • Services • Four types of services • identity-related service. It is used to get the identity of objects that have sent the request. • Information aggregation is another service whose purpose is to collect all the information from objects. • The third service is a collaborative service that makes decisions according to the collected information and sends appropriate responses to the devices. • The last service is ubiquitous service, which is used to respond the devices immediately without rigidity about time and place.
  • 16. Common security threats of perception layer are: Eavesdropping: Eavesdropping is an unauthorized real-time attack where private communications, such as phone calls, text messages, fax transmissions or video conferences are intercepted by an attacker. It tries to steal information that is transmitted over a network. It takes advantage of unsecure transmission to access the information being sent and received. Node Capture: It is one of the hazardous attacks faced in the perception layer of IoT. An attacker gains full control over a key node, such as a gateway node. It may leak all information including communication between sender and receiver, a key used to make secure communication and information stored in memory Fake Node and Malicious: It is an attack in which an attacker adds a node to the system and inputs fake data. It aims to stop transmitting real information. A node added by an attacker consumes precious energy of real nodes and potentially control in order to destroy the network. Replay Attack: It is also known as a play back attack. It is an attack in which an intruder eavesdrops on the conservation between sender and receiver and takes authentic information from the sender
  • 17. Network Layer: Common security threats and problems to network layers are: Denial of Service (DoS) Attack: A DoS attack is an attack to prevent authentic users from accessing devices or other network resources. It is typically accomplished by flooding the targeted devices or network resources with redundant requests in an order to make it impossible or difficult for some or all authentic users to use them Main-in-The-Middle (MiTM) Attack: MiTM attack is an attack where the attacker secretly intercepts and alters the communication between sender and receiver who believe they are directly communicating with each other Storage Attack: The information of users is stored on storage devices or the cloud. Both storage devices and cloud can be attacked by the attacker and user’s information may be changed to incorrect details. The replication of information associated with the access of other information by different types of people provides more chances for attacks. Exploit Attack: An exploit is any immoral or illegal attack in a form of software, chunks of data or a sequence of commands. It takes advantage of security vulnerabilities in an application, system or hardware. It usually comes with the aim of gaining control of the system and steals information stored on a network [
  • 18. Application Layer Common security threats and problem of application layer are: Cross Site Scripting: It is an injection attack. It enables an attacker to insert a client-side script, such as java script in a trusted site viewed other users. By doing so, an attacker can completely change the contents of the application according to his needs and use original information in an illegal way. Malicious Code Attack: It is a code in any part of software intended to cause undesired effects and damage to the system. It is a type of threat that may not be blocked or controlled by the use of anti-virus tools. It can either activate itself or be like a program requiring a user’s attention to perform an action. The ability of dealing with Mass Data: Due to a large number of devices and a massive amount of data transmission between users, it has no ability to deal with data processing according to the requirements. As a result, it leads to network disturbance and data loss.
  • 19.
  • 20. Support Layer: The support layer has two responsibilities. • It confirms that information is sent by the authentic users and protected from threats. There are many ways to verify the users and the information. The most commonly used method is the authentication. It is implemented by using pre-shared secrets, keys and passwords. • The second responsibility of the support layer is sending information to the network layer. The medium to transmit information from the support layer to network layer can be wireless and wire based. • Common threats and problems of the support layer are • DoS Attack: The DoS attack in a support layer is related to the network layer. An attacker sends a large amount of data to make network traffic inundated. Thus, the massive consumption of system resources exhausts the IoT and makes the user not capable of accessing the system. • Malicious Insider Attack: It occurs from the inside of an IoT environment to access the personal information of users. It is performed by an authorized user to access the information of other user. It is a very different and complex attack that requires different mechanisms to prevent the threat
  • 21. It is the responsibility of IoT to facilitate users by performing their tasks. It is the most important element of IoT to fulfill its responsibilities. It acts like the brain of IoT. It gets all information and makes appropriate decisions to send responses to the devices.
  • 24. CLIENT SENDS REQUEST TO SERVER SERVER Receives request from client, process request, looks up/fetches resources prepares responds and sends respondns to client Resources Request Response Request - Response Communication Model
  • 30. Difference between M2M and IoT Area IoT M2M Communication Protocols Focus of communication in IoT is usually on the protocols above the network layer such as HTTP,CoAP,MQTT, etc. Uses propreitary on non IP based communication protocols for communication within M2M networks. eg. ZIGBEE,6LoWPAN,Bluetooth etc. Machines in M2M vs things in IoT Things in IoT referes to physical objects that have unique identifiers and can sense and communicate with their external environment or their internal physical states. The unique identifiers are the IP(or MAC). Things have software components for accessing,processing and storing sensor information.
  • 31. Area IoT M2M Hardware vs Software emphasis More on software More on Hardware Data Collection and Analysis data collected on cloud Data collected in point solutions
  • 33. IoT Communication API REST-Based Communication API (Representational State Transfer) • Set of architectural principlas by which web services/API can be designed that focus on system resources and how resources states are addressed and transferred. • Follows the REQUEST-RESPONSE communication model. • REST architectural constraints : • Client-Server: • Stateless • Cache-able • Layered System • Uniform Interface • Code on Demand
  • 34. Client-Server: Constraint of seperation of concerns. Clients should not be concerned with storage of data which is a concern of server. Server should not be concerned about the user interface which is a concern of client. Seperation allows client and server to be independently developed 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. Cache-able: Cache constraint requires that the data within a response to a request be implicitly or explicitly be labeled as cache-abled or non-cache-abled. 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: constraints the behaviour of components such that each component cannot see beyond the immediate layer with which they are interacting. For eg. a client cannot say if it is directly connected to the end server or through an intermediate.
  • 35. Uniform Interface: Requires that the method of communication between a client and server is uniform. Resources are identified in the requests. 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 contexts.
  • 37. HTTP Request methods and actions
  • 39. SDN and NFV for IoT
  • 42. Centralized Network Controller(CNC): With decoupled control and data planes and centralized network controller , the network controller can rapidly configure the network. SDN applications can be deployed through programmable open API. Programmable Open API: SDN support programmable open API. for interface between SDN application and control layers. With the open API various network services such as routing, QoS, access control can be implemented. Standard Communication Interface(OpenFlow): SDN uses a standard communication interface between the control and infrastructure layers. OpenFLow which is defined by Open Networking Foundation(ONF) is the broadly accepted protocol for the southbound interface. With OpenFlow, the forwarding plane of the networking device can be directly accessed and manipulated. OpenFlow uses the concept of flow to define network traffic based on pre-defined rules. Flows can be programmed statically or dynamically by the SDN software.
  • 44. OPEN FLOW TABLE: Open FLow protocol is implemented on both sides of the interface between the controller and the network device. The controller manages the switch via the open flow switch protocol. The controller can add, update, delete flow entries in table. Each flow table contains a set of flow entries. Each flow entries consists of match fields , counters and a set of instructions to apply to matching packets.
  • 46. NFV is a technology that leverages virtualization to consolidate the heterogenous network devices onto industry standard high volume servers, switches and storage. NFV is complimentay to SDN as NFV can provide infrastructure on which it runs. They are mutually beneficial for each other but not dependent. VNF: VNF is the software implementation of a network function which is capable of running over the NVF Infrastructure(NVFI). NVF Infrastructure(NVFI): NFVI includes compute,network and storage that are virtualized. NFV Management and Orchestration:Focuses on all virtualization-specific management tasks and covers the orchestration and life cycle management of physical and /or software resources that support the infrastructure virtualization and the life cycle management of VNF.
  • 48. Home network with virtualized home gateway
  • 49. IoT Platforms design methodology • Important to design a generic design methodology independent of specific product ,service or programming language. • STEP 1: Purpose and Requirements specification: • Define the purpose and requirements of the system(such as data collection requirements,data analysis requirements,system management requirements, data privacy and security requirements,user interface requirements).
  • 50. Fig: Steps involved in the IoT system design methodology
  • 51. Process Specification: Here USE CASE of the system is formally described based and derived from purpose and requirements specification. Fig: Process specification for home automation system
  • 52. STEP 3:DOMAIN MODEL SPECIFICATION: The domain model describes the main concepts, entities and objects in the domain of IoT system to be designed. Domain model defines the attributes of the objects and the relationships between objects. Defines the attributes of the objects and the relationships between objects. Physical Entity: Identifiable entity in physical environment(eg. a room, a light, a car etc.) IoT system provides information about physical entity using sensors. In home automation system two physical entities - one is the room (of which lighting conditons to be monitored and other is the light appliance to be controlled. Virtual Entity: Representation of physical entity in the digital world. For each physical entity there is a virtual entity in the domain model. Device: Provides a medium for interactions between physical entities and virtual entities. They are used to gather information about physical entities. Resource: Software components which can be either on device or network resources. Service: Provides an interface for interacting with physical entities.
  • 53. In HOME AUTOMATION there are three services: 1) Service that sets mode to auto or manual or retreives the current mode. 2) Service that sets the light appliance state to ON/OFF or retreives the current light state. 3) A controller service that runs as a native service on the device. In AUTO Mode the controller service monitors the light level and swithches the light ON/OFF and updates the status in the status database. In MANUAL mode,the controller service retreives the current state from the database and switches the light ON/OFF.
  • 54.
  • 55. STEP 4: Information model specification: Here Information model defines the structure of all information in the IoT system. Eg. attributes of virtual entities , relations etc. First the virtual entities are listed defined in the DOMAIN model. Later more details are added to the virtual entities by adding attributes and relations. In home automation there are two virtual entities - a virtual entity for light appliance ( with attribute light and state) and a virtual entity for the room( with attribute light level)
  • 56. Connecting to Pi connected locally • ssh pi@raspberrypi.local
  • 57. Making ready the working environment
  • 59. Putting the LED 'ON & OFF' import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BOARD) blinkCount=3 count=0 LEDPin=22 #setup the pin the Led is connected to GPIO.setup(LEDPin,GPIO.OUT) while count < blinkCount: GPIO.output(LEDPin,True) print("LED ON") sleep(3) GPIO.output(LEDPin,False) print("LED off") sleep(1) count +=1
  • 61. For uploading error: Cannot write to serial port
  • 63. In the lower-right part of the Arduino board, you’ll see six pins marked “Analog In”; these are special pins that can tell us not only whether there is a voltage applied to them, but if so, also its value. By using the analogRead() function, we can read the voltage applied to one of the pins. This function returns a number between 0 and 1023, which represents voltages between 0 and 5 volts. For example, if there is a voltage of 2.5 V applied to pin number 0, analogRead(0) returns 512.
  • 64. delay takes parameter in milliseconds i.e 1000ms=1sec
  • 65.
  • 66.
  • 67. Connecting through a PUSH Button We connect three wires to the Arduino board. The first goes from one leg of the pushbutton through a pull-up resistor (here 2.2 KOhms) to the 5 volt supply. The second goes from the corresponding leg of the pushbutton to ground. The third connects to a digital i/o pin (here pin 7) which reads the button's state. When the pushbutton is open (unpressed) there is no connection between the two legs of the pushbutton, so the pin is connected to 5 volts (through the pull-up resistor) and we read a HIGH. When the button is closed (pressed), it makes a connection between its two legs, connecting the pin to ground, so that we read a LOW. (The pin is still connected to 5 volts, but the resistor in-between them means that the pin is "closer" to ground.)
  • 68.
  • 70.
  • 71. For example, if the object is 20 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 588 microseconds. But what you will get from the Echo pin will be double that number because the sound wave needs to travel forward and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2.
  • 72. 1. First do the wiring as shown in the picture 2. Open Arduino IDE Software and write down your code, or download the code below and open it 3. Choose your own Arduino board (in this case Arduino Uno), by selecting Tools > Board > Arduino/Geniuno Uno 4. Choose your COM Port (usually it appears only one existing port), Tools > Port > COM.. (If there are more than one ports, try it one by one) 5. Upload your code by pressing Ctrl + U or Sketch > Upload 6. To display the measurement data you can use Serial Monitor by pressing Ctrl + Shift + M (make sure that the baudrate speed is 9600) pulsein():Reads a pulse (either HIGH or LOW) on a pin. For example, if value is HIGH, pulseIn() waits for the pin to go from LOW to HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds or gives up and returns 0 if no complete pulse was received within the timeout.
  • 73. #define echoPin 2 // attach pin D9 Arduino to pin Echo of HC-SR04 #define trigPin 3 //attach pin D8 Arduino to pin Trig of HC-SR04 // defines variables long duration; // variable for the duration of sound wave travel int distance; // variable for the distance measurement void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT Serial.begin(9600); // // Serial Communication is starting with 9600 of baudrate speed Serial.println("Ultrasonic Sensor HC-SR04 Test"); // print some text in Serial Monitor Serial.println("with Arduino UNO R3"); }
  • 74. void loop() { // Clears the trigPin condition digitalWrite(trigPin, LOW); delayMicroseconds(2); // Sets the trigPin HIGH (ACTIVE) for 10 microseconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back) // Displays the distance on the Serial Monitor Serial.print("Distance: "); Serial.print(distance); Serial.println(" cm"); }
  • 75. int sensorPin = A0; int sensorValue; int limit = 300; void setup() { Serial.begin(9600); pinMode(13, OUTPUT); } void loop() { sensorValue = analogRead(sensorPin); Serial.println("Analog Value : "); Serial.println(sensorValue); if (sensorValue<limit) { digitalWrite(13, HIGH); } else { digitalWrite(13, LOW); } delay(1000); } Connecting moisture sensor to arduino
  • 78. This Dallas Temperature library is a hardware-specific library which handles lower-level functions. It needs to be paired with One Wire Library to communicate with any one-wire device not just DS18B20. Install this library as well.
  • 79. #include <OneWire.h> #include <DallasTemperature.h> // Data wire is plugged into digital pin 2 on the Arduino #define ONE_WIRE_BUS 2 // Setup a oneWire instance to communicate with any OneWire device OneWire oneWire(ONE_WIRE_BUS); // Pass oneWire reference to DallasTemperature library DallasTemperature sensors(&oneWire); void setup(void) { sensors.begin(); // Start up the library Serial.begin(9600); } void loop(void) { // Send the command to get temperatures sensors.requestTemperatures(); //print the temperature in Celsius Serial.print("Temperature: "); Serial.print(sensors.getTempCByIndex(0)); Serial.print((char)176);//shows degrees character Serial.print("C | "); //print the temperature in Fahrenheit Serial.print((sensors.getTempCByIndex(0) * 9.0) / 5.0 + 32.0); Serial.print((char)176);//shows degrees character Serial.println("F"); delay(500); }
  • 80.
  • 81. Arduino IR sensor int IRSensor = 2; // connect ir sensor to arduino pin 2 int LED = 13; // conect Led to arduino pin 13 void setup() { pinMode (IRSensor, INPUT); // sensor pin INPUT pinMode (LED, OUTPUT); // Led pin OUTPUT } void loop() { int statusSensor = digitalRead (IRSensor); if (statusSensor == 1) digitalWrite(LED, LOW); // LED LOW } else { digitalWrite(LED, HIGH); // LED High } }
  • 82. 4 digit 7 -segment display
  • 83.
  • 84. import serial import time # Define the serial port and baud rate. # Ensure the 'COM#' corresponds to what was seen in the Windows Device Manager ser = serial.Serial('/dev/ttyACM2', 9600) def led_on_off(): user_input = input() user_input.strip() if user_input =="on": print("LED is on...") time.sleep(0.1) ser.write(b'H') led_on_off() elif user_input =="off": print("LED is off...") time.sleep(0.1) ser.write(b'L') led_on_off() elif user_input =="quit" or user_input == "q": print("Program Exiting") time.sleep(0.1) ser.write(b'L') ser.close() else: print("Invalid input. Type on / off / quit.") led_on_off() time.sleep(2) # wait for the serial connection to initialize led_on_off() Python Ardudino Interaction to control LED
  • 85. int data; int LED=13; String x; int y; void setup() { Serial.begin(9600); //initialize serial COM at 9600 baudrate pinMode(LED, OUTPUT); //declare the LED pin (13) as output digitalWrite (LED, LOW); //Turn OFF the Led in the beginning Serial.println("Hello!,How are you Python ?"); } void loop() { while (!Serial.available()); x = Serial.readString(); x.trim(); Serial.print(x[0]); Serial.print("before if x"); Serial.print(x); //Turn On the Led if (x[0]=='H') { digitalWrite (LED, HIGH); //Turn On the Led Serial.print("true"); } else if (x[0] =='L') digitalWrite (LED, LOW); //Turn OFF the Led }
  • 87. MQTT
  • 88. sudo apt-get update sudo apt-get install mosquitto; sudo apt-get install mosquitto-clients
  • 89.
  • 90.
  • 91. The architecture MQTT BROKER(MAY ALSO RUN ON A CLOUD SERVER) MQTT PUBLISHER(Commands ON or OFF MQTT SUBSCRIBER LED CIRCUIT ssh pi@raspberrypi.local
  • 92. MQTT SUBSCRIBER import paho.mqtt.client as mqtt from blink2 import blin broker_url="192.168.60.252" broker_port=1883 def on_connect(client, userdata, flags, rc): print("Connected With Result Code ", rc) def on_disconnect(client, userdata, rc): print("Client Got Disconnected") def on_message(client, userdata, message): strng=message.payload.decode() print("Message received" + strng) blin(strng) client = mqtt.Client() client.on_connect = on_connect client.on_message = on_message client.connect(broker_url, broker_port) client.subscribe("LED", qos=1) client.loop_forever()
  • 93. MQTT PUBLISHER import paho.mqtt.client as mqtt import sys broker_url="192.168.60.252" broker_port=1883 def on_connect(client, userdata, flags, rc): print("Connected With Result Code " (rc)) def on_disconnect(client, userdata, rc): print("Client Got Disconnected") client=mqtt.Client() client.connect(broker_url,broker_port) #If the connection is successful, you will see it output 0 on the screen. client.publish(topic="LED", payload=sys.argv[1], qos=0, retain=False) #client.loop_forever() Running the code: python mqttpub.py ON
  • 94. Modified blink to blink2 import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BOARD) LEDPin=22 #setup the pin the Led is connected to GPIO.setup(LEDPin,GPIO.OUT) def blin(param): if param=="ON": GPIO.output(LEDPin,True) sleep(3) elif param=="OFF": GPIO.output(LEDPin,False) print("LED off") sleep(1)
  • 95. MQTT & moisture sensor
  • 96. Testing water content from PI 5v GND DO
  • 97. import RPi.GPIO as GPIO import time #GPIO SETUP channel = 16 GPIO.setmode(GPIO.BOARD) GPIO.setup(channel, GPIO.IN) def callback(channel): if GPIO.input(channel): print "Water Detected!" GPIO.add_event_detect(channel, GPIO.BOTH, bouncetime=300) # let us know when the pin goes HIGH or LOW GPIO.add_event_callback(channel, callback) # assign function to GPIO PIN, Run function on change
  • 98. Interfacing with MQTT 5v GND DO Mqtt publisher output output mqtt subscriber
  • 99. MQTT MOIST_PUBLISHER import paho.mqtt.client as mqtt import sys import RPi.GPIO as GPIO channel=16 msg="N" broker_url="192.168.60.252" broker_port=1883 def on_connect(client, userdata, flags, rc): print("Connected With Result Code " (rc)) def on_disconnect(client, userdata, rc): print("Client Got Disconnected") client=mqtt.Client() client.connect(broker_url,broker_port) #If the connection is successful, you will see it output 0 on the screen. GPIO.setmode(GPIO.BOARD) GPIO.setup(channel,GPIO.IN) def mycallback(channel): global msg if GPIO.input(channel): msg="ON" client.publish(topic="MOIST",payload=msg,qos=0,retain=Fa lse) print("ON") else: msg="OFF" client.publish(topic="MOIST",payload=msg,qos=0,retain=Fa lse) print("OFF") GPIO.add_event_detect(channel,GPIO.BOTH) GPIO.add_event_callback(channel,mycallback) #client.publish(topic="MOIST", payload=msg, qos=0, retain=False) client.loop_forever()
  • 100. MQTT MOIST_SUBSCRIBER import paho.mqtt.client as mqtt from blink3 import blin broker_url="192.168.60.252" broker_port=1883 def on_connect(client, userdata, flags, rc): print("Connected With Result Code ", rc) def on_disconnect(client, userdata, rc): print("Client Got Disconnected") def on_message(client, userdata, message): strng=message.payload.decode() print("Message received" + strng) blin(strng) client = mqtt.Client() client.on_connect = on_connect client.on_message = on_message client.connect(broker_url, broker_port) client.subscribe("MOIST", qos=1) client.loop_forever()
  • 101. CloudMqtt • From subscriber ubuntu terminal • mosquitto_sub -h postman.cloudmqtt.com -p 14798 -t LED -u xejupbki -P ReeIdW8jsAv0
  • 105. The first App- Hello world
  • 106. Interacting App with Pi. • https://medium.com/@gaikwadchetan93/android-real-time- communication-using-mqtt-9ea42551475d • except the service version in the build gradle
  • 107. MQTT: Message Queuing Telemetry Transport
  • 108. At any time, clients can subscribe to and unsubscribe from one or more topics by connecting to a broker. So if a new industrial device is installed (e.g., a new reactor, “reactorX” ), the IT operations will have to configure its IoT node with the Internet Protocol (IP) address and connection details of the broker. When booting up, the new IoT node will announce its presence to the broker and subscribe to the requested topics. MQTT subscribers and publishers are transient and can come and go at any time, and could receive old, queued messages when they come back online.
  • 109. CoAP: Constrained Application Protocol CoAP is a client-server protocol, which means that the data exchange is initiated by a client node with a request sent to a server node, which will answer with a response. CoAP does not require the client to open or keep a connection to a server because it’s based on User Datagram Protocol (UDP). At any time, a client can send one CoAP packet to a server. Each request has a few options, with the most important one being the Uniform Resource Identifier (URI), which indicates the “path” to the requested resource — much like Uniform Resource Locators (URLs) for websites. Note that a node could be both server and client at the same time, implementing a point-to-point, full- duplex data layer.
  • 110. Following the same example used in the MQTT description above, a client node could command another node to, say, “turn on” or “execute a given task,” by sending a CoAP packet such as “/station1/substation3/reactor3” with payload “on” . The CoAP server will interpret the URI, extract the “on” payload, and decide what to do according to its logic. Depending on the request, the server could reply with an acknowledgment, or just remain silent: Not all requests must be acknowledged.
  • 111.
  • 112. Vulenerability in MQTT Implementation • MQTT Vulnerability
  • 114. Previous versions of the standard contained vulnerable pseudocode examples as a reference for developers. For example, the code example to parse the “remaining length” field in packets changed between versions 3.1 8 and 3.1.1 9 + errata, 10 going from a “no check” to “wrong check” and then to “correct check”. This turned out to be an interesting pattern to look for, leading us to discover a memory error (exploitable to obtain a remote code execution primitive) in real MQTT implementations. On top of this, the MQTT version 5.0 specification 11 is not entirely compatible with previous versions, which could delay its future adoption despite the security improvements that it brings.
  • 115. Unicode Handling in Topic Strings Another interesting venue prone to error is the handling of topic strings. The first issue is that the standard leaves it up to the developers’ choice to close the connection upon failing validation of disallowed UTF-8 code points.