Contents
Unit-3 Design Principles for ➔ Web Communication protocols for Connected Devices:
Constrained RESTful environment (CoRE)
the Web Connectivity for ➔ Service oriented protocol (COAP)
➔ Communication protocols based on the exchange of messages
Connected-Devices
(MQTT)
➔ Web Connectivity for connected-Devices network using
SOAP,REST and HTTP RESTFUL.
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 2
Constrained Environment for Connected Devices CoAP (Constrained Application Protocol)
➔
➔ Data is limited in size
An IETF recommended protocol for constrained environment devices
➔ CoAP would become the standard protocol to enable interaction between devices and to support IoT applications
➔ A web-object’s data transfer standard protocol for sending a request or response
➔ 10s of Bytes from a device CoAP Features:
➔ Limited compared to data interchange of 1000s of bytes 1. It provides a simple discovery mechanism
2. Integration with Web is easy
between web clients and web servers when using HTTP, TCP 3. It provides asynchronous message exchange
and IP 4. Uses URIs to define resources/services
➔ Data routes over the low power and lossy (ROLL) network
5. Uses REST-like request/response model
6.Use of object model for resources, and each object can have single or multiple instances.
➔ Devices may sleep most of the time in low power environment 7.Each resource can have single or multiple instances
➔ Awakes when required (when a client initiates) 8.Supports resource directory and resource discovery functions.
9.The resource identifiers use the URIs coap://…
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 3 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 4
CoAP Structure Model Message Layer model
➔ CoAP employs a two layers structure. Message Layer supports 4 types message:
➔ The bottom layer is Message layer that
➔ CON (confirmable),
has been designed to deal with UDP and
➔ NON (non-confirmable),
asynchronous switching.
➔ ACK (Acknowledgement),
➔ The request/response layer concerns
➔ RST (Reset)
communication method and deal with
request/response message.
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 5 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 6
Reliable message transport Unreliable message transport:
➔ Keep retransmission until get ACK with the same ➔ transporting with NON type message.
message ID. ➔ It doesn't need to be ACKed, but has to contain
➔ Using default timeout and decreasing counting time message ID for supervising in case of retransmission.
exponentially when transmitting CON. ➔ If recipient fail to process message, server replies
➔ If recipient fail to process message, it responses by RST. shows unreliable message transport.
replacing ACK with RST. Fig shows a reliable
message transport.
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 7 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 8
Separate response: If server receive a
Request/response Layer model CON type message but not able to
response this request immediately, it
Piggy-backed: Client sends will send an empty ACK in case of client
request using CON type or NON resend this message.
type message and receives ➔ When server ready to response this
response ACK with confirmable
request, it will send a new CON to
message immediately.
client and client reply a confirmable
In fig, for successful response, message with acknowledgment.
ACK contain response message ➔ ACK is just to confirm CON
(identify by using token), for failure message, no matter CON message
response, ACK contain failure
carry request or response
response code.
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 9 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 10
Non confirmable request and response: unlike
Piggy-backed response carry confirmable
Message Format
message, in Non confirmable request client
send NON type message indicate that Server CoAP is based on the exchange of
compact messages that, by default, are
don't need to confirm. Server will resend a
transmitted over UDP (i.e. each CoAP
NON type message with response
message occupies the data section of one
UDP datagram) .
Message of CoAP uses simple binary
format. Message= fixed-size 4-byte
header plus a variable-length Token plus a
sequence of CoAP options plus payload.
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 11 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 12
COAP Client Web Connectivity
Transport Layer Security (TLS), earlier known as Secure Socket Layer (SSL) is the protocol
used for securing the TCP-based Internet data interchanges. DTLS(Datagram Transport Layer
Security) is the TLS for datagram. The features of DTLS are:
➔ DTLS provisions for three types of security services-integrity, authentication and
confidentiality.
➔ DTLS protocol derives from TLS protocol and binds UDP(User Datagram Protocol) for
secured datagram transport.
➔ DTLS is well suited for securing applications, for example, tunnelling applications (VPN),
applications that tend to run out of file descriptors or socket buffers or applications which
are delay sensitive (and thus use UDP).
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 13 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 14
Secured Use of a Key for Client
Authentication
PSK stands for Pre-Shared Key and is a method of securing using a key to authenticate a RPK stands for Random Pair-wise Keys, which also stands for Raw Public Key meaning only the
client. The key contains up to 133 characters in English. private/public key [means end 1 using RPK uses (KI and Kp) and the other end using RPK uses (K2 and
Kp)] are asymmetric.
➔ PSK method generates a unique encryption key for each client. A PSK is a symmetric key
without forward secrecy (sender key not secret from receiver). ➔ Public key refers to a key (for example, a set of 128 or 256 bits), Kp which an intermediate server
➔ Symmetric key means both ends 1 and 2 use the same key, K12 for encryption and or trusted entity, such as a bank server (or object) provides to both the sender and receiver.
decryption. Encryption uses an algorithm. ➔ The sender communicates using its key; for example, K1 and the receiver uses its key K2 when it
communicates to the server; the server uses Kp.
➔ Private key refers to a key agreed for usage of data encryption (ciphering) between a pair of
➔ Messages exchange between sender and server using Kl and Kp. Messages exchange between
sender and receiver. receiver and server using K2 and Kp.
➔ The key is kept private between the two, Sender and receiver can be objects, applications, ➔ The keys K1 and K2 are therefore kept secret between one another, sender and receiver. When
web services or processes. message or data communication takes place each uses its own secret key and Kp of an
intermediate server or entity.
➔ The advantage is that one communicating end cannot use the other end's key or even misuse that
key later.
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 15 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 16
COAP SMS
M2M or IoT device uses SMS quite frequently. SMS is identified as the transport protocol for
transmission of small data (up to 160 characters). It is used for communicating with a GSM/GPRS mobile
device.
➔ M2M or loT device uses message queuing quite frequently due to ROLL environment and
constrained devices (awake only when initiated) or connection-breaks for long periods.
➔ CoAP-SMS and CoAP-MQ are two protocols drafted and recommended by IETF.
➔ CoAP-SMS is a protocol when CoAP object uses IP as well as cellular networks and uses SMS.
➔ It is an alternative to UDP-DTLS over ROLL for CoAP object messages and when using cellular
communication.
➔ A CoAP client communicates to a mobile terminal (MT) endpoint over the General Packet Radio
Service (GPRS), High Speed Packet Access (HSPA) or Long Term Evolution (LTE) networks usin8
CoAP-SMS protocol.
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 17 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 18
Features of COAP SMS
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 19 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 20
➔ Figure(a) shows a CoAP request or response communication to a machine, ➔ Figure(c) shows a CoAP request or response communication from a
loT device or MT. machine, IoT device or MO. A CoAP client sends request to SMS-C which
◆ A CoAP client sends request to SMS-C which transmits the request to an MT. A CoAP
transmits the request.
server sends response to SMS-C which transmits the response to the client.
◆ A CoAP server sends the response to SMS-C which transmits it to the client.
➔ Figure (b) shows a computer or machine interface using IP for sending
➔ Figure(d) shows a computer or machine interface using IP for receiving
request or receiving the CoAP data or HTTP request (REQ) to a mobile
request or sending response (RES) as CoAP data or HTTP REQ mobile
service provider using SMPP or CIMD for data interchange.
service provider using SMPP or CIMD for data interchange.
◆ The service provider communicates using SS7 or CIMD or SMPP with machine or loT
◆ The SMS-C communicates that to CoAP-MQ BROKER using SS7 or CIMP or SMPP.
device or MT with an in-between node SMS-C.
◆ SMS-SP receives request or sends response to machine or loT device or mobile origin.
◆ The terminal sends response to the origin using SMS-C and CoAP-MQ Broker.
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 21 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 22
COAP MQ
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 23 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 24
HOW DOES MQTT WORK?
MQTT protocol architecture uses the publish-subscribe model.
➔ What it basically means is that the device sending the message and the device receiving the
message don’t communicate with each other directly, instead the publisher connects with the
broker, which then broadcasts the message to the devices that have subscribed or registered to
the particular topic.
➔ Publish/Subscribe model has data providers and data consumers instead of server/client.
➔ In other words, data providers and consumers don’t know which device provides data for them or
consumes their provided data.
➔ In the Pub-Sub model, we have a centralized message broker that distributes data between all
devices.
➔ Each device can be publisher or subscriber or both of them at the same time. In the Pub-Sub
model, each device only connects to the broker and doesn’t know about other present devices on
the network.
➔ The broker increases network performance in uncertain conditions.
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 25 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 26
Pros of MQTT
MQTT Broker Functions
➔ The MQTT protocol payload can carry any type of data such as binary, ascii
➔ Functions as a server node capable of storing messages from publishers and forwarding them to
the subscribing clients. text etc. The receiver need to interpret and decode as per format used by the
➔ Receives topics from the publishers. transmitter. Hence MQTT is packet agnostic.
➔ Performs a store-and-forward function, stores topics from publishers and forwards to subscribers.
➔ Receives subscriptions from clients on the topics, matches subscriptions and publications in order ➔ It uses packet of low size and hence can be used for low bandwidth
to route messages to right endpoints.
➔ Recovers subscriptions on reconnect after a disconnection, unless the client explicitly
applications.
disconnected. ➔ It offers lower battery power consumption.
➔ Finds client disconnection until DISCONNECT message receives, keeps message alive till explicit
disconnection. ➔ It is reliable protocol as it uses QoS options to provide guaranteed delivery.
➔ Retains the last-received message from a publisher for a new connected subscriber on the same ➔ Due to its publish/subscribe model, It is scalable.
topic, when retain field in the header is set.
➔ Authentication by Username/Password in connect message and client security is through SSL/TLS. ➔ A publishing device can send data to server at any time regardless of its
Security considerations are same as of CoAP, web-linking and CoRE resource directory. state.
➔ Support from Intelligent and business analyst server and other servers through a MQTT server
with a gateway.
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 27 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 28
APPLICATIONS
Cons of MQTT
➔ MQTT uses TCP protocol which requires more processing power and more
memory. TCP uses handshake protocol which requires frequent wake up and
communication time intervals.
◆ This affects battery consumption. Moreover TCP connected devices tend to keep sockets
open for each other which adds memory/power requirements.
➔ Centralized broker limits the scalability as each client devices take up some
overhead. In order to avail scalability, local broker hub is used.
➔ Centralized broker can be point of failure as client connections with broker
are open all the time.
➔ It is not easy to implement compare to HTTP.
➔ It does not support advanced features such as flow control.
➔ In MQTT protocol, clients must have to support TCP/IP.
N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 29 N.Kishore Chandra Dev,Asst.Prof.,SRKREC. 30
XMPP
● XMPP or eXtensible Messaging and Presence Protocol, is an open standard communications
protocol based on XML (Extensible Markup Language). At its root, XMPP is a chat protocol
that allows for the transmission of XML fragments, i.e. data, between two network
endpoints.
Features of XMPP are
XMPP do the following
● XMPP uses XML
● XML elements are sent in the open ended stream within the tag and corresponding ● no end to end encryption
end tags ● no support for QoS like mqtt does
● 3 basic types of XMPP elements are message , presence, IQ (information query) ● higher overloaded being text best in place of binary implementation
● Extensibility to constrained environment messaging and presence protocol as well as
IP network messaging.
● Extensibility of request response architecture to IQ, pubsub messaging, chat room
MCU messaging and other architectures ,decentralized XMPP server
Pros of XMPP
● Labelling scheme to locate devices on the entire network easily
Cons of XMPP
● End to end encryption not possible
● Quality of service not available
XMPP Use Cases
● Smartphones can access a smart thermostat via the internet
● A gaming console that allows gamers to message other gamers instantly
Communication gateways Http request and response method
Data exchange between HTTP web objects
SOAP can exchange complete documents or call a remote procedure. SOAP can be used for broadcasting a
message.
REST AND RESTFUL HTTP WEB APPLICATIONS
RESTful RESTful HTTP API’S
RESTful HTTP Verbs