Outline: 1. Iot Architecture 2. Iot Protocol Stack
Outline: 1. Iot Architecture 2. Iot Protocol Stack
Outline
1. IoT Architecture
2. IoT Protocol Stack
3. Bluetooth
4. ZigBee
5. 6LoPAN
6. LoRa
7. MQTT - Message Queueing Telemetry Transport
8. CoAP - Constrained Application Protocol
9. XMPP - eXtensible Messaging and Presence Protocol
10. Protocol Implementation
11. IoT Communication APIs
IoT Architecture
IoT Broker Architecture
IoT Protocol Stack : Standardized IoT Protocols
Radio Communication
• Electromagnetic Waves
• No medium required
• Modulation
• Well described mystery
• Wireless/Airwaves
• Inverse Square Law
Bluetooth
• Bluetooth is a network technology that connects mobile devices wirelessly over a short-range to form a personal area network (PAN).
• A cable replacement technology.
• Developed by Ericsson-1994.
• Operates in the unlicensed industrial, scientific and medical (ISM) band at 2.4 GHz
• Frequency Hopping scheme (1600 hops/sec)
• 1 Mb/s symbol rate
• Range 10+ meters
• Single chip radio + baseband
• Key features:
• Robustness
• low complexity
• low power, and
• low cost.
• It is a significant protocol for IoT applications.
Bluetooth Applications
• In laptops, notebooks and wireless PCs
• In mobile phones and PDAs (personal digital assistant).
• In printers.
• In wireless headsets.
• In wireless PANs (personal area networks) and even LANs
(local area networks)
• To transfer data files, videos, and images and MP3 or MP4.
• In wireless peripheral devices like mouse and keyboards.
• In data logging equipment.
• In the short-range transmission of data from sensors devices
to sensor nodes like mobile phones.
• Physical Layer − This includes Bluetooth radio
and Baseband (also in the data link layer.
• Radio − This is a physical layer equivalent
protocol that lays down the physical
structure and specifications for
transmission of radio waves. It defines air
interface, frequency bands, frequency
hopping specifications, and modulation
techniques.
• Baseband − This protocol takes the services
of radio protocol. It defines the addressing
scheme, packet frame format, timing, and
power control algorithms.
• Data Link Layer − This includes Baseband, Link Manager Protocol (LMP), and Logical Link Control and
Adaptation Protocol (L2CAP).
• Link Manager Protocol (LMP) − LMP establishes logical links between Bluetooth devices and
maintains the links for enabling communications. The other main functions of LMP are device
authentication, message encryption, and negotiation of packet sizes.
• Logical Link Control and Adaptation Protocol (L2CAP) − L2CAP provides adaption between upper
layer frame and baseband layer frame format. L2CAP provides support for both connection-oriented
as well as connectionless services.
• Middleware Layer
• RFComm − It is short for Radio Frontend Component. It provides a serial interface with WAP.
• Adopted Protocols − These are the protocols that are adopted from standard models. The commonly
adopted protocols used in Bluetooth are Point-to-Point Protocol (PPP), Internet Protocol (IP), User
Datagram Protocol (UDP), Transmission Control Protocol (TCP), and Wireless Application Protocol
(WAP).
• Service Discovery Protocol (SDP)− SDP takes care of service-related queries like device information so
as to establish a connection between contending Bluetooth devices.
• AT Commands − ATtention command set.
• Applications Layer − This includes the application profiles that allow the user to interact with the
Bluetooth applications.
HC-05 6pin Bluetooth Module
802.15.4
• Low Power
• Low bandwidth
• Addressing
• Affordable
• Small
• Standardized
• Popular
802.15.4 Configurations
• Single Peer
• Multi Peer
• Broadcast
802.15.4 Architecture
Applications
ZigBee
• Star
• Mesh
• Whip
Antennas
• Chip
• RPSMA
• u.FL
Regular vs. Pro
• 1-2mW • 50-60mW
• Smaller • Longer
• Shorter range (100m) • Longer range (300m)
• Cheaper
• More expensive
ZigBee Stack Architecture :
TELECOM SERVICES
asset mgt security
process HVAC
control m-commerce lighting control
environmental INDUSTRIAL
CONTROL info services HOME CONTROL
access control
energy mgt object interaction (Internet of irrigation
Things) Slide 19
Comparison with peer technologies!
Edge router
• Runs special protocols
• Simplifies operation
• Shared database: Whiteboard
43
MQTT interaction model
44
MQTT in Short
• MQTT is a Client Server publish/subscribe messaging
transport protocol
• More features:
• Simple to implement (especially at the sensor side)
• QoS Support
• Lightweight and bandwidth efficient and Data agnostic
• Session awareness
45
MQTT Architecture
MQTT Communication Pattern
Publish/Subscribe paradigm
•Clients don’t know each other
• One-to-Many paradigm
•Every client publishes & subscribes
•PUSH information paradigm compared to PULL’s one in COAP
47
MQTT Components
• Broker and connected Clients
• broker receives subscriptions from clients on
topics
• broker receives messages and forward them
• clients subscribe/publish on topics
• Brokers bridge configuration
MQTT Packet Format
MQTT Open Connection
CONNECT
message fields:
MQTT Publishing
PUBLISH
message fields:
MQTT QoS 0: “at most once”
55
MQTT for Sensor Networks – MQTT-SN
• Uses UDP
• Supports topic name indexing
• Reduced size of the payloads (by numbering the data packets with
numeric topic id’s rather than long topic names)
56
Getting Started with MQTT
• MQTT protocol brokers:
• Mosquitto
• HiveMQ
• Emqttd
• ActiveMQ
• IBM MessageSight
• JoramMQ
• RabbitMQ
• VerneMQ
60
CoAP at a Glance
61
COAP using GET and RESTful URLs
62
HTTP vs. CoAP
63
CoAP Messaging Basics
• Transport:
• (mainly) UDP binding
• Message Exchange between Endpoints
• Messages with 4 bytes header (shared by request and
responses) containing a message ID (16 bits)
• Reliable exchange through Confirmable Messages which must
be acknowledged (through ACK or Reset Messages). Simple
Stop-and-Wait retransmission with exponential back-off.
• Unreliable exchange through Non-Confirmable Message
• Duplicate detection for both confirmable and non-confirmable
messages (through message ID)
64
CoAP Message Format
66
CoAP Message Semantics
CoAP Request and Response
CoAP Request and Response Example
CoAP Separate Response Example
CoAP Non-confirmable Request Example
CoAP Dealing with Packet Loss
75
CoAP vs MQTT
• MQTT is a many-to-many communication protocol for passing messages between
multiple clients through a central broker. It decouples producer and consumer by letting
clients publish and having the broker decide where to route and copy messages. While
MQTT has some support for persistence, it does best as a communications bus for live
data.
• CoAP is, primarily, a one-to-one protocol for transferring state information between
client and server. While it has support for observing resources, CoAP is best suited to a
state transfer model, not purely event based.
• MQTT clients make a long-lived outgoing TCP connection to a broker. This usually
presents no problem for devices behind NAT. CoAP clients and servers both send and
receive UDP packets. In NAT environments, tunnelling or port forwarding can be used to
allow CoAP, or devices may first initiate a connection to the head-end as in LWM2M.
• MQTT provides no support for labelling messages with types or other metadata to help
clients understand it. MQTT messages can be used for any purpose, but all clients must
know the message formats up-front to allow communication. CoAP, conversely, provides
inbuilt support for content negotiation and discovery allowing devices to probe each
other to find ways of exchanging data.
76
Getting Started with CoAP
• Open source implementations:
• Java CoAP Library Californium
• C CoAP Library Erbium
• libCoAP C Library
• jCoAP Java Library
• OpenCoAP C Library
• TinyOS and Contiki include CoAP support
• Firefox has a CoAP plugin called Copper
• Wireshark has CoAP plugin
77
CoAP Summary
• Like HTTP, CoAP is a document transfer protocol. Unlike HTTP, CoAP is designed for the
needs of constrained devices.
• CoAP packets are much smaller than HTTP TCP flows. Bitfields and mappings from strings
to integers are used extensively to save space. Packets are simple to generate and can be
parsed in place without consuming extra RAM in constrained devices.
• CoAP runs over UDP, not TCP. Clients and servers communicate through connectionless
datagrams. Retries and reordering are implemented in the application stack. Removing
the need for TCP may allow full IP networking in small microcontrollers. CoAP allows
UDP broadcast and multicast to be used for addressing.
• CoAP follows a client/server model. Clients make requests to servers, servers send back
responses. Clients may GET, PUT, POST and DELETE resources.
• CoAP is designed to interoperate with HTTP and the RESTful web at large through simple
proxies.
• Because CoAP is datagram based, it may be used on top of SMS and other packet based
communications protocols.
78
XMPP - eXtensible Messaging and Presence Protocol
Who uses XMPP?
• Cisco Webex
• WhatsApp uses a trimmed down version
• Google’s Firebase and Google’s Android
XMPP
• Bi-directional streaming XML
• Core: IETF RFC 3920, 3921
• Extensions: XMPP Standards Foundation (XSF)
• Membership-based
• Elected technical council
• Unit of work: XMPP Extension Protocol (XEP)
• Process: Experimental, Proposed, Draft, Final
• Goals:
• Simple clients
• Federate everything
XMPP was originally named Jabber
90
Protocol Implementation
Protocol Implementation
IoT Communication APIs
• REST – based Communication APIs
• WebSocket – based Communication APIs
REST-based Communication APIs
• Representational State Transfer (REST) is a set of architectural
principles by which you can design web services and web APIs that
focus on a system’s resources and how system resource states are
addressed and transferred
• REST APIs follow the request-response communication model
• The REST architectural constraints apply to the components,
connectors, and data elements within a distributed hypermedia
system
REST Architectural Constraints
• Client –Server
• The principle behind the client-server constraints is the separation of
concerns
• Stateless
• Each request from client to server must contains all the information
necessary to understand the request
• The session state is kept entirely on the client
• Cache-able
• Cache constraints requires that the data within a response to a request be
implicitly or explicitly labeled as cache-able or non-cache-able
REST Architectural Constraints
• Layered System
• Layered system constraints, constraints the behavior of components such
that each component cannot see beyond the immediate layer with which
they are interacting
• Uniform Interface
• Interface constraints requires that the method of communication between a
client and a server must be uniform
• Code on demand
• Servers can provide executable code or scripts for clients to execute in their
context
WebSocket-based Communication APIs
• WebSocket APIs allow bi-directional, full duplex communication
between clients and servers
• It follows the exclusive pair communication model
• WebSocket APIs reduce the network traffic and latency as there is no
overhead for connection setup and termination requests for each
message