Steven Edouard SDET, US - DX Audience West Microsoft Bruno Terkaly Principal Software Engineer - Microsoft
Steven and Bruno Info
Section 3 Software Architecture
Section 7 The Protocol challenge
Progress IoT Robotics Machine Learning Big Data Social (Twitter, Facebook) Cloud Mobile Wafers CPUs Memory The Internet Time
Some IOT Examples
Example Internet of Things (IoT) devices 2014
Example Internet of Things (IoT) devices 2014
A prior project with Arduino Home Network Arduino Sprinkler Controller http Sprinkler Valve Data / State Service Bus Background Process National Weather Service Linux Virtual Machine Python Admin WebSite Mobile Services Azure Cloud
Doorbell soldered to a Raspberry PI Phone Application receiving notification
Why Cloud? Processing lots of information (sensors, cameras) Limited Compute Power Limited Battery Security Issues
Acoustic, sound, vibration Automotive, transportation Electric current, electric potential, magnetic, radio Chemical Flow, fluid velocity Environment, weather, moisture, humidity
Ionizing radiation, subatomic particles Navigation instruments Position, angle, displacement, distance, speed, acceleration Pressure Force, density, level Thermal, heat, temperature Proximity, presence Optical, light, imaging, photon Sensor technology
Let s build our own device Azure is the glue that binds these devices together Doorbell Camera Raspberry PI ios, Android, Windows Phone You could have a common code base with Xamarin
System board A/C adapter General purpose input/output (GPIO) breakout Breadboard wires Assorted resisters and LEDs Breadboard
Understanding the GPIO One of the core components is the GPIO breadboard. The GPIO is a hardware circuit with 26 separate pins (numbered left to right) that let you expand the system to interact with other devices. Generally, these pins let you connect such things as sensors, actuators, LEDs and so on. There are different types of pins, though.
There are two pins providing a power source for connected devices, specifically a 3.3 volt and a 5 volt. There s also a 0 volt pin that acts as a ground, which is necessary to define a circuit.
If you wish to perform serial communications, you ll find TX and RX pins (RS-232) for transmitting and receiving data. The software that runs on the device will need to communicate with these pins.
Section 3 Software Architecture Service Bus Storage Raspberry Linux mono C# Queues JavaScript Node.js
What are the pieces to the architecture? Part Cloud, Part Client Dev Azure for cloud, Linux for Raspberry OS, Mono Runtime Installed Languages: C# Service Bus Queues Storage Raspberry Linux mono JavaScript Node.js
Service Bus Queues MongoDB - MongoLabs Queues Azure Mobile Services API Notification Hub Azure Storage Uploaded Images Mobile
Cloud is ideal for Real-Time Analysis: Time-Series, Map/Reduce Finding relationships existing between phenomena or things or between mathematical or statistical variables Results in Alerting, Limit Detection Pre-emptive troubleshooting Data Analytics, Machine Learning Pattern Detection Behavior Prediction Plausibility Analysis Fraud Detection Power and scale of cloud computing
Telemetry A client device sends data (one way) to a cloud service. Temperature 4 Patterns For Devices To Communicate With Cloud Notification Inquiry A client device sends a query to the cloud service and receives a response. A cloud service issues a command to a client device and the client device returns a success or failure response. Maintenance required Turn on cooling/heating Command A cloud service issues a oneway out-of-band notification to a client device that s important for the device s operation. Go into wait state
Azure s many capabilities Network Compute Storage Virtual Machine Services (Windows, Linux, etc) VPN Cloud Storage SQL Hadoop/HDInsight Web Sites Cloud Services Media Services Active Directory Multi Factor Auth Mobile Services Service Bus Notification Hub BizTalk Services Traffic Manager, Load Balancing, Firewall Node.js, Java, PHP, Perl, Python, Ruby NoSQL
Cloud Services Service Bus Queue
Getting connected directly to storage services Azure Mobile Services API Request SAS key 1 Doorbell Camera Raspberry PI 2 Receive SAS key 3 Send SAS key and photo to Azure Storage Azure Storage Uploaded Images Linux and Mono http -> Key Point Device can talk directly to storage with HTTP
Why are Service Bus Queues so powerful 2) Azure Storage Uploaded Images 4) 3 rd Party Face Recognition API 5) Service Bus Queues expose a regular RESTful API MongoLab Allows you to send and receive messages by Azure Mobile long Services polling API Long polling is an HTTP connection open for a Notification Hub certain period of time 1) 3) Service Bus Queues Long polling is a great technique for IoT computing scenarios because it supports timeouts 6) This allows devices to close the connections until the next long poll Queues Provides relief to power consumption and network resources
Data Storage In the Cloud Key-value stores Azure tables, Redis, DynamoDB Types of data stores in NoSQL world Column Family stores Cassandra, HBASE Document Store MongoDB, CouchDB Graph store Neo4J
Skip
Various languages operate at different speeds on Raspberry PI. When pin22 is true, the photo taking process starts in TakeAndSendPicture We used C# Python is fairly slow and you can t use it in scenarios where speed is crucial Client Code 10hz is fast enough to check if the doorbell switch has pulled pin22 (connected to doorbell)
Code running on Raspberry PI 1. Take a photo 2. Get the key so we can upload photo 3. Upload photo 4. Put a message on the queue
Node.js code that gives SAS key to PI
C# code running on Mono on Raspberry PI Do a post to endpoint in cloud Build body part of http post Skip
Network Connectivity Do we have a problem?
Network Connectivity For many years, secure connectivity meant using TCP/IP with IPv4, combined with VPNs. This worked reasonably well, but is now showing signs of age.
For starters, it s difficult to get a unique IP address We ve pretty much run out of IP addresses Diehard fans have an answer IPv6 will come to the rescue
The conventional wisdom is that if you give the device a unique IP address, all your difficult problems are solved Unfortunately, this solves only a small part of the overall problem Giving each device its own unique IP address is definitely not the silver bullet many had hoped
Just to be clear, IPv6 and VPNs are fraught with problems in a crowded, connected-device world. Bandwidth, in particular, is a challenge. Chatty connectivity between device and network can lead to excessive traffic.
Using typical HTTP request/response approaches for all messaging drains battery life on many devices Too many wasteful bytes are sent This can get prohibitively expensive if you re supporting thousands of devices
Imagine your device has to send temperature data every 5 seconds The payload for the temperature data is a generous 20 bytes In a 24-hour period, the temperature data by itself would transmit from the device to the cloud about 350,000 bytes
Now add HTTP request/response envelope HTTP introduces an extra 800 bytes This is a factor of 41 Sending more than 14MB to the cloud instead of just the 350KB of temperature data.
How safe is this device? Not at all if this device is part of a VPN Because it is not under your immediate physical control Once a single device is breached, all devices connected to the same VPN are vulnerable Using a VPN is largely equivalent to having a network adapter on that network IPv4, IPv6, and all protocols that are built upon them What is the preferred solution?
Section 7 The Protocol challenge
Are there some alternative protocols? What is AMQP?
Advanced Message Queuing Protocol Microsoft supports Advanced Message Queuing Protocol (AMQP) AMQP is a binary and bidirectional open protocol with support for many platforms, including Embedded Linux. 1.0 was added first in the Azure Service Bus (middle of 2013) Microsoft works directly with the Apache Foundation contributing to Apache QPid Proton Provides message orientation, queuing, routing, pubsub, reliability and security. It is very efficient