Edge To Cloud Protocol
Edge To Cloud Protocol
HTTP stands for HyperText Transfer Protocol. It is invented by Tim Berner. HyperText is the type
of text which is specially coded with the help of some standard coding language called HyperText
Markup Language (HTML). HTTP/2 is the successor version of HTTP, which was published on
May 2015. HTTP/3 is the latest version of HTTP, which is published in 2022.
The protocols that are used to transfer hypertext between two computers is known as HyperText
Transfer Protocol.
HTTP provides standard between a web browser and web server to establish communication. It is
set of rules for transferring data from one computer to another. Data such as text, images, and other
multimedia files are shared on the World Wide Web. Whenever a web user opens their web browser,
user indirectly uses HTTP. It is an application protocol which is used for distributed, collaborative,
hypermdia information systems.
How it works ?
First of all, whenever we want to open any website then first we open web browser after that we
will type URL of that website (e.g., www.facebook.com ). This URL is now sent to Domain Name
Server (DNS). Then DNS first check records for this URL in their database, then DNS will return IP
address to web browser corresponding to this URL. Now browser is able to sent request to actual
server.
After server sends data to client, connection will be closed. If we want something else from server
we should have to re-establish connection between client and server.
History ::
Tim Berners Lee and his team at CERN gets credit for inventing original HTTP and associated
technologies.
1. HTTP version 0.9 –This was first version of HTTP which was introduced in 1991.
2. HTTP version 1.0 –In 1996, RFC 1945 (Request For Comments) was introduced in HTTP
version 1.0.
3. HTTP version 1.1 –In January 1997, RFC 2068 was introduced in HTTP version 1.1.
Improvements and updates to HTTP version 1.1 standard were released under RFC 2616 in
June 1999.
4. HTTP version 2.0 –The HTTP version 2.0 specification was published as RFC 7540 on
May 14, 2015.
5. HTTP version 3.0 –HTTP version 3.0 is based on previous RFC draft. It is renamed as
HyperText Transfer Protocol QUIC which is a transport layer network protocol developed
by Google.
Characteristics of HTTP: HTTP is IP based communication protocol which is used to deliver data
from server to client or vice-versa.
1. Server processes a request, which is raised by client and also server and client knows each
other only during current request and response period.
2. Any type of content can be exchanged as long as server and client are compatible with it.
3. Once data is exchanged then servers and client are no more connected with each other.
4. It is a request and response protocol based on client and server requirements.
5. It is connection less protocol because after connection is closed, server does not remember
anything about client and client does not remember anything about server.
6. It is stateless protocol because both client and server does not expecting anything from each
other but they are still able to communicate.
Advantages :
Memory usage and CPU usage are low because of less simultaneous connections.
Since there are few TCP connections hence network congestion are less.
Since handshaking is done at initial connection stage, then latency is reduced because there
is no further need of handshaking for subsequent requests.
The error can be reports without closing connection.
HTTP allows HTTP pipe-lining of request or response.
Disadvantages :
WebSocket: WebSocket is bidirectional, a full-duplex protocol that is used in the same scenario of
client-server communication, unlike HTTP it starts from ws:// or wss://. It is a stateful protocol,
which means the connection between client and server will keep alive until it is terminated by either
party (client or server). After closing the connection by either of the client and server, the
connection is terminated from both ends.
Let’s take an example of client-server communication, there is the client which is a web browser
and a server, whenever we initiate the connection between client and server, the client-server made
the handshaking and decide to create a new connection and this connection will keep alive until
terminated by any of them. When the connection is established and alive the communication takes
place using the same connection channel until it is terminated.
This is how after client-server handshaking, the client-server decide on a new connection to keep it
alive, this new connection will be known as WebSocket. Once the communication link
establishment and the connection are opened, message exchange will take place in bidirectional
mode until connection persists between client-server. If anyone of them (client-server) dies or
decide to close the connection is closed by both of the party. The way in which socket works is
slightly different from how HTTP works, the status code 101 denotes the switching protocol in
WebSocket.
When can a web socket be used:
Real-time web application: Real-time web application uses a web socket to show the data
at the client end, which is continuously being sent by the backend server. In WebSocket, data
is continuously pushed/transmitted into the same connection which is already open, that is
why WebSocket is faster and improves the application performance.
For e.g. in a trading website or bitcoin trading, for displaying the price fluctuation and
movement data is continuously pushed by the backend server to the client end by using a
WebSocket channel.
Chat application: Chat applications use WebSockets to establish the connection only once
for exchange, publishing, and broadcasting the message among the subscribers. It reuses the
same WebSocket connection, for sending and receiving the message and for one-to-one
message transfer.
When not to use WebSocket: WebSocket can be used if we want any real-time updated or
continuous streams of data that are being transmitted over the network. If we want to fetch old data,
or want to get the data only once to process it with an application we should go with HTTP
protocol, old data which is not required very frequently or fetched only once can be queried by the
simple HTTP request, so in this scenario, it’s better not use WebSocket.
Note: RESTful web services are sufficient to get the data from the server if we are loading the data
only once.
Differences between HTTP and WebSocket Connection:
It was created by Andy Standford-Clark and Arlen Nipper. It is an IoT interaction protocol based on
the Publish/Subscribe model. This model is a simple model that provides support for QoS (Quality
of Service). Due to its abilities, it can be found in every second IoT based device. This protocol has
many features as it is over TCP and uses SSL/TLS for security. For messaging between server it
uses CONNECT, PUBLISH, SUBSCRIBE, DISCONNECT, etc.
Difference between MQTT and HTTP protocols :
https://www.geeksforgeeks.org/difference-between-mqtt-and-http-protocols/
This model is not restricted to one-to-one communication between clients. Although the
publisher client sends a single message on specific topic, broker sends multiple messages to
all different clients subscribed to that topic. Similarly, messages sent by multiple such
publisher clients on multiple different topics will be sent to all multiple clients subscribed to
those topics.
Hence one-to-many, many-to-one, as well as many-to-many communication is possible
using this model. Also, clients can publish data and at the same time receive data due to this
two-way communication protocol. Hence MQTT is considered to be bi-directional protocol.
The default unencrypted MQTT port used for data transmission is 1883. The encrypted port
for secure transmission is 8883.
2. Eliminates insecure connections –
In a complex system where multiple devices are connected with each other, each device not
only has to manage its connections with other devices but also has to ensure that these
connections are secure. But in the publish-subscribe model, the broker becomes central
server managing all security aspects. It is responsible for the authentication and
authorization of all connected clients.
3. Lightweight Communication –
Data transmission is quick, efficient, and lightweight because MQTT messages have small
code footprint. These control messages have a fixed header of size 2 bytes and payload
message up to size 256 megabytes.
https://www.geeksforgeeks.org/introduction-of-message-queue-telemetry-transport-protocol-mqtt/
MQTT and MQTT-SN are different from each other. MQTT is a protocol which is designed to be
light weight for M2M, but it needs TCP/IP stack to operate. But if the sensor nodes cannot hold the
TCP/IP stack then here comes MQTT-SN which does not depend on TCP/IP for it to operate.
Due to sudden increase of interest in Wireless Sensor Network (because of simplicity, low cost and
easy deployment), a light weight pub-sub protocol has been developed called MQTT-SN. The SN or
Sensor Network in the protocol name indicates that it is specifically designed for sensor networks.
As sensor nodes are specifically made with limited processing capabilities and limited amount of
storage, so these sensor nodes cannot have TCP/IP stack with themselves because TCP/IP protocol
stack is too heavy to be handled by such tiny sensor nodes due to big payload, retry mechanism,
time to live for the packets etc.
MQTT-SN was originally designed for running on top of the Zigbee APS layer. Any network which
provides a bi-directional data transfer service between any node and a particular one (gateway)
should be able to support MQTT-SN.
How MQTT-SN is different from MQTT?
First thing, MQTT-SN is designed to be as close as possible to MQTT, but is adapted to the
particular behavior of wireless communication network such as low bandwidth, high link failures,
short message length etc. Second, MQTT-SN is optimized for the implementation on low cost,
battery-operated devices with limited processing and storage resources. Third, MQTT-SN needs a
bridge to translate MQTT-SN messages into MQTT messages.
Compared to MQTT, MQTT-SN is characterized by following differences –
1) MQTT-SN supports topic ID instead of topic name. First client sends a registration request with
topic name and topic ID (2 octets) to the broker. After the registration is accepted, client uses topic
ID to refer the topic name. This saves media bandwidth and device memory – it is quite expensive
to keep and send topic names like home/livingroom/socket2/meter in memory for each publish
message.
2) The Topic name to topic ID can be preconfigured in MQTT-SN gateway, so that even registration
message can be skipped before publish.
3) A discovery procedure helps clients without a pre-configured server/gateway’s address to
discover the actual network address of an operating server/gateway. Multiple gateways may be
present at the same time within a single wireless network and can co-operate in a load-sharing or
stand-by mode.
4) The Clients connect to the broker through a gateway device, which resides within the sensor
network and connects to the broker.
MQTT-SN Architecture
The architecture of MQTT-SN can be represented by the following figure –
Fig. 1: Image showing MQTT-SN Architecture
There are three kinds of MQTT-SN components – MQTT-SN clients, MQTT-SN gateways (GW)
and MQTT-SN forwarders. MQTT-SN clients connect themselves to a MQTT server via a MQTT-
SN GW using the MQTT-SN protocol. A MQTT-SN GW may or may not be integrated with a
MQTT server. In case of a stand-alone GW, the MQTT protocol is used between the MQTT server
and the MQTT-SN GW. Its main function is the translation between MQTT and MQTT-SN. MQTT-
SN clients can also access a GW via a forwarder in case the GW is not directly attached to their
network. The forwarder simply encapsulates the MQTT-SN frames it receives on the wireless side
and forwards them unchanged to the GW. In the opposite direction, it releases the frames it receives
from the gateway and sends them to the clients, unchanged too.
There are two types of Gateways depending on how a Gateway performs the protocol translation
between MQTT and MQTT-SN:
1) Transparent Gateway – For each MQTT-SN client, transparent gateway will form an individual
MQTT connection to the MQTT broker.
2) Aggregating Gateway – In this, for all MQTT-SN clients, the Aggregating gateway will form
only one MQTT connection to the MQTT broker. The advantage of using aggregating gateway is
shown where WSN network has large number of sensor nodes because it helps in reducing the
number of MQTT connections that broker has to create with individual client.
https://www.engineersgarage.com/mqtt-for-sensor-networks-mqtt-sn-iot-part-39/
Constrained Application Protocol (aka CoAP) is a specialized web transfer protocol for use with
constrained nodes (low power sensors and actuators) and constrained networks (low power, lossy
network). It enables those nodes to be able to talk with other constrained nodes over Internet. The
protocol is specifically designed for M2M applications such as smart energy, home automation and
many Industrial applications.
Fig. 1: Overview of CoAP Protocol for Constraint Devices
CoAP protocol is necessary because traditional protocols such as TCP/IP are considered “too
heavy” for IoT applications that involves constrained devices. CoAP protocol runs on devices that
support UDP protocol. In UDP protocol, client and server communicate through connectionless
datagrams.
https://www.engineersgarage.com/constrained-application-protocol-iot-part-32/
https://www.geeksforgeeks.org/difference-between-coap-and-mqtt-protocols/
STOMP provides an interoperable wire format so that STOMP clients can communicate with any
STOMP message broker to provide easy and widespread messaging interoperability among many
languages, platforms and brokers.
STOMP is a very simple and easy to implement protocol, coming from the HTTP school of design;
the server side may be hard to implement well, but it is very easy to write a client to get yourself
connected. For example you can use Telnet to login to any STOMP broker and interact with it!
The protocol is broadly similar to HTTP, and works over TCP using the following commands:
CONNECT
SEND
SUBSCRIBE
UNSUBSCRIBE
BEGIN
COMMIT
ABORT
ACK
NACK
DISCONNECT
Communication between client and server is through a “frame” consisting of a number of lines. The
first line contains the command, followed by headers in the form <key>: <value> (one per line),
followed by a blank line and then the body content, ending in a null character. Communication
between server and client is through a MESSAGE, RECEIPT or ERROR frame with a similar
format of headers and body content.
https://www.thetechplatform.com/post/stomp-simple-or-streaming-text-orientated-messaging-
protocol
The Advanced Message Queuing Protocol (AMQP) creates interoperability between clients and
brokers (i.e. messaging middleware). Its goal of creation was to enable a wide range of different
applications and systems to be able to work together, regardless of their internal designs,
standardizing enterprise messaging on industrial scale.
AMQP includes the definitions for both the way networking takes place and the way message
broker applications work. This means the specifications for:
Operations of routing and storage of messages with the message brokers and set of rules to
define how components involved work
And a wire protocol to implement how communications between the clients and the brokers
performing the above operations work
Whenever there is a need for high-quality and safe delivery of messages between applications and
processes, AMQP implementing message brokering solutions can be considered for use.
AMQP ensures
Message acknowledgements
Allowing servers to respond to immediate requests quickly and delegate time consuming
tasks for later processing
Message: Content of data transferred / routed including information such as payload and
message attributes.
The AMQP Model defining how messages are received, routed, stored, queued and how application
parts handling these tasks work rely on the clear set definitions of the below components:
Exchange: A part of the broker (i.e. server) which receives messages and routes them to
queues
Queue (message queue): A named entity which messages are associated with and from
where consumers receive them
In AMQP, “message brokers” translate to applications which receive the actual messages and route
(i.e. transfer) them to relevant parties.
APPLICATION EXCHANGE TASK LIST WORKER
[DATA] -------> [DATA] ---> [D]+[D][D][D] ---> [DATA]
Publisher EXCHANGE Queue Consumer
https://www.digitalocean.com/community/tutorials/an-advanced-message-queuing-protocol-amqp-
walkthrough