Unit-3 Iot (Q&a)
Unit-3 Iot (Q&a)
A. Python is increasingly being adopted in IoT (Internet of Things) development due to several benefits
it offers:
1. Ease of Learning and Readability: Python's simple and clean syntax makes it easy to learn,
understand, and write code. This is particularly advantageous for IoT developers who may come
from diverse backgrounds, including hardware engineering or data science.
2. Wide Range of Libraries and Frameworks: Python boasts a vast ecosystem of libraries and
frameworks that cater to various IoT needs.
3. making it easier to work with embedded systems. Additionally, libraries such as PySerial
facilitate serial communication, while Requests and Flask enable web-based communication
for IoT devices.
4. Cross-Platform Compatibility: Python runs on multiple platforms, including Linux, Windows,
macOS, and various embedded systems. This cross-platform compatibility is crucial in IoT
development, where devices may have diverse operating environments.
5. Community Support: Python has a large and active community of developers contributing to its
growth.
6. Rapid Prototyping and Development: Python's high-level abstractions and dynamic typing
facilitate rapid prototyping and development cycles
7. Integration with Data Analytics and Machine Learning: Python's popularity in data analytics
and machine learning makes it a natural choice for IoT projects that involve data processing,
analysis, and machine learning at the edge. Libraries like NumPy, Pandas, TensorFlow, and
scikit-learn seamlessly integrate with IoT applications, enabling advanced analytics and
decision-making capabilities.
8. Support for Asynchronous Programming: Asynchronous programming is crucial for IoT
applications to handle concurrent tasks efficiently without blocking operations. Python's
asyncio library provides built-in support for asynchronous programming, making it easier to
develop IoT systems that can handle multiple concurrent tasks effectively.
9. Scalability: While Python is often criticized for its performance compared to lower-level
languages like C or C++, advancements such as Just-In-Time (JIT) compilation and
optimizations in Python interpreters have improved its performance significantly.
DEPARTMENT OF DATASCIENCE
2
There are several Python packages tailored for IoT development that facilitate various aspects of
internet connectivity, communication protocols, device management, and data processing. Here are
some notable ones:
DEPARTMENT OF DATASCIENCE
3
processing sensor data, performing data analysis, and extracting insights from IoT-
generated data streams.
These packages cover a range of functionalities necessary for IoT development, from communication
protocols and web connectivity to device management and data processing, enabling developers to
build sophisticated and scalable IoT solutions using Python.
The below is a simple Python program using the gpiozero library to control a GPIO pin on a
Raspberry Pi to blink an LED. Ensure you have the gpiozero library installed. If not, you can install it
using pip install gpiozero.
python
from gpiozero import LED
from time import sleep
Make sure to connect the positive (anode) leg of the LED to the GPIO pin defined in led_pin (in this
case, pin 17), and the negative (cathode) leg to the ground (GND) pin of the Raspberry Pi.
This program will blink the LED connected to the specified GPIO pin five times, with each blink
lasting for one second. Adjust the pin number and the number of blinks as needed.
Q.4.Why the python is the first choice for the Raspberry Pi language than C or C++?
Python is often the first choice for Raspberry Pi development over languages like C or C++ for several
reasons:
1. Ease of Learning and Use: Python has a simple and clean syntax that is easy to read and
understand, making it accessible to beginners and experienced programmers alike. This ease of
learning and use lowers the barrier to entry for Raspberry Pi enthusiasts, hobbyists, and students
who may not have a background in programming.
2. Rapid Prototyping and Development: Python's high-level abstractions and dynamic typing
enable rapid prototyping and development cycles. With Python, developers can quickly iterate
DEPARTMENT OF DATASCIENCE
4
on ideas and projects, making it ideal for experimenting and building projects on the Raspberry
Pi platform.
3. Vast Ecosystem of Libraries: Python boasts a vast ecosystem of libraries and frameworks for
various purposes, including web development, data analysis, machine learning, and IoT. Many
of these libraries are well-supported on the Raspberry Pi platform, allowing developers to
leverage existing tools and resources to expedite development.
4. Community Support: Python has a large and active community of developers who contribute
to its growth and provide support through forums, online resources, and open-source projects.
This extensive community support means that Raspberry Pi developers can easily find help,
documentation, and solutions to their problems.
5. Cross-Platform Compatibility: Python runs on multiple platforms, including Linux, Windows,
macOS, and various embedded systems. This cross-platform compatibility is crucial for
Raspberry Pi development, where developers may need to deploy their projects on different
environments.
6. Integration with Hardware and IoT: Python has libraries like gpiozero and picamera that
facilitate interaction with GPIO pins, sensors, actuators, and other hardware components
commonly used with the Raspberry Pi. Python's flexibility and ease of integration make it well-
suited for IoT and hardware-related projects.
7. Performance: While Python is often criticized for its performance compared to lower-level
languages like C or C++, advancements such as Just-In-Time (JIT) compilation and
optimizations in Python interpreters have improved its performance significantly. For many
Raspberry Pi projects, the performance difference may not be critical, and the productivity gains
from using Python outweigh the performance considerations.
DEPARTMENT OF DATASCIENCE
5
IOT HARDWARE
Transducer :
Sensors characteristics :
1. Static
2. Dynamic
1. Static characteristics :
It is about how the output of a sensor changes in response to an input change after steady state
condition.
• Accuracy: Accuracy is the capability of measuring instruments to give a result close to the true
value of the measured quantity. It measures errors. It is measured by absolute and relative
errors. Express the correctness of the output compared to a higher prior system. Absolute error
= Measured value – True value
Relative error = Measured value/True value
• Range: Gives the highest and the lowest value of the physical quantity within which the sensor
can actually sense. Beyond these values, there is no sense or no kind of response.
e.g. RTD for measurement of temperature has a range of -200`c to 800`c.
• Resolution: Resolution is an important specification for selection of sensors. The higher the
resolution, better the precision.
• Precision: It is the capacity of a measuring instrument to give the same reading when
repetitively measuring the same quantity under the same prescribed conditions.
• Sensitivity: Sensitivity indicates the ratio of incremental change in the response of the system
with respect to incremental change in input parameters
• Linearity: The deviation of the sensor value curve from a particularly straight lineA curve’s
slope resemblance to a straight line describes linearity.
• Drift: The difference in the measurement of the sensor from a specific reading when kept at that
value for a long period of time.
• Repeatability: The deviation between measurements in a sequence under the same conditions.
The measurements have to be made under a short enough time duration so as not to allow
significant long-term drift.
Dynamic Characteristics :
Properties of the systems
• Zero-order system: The output shows a response to the input signal with no delay. It does not
include energy-storing elements.
Ex. potentiometer measure, linear and rotary displacements.
DEPARTMENT OF DATASCIENCE
6
• First-order system: When the output approaches its final value gradually.
Consists of an energy storage and dissipation element.
• Second-order system: Complex output response. The output response of the sensor oscillates
before steady state.
Sensor Classification :
1. Passive Sensor –
Can not independently sense the input. Ex- Accelerometer, soil moisture, water level and
temperature sensors.
2. Active Sensor –
Independently sense the input. Example- Radar, sounder and laser altimeter sensors.
3. Analog Sensor –
The response or output of the sensor is some continuous function of its input parameter. Ex-
Temperature sensor, LDR, analog pressure sensor and analog hall effect.
4. Digital sensor –
Response in binary nature. Design to overcome the disadvantages of analog sensors. Along with
the analog sensor, it also comprises extra electronics for bit conversion. Example – Passive
infrared (PIR) sensor and digital temperature sensor(DS1620).
5. Scalar sensor –
Detects the input parameter only based on its magnitude. The answer for the sensor is a function
of magnitude of some input parameter. Not affected by the direction of input parameters.
Example – temperature, gas, strain, color and smoke sensor.
6. Vector sensor –
The response of the sensor depends on the magnitude of the direction and orientation of input
parameter. Example – Accelerometer, gyroscope, magnetic field and motion detector sensors.
Types of sensors –
• Electrical sensor :
Simple contact sensors operate by making the sensor and the component complete an electrical circuit.
Non- contact electrical proximity sensors rely on the electrical principles of either induction for
detecting metals or capacitance for detecting non metals as well.
• Light sensor:
Light sensor is also known as photo sensors and one of the important sensor.
DEPARTMENT OF DATASCIENCE
7
The property of LDR is that its resistance is inversely proportional to the intensity of the ambient light
i.e when the intensity of light increases, it’s resistance decreases and vise versa.
• Touch sensor:
1. Resistive type
2. Capacitive type
Because they are more accurate and have better signal to noise ratio.
• Range sensing:
Range sensing concerns detecting how near or far a component is from the sensing position, although
they can also be used as proximity sensors.
Distance or range sensors use non-contact analog techniques. Short range sensing, between a few
millimetres and a few hundred millimetres is carried out using electrical capacitance, inductance and
magnetic technique.
Longer range sensing is carried out using transmitted energy waves of various types eg radio waves,
sound waves and lasers.
• Mechanical sensor:
Any suitable mechanical / electrical switch may be adopted but because a certain amount of force is
required to operate a mechanical switch it is common to use micro-switches.
• Pneumatic sensor:
The pneumatic proximity sensor is an example of a contact type sensor. These cannot be used where
light components may be blown away.
DEPARTMENT OF DATASCIENCE
8
• Speed Sensor:
Sensor used for detecting the speed of any object or vehicle which is in motion is known as speed
sensor .For example – Wind Speed Sensors, Speedometer ,UDAR ,Ground Speed Radar .
• Temperature Sensor:
Devices which monitors and tracks the temperature and gives temperature’s measurement as an
electrical signal are termed as temperature sensors .These electrical signals will be in the form of
voltage and is directly proportional to the temperature measurement .
• PIR Sensor:
PIR stands for passive infrared sensor and it is an electronic sensor that is used for the tracking and
measurement of infrared (IR) light radiating from objects in its field of view and is also known as
Pyroelectric sensor .It is mainly used for detecting human motion and movement detection .
• Ultrasonic Sensor:
The principle of ultrasonic sensor is similar to the working principle of SONAR or RADAR in which
the interpretation of echoes from radio or sound waves to evaluate the attributes of a target by
generating the high frequency sound waves .
An actuator is a machine component or system that moves or controls the mechanism of the system.
Sensors in the device sense the environment, then control signals are generated for the actuators
according to the actions needed to perform.
A servo motor is an example of an actuator. They are linear or rotatory actuators, can move to a given
specified angular or linear position. We can use servo motors for IoT applications and make the motor
rotate to 90 degrees, 180 degrees, etc., as per our need.
The following diagram shows what actuators do, the controller directs the actuator based on the sensor
data to do the work.
DEPARTMENT OF DATASCIENCE
9
The control system acts upon an environment through the actuator. It requires a source of energy and a
control signal. When it receives a control signal, it converts the source of energy to a mechanical
operation. On this basis, on which form of energy it uses, it has different types given below.
Types of Actuators :
1. Hydraulic Actuators –
A hydraulic actuator uses hydraulic power to perform a mechanical operation. They are actuated by a
cylinder or fluid motor. The mechanical motion is converted to rotary, linear, or oscillatory motion,
according to the need of the IoT device. Ex- construction equipment uses hydraulic actuators because
hydraulic actuators can generate a large amount of force.
Advantages :
• Hydraulic actuators can produce a large magnitude of force and high speed.
• Used in welding, clamping, etc.
• Used for lowering or raising the vehicles in car transport carriers.
Disadvantages :
• Hydraulic fluid leaks can cause efficiency loss and issues of cleaning.
• It is expensive.
• It requires noise reduction equipment, heat exchangers, and high maintenance systems.
2. Pneumatic Actuators –
A pneumatic actuator uses energy formed by vacuum or compressed air at high pressure to convert into
either linear or rotary motion. Example- Used in robotics, use sensors that work like human fingers by
using compressed air.
Advantages :
• They are a low-cost option and are used at extreme temperatures where using air is a safer
option than chemicals.
• They need low maintenance, are durable, and have a long operational life.
• It is very quick in starting and stopping the motion.
Disadvantages :
DEPARTMENT OF DATASCIENCE
10
3. Electrical Actuators –
An electric actuator uses electrical energy, is usually actuated by a motor that converts electrical energy
into mechanical torque. An example of an electric actuator is a solenoid based electric bell.
Advantages :
Disadvantages :
• It is expensive.
• It depends a lot on environmental conditions.
• Thermal/Magnetic Actuators –
These are actuated by thermal or mechanical energy. Shape Memory Alloys (SMAs) or
Magnetic Shape‐Memory Alloys (MSMAs) are used by these actuators. An example of a
thermal/magnetic actuator can be a piezo motor using SMA.
• Mechanical Actuators –
A mechanical actuator executes movement by converting rotary motion into linear motion. It
involves pulleys, chains, gears, rails, and other devices to operate. Example – A crankshaft.
• Soft Actuators
• Shape Memory Polymers
• Light Activated Polymers
Q.7.Explain with example MQTT protocol.What is the role of MQTT protocol in IOT?
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. It is used in IOT and M2M Applications.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:
DEPARTMENT OF DATASCIENCE
11
ADVERTISEMENT
ADVERTISEMENT
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. In simple words, we can say that 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.
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.
DEPARTMENT OF DATASCIENCE
12
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
DEPARTMENT OF DATASCIENCE
13
The MQTT uses the command and the command acknowledgment format, which means that each
command has an associated acknowledgment. As shown in the above 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.
Now we will look at the packet structure or message format of the MQTT.
Advantages:
Disadvantages:
• There are, however, some drawbacks to MQTT, such as its inability to support video
streaming and its latency problems.
Applications;
CoAP is an IoT protocol. CoAP stands for Constrained Application Protocol and it is defined in RFC
7252. CoAP is a simple protocol with low overhead specifically designed for constrained devices (such
as microcontrollers) and constrained networks. This protocol is used in M2M data exchange and it is
very similar to HTTP .
DEPARTMENT OF DATASCIENCE
14
• Confirmable
• Non-confirmable
• Acknowledgment
• Reset
Client: The entity that sends a request and the destination of the response
Server: The entity that receives a request from a client and sends back a response to the client
A confirmable message is a reliable message. When exchanging messages between two endpoints,
these messages can be reliable. In CoAP a reliable message is obtained using a Confirmable message
(CON). Using this kind of message, the client can be sure that the message will arrive at the server. A
Confirmable message is sent again and again until the other party sends an acknowledge message
(ACK). The ACK message contains the same ID of the confirmable message (CON).
DEPARTMENT OF DATASCIENCE
15
If the server has troubles managing the incoming request it can send back a Rest message (RST) instead
of the Acknowledge message (ACK):
The other message category is the Non-confirmable (NON) messages. These are messages that don’t
require an Acknowledge by the server. They are unreliable messages or in other words messages that
do not contain critical information that must be delivered to the server. To this category belongs
messages that contain values read from sensors.
The CoAP Request/Response is the second layer in the CoAP abstraction layer. The request is sent
using a Confirmable (CON) or Non-Confirmable (NON) message. There are several scenarios
depending on if the server can answer immediately to the client request or the answer if not available:
If the server can answer immediately to the client request then if the request is carried using a
Confirmable message (CON) then the server sends back to the client an Acknowledge message
containing the response or the error code:
DEPARTMENT OF DATASCIENCE
16
This paragraph covers the CoAP Message format. By now we have discussed different kinds of
messages exchanged between the client and the server, now it is time to analyze the message format.
The constrained application protocol is meat for constrained environments and for this reason, it uses
compact messages. To avoid fragmentation, a message occupies the data section of a UDP datagram. A
message is made by several parts:
Where:
DEPARTMENT OF DATASCIENCE
17
Advantages:
• It is simple protocol and uses less overhead due to operation over UDP.
• Synchronous communication is not necessity in CoAP protocol.
• It has lower latency compare to HTTP.
• It consumes less power than HTTP.
Disadvantages:
Applications:
It is generally used for machine-to-machine (M2M) applications such as smart energy and building
automation.
• Zigbee Coordinator Device: It communicates with routers. This device is used for connecting
the devices.
• Zigbee Router: It is used for passing the data between devices.
• Zigbee End Device: It is the device that is going to be controlled.
DEPARTMENT OF DATASCIENCE
18
• Star Topology (ZigBee Smart Energy): Consists of a coordinator and several end devices, end
devices communicate only with the coordinator.
• Mesh Topology (Self Healing Process): Mesh topology consists of one coordinator, several
routers, and end devices.
• Tree Topology: In this topology, the network consists of a central node which is a coordinator,
several routers, and end devices. the function of the router is to extend the network coverage.
Architecture of Zigbee:
1. Application Layer
2. Application Interface Layer
3. Security Layer
4. Network Layer
5. Medium Access Control Layer
6. Physical Layer
DEPARTMENT OF DATASCIENCE
19
• Physical layer: The lowest two layers i.e the physical and the MAC (Medium Access Control)
Layer are defined by the IEEE 802.15.4 specifications. The Physical layer is closest to the
hardware and directly controls and communicates with the Zigbee radio
• Medium Access Control layer (MAC layer): The layer is responsible for the interface between
the physical and network layer.
• Network layer: This layer acts as an interface between the MAC layer and the application layer.
It is responsible for mesh networking.
• Application layer: The application layer in the Zigbee stack is the highest protocol layer and it
consists of the application support sub-layer and Zigbee device object. It contains manufacturer-
defined applications.
Advantages of Zigbee:
Disadvantages of Zigbee :
1. Limited range: Zigbee has a relatively short range compared to other wireless communications
protocols,
2. Limited data rate: Zigbee is designed for low-data-rate applications, which can make it less
suitable for applications that require high-speed data transfer.
3. Interoperability: Zigbee is not as widely adopted as other IoT protocols, which can make it
difficult to find devices that are compatible with each other.
4. Security: Zigbee’s security features are not as robust as other IoT protocols, making it more
vulnerable to hacking and other security threats.
Zigbee Applications:
1. Home Automation
2. Medical Data Collection
3. Industrial Control Systems
4. meter reading system
DEPARTMENT OF DATASCIENCE
20
1. Constrained Application Protocol (COAP): The constrained application protocol is a client server-
based protocol. With this protocol, the COAP packet can be shared between different client nodes
which are commanded by the COAP server. The server is responsible to share the information
depending on its logic but has not acknowledged it. This is used with the applications which support the
state transfer model.
2. Message Queuing Telemetry Transport (MQTT): The message query telemetry transport protocol
is a communication-based protocol that is used for IoT devices. This protocol is based on the publish-
subscribe methodology in which clients receive the information through a broker only to the subscribed
topic. A broker is a mediator who categorizes messages into labels before being delivered.
Communication
It uses Request-Response model. It uses Publish-Subscribe model
Type
Transport layer This mainly uses User Datagram This mainly uses Transmission
protocol protocol(UDP) Control protocol(TCP)
Header size It has 4 bytes sized header It has 2 bytes sized header
RESTful based Yes it uses REST principles No it does not uses REST principles
DEPARTMENT OF DATASCIENCE
21
Transmission Control Protocol is a connection-oriented protocol for communications that helps in the
exchange of messages between different devices over a network. The Internet Protocol (IP), which
establishes the technique for sending data packets between computers, works with TCP.
The position of TCP is at the transport layer of the OSI model. TCP also helps in ensuring that information
is transmitted accurately by establishing a virtual connection between the sender and receiver.
To make sure that each message reaches its target location intact, the TCP/IP model breaks down the data
into small bundles and afterward reassembles the bundles into the original message on the opposite end.
Sending the information in little bundles of information makes it simpler to maintain efficiency as
opposed to sending everything in one go.
After a particular message is broken down into bundles, these bundles may travel along multiple routes
if one route is jammed but the destination remains the same.
TCP
For Example: When a user requests a web page on the internet, somewhere in the world, the server
processes that request and sends back an HTML Page to that user. The server makes use of a protocol
DEPARTMENT OF DATASCIENCE
22
called the HTTP Protocol. The HTTP then requests the TCP layer to set the required connection and send
the HTML file.
Now, the TCP breaks the data into small packets and forwards it toward the Internet Protocol (IP) layer.
The packets are then sent to the destination through different routes.
The TCP layer in the user’s system waits for the transmission to get finished and acknowledges once all
packets have been received.
Features of TCP/IP
Some of the most prominent features of Transmission control protocol are mentioned below.
• Segment Numbering System: TCP keeps track of the segments being transmitted or received
by assigning numbers to each and every single one of them. A specific Byte Number is assigned
to data bytes that are to be transferred while segments are assigned sequence numbers.
Acknowledgment Numbers are assigned to received segments.
• Connection Oriented: It means sender and receiver are connected to each other till the
completion of the process. The order of the data is maintained i.e. order remains same before
and after transmission.
• Full Duplex: In TCP data can be transmitted from receiver to the sender or vice – versa at the
same time. It increases efficiency of data flow between sender and receiver.
DEPARTMENT OF DATASCIENCE
23
• Flow Control: Flow control limits the rate at which a sender transfers data. This is done to
ensure reliable delivery. The receiver continually hints to the sender on how much data can be
received (using a sliding window).
• Error Control: TCP implements an error control mechanism for reliable data transfer. Error
control is byte-oriented. Segments are checked for error detection
• Congestion Control: TCP takes into account the level of congestion in the network.
Congestion level is determined by the amount of data sent by a sender.
Advantages of TCP
• It is a reliable protocol.
• It makes sure that the data reaches the proper destination in the exact order that it was sent.
• It assigns an IP address to each computer on the network and a domain name to each site thus
making each device site to be distinguishable over the network.
Disadvantages of TCP
• TCP is made for Wide Area Networks, thus its size can become an issue for small networks
with low resources.
• TCP runs several layers so it can slow down the speed of the network.
• It is not generic in nature. Meaning, it cannot represent any protocol stack other than the TCP/IP
suite. E.g., it cannot work with a Bluetooth connection.
The brief introduction to Internet Protocol (IP) and TCP (Transmission Control Protocol):
DEPARTMENT OF DATASCIENCE
24
User Datagram Protocol (UDP) is a Transport Layer protocol. UDP is a part of the Internet Protocol
suite, referred to as UDP/IP suite. Unlike TCP, it is an unreliable and connectionless protocol. So, there
is no need to establish a connection before data transfer. The UDP helps to establish low-latency and
loss-tolerating connections over the network. The UDP enables process-to-process communication.
DEPARTMENT OF DATASCIENCE
25
UDP Header
UDP header is an 8-byte fixed and simple header, while for TCP it may vary from 20 bytes to 60 bytes.
The first 8 Bytes contain all necessary header information and the remaining part consists of data. UDP
port number fields are each 16 bits long, therefore the range for port numbers is defined from 0 to 65535;
port number 0 is reserved. Port numbers help to distinguish different user requests or processes.
1. Source Port: Source Port is a 2 Byte long field used to identify the port number of the source.
2. Destination Port: It is a 2 Byte long field, used to identify the port of the destined packet.
3. Length: Length is the length of UDP including the header and the data. It is a 16-bits field.
4. Checksum: Checksum is 2 Bytes long field. It is the 16-bit one’s complement of the one’s
complement sum of the UDP header, the pseudo-header of information from the IP header, and
the data, padded with zero octets at the end (if necessary) to make a multiple of two octets.
Advantages of UDP
• Speed: UDP is faster than TCP because it does not have the overhead of establishing a
connection and ensuring reliable data delivery.
DEPARTMENT OF DATASCIENCE
26
• Lower latency: Since there is no connection establishment, there is lower latency and faster
response time.
• Simplicity: UDP has a simpler protocol design than TCP, making it easier to implement and
manage.
• Broadcast support: UDP supports broadcasting to multiple recipients, making it useful for
applications such as video streaming and online gaming.
• Smaller packet size: UDP uses smaller packet sizes than TCP, which can reduce network
congestion and improve overall network performance.
• User Datagram Protocol (UDP) is more efficient in terms of both latency and bandwidth.
Disadvantages of UDP
• No reliability: UDP does not guarantee delivery of packets or order of delivery, which can lead
to missing or duplicate data.
• No congestion control: UDP does not have congestion control, which means that it can send
packets at a rate that can cause network congestion.
• No flow control: UDP does not have flow control, which means that it can overwhelm the
receiver with packets that it cannot handle.
• Limited use cases: UDP is not suitable for applications that require reliable data delivery, such
as email or file transfers, and is better suited for applications that can tolerate some data loss,
such as video streaming or online gaming.
Applications:
DEPARTMENT OF DATASCIENCE
27
DEPARTMENT OF DATASCIENCE
28
DEPARTMENT OF DATASCIENCE
29
Bluetooth is used for short-range wireless voice and data communication. It is a Wireless Personal
Area Network (WPAN) technology and is used for data communications over smaller distances. This
generation changed into being invented via Ericson in 1994. It operates within the unlicensed,
business, scientific, and clinical (ISM) bands from 2.4 GHz to 2.485 GHz. Bluetooth stages up to 10
meters. Depending upon the version, it presents information up to at least 1 Mbps or 3 Mbps. The
spreading method that it uses is FHSS (Frequency-hopping unfold spectrum). A Bluetooth network is
called a piconet and a group of interconnected piconets is called a scatternet.
DEPARTMENT OF DATASCIENCE
30
Architecture of Bluetooth
Piconet: Piconet is a type of Bluetooth network that contains one primary node called the master node
and seven active secondary nodes called slave nodes. Thus, we can say that there is a total of 8 active
nodes which are present at a distance of 10 meters. The communication between the primary and
secondary nodes can be one-to-one or one-to-many. Possible communication is only between the
master and slave; Slave-slave communication is not possible. It also has 255 parked nodes, these are
secondary nodes and cannot take participation in communication unless it gets converted to the active
state.
Bluetooth Architecture
Scatternet: It is formed by using various piconets. A slave that is present in one piconet can act as master or
we can say primary in another piconet. This kind of node can receive a message from a master in one piconet
and deliver the message to its slave in the other piconet where it is acting as a master. This type of node is
referred to as a bridge node. A station cannot be mastered in two piconets.
DEPARTMENT OF DATASCIENCE
31
1. Radio (RF) layer: It specifies the details of the air interface, including frequency, the use of
frequency hopping and transmit power. It performs modulation/demodulation of the data into
RF signals. It defines the physical characteristics of Bluetooth transceivers. It defines two
types of physical links: connection-less and connection-oriented.
2. Baseband Link layer: The baseband is the digital engine of a Bluetooth system and is
equivalent to the MAC sublayer in LANs. It performs the connection establishment within a
piconet, addressing, packet format, timing and power control.
3. Link Manager protocol layer: It performs the management of the already established links
which includes authentication and encryption processes. It is responsible for creating the
links, monitoring their health, and terminating them gracefully upon command or failure.
4. Logical Link Control and Adaption (L2CAP) Protocol layer: It is also known as the heart
of the Bluetooth protocol stack. It allows the communication between upper and lower layers
of the Bluetooth protocol stack. It packages the data packets received from upper layers into
the form expected by lower layers. It also performs segmentation and multiplexing.
5. Service Discovery Protocol (SDP) layer: It is short for Service Discovery Protocol. It allows
discovering the services available on another Bluetooth-enabled device.
8. WAP: It is short for Wireless Access Protocol. It is used for internet access.
9. TCS: It is short for Telephony Control Protocol. It provides telephony service. The basic
function of this layer is call control (setup & release) and group management for the gateway
serving multiple devices.
10. Application layer: It enables the user to interact with the application.
DEPARTMENT OF DATASCIENCE
32
Types of Bluetooth
Various types of Bluetooth are available in the market nowadays. Let us look at them.
• In-Car Headset: One can make calls from the car speaker system without the use of mobile
phones.
• Webcam: One can link the camera with the help of Bluetooth with their laptop or phone.
• Bluetooth-equipped Printer: The printer can be used when connected via Bluetooth with
mobile phone or laptop.
• Bluetooth Global Positioning System (GPS): To use Global Positioning System (GPS) in
cars, one can connect their phone with car system via Bluetooth to fetch the directions of the
address.
DEPARTMENT OF DATASCIENCE
33
Advantages of Bluetooth
Disadvantages of Bluetooth
Applications of Bluetooth
• It can transfer data in terms of videos, songs, photographs, or files from one cell phone to
another cell phone or computer.
Q.19.List Bluetooth Key Versions. What are the difficulties associated with them,[7M].
Bluetooth Key Versions (BR/EDR and LE) refer to different versions of the Bluetooth protocol, each
introducing advancements and improvements over previous versions. As of my last update, here are
the key versions of Bluetooth:
1. Bluetooth 1.x and 2.x: These early versions of Bluetooth, collectively known as Bluetooth
Classic or BR/EDR (Basic Rate/Enhanced Data Rate), introduced basic wireless connectivity
for audio streaming, file transfer, and peripheral device connections. They had limited data
transfer speeds and were primarily designed for short-range communication between devices.
2. Bluetooth 3.0: Bluetooth 3.0 introduced the High-Speed (HS) mode, which utilized Wi-Fi
technology for faster data transfer rates when needed. It maintained backward compatibility
with previous versions but added the option for faster data transfer for compatible devices.
DEPARTMENT OF DATASCIENCE
34
3. Bluetooth 4.0: Bluetooth 4.0 introduced the Low Energy (LE) mode, also known as
Bluetooth Smart, alongside the classic BR/EDR mode. LE mode optimized power
consumption for devices with low data transfer requirements, such as sensors, wearables, and
smart home devices. Bluetooth 4.0 also introduced features like Bluetooth Smart Ready and
Bluetooth Smart, allowing devices to support both classic and low-energy modes.
4. Bluetooth 5.0: Bluetooth 5.0 introduced significant enhancements over previous versions,
including increased data transfer speeds, longer range, and improved coexistence with other
wireless technologies. It also introduced features like Bluetooth Low Energy (LE) advertising
extensions, which allow for more efficient data exchange and improved performance in
crowded wireless environments.
1. Compatibility Issues: Newer versions of Bluetooth may not be fully backward compatible
with older versions, leading to interoperability issues between devices. For example, a
Bluetooth 5.0 device may not be able to connect to a Bluetooth 2.x device due to differences
in protocols and features.
2. Complexity of Development: Supporting multiple Bluetooth versions and modes in devices
can add complexity to development efforts. Developers need to ensure compatibility across
different versions while optimizing power consumption, data transfer speeds, and other
performance metrics.
3. Security Concerns: Each Bluetooth version may introduce new security vulnerabilities or
require additional security measures to protect devices and data. Implementing robust security
features can be challenging and may require ongoing updates to address emerging threats.
4. Power Consumption: While Bluetooth Low Energy (LE) mode significantly reduces power
consumption compared to classic Bluetooth, optimizing power usage for specific use cases
and ensuring compatibility with different devices can still be challenging for developers.
5. Interference and Coexistence: In environments with multiple Bluetooth devices or other
wireless technologies, interference and coexistence issues may arise, impacting the
performance and reliability of Bluetooth connections. Addressing these challenges requires
careful planning and implementation of mitigation strategies.
BLE (Bluetooth Low Energy) is wireless PAN technology designed and maintained by Bluetooth
Special Interest Group (SIG). There are various versions of bluetooth.
The version 4.2 and above is referred as BLE. The latest in the series are v5.0 and v5.1. BLE
specifications are intended to reduce power consumption and cost of devices while maintaining
coverage range. BLE is known as "Bluetooth Smart" where as previous version is known as
"bluetooth classic".
DEPARTMENT OF DATASCIENCE
35
The figure-2 depicts BLE system architecture. Let us understand functions of different layers of
this BLE protocol stack.
• Physical Layer :
• The transmitter uses GFSK modulation and operates at unlicensed 2.4 GHz frequency band.
• Using this PHY layer, BLE offers data rates of 1 Mbps (Bluetooth v4.2)/2 Mbps (Bluetooth v5.0).
• It uses frequency hopping transceiver.
• Two modulation schemes are specified to deliver 1 Msym/s and 2 Msym/s.
• Two PHY layer variants are specified viz. uncoded and coded.
• A Time Division Duplex (TDD) topology is employed in both of the PHY modes.
• Link Layer : This layer sits above the Physical layer. It is responsible for advertising, scanning,
and creating/maintaining connections. The role of BLE devices changes in peer to peer (i.e. Unicast)
or broadcast modes. The common roles are Advertiser/Scanner (Initiator), Slave/Master or
DEPARTMENT OF DATASCIENCE
36
The figure-1 depicts BLE device states >>. The device will be in any one of these states which
include Standby state, Advertising state, Scanning state, Initiating state, Connection State and
Synchronization state.
• HCI : It provides communication between controller and host through standard interface types.
This HCI layer can be implemented either using API or by interfaces such as UART/SPI/USB.
Standard HCI commands and events are defined in the bluetooth specifications.
• L2CAP :This layer offers data encapsulation services to upper layers. This allows logical end to
end data communication.
• SMP :This security Manager layer provides methods for device pairing and key distributions. It
offers services to other protocol stack layers in order to securely connect and exchange data between
BLE devices.
• GAP : This layer directly interfaces with application layer and/or profiles on it. It handles device
discovery and connection related services for BLE device. It also takes care of initiation of security
features.
• GATT : This layer is service framework which specifies sub-procedures to use ATT. Data
communications between two BLE devices are handled through these sub-procedures. The
applications and/or profiles will use GATT directly.
• ATT : This layer allows BLE device to expose certain pieces of data or attributes.
• Application Layer :
• The BLE protocol stack layers interact with applications and profiles as desired. Application
interoperability in the Bluetooth system is accomplished by Bluetooth profiles.
• The profile defines the vertical interactions between the layers as well as the peer-to-peer
interactions of specific layers between devices.
• A profile composed of one or more services to address particular use case. A service consists of
characteristics or references to other services.
• Any profiles/applications run on top of GAP/GATT layers of BLE protocol stack. It handles device
discovery and connection related services for the BLE device.
DEPARTMENT OF DATASCIENCE
37
DEPARTMENT OF DATASCIENCE