ch07-Wireless Embedded Internet-HMI (1)
ch07-Wireless Embedded Internet-HMI (1)
Content
Chapter 7: Wireless Embedded Internet
ICMPv6
Auto-configuration & Neighbor Discovery
IP routing in WSNs: RPL
Embedded web – REST/CoAP
MQTT-SN
HMI
IPv6 review
IPv4 and IPv6
comparison
6LoWPAN: IPv6
Header Compression:
support L3 routing
(Route-Over)
6LoWPAN Neighbor
Discovery (ND)
ICMPv6
Internet Control Message
Protocol v6
Modification from ICMP for IPv4
Neighbor Discovery (ND)
Replace ARP, ICMP
Reachability of Neighbors
Hosts use to discovery routers,
auto-configuration of addresses
Duplicate Address Detection
(DAD)
5 ND messages:
• Router Solicitation (type 133)
• Router Advertisement (type 134)
• Neighbor Solicitation (type 135)
• Neighbor Advertisement (type 136)
• Redirect (type 137)
Auto-configuration
IP Routing in WSNs
Low power and Lossy Network (LLN) consists of an
edge router (also called as LLN Border Router LBR),
Router(R) and Host(H):
H chooses only the default router
R forwards traffic
ROLL operates only within LoWPAN and terminates at LBR
LLNs: Fact
LLNs have not to be confused with Wireless Sensor Networks
A WSN is an LLN, but not the opposite !
LLNs are not necessarily wireless.
Industrial automation networks are wired.
LLNs will use IPv6. No discussions about this.
IPv4 is a dead horse.
LLN nodes can not be easily configured.
Typically, they’re cheap, small and with very limited memory/CPU
Upward Route
Downward: the direction from the
DODAG root towards leaf nodes
Data flow away from the DAG root –
P2MP traffic flows
RPL Metrics
A metric defines how a node (or link) will affect the path. A
metric is used to compute the node’s rank and to decide
about preferred Parents.
Each metric is carried in a DAG Metric Container,
embedded in the relevant RPL control messages.
Node metrics: Node-related information, such as: Node
State and Attributes, Node Energy, Hop-Count
Link metrics: Link-related information, such as:
Throughput, Latency, Link Reliability, Link Color
Routing metric:
RFC 6551: path calculations (node energy, hop count, throughput,
latency, etc…
Rank vs OF
Rank: node's individual position relative to other nodes
with respect to a DODAG root
Increases in the Down direction and decreases in the Up
direction
Rank computed depends on the Objective Function (OF) - e.g.
calculated as a simple topological distance (hop counts) or may
also be calculated as a function of link metrics
Objective Function (OF): Defines the optimization
objectives to compute the Rank
Optimization objectives : minimizing energy, minimizing latency,
or satisfying some constraints, etc…
Dictates how routers (parents) inside the DODAG are selected.
RPL Instance
RPL Instance: Composed of one or more disjoint DODAGs, each of
which has an unique DODAGID
All DODAGs in the same RPL Instance use the same OF (Objective
Function)
DAG Construction
Distance-Vector
advertise path cost (routing
metric)
choose a parent (default router/
next hop) that minimize path
cost
Avoids loops & count-to-infinity
Assign every node a rank
Node Rank: Relative position
within a DODAG
Rank strictly decreasing towards
the root
Parents & Siblings
Parents –nodes with lower ranks
Siblings –nodes with same ranks
Dept. of Telecoms Engineering 21
Design and Development of IoT Applications 5-Aug-24
RPL does not guarantee the absence of loops but rather tries to avoid them
and specifies mechanisms to detect loops via data path validation
Dept. of Telecoms Engineering 22
Design and Development of IoT Applications 5-Aug-24
Non-storing mode
Only the root stores routes to the
all routers in WSNs
Calculates routes to all destination
by piecing together the info
(address of the routers) collected
from DAO messages
Data forwards using source routing
Dept. of Telecoms Engineering 25
Design and Development of IoT Applications 5-Aug-24
RPL Repair
Global repair: makes use of DODAG Sequence Numbers
Local repair - poison the sub-DODAG by advertising the rank of
INFINITY
DAG Construction
LLN links are depicted
LBR-1 LBR is configured by the
1 2 system administrator (There
3 could be several LBR)
A
1
B
1
C Links are annotated w/ ETX
1
1
1
RPL uses new ICMPv6
messages
1
4
F D E DIO: DODAG Information Object
1 DAO: Destination Advertisement
1 1 1
Object
1 DIS: DODAG Information
G H I
Solicitation
DAG Construction
Objective Code Point for
LBR-1
example
1 2
Metric: ETX
3 Objective: Minimize ETX
1 1 Depth computation: Depth ~ ETX
A B C
• Note that a practical computation
1 may be more coarse
1 1
1
4
F D E
1
1 1 1
1
G H I
DAG Construction
LBR-1 multicasts RA-DIO
LBR-1 Nodes A, B, C receive and
1 2 process RA-DIO
3
Nodes A, B, C consider link
1 1
A B C metrics to LBR-1 and the
1
1
1
optimization objective
1
The optimization objective can
4
F D E be satisfied by joining the DAG
1 1
1
1
rooted at LBR-1
Nodes A, B, C add LBR-1 as a
1
G H I DAG parent and join the DAG
DAG Construction
Node A is at Depth 1 in the
LBR-1
DAG, as calculated by the
1 2
routine indicated by the
3 example OCP (Depth ~ ETX)
A
1
B
1
C Node B is at Depth 3, Node C
1
is at Depth 2
1 1
Nodes A, B, C have installed
1
F D 4
E default routes (::/0) with
1
LBR-1 as successor
1 1 1
1
G H I
DAG Construction
The RA timer on Node C
LBR-1 expires
1 2 Node C multicasts RA-DIO
3
LBR-1 ignores RA-DIO from
1 1
A B C deeper node
1
1
1 Node B can add Node C as
1
alternate DAG Parent,
4
F D E remaining at Depth 3
1 1
1
1 Node E joins the DAG at
Depth 3 by adding Node C as
1
G H I DAG Parent
If a node is configured to act as a router, it starts advertising the graph information to its neighbors
A leaf node, it simply joins the graph and does not send any DIO message
Dept. of Telecoms Engineering 34
Design and Development of IoT Applications 5-Aug-24
DAG Construction
LBR-1 multicasts DIO
LBR-1 Node A is at Depth 1, and can
1 2 reach ::/0 via LBR-1 with ETX
3 1
A
1
B
1
C Node B is at Depth 3, with
1 DAG Parents LBR-1, and can
1 1
reach ::/0 via LBR-1 or C with
1
F D 4
E ETX 3
1 Node C is at Depth 2, ::/0 via
1 1 1
LBR-1 with ETX 2
G
1
H I Node E is at Depth 3, ::/0 via
C with ETX 3
DAG Construction
The RA timer on Node A expires
LBR-1 Node A multicasts RA-DIO
1 2
LBR-1 ignores RA-DIO from
3
deeper node
Node B adds Node A
1 1
A B C Node B can improve to a more
1 optimum position in the DAG
1 1
Node B removes LBR-1, Node C
1
4
as DAG Parents
F D E
Node B removes (keeps as
1 backup)
1 1 1
::/0 via LBR-1 with ETX 3
1
::/0 via C with ETX 3
G H I Adds:
::/0 via A with ETX 2
DAG Construction
Node A is at Depth 1, ::/0 via
LBR-1 LBR-1 with ETX 1
1 2 Node B is at Depth 2, ::/0 via
3
A with ETX 2
1 1
A B C Node C is at Depth 2, ::/0 via
1
1
1
LBR-1 with ETX 2
1
Node E is at Depth 3, ::/0 via
4
F D E C with ETX 3
1
1 1 1
1
G H I
DAG Construction
DAG Construction
continues…
LBR-1
1 2
And is continuously
3
maintained
This rippling effect builds the
1 1
A B C graph edges out from the
root to the leaf nodes where
1
1 1 the process terminates
Each node of the graph has a
1 routing entry towards its
4
F D E
parent in a hop‐by‐hop
1 fashion
1 1 1
The leaf node can send a
1 packet all the way to root of
G H I the graph by just forwarding
the packet to its immediate
parent
1
G H I
Destination Advertisements
Some nodes may be able to
LBR-1 store routing state for outward
1 flows (LBR-1, A, F)
Some nodes may not (B, D)
1
A B Some nodes may have a
1
limited ability; DAs may
indicate a priority for storage
1
F D
1 1
1
G H
Destination Advertisements
DAs may be triggered by DAG
LBR-1 root or node who detects a
1 change
1
A B DA timers configured such
1
that DAs start at greater
depth, and may aggregate as
1
F D they move up
1 1
1
G H
Destination Advertisements
LBR-1 triggers Destination
LBR-1
Advertisement mechanism in DIO
1 G emits NA to F with DAO
indicating reachability to
A
1
B destination prefix G::
F stores G:: via G
1
H emits NA to F for destination
1
F D prefix H::
1 1
F stores H:: via H
1
G H
Destination Advertisements
Suppose in this example F has a
LBR-1
prefix F*:: capable of aggregating
1
{F::, G::, H::}
The method to provision such a prefix is
1 beyond the scope of RPL
A B
F emits NA to D with DAO indicating
1 reachability to destination prefix F*::
F
1
D
D cannot store…
1 1
(continued)
1
G H
Destination Advertisements
D adds F to the Reverse Route Stack
LBR-1 in the DAO, and passes DAO on to B
1 for F*:: [F]
D also emits a DAO indicating prefix
1
A B D:: to B
1
B cannot store routing state…
1
F D
1 1
(continued)
1
G H
Destination Advertisements
B adds D to the Reverse Route
LBR-1 Stack in the DAO for D::, and passes
1 DAO D:: [D] on to A
A stores D:: via B, with the
1
A B piecewise source route [D]
1
B also emits a DAO indicating prefix
B:: to A
1
F D A stores B:: via B
1 1
(continued)
1
G H
Destination Advertisements
A emits DAOs to LBR-1 for
LBR-1 destination prefixes A::, B::, D::,
1 and F*
LBR-1 stores A:: via A, B:: via A,
1
A B D:: via A, and F*:: via A
1
A stored B:: via B, D:: via B [D],
F* via B [D, F]
1
F D B, D stored nothing
1 1 F stored G:: via G, H:: via H
1
G H
P2MP Traffic
The routing state setup by
LBR-1 Destination Advertisement is used
1 to direct P2MP traffic outward
LBR-1 directs traffic for G (F*::) to A
1
A B A adds source routing directive, [D,
1
F], and forwards to B
1
B uses source routing directive to
F D forward to D...
1 1
1
G H
P2MP Traffic
D uses source routing directive to
LBR-1 forward to F
1 F uses routing state to forward to G
Note the use of source routing to
1
A B traverse the stateless region of the
1
LLN
The details of the source routing
1
F D mechanism are still to be defined
1 1
1
G H
P2P Traffic
By default, P2P traffic follows
LBR-1 the default route until a node
1 2 is encountered who has a
3 more explicit route
A
1
B
1
C P2P traffic flows inwards
1 along the DAG until a
1 1
common node is reached to
1
F D 4 E direct the traffic outwards
1
1 1 1
1
G H I
P2P Traffic
The default scheme allows
LBR-1 P2P traffic with minimal state
1 2 required of nodes – but is
3 not appropriate in all cases
A
1
B
1
C More optimal P2P routes
1 may be computed and
1 1
installed if the application
1
F D 4 E requires
1
RPL does not specify nor
1 1 1 preclude such a mechanism at
this time
1
G H I
1
G H I
1
G H I
1
G H I
DAG Maintenance
Node I multicasts an RA-DIO
LBR-1 Node D sees a chance to
1 2 rejoin grounded DAG at
3
depth 5 through Node I
1 1
A B C Node D starts a DAG Hop
1
1
1
timer of duration 4
associated with Node I
1
F D 4 E
1
1 1 1
1
G H I
DAG Maintenance
Suppose a link A—F becomes
LBR-1
viable
1 2 Node A multicasts an RA-DIO
3
Node F sees a chance to
1 1
A B C rejoin grounded DAG at
1 depth 2 through Node A
1 1 1
Node F starts a DAG Hop
1
F D 4 E timer of duration 1
1 associated with Node A
1 1 1
1
G H I
1
G H I
Loop Avoidance
Two mechanisms to avoid count-to-infinity
Floating DAG
Leave DAG, color sub-DAG, then look for new routes
Operation local to nodes that must increase their depth
Does not guarantee loop freedom
RPL: summary
Working with 6LoWPAN
Support IP-based Application
Support P2MP, MP2P traffic
Routing state is minimized: stateless nodes have to
store only instance(s) configuration parameters and a
list of parent nodes
Consider both link and node properties when choosing
paths
Link failures does not trigger global network re-
optimization
IPv4 Interoperability
Design Issues
Link Layer
Payload size, limited
bandwidth, lossy
Multicast support
Networking
Limited compressed UDP port
Host issues
Sleeping cycles
Identification (64 bit, 16 bit
addresses)
Compression
Header and payload
compression
End-to-end or by an
intermediate node
Security
Application layer security
Firewalling at the edge router
Dept. of Telecoms Engineering 69
Design and Development of IoT Applications 5-Aug-24
Web Service
De-facto for inter-server
communications
All Internet servers speak HTTP/XML
SOAP or REST architecture
Advantages
Formal message sequences
Internet-wide support
Most Internet applications use web
services, which depend on the basic
Representational State Transfer (REST)
architecture
Disadvantages for embedded services
Inefficient, complex
REST Architecture
Representational State Transfer (REST)
Describes client-server and cacheable communications
protocol, such as HTTP, to make simple calls between
network devices
REST-style architectures consist of clients and
servers
Clients initiate requests to servers
Servers process requests and return appropriate
responses
Requests and responses are built around the transfer of
representations of resources
Resources: mostly identified by its URI (Uniform
Resources Identifier)
Resources may be web-address, a physical resource or
simply a document located somewhere on a server
Representations: to manipulate resources
Representation defines the format of the resource
Typical representations are HTML, XML or JSON,
but may be also binary, plain-text, MIME types, etc
Methods: allows clients to retrieve, modify or delete
resources by use of their representations
The basic operations/methods on a resource are GET,
PUT, POST and DELETE
Dept. of Telecoms Engineering 71
Design and Development of IoT Applications 5-Aug-24
Resource
Protocols (e.g. HTTP, CoAP)
Sources of specific information
(e.g. sensors, web-content)
Identified by an Uniform
Resource Identifier (URI)
Manipulation through
Methods (e.g. GET, PUT)
Represented as jpg, plain-text,
etc.
CoAP is not
A replacement for HTTP
General HTTP compression
Separate from the web
CORE Architecture
Use of web services on the Internet
depends on the Representational C: Constrained node ‐ sensor nodes
State Transfer (REST) architecture Non‐constrained nodes ‐ server,
RESTful protocol to cater the special proxy, node, etc
requirements of a constrained
environment
Simple RESTful protocol transport
Create, Read, Update, Delete, Notify
• Small, simple header
• 4 byte base header
• TLV options, typically 1-270 bytes per
option
URI support: e.g.
coap://fec0::1:5683/temp
Subset of content types
Subset of HTTP-compatible response
codes
UDP bindings
default port = 5683
Option Header
Option Delta- Difference
between this option type
and the previous!
Length - Length of the
option value (0-270)!
Value- The value of
Length bytes
immediately follows
Length
CoAP Code
Structure of the 8 bit
Response code:
3 classes:
2 – Success
4 – Client error
5 – Server error
Methods of CoAP
CoAP Operation
CoAP interaction is similar to the client/server model (CoAP
end points)
URI and Content-type support (like in HTTP)
Message exchange is similar to HTTP
Request action is originated by a client (using a Method code)
Request is for a Resource (identified by a URI) on a server
Response is sent with a Response Code
CoAP Operation
Unlike HTTP, CoAP deals
Operates over UDP, with reliable unicast
and multicast support
• Retransmission (= reliable unicast) A CoAP end-
point keeps track of open Confirmable
messages it sent that are waiting for a response
• Simple Congestion Control - exponential back-
off mechanism
Deals with message interchanges
separately
• Server might need longer time to obtain the
representation of resource. This results in the
client retransmitting the request
CoAP Operation
Operates over UDP, with
reliable unicast and best-
effort multicast support
CON vs NON messages?
If CON/NON messages cannot
be processed,
Server sends RST message
Why MID & Token?
CoAP Options
Content‐Type: Specifies the format of the application payload
Max‐Age: Maximum age for a message to be cached
Proxy‐Uri: Defines an absolute URI to a proxy
Token: Matches a separate response to a request
Uri‐Host: Specifies the Internet host of a resource (only added
if not representing the destination IP address of the request)
Uri‐Path: Specifies the resource of the host
Uri‐Port: Specifies the port of the host (only added if differs
from the destination UDP port request)
Uri‐Query: Indicates additional options for the request
etc..
Request Example
Request and Response
CON message
NON message
Request Example
Normal response
Caching
CoAP includes a simple
caching model
Cache ability determined by
response code
Freshness model
Max-Age option indicates
cache lifetime
Validation model
Validity checked using the Etag
Option
A proxy often supports
caching
Usually on behalf of a sleeping
node,
and to reduce network load
Observation
The Observe Option, when present,
modifies the GET method so it does
not only retrieve a representation
of the current state of the resource
identified by the request URI, but
also requests the server to add the
client to the list of observers of the
resource.
In a response, the Observe Option
identifies the message as a
notification, which implies that the
client has been added to the list of
observers and that the server will
notify the client of further changes
to the resource state
Block Transfer
Transfers larger than can be accommodated in constrained-network link-
layer packets can be performed in smaller blocks.
No hard-to-manage conversation state is created at the adaptation layer
or IP layer for fragmentation.
Resource Discovery
Resource Discovery with CoRE Link Format
Web linking as per RFC5988
Discovering the links hosted by CoAP servers
GET /.well-known/core
Returns a link-header style format
URL, relation, type, interface, content-type etc.
MQTT
MQTT (Message Queuing
Telemetry Transport) is a
machine-to-machine
connectivity protocol that
runs over TCP/IP.
Lightweight, simple,
MQTT is based on a
publish- subscribe
structure:
Publisher
Broker
Subscriber
QoS Support
QoS 0, QoS 1, QoS 2
MQTT: Benefits
Lightweight and efficient: MQTT reports by exception and message
headers are very small, minimizing the resources required for the
client and network bandwidth.
Bi-directional: allows messaging from devices to the cloud and from
the cloud to devices, which enables broadcasting messages to
groups of things.
Supports unreliable networks: support for persistent sessions
reduces the reconnection time required over unreliable networks.
Scalable: can scale to connect millions of IoT devices simultaneously.
Security enabled: MQTT makes it easy to encrypt messages using
TLS (transport layer security) and authenticate clients using modern
authentication protocols, such as OAuth.
Reliable: The publish/subscribe functionality and the ability to
queue messages means no data loss through MQTT. MQTT also
supports reliable message delivery through the three defined QoS
Dept. of Telecoms Engineering 94
Design and Development of IoT Applications 5-Aug-24
MQTT Example
Clients do not have addresses like in
email systems, and messages are not
sent to clients.
Messages are published to a broker
on a topic.
The job of an MQTT broker is to filter
messages based on topic, and
then distribute them to subscribers.
A client can receive these messages by
subscribing to that topic on the same
broker
There is no direct connection between
a publisher and subscriber.
All clients can publish (broadcast) and
subscribe (receive).
MQTT brokers do not normally store
messages.
MQTT-S Protocol
MQ Telemetry transport for WSNs
Publish/Subscribe protocol
Optimized for low-bandwidth wireless
sensor networks (MQTT-S)
Integrated with Brokers (gateways)
Can be used with UDP/6LoWPAN
Model: client/broker
Application: M2M
MQTT-S Protocol
Connect message split into three messages, two are optional
and are used for the will message
Topic ID’s used in place of topic names.
Short Topic names
Pre-defined topics.
Discovery process to let clients discover the Gateway
Will Topic and messages can be changed during the session
Offline keep alive procedure for sleeping clients.
MQTT-SN Architecture
When client 1 talks to client 2 does it require the MQTT broker
to do so? Specifically in the diagram above for clients 3 and 4.
Is it: MQTT-SN >MQTT-SN. In this case the gateway is also a
MQTT-SN broker.
or is it: MQTT-SN >MQTT>MQTT-SN. In this case the gateway is
an MQTT-SN gateway and an MQTT broker.
http://www.steves‐internet‐guide.com/mqtt‐sn/
Dept. of Telecoms Engineering 98
Design and Development of IoT Applications 5-Aug-24
MQTT-SN in Contiki
Gateway Type: The specification defines two gateway
types:
A transparent gateway were each MQTT-SN connection has
a corresponding MQTT connection. This is the easiest type
to implement.
An aggregating gateway were multiple MQTT-SN
connections share a single MQTT connection
http://www.steves‐internet‐guide.com/mqtt‐sn/
Dept. of Telecoms Engineering 99
Design and Development of IoT Applications 5-Aug-24
http://www.steves‐internet‐guide.com/mqtt‐sn/
Dept. of Telecoms Engineering 101
Design and Development of IoT Applications 5-Aug-24
MQTT-SN in Contiki
MQTT-SN with RSMB in Contiki
COAP/MQTT-SN
Human-Machine Interface
Benefit:
Make the Smart Applications more than a
Remote-control system
Natural interaction with humane (via voice,
gesture, etc..)
Technologies:
AI, Machine learning, Data Science
Cloud-based or local model (AI on-the-Edge)
Human-Machine Interface
Integrated Alexa, Google Voice
Human-Machine Interface
-
IP/LoWPAN
Border Router
control
HMI
WSN
Voice
LoWPAN/IPv6
network
Human-Machine Interface
-
subscribe
topics
IP/LoWPAN
Border Router
control
MQTT Client
WSN
LoWPAN/IPv6
network
IoT Cloud
IoT Device
Text