Iot Notes 2
Iot Notes 2
IOT Protocols
IoT Messaging Protocols
• MQTT stands for Message Queuing Telemetry Transport. MQTT is a
machine to machine internet of things connectivity protocol. It is an
extremely lightweight and publish-subscribe messaging transport protocol.
• This protocol is useful for the connection with the remote location where
the bandwidth is a premium. These characteristics make it useful in various
situations, including constant environment such as for communication
machine to machine and internet of things contexts.
• It is a publish and subscribe system where we can publish and receive the
messages as a client. It makes it easy for communication between multiple
devices.
• It is a simple messaging protocol designed for the constrained devices and
with low bandwidth, so it's a perfect solution for the internet of things
applications.
Characteristics of MQTT
The MQTT has some unique features which are hardly found in other protocols. Some of
the features of an MQTT are given below:
•It is a machine to machine protocol, i.e., it provides communication between the
devices.
•It is designed as a simple and lightweight messaging protocol that uses a
publish/subscribe system to exchange the information between the client and the server.
•It does not require that both the client and the server establish a connection at the
same time.
•It provides faster data transmission, like how WhatsApp/messenger provides a faster
delivery.
•It's a real-time messaging protocol.
•It allows the clients to subscribe to the narrow selection of topics so that they can
receive the information they are looking for.
MQTT Architecture
To understand the MQTT architecture, we first look at the components of the
MQTT.
• Message
• Client
• Server or Broker
• TOPIC
Message
• The message is the data that is carried out by the protocol across the network for
the application. When the message is transmitted over the network, then the
message contains the following parameters:
1.Payload data
2.Quality of Service (QoS)
3.Collection of Properties
4.Topic Name
Client
• In MQTT, the subscriber and publisher are the two roles of a client.
The clients subscribe to the topics to publish and receive messages.
That is if any program or device uses an MQTT, then that device is
referred to as a client. A device is a client if it opens the network
connection to the server, publishes messages that other clients want
to see, subscribes to the messages that it is interested in receiving,
unsubscribes to the messages that it is not interested in receiving,
and closes the network connection to the server.
In MQTT, the client performs two operations:
• Publish: When the client sends the data to the server, then we call
this operation as a publish.
• Subscribe: When the client receives the data from the server, then we
call this operation a subscription.
Server
• The device or a program that allows the client to publish the
messages and subscribe to the messages. A server accepts the
network connection from the client, accepts the messages from the
client, processes the subscribe and unsubscribe requests, forwards
the application messages to the client, and closes the network
connection from the client.
TOPIC
• The label provided to the message is checked against the subscription
known by the server is known as TOPIC.
Architecture of MQTT
To understand it more clearly, we will look at the example. Suppose a device has a temperature
sensor and wants to send the rating to the server or the broker. If the phone or desktop application
wishes to receive this temperature value on the other side, then there will be two things that
happened.
The publisher first defines the topic; for example, the temperature then publishes the message, i.e.,
the temperature's value. After publishing the message, the phone or the desktop application on the
other side will subscribe to the topic, i.e., temperature and then receive the published message, i.e.,
the value of the temperature.
The server or the broker's role is to deliver the published message to the phone or the desktop
application.
MQTT Message Format
• The MQTT uses the command and the command acknowledgment
format, which means that each command has an associated
acknowledgment. As shown in the figure that the connect command
has connect acknowledgment, subscribe command has subscribe
acknowledgment, and publish command has publish
acknowledgment. This mechanism is similar to the handshaking
mechanism as in TCP protocol.
IOT Messaging Protocol: CoAP
• CoAP, the Constrained Application Protocol, is a
specialized protocol designed to facilitate
communication between constrained devices in low-
power, low-bandwidth networks.
• Unlike traditional protocols like HTTP, CoAP is
tailored to meet the unique demands of IoT devices.
By minimizing overhead and utilizing efficient
messaging, CoAP enables reliable communication in
resource-constrained scenarios.
CoAP Architecture
• This protocol follows a client-server architecture, mirroring the
structure of HTTP but optimized for IoT. Devices in a CoAP
network can act as clients, servers, or both. Clients initiate
communication by sending requests to servers, which in turn
respond with relevant data or actions. This architectural model
simplifies communication between devices and applications while
considering the limitations of constrained environments.
The architecture is centered around the client-server model, which
is a fundamental approach in CoAP, similar to HTTP. This protocol
has optimized this architecture for the unique requirements of IoT
environments.
• CoAP Clients: These are devices or applications that initiate
communication by sending CoAP requests to CoAP servers.
Clients can be sensors, actuators, or any other IoT devices that
require data or actions from the network.
• CoAP Servers: These are devices that respond to CoAP requests
from clients. Servers can also serve as resources that clients
interact with. Servers process incoming requests, perform
relevant actions, and generate responses containing the
requested data or indicating the status of the operation.
• CoAP Requests: Clients send CoAP requests to servers to initiate
actions or retrieve data. CoAP supports various request methods,
such as GET (retrieve data), POST (create new resource), PUT
(update resource), and DELETE (remove resource).
• CoAP Responses: Servers generate CoAP responses
containing the requested data or the outcome of the
requested action. Responses can be confirmable (CON) or
non-confirmable (NON), depending on the desired level of
reliability. Confirmable responses include an
acknowledgment (ACK) from the client.
• CoAP Network and Communication: The communication
between clients and servers happens over the CoAP
network. CoAP is designed to operate over constrained
networks, which might have limited bandwidth and
resources. The protocol’s lightweight nature ensures efficient
communication in such environments.
CoAP Message Types
• This IoT messaging protocol defines four primary message types, each
serving a specific purpose:
• CON (Confirmable): This type ensures reliable communication by
requiring acknowledgment and retransmission of messages until
acknowledged. It suits scenarios where data integrity is crucial.
• NON (Non-Confirmable): NON messages prioritize efficiency over
reliability, making them suitable for scenarios where occasional data
loss is acceptable.
• ACK (Acknowledgment): The recipient of a CON message sends an ACK
message to confirm receipt. It forms a vital part of CoAP’s reliability
mechanism.
• RST (Reset): When a server or client receives a message that cannot be
processed, it sends an RST message to indicate this situation.
CoAP Resources and URIs
• CoAP supports a set of methods that clients can use to interact with
resources:
1. GET Method
• The GET method is one of the fundamental methods supported by
CoAP. It allows clients to retrieve a representation of a resource from a
server. A “representation” can be thought of as the current state or
content of the requested resource. When a client sends a GET request,
it is asking the server to provide information about the resource’s
current status.
• For example, in a smart home scenario, a CoAP client (such as a
smartphone app) might send a GET request to a CoAP server that
controls a smart thermostat. The server would respond with a
representation of the thermostat’s current temperature setting,
humidity level, and other relevant data.
2. POST Method
• The POST method enables clients to send data to a server. This
method is typically used for creating new resources on the server
or submitting data for processing. When a client sends a POST
request, it’s asking the server to handle the enclosed data and
perform an action accordingly.
• In the context of IoT, a CoAP client might send a POST request to
a server that manages a home security system. The request could
include data about a detected motion event or a door opening.
The server would process this data and potentially take actions
like sending alerts or logging the event.
3.PUT Method
• The PUT method allows clients to update or create a
resource’s state on the server. Clients use PUT when they
want to modify the content or properties of a resource. If the
resource doesn’t exist, PUT can also be used to create a new
resource.
• For instance, consider a CoAP-enabled environmental
sensor. The sensor might send a PUT request to update its
current temperature reading on the server. If the sensor
detects a change in temperature, it could use PUT to ensure
that the server’s record of the temperature is accurate.
4.DELETE Method
• As the name suggests, the DELETE method is used to request
the removal or deletion of a resource on the server. When a
client sends a DELETE request, it’s asking the server to
eliminate the specified resource.
• In an industrial setting, a CoAP client representing a
maintenance robot could send a DELETE request to a server
managing a broken machine. This request could prompt the
server to remove the machine’s resource representation
from its records, indicating that the machine is no longer
operational
TRANSPORT LAYER PROTOCOL:BLE and Li-Fi
Bluetooth Low Energy
• Bluetooth is a wireless communication protocol designed for short-
range communication between devices. It's commonly used for
connecting devices like smartphones, headphones, keyboards, and
IoT (Internet of Things) devices. Bluetooth Low Energy (BLE) is a
specific version of the Bluetooth protocol that is particularly well-
suited for IoT applications due to its low power consumption.
Technical overview of BLE
• 1. Physical Layer:
• Frequency Bands: BLE operates in the 2.4 GHz ISM (Industrial, Scientific, and
Medical) band.
• Channels: It uses 40 channels spaced 2 MHz apart to minimize interference.
• Frequency Hopping: BLE uses frequency hopping spread spectrum (FHSS) to
avoid interference and fading. This means that the signal hops between different
channels rapidly, providing resilience against interference
• 2. Link Layer:
• Advertising and Scanning: BLE devices can operate in two modes: Advertising
and scanning. Advertising devices broadcast packets at regular intervals, while
scanning devices listen for these packets. This is how devices discover and
connect to each other.
• Connection Types: BLE supports two types of connections - connection-oriented
(for continuous data streaming) and connectionless (for intermittent data
transfer).
• 3. Physical Channel Access:
• BLE uses a Time Division Multiple Access (TDMA) approach, where time is
divided into time slots, and devices take turns transmitting data.
• The device can be in an active or low-power mode, depending on the
specific requirements.
• 4. Protocol Stack:
• Layers: BLE protocol stack consists of several layers - Physical Layer, Link
Layer, Attribute Protocol (ATT), Generic Attribute Profile (GATT), Security
Manager, and Generic Access Profile (GAP).
• ATT and GATT: These are used for organizing and exchanging data between
devices. GATT defines how BLE devices exchange data with Services,
Characteristics, and Descriptors.
5. Host Controller Interface (HCI):
• HCI provides a standardized interface between the Bluetooth
controller (hardware) and the host (software). This allows for easier
integration of BLE into various platforms and operating systems.
6. Security and Privacy:
• BLE provides various security features to ensure data confidentiality,
integrity, and authenticity.
• Pairing and Bonding: Devices can establish a secure connection
through pairing, where they exchange security keys. Bonding allows
devices to remember each other for future connections without re-
pairing.
• Encryption: Once paired, data exchanged between devices can be
encrypted to prevent eavesdropping and tampering.
7. Profiles and Services:
• BLE defines profiles that specify how devices communicate for
specific applications. Examples include:
• Heart Rate Profile: Defines how heart rate monitors communicate
heart rate data.
• Battery Service: Provides information about the battery level of a
device.
• Environmental Sensing Profile: Allows environmental sensors (e.g.,
temperature, humidity) to communicate data.
8. Application Layer:
• At the application layer, developers can create custom applications
using the BLE stack. This layer interacts with the GATT layer to
read/write characteristics, handle notifications, and implement
specific IoT functionalities.
• 9. Power Consumption:
• BLE is designed to be power-efficient, making it suitable for IoT
devices with limited power resources.
• Devices can operate in low-power modes and wake up periodically for
data exchange.
Conclusion:
• Bluetooth Low Energy (BLE) in IoT applications offers a robust
architecture optimized for low-power, short-range communication. By
understanding its physical, link, and application layers, along with
profiles and security features, developers can design efficient and
secure IoT solutions using BLE technology.
IoT Specifics:
1. IoT Protocols:
• BLE can be used as a standalone protocol for IoT or in conjunction
with other protocols like MQTT or CoAP for higher-level
communication.
2. Device Profiles:
• BLE defines specific profiles for various IoT applications, such as the
Generic Attribute Profile (GATT) for defining services and
characteristics.
3. Interoperability:
• BLE ensures interoperability between different devices by defining
standardized profiles that manufacturers can implement.
2. Li-Fi(Light Fidelity
• A technology that is 100 times faster than current average wifi speeds!
Yes, this technology exists, and this is known as Light Fidelity(LiFi).
• LiFi, also known as LIGHT FIDELITY, is a both-sided wireless
communication system that releases information via LED (Light Emitting
Device) or Infrared Light.
• LiFi technology was the first time it came into use in the year 2011. LiFi is
an extension of WIFI Communication which requires a light source for
data sending and communication on the internet.
• The most significant feature of LiFi is that it’s most faster than WIFI
communication.
• LiFi increases the speed and bandwidth of wifi, 3G, and 4G. LiFi
transmission speeds can go over 100 Gbps, 14 times faster than WIFI
Communication, also known as the world’s fastest wifi.
• The interference or the obstacles are less during the communication
process, so in seawater, it is preferable to use LiFi as WIFI communication
can have numerous interference while communicating. The founder of the
father of this technology is Professor Harald Hass.
• The Li-Fi circuit is used consists of mainly three sub-
assemblies
1.RF Driver – RF Driver is used for controlling or handling the
circuit for digital and analog lighting controls.
2.Emitter – An emitter device is used to emit or generate
charged particles.
3.Power Supply: Power Supply is an electrical device used to
supply electrical power to an electrical load for operation.
Working
1.The working or the implementation of LiFi is not very complex like
WIFI communication. It is straightforward to send information
through the LED light bulb, which emits pulsed light to receivers.
After that, the receiver collects the sent data or information and
understands the transmitted data.
2.The LED bulb can be toggled on and off instantly for more reliable
communication and for saving power. So only the things we require
for this communication are some LEDs Bulbs and a controller that
codes into those LEDs Bulbs.
3.In some cases, we need to alter or modify the rate of transmission
in which the lED bulb flash depending upon the information we
want to encode.
4.As we stated above, the Light source is the main component in this
communication, so that light source will serve as the central hub for
data transmission from one point to another destination point.
Advantages of LiFi :
1.Every User wants the communication and data transfer should be fast, so
LiFi does this for us; its main advantage is the Speed of Transmission.
LIFEIrDA-compliant standard-compliant is 10000 times or even faster
than the Spectrum used by RADIO waves in WIFI communication or data
transfer.
2.The structure of LiFi is not very complex as WIFI, as Lightboxes are
already present in LiFi, so the design is already available and pre-
installed.
3.As the Speed is high, indirectly data transfer rate increases. So the data
transfer rate of LiFi is approximately 10 Gbps or sometimes more.
4.Light is the primary source required in LiFi structure for communication,
and luckily Light is already available in natural or artificial ways.
Everywhere there is Light, so the Data is present where Light exists.
5.We all know LEDs use a very minimal amount of energy for
their usage or operation. So the energy and cost required for
Data Transfer in LiFi are also minimal.
6.The interference or obstacles in WIFI are more than the LiFi, so
LiFi is more secure than the WIFI communication, and this is
also an essential advantage regarding LiFi.
Disadvantages of LiFi :
• No Thing is perfect! Every aspect has its advantages and
disadvantages. So LiFi also has some disadvantages.
1.LIFI has a minimal area of scope or range also connectivity.
2.There is an Unavailability of Compatible Technologies.
3.LIFI can give rise to Light Interference and Light Pollution.
4.LiFI has Possible cost Implications.
5.Cannot penetrate through walls.
6.Interference from external sources i.e. sun, normal bulbs,
candles, etc.
NETWORK PROTOCOL:6LoWPAN
6LoWPAN
• What is 6LoWPAN?
6LoWPAN stands for IPv6 over Low-Power Wireless Personal Area
Networks. It’s a communication protocol designed to enable small,
low-power devices to connect over wireless networks.
6LoWPAN is an IPv6 protocol, and It’s extended from IPv6 over
Low Power Personal Area Network.
WPAN is a Personal Area Network (PAN) where the
interconnected devices are centered around a person’s
workspace and connected through a wireless medium.
6LoWPAN allows communication using the IPv6 protocol. IPv6
is Internet Protocol Version 6 is a network layer protocol that
allows communication to take place over the network. It is faster
and more reliable and provides a large number of addresses.
• It has very low cost, short-range, low memory usage, and low
bit rate. It comprises an Edge Router and Sensor Nodes. Even
the smallest of the IoT devices can now be part of the network,
and the information can be transmitted to the outside world as
well. For example, LED Streetlights.
• It is a technology that makes the individual nodes IP-enabled.
6LoWPAN can interact with 802.15.4 devices and also other
types of devices on an IP Network.
Basic Requirements of 6LoWPAN
• The device should be having sleep mode in order to support
the battery saving.
• Minimal memory requirement.
• Routing overhead should be lowered.
Functioning of the 6LoWPAN Network