Introduction to Internet of Things
Alexander Nelson
December 2, 2019
University of Arkansas - Department of Computer Science and Computer Engineering
Internet of Things
Internet of Things (IoT) – Network of devices, and connectivity to
interact & exchange data
What ramifications does IoT have for embedded systems?
1
History
Machine-to-Machine (M2M) Communication – Systems exchange
information w/ no user interaction
Caller ID (1968) – Phones needed to process analog waveform to
exchange identifier
Smart Meters & Load balancing (1977) → precursor to smart grid/ modern smart meters
Cellular M2M (1995) – GSM module “M1” - share data over
cellular network
Device-to-Device (D2D) – Direct M2M connection without
traversing WAN/core network
Either cellular or unlicensed spectrum (e.g. WiFi/Bluetooth)
2
History – Carnegie Mellon – Connected Coca-Cola machine1
In the mid-seventies expansion of the department caused people’s
offices to be located ever further away from the main terminal room
where the Coke machine stood. It got rather annoying to traipse down
to the third floor only to find the machine empty - or worse, to shell
out hard-earned cash to receive a recently loaded, still-warm Coke.
One day a couple of people got together to devise a solution.
They installed micro-switches in the Coke machine to sense how many
bottles were present in each of its six columns of bottles. The
switches were hooked up to CMUA, the PDP-10 that was then the main
departmental computer. A server program was written to keep tabs on
the Coke machine’s state, including how long each bottle had been in
the machine. When you ran the companion status inquiry program, you’d
get a display that might look like this:
EMPTY EMPTY 1h 3m
COLD COLD 1h 4m1https://www.cs.cmu.edu/~coke/history_long.txt 3
https://www.cs.cmu.edu/~coke/history_long.txt
History – Computer for the 21st Century (1991)
Precurser to PDAs / tablets / smart TVs
4
History
1999 – The term “Internet of Things” attributed to Kevin Ashton
(prefers Internet for Things)
2002 – Cooltown (HP Labs) – URLs with links to object
descriptors & actions
2008-2009 – Number of connected objects outnumbered connected
people
5
Forecast
Number of Connected Devices
6
How can 50B devices all be connected?
6
Wireless Networking Categories
• LPWAN – Low PowerWide Area Network
• WWAN - WirelessWide Area Network
• WPAN – WirelessPersonal Area
Network
• WLAN – WirelessLocal Area Network
7
WWANs
Wireless Networking Categories
2
2“Smart Cities Technologies” Ivan Nunes Da Silva and Rogerio Andrade –
ISBN 978-953-51-2808-3
8
WWAN – Wireless Wide Area Network
WWAN – Set of technologies that provide wireless access to
geographically distant sources
Includes:
• Cellular Technologies• 2G• 3G• LTE• LTE-M
• IEEE 802.16 – WiMAX• LPWAN Technologies
• LoRA• SigFox• Ingenu
• Mesh Networking?
9
Cellular Communications
Cellular Network – Communication network where last link is
wireless
Distributed over land areas – “cells”
3
3By Andrew pmk - SVG version of Frequency reuse.fig by Mozzerati, CC
BY-SA 2.5, https://commons.wikimedia.org/w/index.php?curid=2155967 10
Cellular Communications
Advantages:
• More capacity than a single large transmitter, same frequencyused for multiple links in different cells
• Cell towers are closer – Mobile devices use less power thanwith single transmitter
• Larger coverage area than a single terrestrial transmitter –additional cell towers can be added indefinitely
11
Cellular Communications
Range is inversely proportional to frequency
CDMA2000 Network
12
WiMAX
WiMAX – Worldwide Interoperability for Microwave Access
Microwave meaning 300MHz-300GHz frequencies
Meant to provide “last-mile” broadband over wireless
Originally 30-40Mbps – Upgraded to 1Gbps in 2011
13
WiMAX
WiMAX – Worldwide Interoperability for Microwave Access
Microwave meaning 300MHz-300GHz frequencies
Meant to provide “last-mile” broadband over wireless
Originally 30-40Mbps – Upgraded to 1Gbps in 2011
Most WiMAX deployments are winding down
14
LPWAN Communications
LPWAN – Low Power Wide Area Network
Designed for long range communications at low bit rates
Data Rates – 0.3kbps-50kbps
15
LPWAN Communications
LPWAN – Low Power Wide Area Network
Designed for long range communications at low bit rates
Data Rates – 0.3kbps-50kbps
Intended for sensor-type deployments at long range
Power IoT/Smart-City type applications
16
LPWAN Communications
17
Mesh Networks
WANETs – Wireless Ad hoc Networks
MANETs – Mobile Ad hoc Networks
ad hoc – latin, literally “for this” – Does not rely on static
infrastructure
MANETs allow for nodes to move freely geographically
18
Mesh Networks
Mesh Networks as WWAN?
Communications technologies similar to cellular networks
Can provide WAN access to small devices through sink nodes
19
Wireless Network Challenges
Wireless Communication
Given a certain amount of RF frequency spectrum, how to
optimize communication?
Metrics:
• Throughput – Total network bits-per-second• Latency – Average time form packet creation to reception• Fairness – Do devices receive equal share of resource
(airtime)?
20
Multiple Access Techniques
If multiple wireless clients exist, how to divide resources?
Multiple Access Methods – Techniques for dividing resources
• CSMA – Carrier Sense Multiple Access• TDMA – Time Division Multiple Access• FDMA – Frequency Division Multiple Access• CDMA – Code Division Multiple Access• SDMA – Space Division Multiple Access
21
Carrier-Sense Multiple Access
CSMA – Carrier Sense Multiple Access
Nodes check to see if anyone is communicating
If channel is empty, they may start
22
Hidden Node Problem
Not detecting communication does not mean channel is clear
23
CSMA/CA
CSMA/CA – CSMA with Collision Avoidance
1. Carrier Sense – Listen for other transmission
2. Random Backoff – If channel is busy, backoff for random
amount of time
3. Request to Send/Clear to Send (RTS/CTS) – Access
Control Signals
4. Transmission – Send entire packet to Access Point (AP)
5. Acknowledgment – AP sends acknowledgment if packet is
received
6. Exponential Backoff – If no ACK, assume collision and
backoff
24
CSMA
Advantages
• Low latency if channel is not busy• No need for centralized control
Disadvantages
• Busy channel causes many collisions – low throughput & highenergy waste
25
TDMA
TDMA – Time Division Multiple Access
4
4By Mozzerati at English Wikipedia - 13:13, 2004 Sep 5 (UTC), CC BY-SA
3.0, https://commons.wikimedia.org/w/index.php?curid=32927708
26
TDMA
Advantages
• Nodes only need to listen during frame – save power• Guaranteed no collision
Disadvantages
• Lower Throughput – A node may not need to use their frame
27
FDMA
FDMA – Frequency Division Multiple Access
Divide available frequency into channels
Nodes communicate on their own channel
Wi-Fi FDMA – 5MHz channel width – 22MHz spectrum spread
28
CDMA
CDMA – Code Division Multiple Access
Use orthogonal psuedorandom codes to allow additive
communication on same spectrum
Four mutually orthogonal codes29
CDMA Example
30
CDMA
Advantages
• Multiple nodes may communicate at the same time• Flexible length of codes – dynamic allocation
Disadvantages
• Reduced throughput per device per frameThat is, takes n times as long to transmit a single bit, where n
is length of the code
• Subject to Near-Far problem
31
Near Far Problem
Problem with SNR for geographically disparate nodes
Near node Noise may be similar to magnitude of far node signal
32
Phase Shift Keying
Phase Shift Keying – PSK
Code division multiple access – Codes are multiplexed by phase
rather than time
33
Protocols
OSI Model
The network technologies
under the four categories
implement the
Transport/Internet layers
of the TCP/IP Model
34
Application Layer Protocols – HTTP
Hypertext Transfer Protocol (HTTP)
Hypertext Transfer
Protocol (HTTP)
Communication basis of
the World Wide Web
Implements a
Request–Response
protocol
35
HTTP Model
HTTP Model –
• Network of Nodes• Nodes contain some text• Nodes can be referenced by hyperlinks (links)• Hyperlinks are identified by Uniform Resource Locators
(URLs)
• URLs are Uniform Resource Identifiers (URIs) with specificschemes (HTTP/S)
• Clients request resources from servers based on URL
36
HTTP Requests
HTTP Requests–
• GET – Retrieve data and have no other effect• HEAD – Asks for response for a GET without the body• POST – Post a resource at a new URI• PUT – Store a resource under a specified URI• DELETE – Remove a resource at a URI• TRACE – Echo received requests to verify changes by
intermediates
• OPTIONS – What methods are available at the URL• CONNECT – Converts request connection to a TCP/IP
tunnel (for SSL)
• PATCH – Apply partial modifications to a resource
37
How can HTTP be leveraged for Ubiquitous
Computing?
37
Web Services
What is a web service?
Set of functions that can be accessed over HTTP protocols
Provide response through a serialized data protocol (e.g. XML,
JSON)
Why use Web Services?
• Allow transmission of data from or to a remote server• Perform proprietary data transformations• Transmit data between programs
38
REST Webservices
REST – Representational State Transfer
Developed in tandem with HTTP 1.1 and formalized in 2000
Distill data transfer to a core set of principles
39
REST Architecture
Core Architectural Properties:
• Performance – Maximize network efficiency• Scalability – Support large number of components and
interactions
• Simplicity and Uniformity in interfaces• Visibility of communication between components• Portability of program code and data• Reliability of components to failures
40
REST Architecture
Six guiding constraints:
• Client-Server Architecture/Model• Statelessness – No client context is stored on the server
between requests
• Cacheability – Clients can cache responses• Layered System – Client doesn’t know if it is connected
directly to the end server
• Code on demand – Temporarily extend functionality of clientby transferring executable code
• Uniform Interface
41
REST Methods
REST Web services use the available HTTP methods
Most often, REST services use four common methods:
• GET• PUT• POST• DELETE
Behavior depends on whether the URL specifies an element or a
collection
42
REST URLs
REST Services use URLs to specify data and method locations
Example:
http://example.com/api/path/?parameter=1&otherparameter=2
The URL will specify:
• HTTP (or HTTPS) as the transfer protocol• The server domain location• The path on the server to the particular function• Optional set of parameters following a ? and separated by &s
43
Collection vs. Element
Element (or Resource) – Object with a type
May have:
• Associated Data• Relationships to other resources• Set of methods that operate on it
Collection – Set of elements
44
GET Method
If the URL points to a single element
Example:
GET http://del.icio.us/api/ahnelson/bookmarks/a211528
Returns information about a specific bookmark
If the URL points to a collection:
Example:
GET http://del.icio.us/api/ahnelson/bookmarks
Returns information about all the bookmarks associated with the
user ahnelson
45
POST Method
POST – Creates a new object
URL specifies the collection to which the object should be added
Specify fields using optional parameters
Often returns the URL of the created object
46
PUT Method
PUT – Can be used to create or update existing record*(s)
URL specifies the resource to be modified
Can prevent creation using PUT by returning a 404 error if
resource doesn’t exist
Specify fields to modify using optional parameters
Typically returns the URL of the modified object
47
DELETE Method
DELETE – Remove record(s)
URL specifies the element or the collection to be deleted
Often returns an HTTP response of 204 (No Content) if successful
48
Responses
The Responses include an HTTP Response code and optional
information in serialized language
Response Codes:
• 200 – OK• 201 – Created• 202 – Accepted• 401 – Unauthorized• 403 – Forbidden• 404 – Not Found
And others
49
Example
Let’s look at an example using test data from the web:
https://jsonplaceholder.typicode.com/
50
Application Layer Protocols –
MQTT
MQTT
MQTT – (Formerly MQ Telemetry Transport)
Developed in 1999 with goals of minimal battery draw and
bandwidth usage to connect oil pipelines over a satellite connection
Implements a publish–subscribe pattern
51
MQTT
MQTT Publish/Subscribe Pattern5
5https://www.hivemq.com/blog/mqtt-essentials-part2-publish-subscribe
52
Publish/Subscribe – Decoupling
Publish/Subscribe pattern decouples data by:
• Space Decoupling – Publisher/Subscriber do not need toknow each other (e.g. don’t need to know port or ip address)
• Time Decoupling – Publisher/Subscriber do not need to runat the same time
• Synchronization Decoupling – Operations on bothcomponents are not halted during publishing/receiving
53
Publish/Subscribe – Message Filtering
How does the broker (server) filter messages so that subscribers
only get correct messages?
• Subject-based Filtering – Filtering based on topic.Receiving client subscribes only to relevant topics. Topics are
slash-separated hierarchical URIs
• Content-based Filtering – When broker filters messagebased on specific content filter-language. Clients subscribe to
filter queries of messages they are interested in. (Message
may not be encrypted for this to work)
• Type-based Filtering – With Object Oriented Programming(OOP) languages, filtering based on type/class is common.
Subscriber could listen to all messages that are of the same
type.
54
MQTT – Client
MQTT Client – Any device connecting to an MQTT broker over
any network
e.g. Microcontroller over 6LoWPAN, Phone over Cellular, Server
over ethernet
Many client libraries are available for most languages
55
MQTT – Broker
MQTT Broker – Responsible for receiving, filtering, and sending
messages to clients
May be responsible for authentication and authorization
May be responsible for persisted clients and missed messages
Can handle thousands of concurrent clients
56
MQTT – Connection
MQTT Connection always from Client←→BrokerNever connecting directly with other clients
Once connection is established, it is kept open until client
disconnects
57
MQTT – Connect Message
Connect Message contains the following:
• clientId – identifer of each MQTT client (should be unique)• cleanSession (boolean) – if client wants persistent session• username* – authorization/authentication• password* – authorization/authentication• lastWillTopic* –• lastWillQos*• lastWillMessage*• lastWillRetain*• keepAlive – interval that client will sent “heartbeat” pings
58
Will Message
“Last Will and Testament”
Will Message – Message sent in event of ungraceful disconnect
Message sent by broker on behalf of client
59
MQTT – CONNACK Message
Connack message contains the following:
• sessionPresent (boolean) – Whether a persistent session existsfor the clientId
• returnCode (int)• 0 – Accepted• 1 – Refused – Unacceptable Protocol Version• 2 – Refused – Identifier Rejected• 3 – Refused – Server Unavailable• 4 – Refused – Bad Username/PW• 5 – Refused – Not Authorized
60
Publishing
After connection, clients may publish messages
Message Fields:
• packetId (int)• topicName (String)• QOS (int)• retainFlag (boolean)• payload (bytes)• dupFlag (boolean)
61
Publishing
Topic – Hierarchically structured string for message filtering
e.g. “UARK/CSCE5013/Sensor1/”
QoS – Quality of Service Level (0, 1, or 2)
Determines the guarantee of message reaching the other end
Retain-Flag – If message will be saved by broker as last known
good value
New subscribers will receive last retain-flag value
62
Publishing
Payload – Content of the message; data agnostic
Can be images, text, encrypted data, JSON, etc...
Packet Identifier – Unique identifier between client & broker
Identify message flow – only relevant for QOS >0
DUP flag – Indicates that message is a duplicate & resent because
of no ACK of original
Only relevant for QOS >0
63
Subscribing
Subscribe – Let broker know to forward messages based on topic
Subscribe message contains:
• packetId• Array of subscribing:
• Topics• QOS Levels
packetId – Verify that subscription happens exactly once
Confirmed by a SubACK from broker with return codes for each
subscription
64
Unsubscribe
Client can unsubscribe by posting an Unsubscribe message
Contains packetId, and topics to unsubscribe from
Confirmed by a unsubACK with a packetID
65
Topics
Topics are UTF-8 (a string encoding) case sensitive strings used to
filter messages
Consists of one or more topic levels
uark/csce5013/sensor1/temperature
4-level topic
Topics must contain at least 1 character, and spaces are
acceptable (but discouraged!)
Forward slash at beginning is also acceptable, but discouraged
i.e. /this topic and this topic are different!
66
Topics – Wildcards
Wildcards can be used to subscribe to more than 1 topic at once
Wildcard Characters:
• “+” – Single Level Wildcard• “#” – Multi Level Wildcard
67
Wildcard Examples
Example: Subscribing to uark/csce5013/+/temperature
• topic uark/csce5013/sensor1/temperature – Match• topic uark/csce5013/sensor2/humidity – No Match• topic /uark/csce5013/sensor1/temperature – No Match• topic uark/csce5013/sensor2/temperature – Match• topic uark/csce5013/Sensor1/Temperature – ?
Example: Subscribe to uark/csce5013/#
• uark/csce5013/sensor1/temparature – Match• uark/csce5013/sensor2/humidity – Match• uark/CSCE5013/ – No Match• uark/csce5013 – Match
68
Topics – Best Practices
Best Practices for Topics:
• Do not use leading forward slash• Do not use spaces in topics• Keep topic short & concise• Use only ASCII characters• Embed a unique identifier or ClientId into the topic• Don’t subscribe to #• Plan for product/programming evolution• Use specific topics rather than general
69
WWANsWireless Network ChallengesProtocolsApplication Layer Protocols – HTTPApplication Layer Protocols – MQTT