0% found this document useful (0 votes)
18 views94 pages

Iot - Unit Iv

Uploaded by

imran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views94 pages

Iot - Unit Iv

Uploaded by

imran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 94

UNIT – V

OSI (Open Systems Interconnection)


The OSI (Open Systems Interconnection) Model is a set of rules that explains how
different computer systems communicate over a network. OSI Model was developed by
the International Organization for Standardization (ISO). The OSI Model consists of 7 layers
and each layer has specific functions and responsibilities.
This layered approach makes it easier for different devices and technologies to work
together. OSI Model provides a clear structure for data transmission and managing network
issues. The OSI Model is widely used as a reference to understand how network systems
function.
In this article, we will discuss the OSI Model and each layer of the OSI Model in
detail. We will also discuss the flow of data in the OSI Model and how the OSI Model is
different from the TCP/IP Model.

OSI Model
For those preparing for competitive exams like GATE, a strong understanding of
networking concepts, including the OSI model, is crucial. To deepen your knowledge in this
area and other key computer science topics, consider enrolling in the GATE CS Self-Paced
course . This course offers comprehensive coverage of the syllabus, helping you build a solid
foundation for your exam preparation.
Layers of the OSI Model
There are 7 layers in the OSI Model and each layer has its specific role in handling data. All
the layers are mentioned below:
 Physical Layer
 Data Link Layer
 Network Layer
 Transport Layer
 Session Layer
 Presentation Layer
 Application Layer
Layer 1 – Physical Layer
The lowest layer of the OSI reference model is the Physical Layer. It is responsible for
the actual physical connection between the devices. The physical layer contains information
in the form of bits. Physical Layer is responsible for transmitting individual bits from one
node to the next. When receiving data, this layer will get the signal received and convert it
into 0s and 1s and send them to the Data Link layer, which will put the frame back together.
Common physical layer devices are Hub, Repeater, Modem, and Cables.

Physical Layer
Functions of the Physical Layer
 Bit Synchronization: The physical layer provides the synchronization of the bits by
providing a clock. This clock controls both sender and receiver thus providing
synchronization at the bit level.
 Bit Rate Control: The Physical layer also defines the transmission rate i.e. the number
of bits sent per second.
 Physical Topologies: Physical layer specifies how the different, devices/nodes are
arranged in a network i.e. bus topology, star topology, or mesh topology.
 Transmission Mode: Physical layer also defines how the data flows between the two
connected devices. The various transmission modes possible are Simplex, half-duplex
and full-duplex.
Layer 2 – Data Link Layer (DLL)
The data link layer is responsible for the node-to-node delivery of the message. The
main function of this layer is to make sure data transfer is error-free from one node to
another, over the physical layer. When a packet arrives in a network, it is the responsibility of
the DLL to transmit it to the Host using its MAC address. Packet in the Data Link layer is
referred to as Frame. Switches and Bridges are common Data Link Layer devices.
The Data Link Layer is divided into two sublayers:
 Logical Link Control (LLC)

 Media Access Control (MAC)

The packet received from the Network layer is further divided into frames depending on the
frame size of the NIC(Network Interface Card). DLL also encapsulates Sender and Receiver’s
MAC address in the header.
The Receiver’s MAC address is obtained by placing an ARP(Address Resolution
Protocol) request onto the wire asking “Who has that IP address?” and the destination host
will reply with its MAC address.
Functions of the Data Link Layer
 Framing: Framing is a function of the data link layer. It provides a way for a sender to
transmit a set of bits that are meaningful to the receiver. This can be accomplished by
attaching special bit patterns to the beginning and end of the frame.
 Physical Addressing: After creating frames, the Data link layer adds physical
addresses (MAC addresses) of the sender and/or receiver in the header of each frame.
 Error Control: The data link layer provides the mechanism of error control in which it
detects and retransmits damaged or lost frames.
 Flow Control: The data rate must be constant on both sides else the data may get
corrupted thus, flow control coordinates the amount of data that can be sent before
receiving an acknowledgment.
 Access Control: When a single communication channel is shared by multiple devices,
the MAC sub-layer of the data link layer helps to determine which device has control
over the channel at a given time.
Layer 3 – Network Layer
The network layer works for the transmission of data from one host to the other
located in different networks. It also takes care of packet routing i.e. selection of the shortest
path to transmit the packet, from the number of routes available. The sender and receiver’s IP
address are placed in the header by the network layer. Segment in the Network layer is
referred to as Packet. Network layer is implemented by networking devices such as routers
and switches.
Functions of the Network Layer
 Routing: The network layer protocols determine which route is suitable from source
to destination. This function of the network layer is known as routing.
 Logical Addressing: To identify each device inter-network uniquely, the network layer
defines an addressing scheme. The sender and receiver’s IP addresses are placed in
the header by the network layer. Such an address distinguishes each device uniquely
and universally.
Layer 4 – Transport Layer
The transport layer provides services to the application layer and takes services from the
network layer. The data in the transport layer is referred to as Segments. It is responsible for
the end-to-end delivery of the complete message. The transport layer also provides the
acknowledgment of the successful data transmission and re-transmits the data if an error is
found. Protocols used in Transport Layer are TCP, UDP NetBIOS, PPTP.
At the sender’s side, the transport layer receives the formatted data from the upper layers,
performs Segmentation, and also implements Flow and error control to ensure proper data
transmission. It also adds Source and Destination port number in its header and forwards the
segmented data to the Network Layer.
 Generally, this destination port number is configured, either by default or manually.
For example, when a web application requests a web server, it typically uses port
number 80, because this is the default port assigned to web applications. Many
applications have default ports assigned.
At the Receiver’s side, Transport Layer reads the port number from its header and forwards
the Data which it has received to the respective application. It also performs sequencing and
reassembling of the segmented data.
Functions of the Transport Layer
 Segmentation and Reassembly: This layer accepts the message from the (session)
layer, and breaks the message into smaller units. Each of the segments produced has a
header associated with it. The transport layer at the destination station reassembles the
message.
 Service Point Addressing: To deliver the message to the correct process, the transport
layer header includes a type of address called service point address or port address.
Thus by specifying this address, the transport layer makes sure that the message is
delivered to the correct process.
Services Provided by Transport Layer
 Connection-Oriented Service

 Connectionless Service
Layer 5 – Session Layer
Session Layer in the OSI Model is responsible for the establishment of connections,
management of connections, terminations of sessions between two devices. It also provides
authentication and security. Protocols used in the Session Layer are NetBIOS, PPTP.
Functions of the Session Layer
 Session Establishment, Maintenance, and Termination: The layer allows the two
processes to establish, use, and terminate a connection.
 Synchronization: This layer allows a process to add checkpoints that are considered
synchronization points in the data. These synchronization points help to identify the
error so that the data is re-synchronized properly, and ends of the messages are not cut
prematurely and data loss is avoided.
 Dialog Controller: The session layer allows two systems to start communication with
each other in half-duplex or full-duplex.
Example
Let us consider a scenario where a user wants to send a message through some Messenger
application running in their browser. The “Messenger” here acts as the application layer
which provides the user with an interface to create the data. This message or so-called Data is
compressed, optionally encrypted (if the data is sensitive), and converted into bits (0’s and
1’s) so that it can be transmitted.

Communication in Session Layer


Layer 6 – Presentation Layer
The presentation layer is also called the Translation layer. The data from the application layer
is extracted here and manipulated as per the required format to transmit over the network.
Protocols used in the Presentation Layer are JPEG, MPEG, GIF, TLS/SSL, etc.
Functions of the Presentation Layer
 Translation: For example, ASCII to EBCDIC.
 Encryption/ Decryption: Data encryption translates the data into another form or code.
The encrypted data is known as the ciphertext and the decrypted data is known as
plain text. A key value is used for encrypting as well as decrypting data.
 Compression: Reduces the number of bits that need to be transmitted on the network.
Layer 7 – Application Layer
At the very top of the OSI Reference Model stack of layers, we find the Application layer
which is implemented by the network applications. These applications produce the data to be
transferred over the network. This layer also serves as a window for the application services
to access the network and for displaying the received information to the user. Protocols used
in the Application layer are SMTP, FTP, DNS, etc.

Application Layer
Functions of the Application Layer
The main functions of the application layer are given below.
 Network Virtual Terminal(NVT): It allows a user to log on to a remote host.
 File Transfer Access and Management(FTAM): This application allows a user to
access files in a remote host, retrieve files in a remote host, and manage or control
files from a remote computer.
 Mail Services: Provide email service.
 Directory Services: This application provides distributed database sources and access
for global information about various objects and services.
How Data Flows in the OSI Model?
When we transfer information from one device to another, it travels through 7 layers of OSI
model. First data travels down through 7 layers from the sender’s end and then climbs back 7
layers on the receiver’s end.
Data flows through the OSI model in a step-by-step process:
 Application Layer: Applications create the data.
 Presentation Layer: Data is formatted and encrypted.
 Session Layer: Connections are established and managed.
 Transport Layer: Data is broken into segments for reliable delivery.
 Network Layer: Segments are packaged into packets and routed.
 Data Link Layer: Packets are framed and sent to the next device.
 Physical Layer: Frames are converted into bits and transmitted physically.
Each layer adds specific information to ensure the data reaches its destination correctly, and
these steps are reversed upon arrival.

We can understand how data flows through OSI Model with the help of an example
mentioned below.
Let us suppose, Person A sends an e-mail to his friend Person B.
Step 1: Person A interacts with e-mail application like Gmail, outlook, etc. Writes his email to
send. (This happens at Application Layer).
Step 2: At Presentation Layer, Mail application prepares for data transmission like encrypting
data and formatting it for transmission.
Step 3: At Session Layer, There is a connection established between the sender and receiver
on the internet.
Step 4: At Transport Layer, Email data is broken into smaller segments. It adds sequence
number and error-checking information to maintain the reliability of the information.
Step 5: At Network Layer, Addressing of packets is done in order to find the best route for
transfer.
Step 6: At Data Link Layer, data packets are encapsulated into frames, then MAC address is
added for local devices and then it checks for error using error detection.
Step 7: At Physical Layer, Frames are transmitted in the form of electrical/ optical signals
over a physical network medium like ethernet cable or WiFi.
After the email reaches the receiver i.e. Person B, the process will reverse and decrypt the e-
mail content. At last, the email will be shown on Person B email client.
Protocols Used in the OSI Layers

Protocol
Layer Working Data Unit Protocols

Establishing Physical
1 – Physical
Connections between Bits USB, SONET/SDH, etc.
Layer
Devices.

2 – Data Node to Node Delivery


Frames Ethernet, PPP, etc.
Link Layer of Message.

Transmission of data
3 – Network from one host to another, IP, ICMP, IGMP, OSPF,
Packets
Layer located in different etc.
networks.

Take Service from Segments (for


4 – Transport Network Layer and TCP) or
TCP, UDP, SCTP, etc.
Layer provide it to the Datagrams
Application Layer. (for UDP)

Establishes Connection,
5 – Session Maintenance, Ensures
Data NetBIOS, RPC, PPTP, etc.
Layer Authentication and
Ensures security.

Data from the


application layer is
6 –
extracted and TLS/SSL, MIME, JPEG,
Presentation Data
manipulated in the PNG, ASCII, etc.
Layer
required format for
transmission.
Protocol
Layer Working Data Unit Protocols

7 – Helps in identifying the


FTP, SMTP, DNS, DHCP,
Application client and synchronizing Data
etc.
Layer communication.

Why Does The OSI Model Matter?


The OSI Model matters because it provides the user a clear structure of “how the data moves
in the network?”. As the OSI Model consists of 7 layers, each layer has its specific role, and
due to which it helps in understanding, identifying and solving the complex network
problems easily by focusing on one of the layers not the entire network.
As the modern Internet does not prefer the OSI Model, but still, the OSI Model is still very
helpful for solving network problems. It helps people understanding network concepts very
easily.
Difference Between OSI and TCP/IP Model

OSI Model TCP/IP Model

OSI stands for Open Systems TCP/IP stands for Transmission Control
Interconnection. Protocol/Internet Protocol.

OSI model has 7 layers. TCP/IP model consists of 4 layers.

Package delivery is guaranteed in OSI Package delivery is not guaranteed in the


Model. TCP/IP Model.

In the OSI model, Only layers 1,2 and 3 All layers of the TCP/IP model are needed
are necessary for data transmission. for data transmission.

Protocols at each layer is independent of Layers are integrated, some layers are
the other layer. required by other layers of TCP/IP model.

OSI Model is a conceptual framework, Widely used in actual networks like Internet
less used in practical applications. and Communication Systems.
OSI vs TCP/IP
Advantages of OSI Model
The OSI Model defines the communication of a computing system into 7 different layers. Its
advantages include:
 It divides network communication into 7 layers which makes it easier to understand
and troubleshoot.
 It standardizes network communications, as each layer has fixed functions and
protocols.
 Diagnosing network problems is easier with the OSI model.
 It is easier to improve with advancements as each layer can get updates separately.
Disadvantages of OSI Model
 The OSI Model has seven layers, which can be complicated and hard to understand
for beginners.
 In real-life networking, most systems use a simpler model called the Internet protocol
suite (TCP/IP), so the OSI Model is not always directly applicable.
 Each layer in the OSI Model adds its own set of rules and operations, which can make
the process more time-consuming and less efficient.
 The OSI Model is more of a theoretical framework, meaning it’s great for
understanding concepts but not always practical for implementation.

Mapping OSI Layers to IoT Architecture


Mapping the OSI (Open Systems Interconnection) model to IoT (Internet of Things)
architecture helps in understanding how data flows through different layers of the system.
Here’s how the OSI layers align with IoT architecture:
OSI Layers and Corresponding IoT Components
1. Physical Layer
o OSI: Deals with the physical connection between devices, including cables,
switches, and radio frequencies.
o IoT: Sensors and actuators that collect and transmit data.
2. Data Link Layer
o OSI: Responsible for node-to-node data transfer and error
detection/correction.
o IoT: Communication protocols such as IEEE 802.15.4 (used in Zigbee) and
MAC (Medium Access Control) addresses for wireless communication.
3. Network Layer
o OSI: Manages the routing of data packets across networks.
o IoT: IP addressing, IPv6, and 6LoWPAN (IPv6 over Low-Power Wireless
Personal Area Networks) for connecting IoT devices over the internet.
4. Transport Layer
o OSI: Ensures end-to-end communication, reliability, and error handling.
o IoT: Protocols like TCP (Transmission Control Protocol) and UDP (User
Datagram Protocol) for data transmission reliability.
5. Session Layer
o OSI: Manages sessions and connections between applications.
o IoT: MQTT (Message Queuing Telemetry Transport) and CoAP (Constrained
Application Protocol) to establish and manage communication sessions.
6. Presentation Layer
o OSI: Translates data between the application layer and the network, handling
encryption and data compression.
o IoT: Data formats, encryption (SSL/TLS), and serialization (JSON, XML) to
ensure secure and understandable data exchange.
7. Application Layer
o OSI: Provides network services to end-users and applications.
o IoT: Application protocols like HTTP/HTTPS, RESTful APIs, and application
platforms that interact with IoT devices and users.
Summary
 Physical Layer: Sensors, actuators, RF modules
 Data Link Layer: Zigbee, Wi-Fi, MAC addresses
 Network Layer: IP addressing, IPv6, 6LoWPAN
 Transport Layer: TCP, UDP
 Session Layer: MQTT, CoAP
 Presentation Layer: SSL/TLS, JSON, XML
 Application Layer: HTTP/HTTPS, RESTful APIs, IoT platforms

Proximity Networking Technologies in IoT


In the world of Internet of Things (IoT), proximity networking technologies play a
crucial role in enabling devices to communicate and interact with each other. These
technologies allow devices to connect and exchange data wirelessly, making IoT applications
more efficient and effective.
Importance of Proximity Networking Technologies in IoT
Proximity networking technologies are essential in IoT for several reasons:
1. Connectivity: Proximity networking technologies enable devices to establish
connections and communicate with each other without the need for physical wires.
This allows for greater flexibility and scalability in IoT deployments.
2. Efficiency: By using proximity networking technologies, IoT devices can transmit and
receive data quickly and efficiently, improving overall system performance.
3. Interoperability: Proximity networking technologies provide a standardized way for
devices from different manufacturers to communicate with each other, ensuring
compatibility and interoperability.
4. Cost-effectiveness: Proximity networking technologies often require less
infrastructure and resources compared to traditional wired networks, making them a
more cost-effective solution for IoT deployments.
Fundamentals of Proximity Networking Technologies
Before diving into specific proximity networking technologies, it is important to understand
some fundamental concepts:
1. Wireless Communication: Proximity networking technologies rely on wireless
communication protocols to transmit data between devices. These protocols define the
rules and procedures for establishing connections, transmitting data, and managing
network resources.
2. Network Architecture: Proximity networking technologies utilize different network
architectures, such as star, mesh, or hybrid, to organize and manage devices within a
network.
3. Communication Protocols: Each proximity networking technology has its own set of
communication protocols that govern how devices communicate and exchange data.
Now that we have a basic understanding of the importance and fundamentals of proximity
networking technologies, let's explore some specific technologies commonly used in IoT.
ZigBee
ZigBee is a low-power, low-data-rate wireless communication technology designed
for short-range applications. It operates on the IEEE 802.15.4 standard and is widely used in
home automation, industrial control, and smart energy management systems.
Definition and Overview of ZigBee
ZigBee is a wireless communication protocol specifically designed for low-power,
low-data-rate applications. It provides reliable and secure communication between devices in
a ZigBee network.
Key Features and Characteristics of ZigBee
 Low Power Consumption: ZigBee devices are designed to operate on low power,
making them ideal for battery-powered IoT devices.
 Low Data Rate: ZigBee supports data rates up to 250 kbps, which is sufficient for
most IoT applications.
 Mesh Network Topology: ZigBee networks typically use a mesh network topology,
allowing for multiple paths of communication and increased reliability.
 Security: ZigBee incorporates various security mechanisms to protect data
transmission and ensure the privacy of IoT devices.
ZigBee Network Architecture
A ZigBee network consists of three main components:
1. ZigBee Coordinator: The ZigBee coordinator is responsible for managing the network
and controlling the communication between devices.
2. ZigBee Router: ZigBee routers act as intermediate devices that facilitate
communication between devices within the network.
3. ZigBee End Device: ZigBee end devices are the final destination or source of data
within the network.
ZigBee Communication Protocols
ZigBee uses various communication protocols to enable devices to communicate and
exchange data. These protocols include:
 ZigBee Application Support Sublayer (APS): APS provides a set of services for
reliable data transfer, addressing, and security.
 ZigBee Network Layer (NWK): NWK handles network management, device
discovery, and routing within the ZigBee network.
 ZigBee Data Link Layer (DLL): DLL is responsible for reliable data transmission and
error detection.
Applications and Examples of ZigBee in IoT
ZigBee is widely used in various IoT applications, including:
 Home Automation: ZigBee enables smart home devices, such as lights, thermostats,
and security systems, to communicate and work together.
 Industrial Control: ZigBee is used in industrial control systems to monitor and control
processes, machinery, and equipment.
 Smart Energy Management: ZigBee is utilized in smart energy management systems
to monitor energy usage, optimize consumption, and enable demand response.
Advantages and Disadvantages of ZigBee
Advantages of ZigBee:
 Low Power Consumption: ZigBee devices have low power requirements, making
them suitable for battery-powered IoT devices.
 Mesh Network Topology: ZigBee networks can provide reliable communication
through multiple paths, increasing network robustness.
 Interoperability: ZigBee devices from different manufacturers can work together
seamlessly, ensuring compatibility and interoperability.
Disadvantages of ZigBee:
 Limited Data Rate: ZigBee has a relatively low data rate compared to other wireless
technologies, which may not be suitable for applications requiring high-speed data
transfer.
 Limited Range: ZigBee operates in the 2.4 GHz frequency band, which limits its
range to a few hundred meters.
 Complex Network Configuration: Setting up and configuring a ZigBee network can
be complex, requiring careful planning and coordination.

Bluetooth
Bluetooth is a wireless communication technology that enables short-range data
exchange between devices. It is widely used in consumer electronics, healthcare, and
automotive applications.
Definition and Overview of Bluetooth
Bluetooth is a wireless communication protocol designed for short-range data
exchange between devices. It operates on the 2.4 GHz frequency band and supports data rates
up to 3 Mbps.
Key Features and Characteristics of Bluetooth
 Short-Range Communication: Bluetooth has a typical range of up to 10 meters,
making it suitable for personal area networks (PANs).
 Low Power Consumption: Bluetooth devices are designed to operate on low power,
making them suitable for battery-powered devices.
 Frequency Hopping Spread Spectrum (FHSS): Bluetooth uses FHSS to minimize
interference from other wireless devices operating in the same frequency band.
 Multiple Profiles: Bluetooth supports various profiles that define specific use cases,
such as audio streaming, file transfer, and device control.
Bluetooth Network Architecture
Bluetooth networks typically consist of two types of devices:
1. Bluetooth Master: The Bluetooth master initiates and controls the communication
within the network.
2. Bluetooth Slave: Bluetooth slaves respond to the commands and requests from the
master.
Bluetooth Communication Protocols
Bluetooth uses several communication protocols to enable devices to communicate and
exchange data. These protocols include:
 Bluetooth Core Protocols: These protocols define the basic functionalities of
Bluetooth, such as device discovery, connection establishment, and data transfer.
 Bluetooth Profiles: Bluetooth profiles define specific use cases and functionalities,
such as hands-free calling, audio streaming, and file transfer.
Applications and Examples of Bluetooth in IoT
Bluetooth is widely used in various IoT applications, including:
 Wireless Audio Streaming: Bluetooth enables wireless audio streaming between
devices, such as smartphones, speakers, and headphones.
 Healthcare Monitoring: Bluetooth is used in healthcare applications to monitor vital
signs, track fitness activities, and transmit data to healthcare providers.
 Automotive Connectivity: Bluetooth allows for hands-free calling, audio streaming,
and device integration in vehicles.
Advantages and Disadvantages of Bluetooth
Advantages of Bluetooth:
 Ease of Use: Bluetooth devices can be easily paired and connected without the need
for complex network configurations.
 Wide Device Compatibility: Bluetooth is supported by a wide range of devices,
including smartphones, tablets, laptops, and IoT devices.
 Low Power Consumption: Bluetooth devices have low power requirements, making
them suitable for battery-powered IoT devices.
Disadvantages of Bluetooth:
 Limited Range: Bluetooth has a limited range of up to 10 meters, which may not be
sufficient for certain IoT applications.
 Interference: Bluetooth operates in the crowded 2.4 GHz frequency band, which can
lead to interference from other wireless devices.
 Data Rate Limitations: Bluetooth has a maximum data rate of 3 Mbps, which may not
be suitable for applications requiring high-speed data transfer.

Serial Communication
Serial communication is a method of transmitting data one bit at a time over a
communication channel. It is commonly used in IoT applications that require simple and
reliable data transfer.
Definition and Overview of Serial Communication
Serial communication is a method of data transmission where bits are sent
sequentially over a communication channel. It uses a single wire or a pair of wires to transmit
data between devices.
Key Features and Characteristics of Serial Communication
 Simplicity: Serial communication is relatively simple and easy to implement, making
it suitable for applications with basic data transfer requirements.
 Reliability: Serial communication is less prone to interference and noise compared to
wireless communication, ensuring reliable data transfer.
 Compatibility: Serial communication can be used with a wide range of devices,
including microcontrollers, sensors, and actuators.
Serial Communication Protocols
Serial communication protocols define the rules and procedures for transmitting and
receiving data. Some commonly used protocols in IoT include:
 RS-232: RS-232 is a standard for serial communication between devices. It uses
voltage levels to represent binary data.
 UART: UART (Universal Asynchronous Receiver-Transmitter) is a hardware module
that enables serial communication.
 SPI: SPI (Serial Peripheral Interface) is a synchronous serial communication protocol
commonly used for communication between microcontrollers and peripheral devices.
 I2C: I2C (Inter-Integrated Circuit) is a serial communication protocol that allows
multiple devices to communicate with each other using a shared bus.
Applications and Examples of Serial Communication in IoT
Serial communication is used in various IoT applications, including:
 Sensor Data Acquisition: Serial communication is commonly used to acquire data
from sensors and transmit it to a central processing unit.
 Actuator Control: Serial communication can be used to control actuators, such as
motors and valves, based on commands received from a central controller.
 Device Configuration: Serial communication is often used to configure and update
firmware on IoT devices.
Advantages and Disadvantages of Serial Communication
Advantages of Serial Communication:
 Simplicity: Serial communication is relatively simple to implement and requires
minimal hardware resources.
 Reliability: Serial communication is less prone to interference and noise compared to
wireless communication, ensuring reliable data transfer.
 Compatibility: Serial communication can be used with a wide range of devices,
making it a versatile choice for IoT applications.
Disadvantages of Serial Communication:
 Limited Data Rate: Serial communication has a limited data rate compared to wireless
communication technologies, which may not be suitable for applications requiring
high-speed data transfer.
 Distance Limitations: Serial communication is typically limited to short distances,
making it less suitable for applications that require long-range communication.
 Wired Connection: Serial communication requires a physical wired connection
between devices, which may not be feasible in certain IoT deployments
ZigBee
ZigBee is a Personal Area Network task group with low rate task group 4. It is a
technology of home networking. ZigBee is a technological standard created for controlling
and sensing the network. As we know that ZigBee is the Personal Area Network of task group
4 so it is based on IEEE 802.15.4 and is created by Zigbee Alliance.
ZigBee is an open, global, packet-based protocol designed to provide an easy-to-use
architecture for secure, reliable, low power wireless networks. Flow or process control
equipment can be place anywhere and still communicate with the rest of the system. It can
also be moved, since the network doesn’t care about the physical location of a sensor, pump
or valve.
ZigBee is a standard that addresses the need for very low-cost implementation of Low
power devices with Low data rates for short-range wireless communications.
IEEE 802.15.4 supports star and peer-to-peer topologies. The ZigBee specification
supports star and two kinds of peer-to-peer topologies, mesh and cluster tree. ZigBee-
compliant devices are sometimes specified as supporting point-to-point and point-to-
multipoint topologies.
Why another short-range communication standard??

Types of ZigBee Devices:


 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.
General Characteristics of Zigbee Standard:
 Low Power Consumption
 Low Data Rate (20- 250 kbps)
 Short-Range (75-100 meters)
 Network Join Time (~ 30 msec)
 Support Small and Large Networks (up to 65000 devices (Theory); 240 devices
(Practically))
 Low Cost of Products and Cheap Implementation (Open Source Protocol)
 Extremely low-duty cycle.
 3 frequency bands with 27 channels.
Operating Frequency Bands (Only one channel will be selected for use in a network):
1. Channel 0: 868 MHz (Europe)
2. Channel 1-10: 915 MHz (the US and Australia)
3. Channel 11-26: 2.4 GHz (Across the World)
Features of Zigbee:
1. Stochastic addressing: A device is assigned a random address and announced. Mechanism
for address conflict resolution. Parents node don’t need to maintain assigned address table.
2. Link Management: Each node maintains quality of links to neighbors. Link quality is used
as link cost in routing.
3. Frequency Agility: Nodes experience interference report to channel manager, which then
selects another channel
4. Asymmetric Link: Each node has different transmit power and sensitivity. Paths may be
asymmetric.
5. Power Management: Routers and Coordinators use main power. End Devices use batteries.
Advantages of Zigbee:
1. Designed for low power consumption.
2. Provides network security and application support services operating on the top of
IEEE.
3. Zigbee makes possible completely networks homes where all devices are able to
communicate and be
4. Use in smart home
5. Easy implementation
6. Adequate security features.
7. Low cost: Zigbee chips and modules are relatively inexpensive, which makes it a
cost-effective solution for IoT applications.
8. Mesh networking: Zigbee uses a mesh network topology, which allows for devices to
communicate with each other without the need for a central hub or router. This makes
it ideal for use in smart home applications where devices need to communicate with
each other and with a central control hub.
9. Reliability: Zigbee protocol is designed to be highly reliable, with robust mechanisms
in place to ensure that data is delivered reliably even in adverse conditions.
Disadvantages of Zigbee:
1. Limited range: Zigbee has a relatively short range compared to other wireless
communications protocols, which can make it less suitable for certain types of
applications or for use in large buildings.
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 Network Topologies:
 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:
Zigbee architecture is a combination of 6 layers.
1. Application Layer
2. Application Interface Layer
3. Security Layer
4. Network Layer
5. Medium Access Control Layer
6. PhysicalLayer
 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.
The physical layer translates the data packets in the over-the-air bits for transmission
and vice-versa during the reception.
 Medium Access Control layer (MAC layer): The layer is responsible for the interface
between the physical and network layer. The MAC layer is also responsible for
providing PAN ID and also network discovery through beacon requests.
 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.
Channel Access:
1. Contention Based Method (Carrier-Sense Multiple Access With Collision Avoidance
Mechanism)
2. Contention Free Method (Coordinator dedicates a specific time slot to each device
(Guaranteed Time Slot (GTS)))
Zigbee Applications:
1. Home Automation
2. Medical Data Collection
3. Industrial Control Systems
4. meter reading system
5. light control system
6. Commercial
7. Government Markets Worldwide
8. Home Networking
Bluetooth
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 scatter net.
What is Bluetooth?
Bluetooth is a wireless technology that lets devices like phones, tablets, and
headphones connect to each other and share information without needing cables. Bluetooth
simply follows the principle of transmitting and receiving data using radio waves. It can be
paired with the other device which has also Bluetooth but it should be within the estimated
communication range to connect. When two devices start to share data, they form a network
called piconet which can further accommodate more than five devices.
Key Features of Bluetooth
 The transmission capacity of Bluetooth is 720 kbps.
 Bluetooth is a wireless device.
 Bluetooth is a Low-cost and short-distance radio communications standard.
 Bluetooth is robust and flexible.
 The basic architecture unit of Bluetooth is a piconet.
Architecture of Bluetooth
The architecture of Bluetooth defines two types of networks:
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.
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.

Bluetooth Architecture
Bluetooth Protocol Stack
 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.
 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.
 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.
 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.
 Service Discovery Protocol (SDP) Layer: It is short for Service Discovery Protocol. It
allows discovering the services available on another Bluetooth-enabled device.

 RF Comm Layer: It is a cabal replacement protocol. It is short for Radio Frontend


Component. It provides a serial interface with WAP and OBEX. It also provides
emulation of serial ports over the logical link control and adaption protocol(L2CAP).
The protocol is based on the ETSI standard TS 07.10.
 OBEX: It is short for Object Exchange. It is a communication protocol to exchange
objects between 2 devices.
 WAP: It is short for Wireless Access Protocol. It is used for internet access.
 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.
 Application Layer: It enables the user to interact with the application.

Bluetooth Protocol Stack


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.
 Stereo Headset: To listen to music in car or in music players at home.
 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.
Applications of Bluetooth
 It can be used in wireless headsets, wireless PANs, and LANs.
 It can connect a digital camera wireless to a mobile phone.
 It can transfer data in terms of videos, songs, photographs, or files from one cell
phone to another cell phone or computer.
 It is used in the sectors of Medical healthcare, sports and fitness, Military.
Advantages
 It is a low-cost and easy-to-use device.
 It can also penetrate through walls.
 It creates an Ad-hoc connection immediately without any wires.
 It is used for voice and data transfer.
Disadvantages
 It can be hacked and hence, less secure.
 It has a slow data transfer rate of 3 Mbps.
 Bluetooth communication does not support routing.
Serial communication is a fundamental aspect of IoT systems, enabling the transfer of data
between devices using a single data line. Here’s a detailed overview of serial communication
in IoT:
Basics of Serial Communication
 Definition: Serial communication involves the transmission of data one bit at a time
over a communication channel or computer bus.
 Protocols: Common serial communication protocols in IoT include UART (Universal
Asynchronous Receiver/Transmitter), SPI (Serial Peripheral Interface), and I2C
(Inter-Integrated Circuit).
Key Protocols
1. UART (Universal Asynchronous Receiver/Transmitter)
o Characteristics:
 Asynchronous communication: No clock signal, data synchronized by
start and stop bits.
 Simple and widely used for device-to-device communication.
o Use Cases: Communication between microcontrollers and peripherals (e.g.,
sensors, GPS modules).
2. SPI (Serial Peripheral Interface)
o Characteristics:
 Synchronous communication: Uses a clock signal (SCLK), master-out-
slave-in (MOSI), master-in-slave-out (MISO), and a chip select (CS)
line.
 Faster data transfer rates compared to UART.
o Use Cases: High-speed communication with sensors, displays, and SD cards.
3. I2C (Inter-Integrated Circuit)
o Characteristics:
 Synchronous communication: Uses two lines, Serial Data Line (SDA)
and Serial Clock Line (SCL).
 Allows multiple devices on the same bus with unique addresses.
o Use Cases: Communication with multiple sensors, real-time clocks, and other
low-speed peripherals.
Applications in IoT
 Data Acquisition: Collecting data from sensors and transferring it to microcontrollers
or gateways.
 Device Control: Sending commands to actuators, motors, and other output devices.
 Inter-Device Communication: Enabling communication between various IoT devices
to form a cohesive network.
Advantages
 Efficiency: Enables efficient and reliable data transfer between devices.
 Flexibility: Supports communication with a wide range of devices and peripherals.
 Simplicity: Often simpler to implement compared to other communication methods
like parallel communication.
Considerations
 Data Rate: Choose the appropriate protocol based on the required data transfer rate.
 Distance: Consider the distance over which data needs to be transmitted (e.g., UART
is suitable for short distances).
 Interference: Minimize electrical noise and interference in the communication lines
for reliable data transfer.

Industrial network protocol


• An industrial network protocol is defined as a set of rules that govern the
communication between devices in industrial settings, such as
 Modbus,
 DNP3,
 OPC,
 ICCP, and others,
either in their original fieldbus form or in modernized TCP/IP or real-time Ethernet
implementations.
Ethernet/IP: Combines Ethernet and the Common Industrial Protocol (CIP)
for real-time control and data exchange.
PROFINET: An open standard for industrial networking,
providing real-time data exchange and flexible configuration.
Modbus TCP/IP: A protocol used for communication over TCP/IP networks,
widely used in industrial environments.
DeviceNet: A network protocol used to interconnect devices for
data exchange in industrial applications.
CC-Link IE: A high-speed industrial network protocol for automation systems.
EtherCAT: Known for its high-speed data exchange and low communication overhead.
SERCOS III: A real-time communication protocol for motion control systems.
Foundation Fieldbus: Used for process automation and control systems.

MODBUS
What is Modbus?
 Modbus, introduced by Modicon(www.modicon.com) in 1979, stands as a serial
communication protocol specifically designed for deployment with its programmable
logic controllers (PLCs).
 Basically, it functions as a mechanism for the transfer of data between electronic
devices when it is transmitted over serial lines.
 Within this framework, the entity seeking data is denoted as the Modbus master, while
those providing data are referred to as Modbus slaves.
 In a typical Modbus network, a singular master exists alongside up to 247 Slaves,
each assigned a unique slaves Address ranging from 1 to 247. Additionally, the master
possesses the capability to transmit information to the slaves.
What is Modbus used for?
 Modbus, as an open protocol, is freely available for integration into equipment by
manufacturers, eliminating the need for royalty payments.
 It has emerged as a standard communication protocol in various industries and stands
as the most prevalent method for linking industrial electronic devices.
 Its widespread adoption spans across numerous manufacturers and diverse sectors. In
practical applications, Modbus is commonly employed for transmitting signals from
instrumentation and control devices to a central controller or data collection system.
 For instance, it facilitates the communication of temperature and humidity
measurements from a system to a computer. In supervisory control and data
acquisition (SCADA) systems, Modbus is frequently utilized to establish a connection
between a supervisory computer and a remote terminal unit (RTU).
 Notably, different versions of the Modbus protocol cater to serial lines (Modbus RTU
and Modbus ASCII) as well as Ethernet (Modbus TCP).
How does Modbus work?

 Modbus, a widely used serial communication protocol, operates by facilitating data


exchange between electronic devices.
 In its basic configuration, a straightforward connection involves a single serial cable
linking the serial ports of two devices: a master and a slave.
 At the core of Modbus communication is the transmission of data through binary
code, represented as a series of ones and zeroes, also known as bits.
 These bits are conveyed through voltage variations. Zeroes are transmitted as positive
voltages, while ones are represented by negative voltages.
 The rapid transmission of these bits characterizes the efficiency of Modbus
communication. A common transmission speed for Modbus is 9600 baud, denoting
the number of bits transmitted per second.
What is master and slave in Modbus?
 Modbus follows a master-slave architecture, where the master initiates requests, and
the slave responds. The Master, often a supervisory system or controller, sends a
request to the slave, typically a field device or sensor, to obtain or manipulate data.
 This request includes essential information such as the salve’s address, function code
specifying the type of operation, and data parameters.

 Upon receiving the request, the slave processes the command and transmits the
requested data back to the master.
 This bidirectional communication allows for real-time monitoring and control of
industrial processes.
 The use of unique slave addresses (ranging from 1 to 247) ensures that each device on
the network can be individually identified and addressed by the master.
How is data stored in Standard Modbus?
 In Standard Modbus, data is organized and stored within the slave device across four
distinct tables.
 These tables are categorized into two types: on/off discrete values (coils) and
numerical values (registers).
 Each type further includes a read-only table and a read-write table, resulting in a total
of four tables.
 Notably, each table can accommodate up to 9999 values.
 For the coils and registers, each possesses a data address within the range of 0000 to
270E. Coils, representing 1-bit on/off discrete values, and registers, serving as
containers for numerical data, share this addressing scheme.
 Registers, being 16 bits or 2 bytes each, also have data addresses ranging from 0000
to 270E.
 The Coil/Register Numbers can be compared to location names in that they serve as
identifiers inside the tables but do not appear in the actual messages transferred
between devices.
 The crucial element used in the messages is the Data Address. To illustrate, consider
the first Holding Register with the number 40001; its corresponding Data Address is
0000.
 The distinction between these two values is referred to as the offset. Each table is
associated with a specific offset, which varies for the four tables: 1, 10001, 30001,
and 40001.
Here’s a table summarizing the key information for coils and registers in Standard Modbus,
including their numbers, data addresses, data types, and table names:

Type Coil/Register Number Data Address Data Type Table Name

Discrete Input 00001 – 09999 0000 – 270E Bit Input Status

Coils 00001 – 09999 0000 – 270E Bit Output Status

Input Register 30001 – 39999 0000 – 270E 16-bit Input Register

Holding Register 40001 – 49999 0000 – 270E 16-bit Holding Register

What is the slave ID in Modbus?


 In Modbus communication, each slave device on the network is assigned a unique
unit address ranging from 1 to 247.
 This address(ID) is crucial for the proper identification of the intended recipient of the
message. The slave address is the first byte of the message sent by the master,
allowing each slave device to quickly determine whether the message is meant for it.
 This addressing mechanism ensures efficient and targeted communication within the
Modbus network, as each slave device can decide whether to process or ignore the
incoming message based on its assigned address.
What is a function code in Modbus?
 In the Modbus protocol, the function code is a numerical code that indicates the type
of action the master requests the slave to perform.
 The function code is the second byte sent by the master in a Modbus message. It
specifies the operation or function that the slave should execute, including which table
to access and whether the operation involves reading from or writing to the table.

Here’s a table with some common Modbus function codes:

Function Code Action Table Name

01 Read Coils Discrete Output Coils

02 Read Discrete Inputs Discrete Input Contacts

03 Read Holding Registers Analog Output Holding Registers

04 Read Input Registers Analog Input Registers

05 Write Single Coil Single Discrete Output Coil

06 Write Single Register Single Analog Output Holding Register

07 Read Exception Status – (Depends on the device)

08 Diagnostic – (Depends on the device)

15 Write Multiple Coils Multiple Discrete Output Coils

16 Write Multiple Registers Multiple Analog Output Holding Registers

 These function codes are just a selection of the many codes defined in the Modbus
standard. Each code has a specific purpose, instructing the slave on how to process the
request.
 For instance, Function Code 03 instructs the slave to read holding registers, while
Function Code 06 instructs the slave to write a single register.
 The combination of the slave address (unit ID), function code, and additional data
forms a complete Modbus message, enabling communication between the master and
slave devices in a Modbus network.
What CRC is used in Modbus?
 CRC stands for Cyclic Redundancy Check, is a method used in Modbus and many
other communication protocols to detect errors in transmitted data.
 In Modbus, a CRC is a two-byte (16-bit) field added to the end of every message for
error detection purposes.

What is the function of CRC in Modbus?


Here is some other information about how Modbus CRC functions:
Calculation during Transmission:
 The CRC is calculated based on every byte in the Modbus message, including the
address, function code, data, and any other relevant fields.
 This calculation uses a mathematical algorithm to generate a unique CRC value for
the specific content of the message.
Appended to Message:
 The calculated CRC value is then appended to the end of the message.
Verification at the Receiver:
 When the slave(receiver) receives the message, it also performs the CRC calculation
on the received data, excluding the appended CRC field.
 The calculated CRC at the slave (receiver) should match the CRC appended to the
message by the master(sender).
Error Detection:
 If the CRC calculated by the receiver does not match the CRC received in the
message, it indicates a potential error in the transmission.
 If the CRCs do not match, the receiving device can request the sender to resend the
message.
Modbus uses CRC to detect errors, which helps to ensure the integrity of the data during
transmission. The CRCs will probably differ if the message changes by even a single bit
while it is being transmitted, indicating that there is a problem. This system improves
Modbus communication reliability.
What is the LRC in Modbus?
In the context of Modbus, Longitudinal Redundancy Check (LRC) is an error-checking
method used in the Modbus RTU (Remote Terminal Unit) communication protocol. LRC is
specific to Modbus RTU, which is designed for serial communication over RS-232 or RS-
485.
Modbus RTU’s LRC operates in the following way:
 LRC is calculated by performing an XOR (exclusive OR) operation on all bytes of the
message, including the device address, function code, data, and any other relevant
fields.
 The result of the XOR operation is then complemented (bitwise NOT) to obtain the
final LRC value.
 The LRC value is typically appended to the end of the message frame, just before the
stop bits.
 LRC is a single-byte check, providing a simple form of error detection.
 Upon receiving a message, the receiving device performs the same XOR and
complement operations on the received bytes. If the calculated LRC matches the
received LRC, the message is considered to be error-free.
 LRC is effective at detecting certain types of errors, such as single-bit errors.It might
not be as reliable, though, as advanced error-checking techniques like Cyclic
Redundancy Check (CRC).
Types of Modbus
 Modbus is a communication protocol commonly used in industrial automation and
control systems.
 There are different variants or types of Modbus protocols, each serving specific
purposes. The two main types are Modbus RTU and Modbus TCP.
Modbus RTU (Remote Terminal Unit):
In industrial contexts, Modbus RTU is a commonly used protocol, especially when using
serial communication is helpful. It is appropriate for a variety of industrial automation and
control applications because of its stability and ease of implementation.
Frame Structure:

 Modbus RTU uses a master-slave communication model.


 The communication frame consists of a start bit, device address, function code, data,
CRC (Cyclic Redundancy Check), and stop bits.
 The frame structure allows for multiple devices to be connected on the same network.
Error Detection:
 Modbus RTU incorporates error-checking through CRC, which helps in detecting
communication errors.
Addressing:
 Devices on a Modbus RTU network are identified by unique addresses.
 Address range for Modbus RTU devices is typically from 1 to 247.

Master-Slave Architecture:
 The master initiates communication by sending requests to the slaves.
 Slaves respond to the master’s requests, and each device has its own address to
differentiate between them.
RS-485 vs. RS-232:
 While RS-232 is suitable for short-distance point-to-point communication, RS-485 is
often preferred for longer distances and multi-drop configurations.
 RS-485 allows for the daisy-chaining of devices, which can be more cost-effective
and practical in certain applications.
Speed Considerations:
 Modbus RTU typically operates at lower speeds compared to Modbus TCP, which
uses Ethernet as its physical layer.
 Transmission speeds can vary but are generally in the range of 9600 to 115200 bits
per second.
Industrial Applications:
 Modbus RTU is widely used in industrial automation and control systems.
 It is commonly employed in applications where wired serial communication is a
preferred or necessary choice due to factors like reliability and environmental
conditions.
Stability:
 The simplicity and efficiency of Modbus RTU make it a robust and reliable choice for
many industrial communication needs.
Modbus TCP (Transmission Control Protocol):
Modbus TCP, which uses Ethernet for communication, is a logical development of the
Modbus protocol. With benefits in speed, range, and compatibility with current network
infrastructure, it is commonly used in modern industrial systems with Ethernet connectivity.
Communication Medium:
 Modbus TCP utilizes Ethernet as the communication medium.
 This enables it to take advantage of the widespread use and familiarity of Ethernet in
industrial and commercial environments.
Data Representation:
 Unlike Modbus RTU’s binary encoding, Modbus TCP uses a format compatible with
the TCP/IP suite.
 This means that it encapsulates Modbus frames into TCP packets, allowing for
seamless integration with Ethernet networks.
Topology:
 Modbus TCP is well-suited for Ethernet networks, offering flexibility in terms of
network topologies.
 It can be used in star, ring, bus, or other network configurations commonly found in
Ethernet-based setups.
Transmission Speed:
 Modbus TCP generally operates at higher speeds compared to Modbus RTU.
 The use of Ethernet as the underlying transport layer contributes to faster data
transmission.
IP Addressing:
 Devices on a Modbus TCP network are identified using IP addresses, making it easier
to integrate into existing TCP/IP network infrastructures.
Master-Slave Architecture:
 Similar to Modbus RTU, Modbus TCP follows the master-slave architecture.
 The master initiates communication by sending requests to the slaves, and the slaves
respond accordingly.
Interoperability:
 Modbus TCP’s compatibility with the TCP/IP suite enhances interoperability with
other networking protocols and technologies commonly used in modern industrial
systems.
Advantages:
 Modbus TCP offers advantages in terms of speed, longer-distance communication,
and compatibility with existing Ethernet infrastructure.
 It is well-suited for applications where real-time communication, large amounts of
data, and integration with other Ethernet-based systems are important.
Security Considerations:
 As with any communication protocol, security measures need to be implemented to
protect Modbus TCP networks from unauthorized access or attacks.
 This may include the use of firewalls, virtual private networks (VPNs), and other
security protocols.

Modbus RTU Vs Modbus TCP


The equipment and situations used in a given industrial system may cause specific
implementations to differ from these general characteristics. The following table provides an
overview of the key differences between Modbus RTU and Modbus TCP:

Characteristic Modbus RTU Modbus TCP

Communication
Serial (RS-232 or RS-485) Ethernet (TCP/IP)
Method

Data Representation Binary Compatible with TCP/IP suite

Topology Point-to-point or multi-drop Flexible (typical Ethernet topologies)

Transmission Speed Typically lower Generally higher

PLC systems, serial


Typical Use Modern industrial systems, Ethernet
communication

Physical Layer Serial Ethernet

Distance Shorter distances Longer distances (typical Ethernet)

May require additional Integrated with existing Ethernet


Interoperability
hardware infrastructure

Ease of Network diagnostics and monitoring


Simpler for serial diagnostics
Troubleshooting tools
What is a Modbus frame?
A Modbus frame refers to the structure of data transmitted over a Modbus network.

A Modbus frame consists of the following elements:


Address Field:
This field identifies the device (or slave) on the Modbus network that the message is intended
for. Each device on the network has a unique address.
Function Code:
The function code specifies the type of action the device should perform. For example, it
could indicate a read operation, write operation, or diagnostic function.
Data Field:
This field contains the actual data being sent or requested. The format and content of the data
field depend on the specific function code and the purpose of the message.
Error Checking:
Modbus frames typically include a form of error-checking to ensure the integrity of the
transmitted data. This can be a simple checksum or a more sophisticated cyclic redundancy
check (CRC).
What are the formats of Modbus commands and responses?
Below is a simplified table illustrating the basic structure of Modbus commands and
responses for the Modbus RTU (Remote Terminal Unit).
The examples provided are for a common Modbus function code, “Read Holding Registers”
(Function Code 03), as an illustration.

Modbus RTU Frame Format:


Command: Read Holding Registers (Function Code 03)

Size
Field Description
(Bytes)

Start of
1 Silent interval or frame start delimiter
Frame

Slave
1 Address of the target device (1 to 247)
Address

Function Specifies the type of action to be performed (03 for Read Holding
1
Code Registers)

Data Variable Parameters specific to the function code

Error Check 2 CRC (Cyclic Redundancy Check) for error detection

End of Frame 1 End of frame delimiter

Response: Read Holding Registers

Field Size (Bytes) Description

Start of Frame 1 Silent interval or frame start delimiter

Slave Address 1 Address of the responding device


Function Code 1 Echo of the received function code

Byte Count 1 Number of bytes in the Data field

Data Variable Actual data read from holding registers

Error Check 2 CRC for error detection

End of frame delimiter


End of Frame 1

Modbus ASCII Frame Format:


Command: Read Holding Registers (Function Code 03)

Field Size (Characters) Description

Start of Frame 1-2 Colon character (:) repeated twice

Slave Address 2 Address of the target device (ASCII chara

Function Code 2 ASCII representation of the function code

Data Variable ASCII representation of parameters

LRC (Longitudinal Redundancy Check) 2 ASCII representation of LRC

End of Frame 2 Carriage return (CR) and line feed (LF) ch

Response: Read Holding Registers

Field Size (Characters) Description

Start of Frame 1-2 Colon character (:) repeated twice

Slave Address 2 Address of the responding device

Function Code 2 ASCII representation of the function code

Byte Count 2 ASCII representation of byte count


Data Variable ASCII representation of actual data read

LRC (Longitudinal Redundancy Check) 2 ASCII representation of LRC

End of Frame 2 Carriage return (CR) and line feed (LF) ch

Remember that the unique Modbus function code and the parameters used in the command or
response will decide the actual data content and lengths. Also, error-checking mechanisms
like CRC and LRC are used to make sure that the data being sent is accurate.
Modbus TCP Message Structure
Modbus TCP utilizes a TCP/IP link for the transmission of Modbus messages. The format of
a Modbus TCP message is as follows:

Field Size Description

Transaction
2 Bytes Identifies the transaction.
Id

Protocol 2 Bytes Set to zero to indicate the Modbus protocol.

Length 2 Bytes Specifies the number of following bytes.

Unit Address 1 Byte Represents the PLC Address encoded as a single byte.

N Contains the Modbus Protocol Data Unit (PDU) with a maximum length
Message
Bytes of 253 bytes.

Notes on Unit Address Usage:


Real Modbus TCP devices exhibit variations in the utilization of the Unit Address field:
 Some devices may choose to ignore the Unit Address field.
 Certain devices might mandate a fixed value for the Unit Address, such as 0 or 255.
 Some devices function as gateways to multiple PLCs, where the Unit Address
determines the specific PLC to communicate with.
Maximum Message Length:
The maximum allowable length for the entire Modbus TCP message is 260 bytes.
Understanding the diverse ways in which the unit address is employed is crucial for
configuring communication with Modbus TCP devices, as this aspect may differ among
various devices. Always refer to the documentation provided by the specific Modbus TCP
device for accurate details on its unit address implementation.
How to Read Modbus Request?
To read a Modbus request, you need to capture and analyze the raw data transmitted over the
Modbus network. Below is an example of how you might read a Modbus RTU request
In this example, consider a Modbus RTU “Read Holding Registers” request (Function Code
03).
Assuming you have captured a Modbus RTU request frame:

 Slave Address (01): The request is for the Modbus device with the address 01.
 Function Code (03): This code indicates the request is to read data from holding
registers.
 Register Address (0000): The starting register address to read from is 0000.
 Number of Registers (0002): The request is asking to read data from two consecutive
registers.
This request simply asks the Modbus device at address 01 to provide the values stored in the
holding registers starting at address 0000, and it specifically requests data from the first two
registers.
Mobus Simulators and Troubleshooting Tools
Free Modbus Simulators:
1. Modbus Poll:
Popular and user-friendly simulator for both master and slave devices. Supports various
Modbus versions (RTU, ASCII and TCP/IP). Provides real-time data monitoring and
diagnostic tools.
2. pyModbus:
Open-source Python library for simulating Modbus communication. Highly customizable and
scriptable option for advanced testing conditions.
3. Modbus Simulator Online:
Simple web-based simulator for quick testing and learning. Supports Modbus RTU and
TCP/IP. No installation required, good for basic testing and learning..
Paid Modbus Simulators:
1. Citect Automation Studio:
Comprehensive industrial automation software with advanced Modbus simulation
capabilities. Offers powerful testing and debugging tools for complex networks.
Free trial available, download link on Citect Automation Studio.

2. Rockwell Automation RSLogix 500/5000:


Programmable logic controllers (PLCs) with built-in Modbus simulation features. Ideal for
testing real-world PLC communication situations.Modbus Troubleshooting Software Tools:
1. Wireshark:
Network protocol analyzer for capturing and analyzing Modbus communication packets.
Helps to identify errors and diagnose network issues.
2. Modbus Tools Suite:
Paid Modbus analysis and troubleshooting tools. Error tracking, protocol decoding, and data
visualization.
3. Fluke Networks EtherScope Network Assistant:
Multi-purpose network troubleshooting tool with Modbus analysis capabilities. Ideal for field
engineers and network administrators.

CAN (Controller Area Network) protocol


CAN stands for Controller Area Network protocol. It is a protocol that was developed
by Robert Bosch in around 1986. The CAN protocol is a standard designed to allow the
microcontroller and other devices to communicate with each other without any host
computer. The feature that makes the CAN protocol unique among other communication
protocols is the broadcast type of bus. Here, broadcast means that the information is
transmitted to all the nodes. The node can be a sensor, microcontroller, or a gateway that
allows the computer to communicate over the network through the USB cable or ethernet
port. The CAN is a message-based protocol, which means that message carries the message
identifier, and based on the identifier, priority is decided.
There is no need for node identification in the CAN network, so it becomes very easy
to insert or delete it from the network. It is a serial half-duplex and asynchronous type of
communication protocol. The CAN is a two-wired communication protocol as the CAN
network is connected through the two-wired bus. The wires are twisted pair having 120Ω
characteristics impedance connected at each end. Initially, it was mainly designed for
communication within the vehicles, but it is now used in many other contexts. Like UDS, and
KWP 2000, CAN also be used for the on-board diagnostics.
Why CAN?
The need for a centralized standard communication protocol came because of the increase in
the number of electronic devices. For example, there can be more than 7 TCU for various
subsystems such as dashboard, transmission control, engine control unit, and many more in a
modern vehicle. If all the nodes are connected one-to-one, then the speed of the
communication would be very high, but the complexity and cost of the wires would be very
high. In the above example, a single dashboard requires 8 connectors, so to overcome this
issue, CAN was introduced as a centralized solution that requires two wires, i.e., CAN high
and CAN low. The solution of using CAN protocol is quite efficient due to its message
prioritization, and flexible as a node can be inserted or removed without affecting the
network.
Applications of CAN protocol
Initially, CAN protocol was designed to target the communication issue that occurs within the
vehicles. But later on, due to the features it offers, it is used in various other fields. The
following are the applications of CAN protocol:
o Automotive (passenger vehicles, trucks, buses)
o Electronic equipment for aviation and navigation
o Industrial automation and mechanical control
o Elevator and escalators
o Building automation
o Medical instruments and equipment
o Marine, medical, industrial, medical
CAN layered architecture
As we know that the OSI model partitions the communication system into 7 different layers.
But the CAN layered architecture consists of two layers, i.e., data-link layer and physical
layer.
Advertisement
Let's understand both the layers.
o Data-link layer: This layer is responsible for node to node data transfer. It allows you
to establish and terminate the connection. It is also responsible for detecting and
correcting the errors that may occur at the physical layer. Data-link layer is subdivided
into two sub-layers:
o MAC: MAC stands for Media Access Control. It defines how devices in a
network gain access to the medium. It provides Encapsulation and
Decapsulation of data, Error detection, and signaling.
o LLC: LLC stands for Logical link control. It is responsible for frame
acceptance filtering, overload notification, and recovery management.
o Physical layer: The physical layer is responsible for the transmission of raw data. It
defines the specifications for the parameters such as voltage level, timing, data rates,
and connector.
CAN specifications define CAN protocol and CAN physical layer, which are defined in the
CAN standard ISO 11898. ISO 11898 has three parts:
o ISO 11898-1: This part contains the specification of the Data-link layer and physical
signal link.
o ISO 11898-2: This part comes under CAN physical layer for high speed CAN. The
high- speed CAN allows data rate upto 1 Mbps used in the power train and the
charges area of the vehicle.
o ISO 11898-3: This part also comes under CAN physical layer for low-speed CAN. It
allows data rate upto 125 kbps, and the low speed CAN is used where the speed of
communication is not a critical factor.
CiA DS-102: The full form of CiA is CAN in Automation, which defines the specifications
for the CAN connector.
As far as the implementation is concerned, the CAN controller and CAN transceiver are
implemented in the software with the help of the application, operating system, and network
management functions.
CAN Framing
Let's understand the structure of the CAN frame.

 SOF: SOF stands for the start of frame, which indicates that the new frame is entered
in a network. It is of 1 bit.
 Identifier: A standard data format defined under the CAN 2.0 A specification uses an
11-bit message identifier for arbitration. Basically, this message identifier sets the
priority of the data frame.
 RTR: RTR stands for Remote Transmission Request, which defines the frame type,
whether it is a data frame or a remote frame. It is of 1-bit.
 Control field: It has user-defined functions.
1. IDE: An IDE bit in a control field stands for identifier extension. A dominant
IDE bit defines the 11-bit standard identifier, whereas recessive IDE bit
defines the 29-bit extended identifier.
2. DLC: DLC stands for Data Length Code, which defines the data length in a
data field. It is of 4 bits.
3. Data field: The data field can contain upto 8 bytes.
 CRC field: The data frame also contains a cyclic redundancy check field of 15 bit,
which is used to detect the corruption if it occurs during the transmission time. The
sender will compute the CRC before sending the data frame, and the receiver also
computes the CRC and then compares the computed CRC with the CRC received
from the sender. If the CRC does not match, then the receiver will generate the error.
 ACK field: This is the receiver's acknowledgment. In other protocols, a separate
packet for an acknowledgment is sent after receiving all the packets, but in case of
CAN protocol, no separate packet is sent for an acknowledgment.
 EOF: EOF stands for end of frame. It contains 7 consecutive recessive bits known
End of frame.
Now we will see how data is transmitted through the CAN network.
A CAN network consists of multiple of CAN nodes. In the above case, we have considered
three CAN nodes, and named them as node A, node B, and node C. CAN node consists of
three elements which are given below:
o Host
A host is a microcontroller or microprocessor which is running some application to do
a specific job. A host decides what the received message means and what message it
should send next.
o CAN Controller
CAN controller deals with the communication functions described by the
CAN protocol. It also triggers the transmission, or the reception of the CAN
messages.
o CANTransceiver
CAN transceiver is responsible for the transmission or the reception of the data on the
CAN bus. It converts the data signal into the stream of data collected from the CAN
bus that the CAN controller can understand.
In the above diagram, unshielded twisted pair cable is used to transmit or receive the data. It
is also known as CAN bus, and CAN bus consists of two lines, i.e., CAN low line and CAN
high line, which are also known as CANH and CANL, respectively.
The transmission occurs due to the differential voltage applied to these lines. The
CAN uses twisted pair cable and differential voltage because of its environment. For
example, in a car, motor, ignition system, and many other devices can cause data loss and
data corruption due to noise. The twisting of the two lines also reduces the magnetic field.
The bus is terminated with 120Ω resistance at each end.
CAN Characteristics
With the help of differential voltage, we will determine how 0 and 1 are transmitted
through the CAN bus. The above figure is the voltage graph that shows the voltage level of
CAN low and CAN high. In CAN terminology, logic 1 is said to be recessive while logic 0 is
dominant. When CAN high line and CAN low line are applied with 2.5 volts, then the actual
differential voltage would be zero volt. A zero volt on CAN bus is read by the CAN
transceiver as a recessive or logic 1.
A zero volt on CAN bus is an ideal state of the bus. When CAN high line is pulled up
to 3.5 volt and the CAN low line is pulled down to 1.5 volt, then the bus's actual differential
voltage would be 2 volts. It is treated as a dominant bit or logic 0 by the CAN transceiver. If
the bus state is reached to dominant or logic 0 then it would become impossible to move to
the recessive state by any other node.
Key points learnt from the CAN characteristics
o Logic 1 is a recessive state. To transmit 1 on CAN bus, both CAN high and CAN low
should be applied with 2.5V.
o Logic 0 is a dominant state. To transmit 0 on CAN bus, CAN high should be applied
at 3.5V and CAN low should be applied at 1.5V.
o The ideal state of the bus is recessive.
o If the node reaches the dominant state, it cannot move back to the recessive state by
any other node.

CAN bus logic


From the above scenario, we get to know that the dominant state overwrites the
recessive state. When the node sends the dominant and the recessive bit simultaneously, then
the bus remains dominant. The recessive level occurs only when all the nodes send the
recessive bit. Such logic is known as AND logic, and physically it is implemented as an open
collector circuit.
CAN Communication Principle
As we know that the message is sent based on the priority set in the arbitration field. For the
standard frame, the message identifier is 11 bit, while for the extended frame, the message
identifier is 29 bit. It allows the system designer to design the message identifier at the design
itself. The smaller the message identifier, the higher, would be the message priority.

The sender wants to send the message and waiting for the CAN bus to become idle. If
the CAN bus is idle, then the sender sends the SOF or the dominant bit for the bus access.
Then, it sends the message identifier bit in the most significant bit. If the node detects the
dominant bit on the bus while it has transmitted the recessive bit, it means that the node has
lost the arbitration and stops transmitting further bits. The sender will wait and resend the
message once the bus is free.

CAN Arbitration Example


If we consider three nodes, i.e., Node 1, Node 2, and Node 3, the message identifiers of these
nodes are 0x7F3, 0x6B3, and 0x6D9, respectively.

The transmission of all the three nodes with the most significant bit is shown in the above
diagram.
Communication between IoT devices and cloud applications is a crucial aspect of IoT
architecture. It enables the collection, processing, storage, and analysis of data on a larger
scale. Here's an overview of how this communication works:
Key Components and Processes
1. IoT Devices
o Sensors and Actuators: Collect data from the physical environment and
perform actions based on received commands.
2. Edge Devices/Gateways
o Data Aggregation: Collect data from multiple IoT devices and perform initial
processing.
o Protocol Translation: Convert data from device-specific protocols to standard
internet protocols.
3. Communication Protocols
o MQTT (Message Queuing Telemetry Transport): A lightweight messaging
protocol ideal for small sensors and mobile devices with low bandwidth.
o HTTP/HTTPS (HyperText Transfer Protocol): Commonly used for web
applications, suitable for larger data packets.
o CoAP (Constrained Application Protocol): Designed for devices with limited
resources, similar to HTTP but optimized for IoT.
o

4. Cloud Platform
o Data Ingestion: Receives data from IoT devices via APIs or direct
communication.
o Data Processing: Analyzes and processes data to extract valuable insights.
o Data Storage: Stores large volumes of data for long-term analysis and
retrieval.
o Data Visualization: Provides dashboards and reports for users to monitor and
analyze data.
5. Security
o Encryption: Ensures data is securely transmitted between IoT devices and the
cloud.
o Authentication: Verifies the identity of devices and users accessing the cloud
services.
o Authorization: Manages access control to ensure only authorized entities can
interact with the data and services.
Steps in the Communication Process
1. Data Collection: IoT devices collect data from the environment using sensors.
2. Data Transmission: Edge devices/gateways aggregate and transmit data to the cloud
using protocols like MQTT or HTTP.
3. Data Reception: The cloud platform ingests the data via APIs or direct connections.
4. Data Processing and Analysis: The cloud platform processes the data to extract
meaningful insights.
5. Data Storage and Visualization: Processed data is stored and made available for
visualization through dashboards and reports.
6. Command and Control: Based on the processed data, commands may be sent back to
IoT devices to perform specific actions.
Example: Smart Home System
 IoT Devices: Smart thermostats, lighting, and security cameras.
 Edge Devices: Home gateway/router aggregating data from all smart devices.
 Communication Protocols: MQTT for efficient messaging between devices and the
cloud.
 Cloud Platform: A cloud service like AWS IoT or Microsoft Azure IoT Hub.
 Security: Ensures secure data transmission and access control.
 User Interface: Mobile app or web portal for users to monitor and control their smart
home devices.
Web Services in Cloud Computing
Cloud computing web services are one of the integral parts of the modern Internet.
They assist in getting in touch through various applications or systems with one another for
the interchange of data and sharing functionalities with the help of the Internet medium. With
the advent of technologies in cloud computing, web services started finding wide applications
in interconnecting different technologies and platforms to facilitate communication and
collaboration with various systems. An introduction to the importance and the role of web
services regarding cloud computing is illustrated below.
What are web Services in Cloud Computing
Cloud Computing Web Services involve integrating web-based applications that are
implemented to allow open standards over an Internet Protocol backbone. It enables two
electronic devices to communicate over a network. The means are provided through different
standards that include HTTP, XML, SOAP, and WSDL, through which various applications
can communicate with each other. This makes the data and service provision across different
systems and platforms inter-operable and cooperative in the cloud.
Components of Web Services
 XML (Extensible Markup Language): XML can be described as a document tagging
language designed to use tag-based encoding when facilitating the creation of
structured documents. This is used in forming the format of structuring information
being exchanged between web services.
 SOAP (Simple Object Access Protocol): This is a communication platform that has no
relation to the transportation protocol. This is a specification for a framework, but
SOAP is a messaging protocol based on XML, and it is intended to be used together
with other protocols and technologies for building such a framework. The most
beautiful thing about web services and SOAP is that everything goes through HTTP,
the standard web protocol.
 WSDL (Web Services Description Language): A Web service cannot be used if it can't
be found. The implementing client has to know where the web service is located.
Also, to invoke the correct web service, the client application has to understand what
the web service does. This is done with the help of Web services description
language(WSDL). The WSDL file is another XML-based file describing what the web
service does to the client application. With this WSDL document, the client
application will know where the web service is located and how to use it.
 UDDI (Universal Description, Discovery, and Integration): UDDI is a discovery of
Web services and publishing of Web services in the discovery type of repository. One
of the possible functionality deliverables includes the ability to let a service provider
advertise their services and enable the consumers to search for services that they need.
 REST (Representational State Transfer): REST is a working model or, more
accurately, a set of standards for building web applications. While the SOAP type of
web service messages use the XML language and are based on complex protocols, the
REST type of SaaS messages utilizes the HTTP standards and interchange data with
the help of JSON.
 HTTP (Hypertext Transfer Protocol): HTTP is a protocol that is used when working
with the WWW, to exchange information between the clients’ and the servers’ sites.
The protocol is often used for Web services right now – both for services based on
SOAP and REST.
 JSON (JavaScript Object Notation): JSON is an easy-to-read data format for the
exchange of data that is particularly used in REST-based web service systems. A
specific type of markup language, it is more compact than XML and is consistently
chosen for its suitability and convenience.
How Do Web Services Work?
1. Service Description (WSDL)
 Publishing the Service: According to the need of the service provider, the provider
needs to publish the web service with WSDL (Web Services Description Language).
This information contains the name of the service – or its location, the operations that
enable it, the messages passed between such services, and the data types employed.
 WSDL Document: This document represents a legal and digital agreement between
the specific service provider and the service consumer as to the ways of accessing the
service.
2. Service Discovery (UDDI)
 Registering the Service: To use web service, the service provider first needs to list his
service in the UDDI (Universal Description, Discovery, and Integration). This is like a
registry that shows where Web services can be published and found.
 Finding the Service: UDDI is used to register and discover a web service where the
service consumer has to search for the most appropriate match. The Ws registry
contains information about the application services and their respective WSDL.
3. Service Invocation (SOAP/REST)
SOAP-based Web Services:
 Request Creation: The service consumer, to execute the service, will generate a SOAP
request message. Communicated below is the content of the message in XML and it is
compliant with the structure defined within the WSDL document.
 Sending the Request: The SOAP message is transferred over a network protocol over
the web to the service provider who has an endpoint.
 Processing the Request: The service provider then takes the SOAP request and
completes the required service on the message received from the requester.
 Response Creation: After it performs the requested operation, the service provider has
to construct a SOAP response message to return it to the consumer.
RESTful Web Services:
 HTTP Methods: Remisable services let developers leverage standard HTTP
operations such as GET, POST, PUT and DELETE. Each method represents the type
of performed operation on the data – read, write, modify, delete.
 Request Creation: The service consumer forges an HTTP request usually with a JSON
containing an expected language in the body of the request and specifying a URI for
the target resource.
 Sending the Request: This call is made in the form of an HTTP request sent to the
endpoint of the service provider.
 Processing the Request: The end-user’s HTTP request reaches the service provider
where the server processes the request and performs the necessary operation to
respond.
 Response Creation: The service provider returns an HTTP response in most cases,
which includes a JSON body that contains the requested data or the status of the
process.
4. Data Interchange (XML/JSON)
 XML: This specification is mainly applied to SOAP-based web services; however,
XML formats the request-response messages in such a way that they can be easily
readable as well as programmatically processible.
 JSON: As far as its application is concerned, JSON is mainly utilized in RESTful web
services but it is quite compact and is relatively easier to parse as compared to XML
due to these reasons the JSON format of data is quite suitable for web or mobile
applications.
5. Service Security
 SSL/TLS: Protect messages transferred between the consumer of a service and the
provider by enciphering them.
 WS-Security: Safeguards the SOAP messages by enhancing the protocol through
aspects such as authentication, encryption, and digital signatures.
 OAuth: Mostly implemented in RESTful services to address a secure paradigm to
control access to the user information so that third-party applications can access them
without involving credentials.
 JWT: JSON Web Token is a compact, URL-safe means of representing claims to be
transferred among two parties in a portable data structure payload.
Features of Web Services
1. Interoperability
 Cross-Platform Communication: The interoperation of applications within the
integrated application incurs applications that are developed for two or more
platforms and are coded in different languages. Web services help in this process.
 Standardized Protocols: They employ standard protocols which include: HTTP, XML,
SOAP, and WSDL which enhance compatibility between the realms.
2. Extensibility
 Flexible Integration: One major advantage of web services is that they are highly
interoperable and portable hence they can easily be incorporated into new applications
in an organization without much alteration to existing systems and procedures.
 Modular Design: They are supposed to be developed in a rather logical manner,
meaning that new features may be incorporated into the system without influencing
any of the services.
3. Scalability
 Distributed Computing: Web services are easily portable over different platforms and
can be implemented on different server instances so that issues with load balancing
and failovers can be easily addressed.
 Horizontal Scaling: They can be scaled horizontally towards bringing in more load by
adding another instance of the service.
4. Reusability
 Service Reusability: Web services enable medium and large companies to modularize
their business processes and use them in different applications with similar
characteristics.
 Component Reuse: Services can be built on existing services making efficient reuse of
software in the form of available services possible.
5. Loose Coupling
 Minimal Dependency: Web services are inherently asynchronous so that the Web
service consumer and the Web service provider do not require entailment of
implementations.
 Independent Deployment: This means that when a subtype is used instead of a more
general type of service implementation on the server side, it is not necessary to
change the client application as long as the interface is the same.
6. Discoverability
 UDDI Registries: To look for a particular service the services available can be
registered and searched through UDDI registries, for the available services.
 Dynamic Binding: The consumers are also able to procure the services dynamically
and offer their requests at runtime.
7. Security
 SSL/TLS: It is necessary to note that web services can employ SSL/TLS to provide
secure communication over the World Wide Web.
 WS-Security: With the current services, we can achieve WS-Security standards such
as message integrity, confidentiality and authentication with the use of SOAP-based
services.
 OAuth: OAuth can be used for secure authorization in RESTful services.
 JWT: This is utilized in trustworthy messaging concerning RESTful services and
identification.
8. Standardized Messaging
 SOAP: SOAP now has a messaging protocol that is articulated in XML which helps in
preserving the structure and manner in which messages are handled.
 REST: REST employs conventional HTTP methods and status assertion, which
contributes towards the reduction of the interaction model.
9. Support for Complex Operations
 Transaction Management: This means that web services can support multi-step and
other types of complex transactions, which will guarantee the right flow of processes.
 Asynchronous Processing: They can operate asynchronously, and this can be useful
when dealing with long-running operations since they can be worked on in the
background.
10. Versatility
 Synchronous and Asynchronous: Web services may be either the request/response
model, where a Web service sends back confirmation of the receipt of a request and
information regarding how the request can be completed or the message-oriented
model, where the two elements exchange messages independent of each other.
 Various Payload Formats: It works with different payloads, though most applications
use either XML or JSON ones depending on the peculiarities of the given program.
11. Platform Independence
 Language Agnostic: The creation and use of Web services does not require the
developer to use any specific language but should support Web standards.
 Protocol Agnostic: Web services can run on different transports although, the most
typical transport is HTTP, other transports include SMTP and JMS.
 REST API Introduction
 REpresentational State Transfer (REST) is an architectural style that defines a set of
constraints to be used for creating web services. REST API is a way of accessing web
services in a simple and flexible way without having any processing.
 REST technology is generally preferred to the more robust Simple Object Access
Protocol (SOAP) technology because REST uses less bandwidth, simple and flexible
making it more suitable for internet usage. It’s used to fetch or give some information
from a web service. All communication done via REST API uses only HTTP request.
 As you explore advanced techniques like building and integrating REST APIs ,
consider expanding your skill set further. A comprehensive Full Stack Web Development
course can enhance both your frontend and backend development skills. This course
will provide you with the knowledge to effectively implement REST APIs within your
web applications.
 Working: A request is sent from client to server in the form of a web URL as HTTP
GET or POST or PUT or DELETE request. After that, a response comes back from the
server in the form of a resource which can be anything like HTML, XML, Image, or
JSON. But now JSON is the most popular format being used in Web Services.
 Build REST API Mastery Learn to integrate popular and practical Python REST APIs
in Django web applications with Educative’s interactive skill path Become a Python-
based API Integrator. Sign up at Educative.io with the code GEEKS10 to save 10% on
your subscription.

 In HTTP there are five methods that are commonly used in a REST-based Architecture
i.e., POST, GET, PUT, PATCH, and DELETE. These correspond to create, read,
update, and delete (or CRUD) operations respectively. There are other methods which
are less frequently used like OPTIONS and HEAD.
 GET: The HTTP GET method is used to read (or retrieve) a representation of a
resource. In the safe path, GET returns a representation in XML or JSON and an HTTP
response code of 200 (OK). In an error case, it most often returns a 404 (NOT
FOUND) or 400 (BAD REQUEST).
 POST: The POST verb is most often utilized to create new resources. In particular, it’s
used to create subordinate resources. That is, subordinate to some other (e.g. parent)
resource. On successful creation, return HTTP status 201, returning a Location header
with a link to the newly-created resource with the 201 HTTP status.
 NOTE: POST is neither safe nor idempotent.
 PUT: It is used for updating the capabilities. However, PUT can also be used
to create a resource in the case where the resource ID is chosen by the client instead of
by the server. In other words, if the PUT is to a URI that contains the value of a non-
existent resource ID. On successful update, return 200 (or 204 if not returning any
content in the body) from a PUT. If using PUT for create, return HTTP status 201 on
successful creation. PUT is not safe operation but it’s idempotent.
 PATCH: It is used to modify capabilities. The PATCH request only needs to contain
the changes to the resource, not the complete resource. This resembles PUT, but the
body contains a set of instructions describing how a resource currently residing on the
server should be modified to produce a new version. This means that the PATCH body
should not just be a modified part of the resource, but in some kind of patch language
like JSON Patch or XML Patch. PATCH is neither safe nor idempotent.
 DELETE: It is used to delete a resource identified by a URI. On successful deletion,
return HTTP status 200 (OK) along with a response body.
 Idempotence: An idempotent HTTP method is a HTTP method that can be called many
times without different outcomes. It would not matter if the method is called only
once, or ten times over. The result should be the same. Again, this only applies to the
result, not the resource itself.
 Comprehensive Course
 Expert Guidance for Efficient Learning
 Hands-on Experience with Real-world Projects
 Proven Track Record with 100,000+ Successful Geeks

TCP/IP Model
 The TCP/IP model is a fundamental framework for computer networking. It stands for
Transmission Control Protocol/Internet Protocol, which are the core protocols of the
Internet. This model defines how data is transmitted over networks, ensuring reliable
communication between devices. It consists of four layers: the Link Layer, the
Internet Layer, the Transport Layer, and the Application Layer. Each layer has specific
functions that help manage different aspects of network communication, making it
essential for understanding and working with modern networks.
 TCP/IP was designed and developed by the Department of Defense (DoD) in the
1960s and is based on standard protocols. The TCP/IP model is a concise version of
the OSI model. It contains four layers, unlike the seven layers in the OSI model. In this
article, we are going to discuss the TCP/IP model in detail.
 TCP/IP model was developed alongside the creation of the ARPANET, which later
became the foundation of the modern internet. It was designed with a focus on the
practical aspects of networking at the time. The lower-level hardware details and
physical transmission medium were largely abstracted away in favor of higher-level
networking protocols.
What Does TCP/IP Do?
 The main work of TCP/IP is to transfer the data of a computer from one device to
another. The main condition of this process is to make data reliable and accurate so
that the receiver will receive the same information which is sent by the sender. To
ensure that, each message reaches its final destination accurately, the TCP/IP model
divides its data into packets and combines them at the other end, which helps in
maintaining the accuracy of the data while transferring from one end to another end.
The TCP/IP model is used in the context of the real-world internet, where a wide range
of physical media and network technologies are in use. Rather than specifying a
particular Physical Layer, the TCP/IP model allows for flexibility in adapting to
different physical implementations.
 Difference Between TCP and IP

 TCP (Transmission
 Feature Control Protocol)  IP (Internet Protocol)

 Ensures reliable,
ordered, and error-  Provides addressing
 Purpose checked delivery of and routing of packets
data between across networks.
applications.

 Type  Connection-oriented  Connectionless

 Manages data  Routes packets of data


transmission between from the source to the
 Function
devices, ensuring data destination based on
integrity and order. IP addresses.

 Yes, includes error  No, IP itself does not


checking and handle errors; relies
 Error Handling
recovery on upper-layer
mechanisms. protocols like TCP.

 Yes, includes flow


 Flow Control  No
control mechanisms.

 Congestion  Yes, manages


 No
Control network congestion.

 Breaks data into


 Breaks data into
smaller packets and
 Data Segmentation packets but does not
reassembles them at
handle reassembly.
the destination.
 TCP (Transmission
 Feature Control Protocol)  IP (Internet Protocol)

 Smaller, typically 20
 Header Size  Larger, 20-60 bytes
bytes

 Does not guarantee


 Provides reliable data
 Reliability delivery, reliability, or
transfer
order.

 Yes, acknowledges
 Transmission
receipt of data  No
Acknowledgment
packets.

 How Does the TCP/IP Model Work?


 Whenever we want to send something over the internet using the TCP/IP Model, the
TCP/IP Model divides the data into packets at the sender’s end and the same packets
have to be recombined at the receiver’s end to form the same data, and this thing
happens to maintain the accuracy of the data. TCP/IP model divides the data into a 4-
layer procedure, where the data first go into this layer in one order and again in reverse
order to get organized in the same way at the receiver’s end.
 For more, you can refer to TCP/IP in Computer Networking.
 Layers of TCP/IP Model
 Application Layer
 Transport Layer(TCP/UDP)

 Network/Internet Layer(IP)
 Network Access Layer

The diagrammatic comparison of the TCP/IP and OSI model is as follows:


1. Network Access Layer
 It is a group of applications requiring network communications. This layer is
responsible for generating the data and requesting connections. It acts on behalf of the
sender and the Network Access layer on the behalf of the receiver. During this article,
we will be talking on the behalf of the receiver.
 The packet’s network protocol type, in this case, TCP/IP, is identified by network
access layer. Error prevention and “framing” are also provided by this layer. Point-to-
Point Protocol (PPP) framing and Ethernet IEEE 802.2 framing are two examples of
data-link layer protocols.
2. Internet or Network Layer
 This layer parallels the functions of OSI’s Network layer. It defines the protocols
which are responsible for the logical transmission of data over the entire network. The
main protocols residing at this layer are as follows:
 IP: IP stands for Internet Protocol and it is responsible for delivering packets from the
source host to the destination host by looking at the IP addresses in the packet headers.
IP has 2 versions: IPv4 and IPv6. IPv4 is the one that most websites are using
currently. But IPv6 is growing as the number of IPv4 addresses is limited in number
when compared to the number of users.
 ICMP: ICMP stands for Internet Control Message Protocol. It is encapsulated within
IP datagrams and is responsible for providing hosts with information about network
problems.
 ARP: ARP stands for Address Resolution Protocol. Its job is to find the hardware
address of a host from a known IP address. ARP has several types: Reverse ARP,
Proxy ARP, Gratuitous ARP, and Inverse ARP.
 The Internet Layer is a layer in the Internet Protocol (IP) suite, which is the set of
protocols that define the Internet. The Internet Layer is responsible for routing packets
of data from one device to another across a network. It does this by assigning each
device a unique IP address, which is used to identify the device and determine the
route that packets should take to reach it.
 Example: Imagine that you are using a computer to send an email to a friend. When
you click “send,” the email is broken down into smaller packets of data, which are then
sent to the Internet Layer for routing. The Internet Layer assigns an IP address to each
packet and uses routing tables to determine the best route for the packet to take to
reach its destination. The packet is then forwarded to the next hop on its route until it
reaches its destination. When all of the packets have been delivered, your friend’s
computer can reassemble them into the original email message.
 In this example, the Internet Layer plays a crucial role in delivering the email from
your computer to your friend’s computer. It uses IP addresses and routing tables to
determine the best route for the packets to take, and it ensures that the packets are
delivered to the correct destination. Without the Internet Layer, it would not be
possible to send data across the Internet.
3. Transport Layer
 The TCP/IP transport layer protocols exchange data receipt acknowledgments and
retransmit missing packets to ensure that packets arrive in order and without error.
End-to-end communication is referred to as such. Transmission Control Protocol
(TCP) and User Datagram Protocol are transport layer protocols at this level (UDP).
 TCP: Applications can interact with one another using TCP as though they were
physically connected by a circuit. TCP transmits data in a way that resembles
character-by-character transmission rather than separate packets. A starting point that
establishes the connection, the whole transmission in byte order, and an ending point
that closes the connection make up this transmission.
 UDP: The datagram delivery service is provided by UDP, the other transport layer
protocol. Connections between receiving and sending hosts are not verified by UDP.
Applications that transport little amounts of data use UDP rather than TCP because it
eliminates the processes of establishing and validating connections.
4. Application Layer
 This layer is analogous to the transport layer of the OSI model. It is responsible for
end-to-end communication and error-free delivery of data. It shields the upper-layer
applications from the complexities of data. The three main protocols present in this
layer are:
 HTTP and HTTPS: HTTP stands for Hypertext transfer protocol. It is used by the
World Wide Web to manage communications between web browsers and servers.
HTTPS stands for HTTP-Secure. It is a combination of HTTP with SSL(Secure Socket
Layer). It is efficient in cases where the browser needs to fill out forms, sign in,
authenticate, and carry out bank transactions.
 SSH: SSH stands for Secure Shell. It is a terminal emulations software similar to
Telnet. The reason SSH is preferred is because of its ability to maintain the encrypted
connection. It sets up a secure session over a TCP/IP connection.
 NTP: NTP stands for Network Time Protocol. It is used to synchronize the clocks on
our computer to one standard time source. It is very useful in situations like bank
transactions. Assume the following situation without the presence of NTP. Suppose
you carry out a transaction, where your computer reads the time at 2:30 PM while the
server records it at 2:28 PM. The server can crash very badly if it’s out of sync.
 The host-to-host layer is a layer in the OSI (Open Systems Interconnection) model that
is responsible for providing communication between hosts (computers or other
devices) on a network. It is also known as the transport layer.
 Some common use cases for the host-to-host layer include:
 Reliable Data Transfer: The host-to-host layer ensures that data is transferred reliably
between hosts by using techniques like error correction and flow control. For example,
if a packet of data is lost during transmission, the host-to-host layer can request that
the packet be retransmitted to ensure that all data is received correctly.
 Segmentation and Reassembly: The host-to-host layer is responsible for breaking up
large blocks of data into smaller segments that can be transmitted over the network,
and then reassembling the data at the destination. This allows data to be transmitted
more efficiently and helps to avoid overloading the network.
 Multiplexing and Demultiplexing: The host-to-host layer is responsible for
multiplexing data from multiple sources onto a single network connection, and then
demultiplexing the data at the destination. This allows multiple devices to share the
same network connection and helps to improve the utilization of the network.
 End-to-End Communication: The host-to-host layer provides a connection-oriented
service that allows hosts to communicate with each other end-to-end, without the need
for intermediate devices to be involved in the communication.
 Example: Consider a network with two hosts, A and B. Host A wants to send a file to
host B. The host-to-host layer in host A will break the file into smaller segments, add
error correction and flow control information, and then transmit the segments over the
network to host B. The host-to-host layer in host B will receive the segments, check
for errors, and reassemble the file. Once the file has been transferred successfully, the
host-to-host layer in host B will acknowledge receipt of the file to host A.
 In this example, the host-to-host layer is responsible for providing a reliable
connection between host A and host B, breaking the file into smaller segments, and
reassembling the segments at the destination. It is also responsible for multiplexing
and demultiplexing the data and providing end-to-end communication between the two
hosts.
 Why TCP/IP Model Does Not Have Physical Layer
 The physical layer is not covered by the TCP/IP model because the data link layer is
considered the point at which the interface occurs between the TCP/IP stock and the
underlying network hardware. Also, it is designed to be independent of the underlying
physical media. This allows TCP/IP to be flexible and adaptable to different types of
physical connections, such as Ethernet, Wi-Fi, fiber optics, or even older technologies
like dial-up modems. The physical layer is typically handled by hardware components
and standards specific to the physical medium being used, like Ethernet cables or radio
waves for Wi-Fi.
 Other Common Internet Protocols
 TCP/IP Model covers many Internet Protocols. The main rule of these Internet
Protocols is how the data is validated and sent over the Internet. Some Common
Internet Protocols include:
 HTTP (Hypertext Transfer Protocol): HTTP takes care of Web Browsers and
Websites.
 FTP (File Transfer Protocol): FTP takes care of how the file is to be sent over the
Internet.
 SMTP (Simple Mail Transfer Protocol): SMTP is used to send and receive data.
 Difference between TCP/IP and OSI Model
 TCP/IP  OSI

 TCP refers to Transmission Control  OSI refers to Open Systems


Protocol. Interconnection.

 TCP/IP uses both the session and


 OSI uses different session and
presentation layer in the application
presentation layers.
layer itself.

 TCP/IP follows connectionless a


 OSI follows a vertical approach.
horizontal approach.

 The Transport layer in TCP/IP does  In the OSI model, the transport
not provide assurance delivery of layer provides assurance delivery
packets. of packets.

 While in the OSI model, Protocols


 Protocols cannot be replaced easily in are better covered and are easy to
TCP/IP model. replace with the technology
change.

 TCP/IP model network layer only


 Connectionless and connection-
provides connectionless (IP) services.
oriented services are provided by
The transport layer (TCP) provides
the network layer in the OSI model.
connections.

Advantages of TCP/IP Model


 Interoperability: The TCP/IP model allows different types of computers and networks
to communicate with each other, promoting compatibility and cooperation among
diverse systems.
 Scalability: TCP/IP is highly scalable, making it suitable for both small and large
networks, from local area networks (LANs) to wide area networks (WANs) like the
internet.
 Standardization: It is based on open standards and protocols, ensuring that different
devices and software can work together without compatibility issues.
 Flexibility: The model supports various routing protocols, data types, and
communication methods, making it adaptable to different networking needs.
 Reliability: TCP/IP includes error-checking and retransmission features that ensure
reliable data transfer, even over long distances and through various network
conditions.
 Disadvantages of TCP/IP Model
 Complex Configuration: Setting up and managing a TCP/IP network can be complex,
especially for large networks with many devices. This complexity can lead to
configuration errors.
 Security Concerns: TCP/IP was not originally designed with security in mind. While
there are now many security protocols available (such as SSL/TLS), they have been
added on top of the basic TCP/IP model, which can lead to vulnerabilities.
 Inefficiency for Small Networks: For very small networks, the overhead and
complexity of the TCP/IP model may be unnecessary and inefficient compared to
simpler networking protocols.
 Limited by Address Space: Although IPv6 addresses this issue, the older IPv4 system
has a limited address space, which can lead to issues with address exhaustion in larger
networks.
 Data Overhead: TCP, the transport protocol, includes a significant amount of overhead
to ensure reliable transmission. This can reduce efficiency, especially for small data
packets or in networks where speed is crucial.
User Datagram Protocol (UDP)
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.
What is User Datagram Protocol?
User Datagram Protocol (UDP) is one of the core protocols of the Internet Protocol
(IP) suite. It is a communication protocol used across the internet for time-sensitive
transmissions such as video playback or DNS lookups . Unlike Transmission Control
Protocol (TCP), UDP is connectionless and does not guarantee delivery, order, or
error checking, making it a lightweight and efficient option for certain types of data
transmission.
UDP is a connectionless protocol that offers minimal error recovery services. For
more insights into network protocols like UDP, consider the GATE CS Self-Paced
Course .
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.

UDP Header
 Source Port: Source Port is a 2 Byte long field used to identify the port number of the
source.
 Destination Port: It is a 2 Byte long field, used to identify the port of the destined
packet.
 Length: Length is the length of UDP including the header and the data. It is a 16-bits
field.
 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.
Notes – Unlike TCP, the Checksum calculation is not mandatory in UDP. No Error
control or flow control is provided by UDP. Hence UDP depends on IP and ICMP for
error reporting. Also UDP provides port numbers so that is can differentiate between
users requests.
Applications of UDP
 Used for simple request-response communication when the size of data is less and
hence there is lesser concern about flow and error control.
 It is a suitable protocol for multicasting as UDP supports packet switching.
 UDP is used for some routing update protocols like RIP(Routing Information Protocol).
 Normally used for real-time applications which can not tolerate uneven delays
between sections of a received message.
 VoIP (Voice over Internet Protocol) services, such as Skype and WhatsApp, use UDP for
real-time voice communication. The delay in voice communication can be noticeable
if packets are delayed due to congestion control, so UDP is used to ensure fast and
efficient data transmission.
 DNS (Domain Name System) also uses UDP for its query/response messages. DNS
queries are typically small and require a quick response time, making UDP a suitable
protocol for this application.
 DHCP (Dynamic Host Configuration Protocol) uses UDP to dynamically assign IP
addresses to devices on a network. DHCP messages are typically small, and the delay
caused by packet loss or retransmission is generally not critical for this application.
 Following implementations uses UDP as a transport layer protocol:
o NTP (Network Time Protocol)
o DNS (Domain Name Service)
o BOOTP, DHCP.
o NNP (Network News Protocol)
o Quote of the day protocol
o TFTP, RTSP, RIP.
 The application layer can do some of the tasks through UDP-
o Trace Route
o Record Route
o Timestamp
 UDP takes a datagram from Network Layer , attaches its header, and sends it to the
user. So, it works fast.
TCP vs UDP

Transmission Control Protocol User Datagram


Basis (TCP) Protocol (UDP)

Type of TCP is a connection-oriented UDP is the


Service protocol. Datagram-
Connection orientation means oriented protocol.
that the communicating This is
devices should establish a because there is
connection before transmitting no overhead for
data and should close the opening a
connection after transmitting connection,
the data. maintaining a
Transmission Control Protocol User Datagram
Basis (TCP) Protocol (UDP)

connection, or
terminating a
connection. UDP
is efficient for
broadcast and
multicast types of
network
transmission.

The delivery of
data to the
TCP is reliable as it guarantees
destination
the delivery of data to the
cannot be
destination router.
guaranteed in
Reliability UDP.

TCP provides extensive error- UDP has only the


checking mechanisms. It is basic error-
Error because it provides flow checking
checking control and acknowledgment mechanism using
mechanism of data. checksums.

No
An acknowledgment segment
Acknowledg acknowledgment
is present.
me nt segment.

There is no
sequencing of
Sequencing of data is a feature
data in UDP. If
of Transmission
the order is
Control Protocol (TCP). this
required, it has to
means that packets arrive in
be managed by
order at the receiver.
the application
Sequence layer.

Speed TCP is comparatively slower UDP is faster,


than UDP. simpler, and more
Transmission Control Protocol User Datagram
Basis (TCP) Protocol (UDP)

efficient than
TCP.

There is no
Retransmission of lost packets retransmission of
is possible in TCP, but not in lost packets in the
Retransmissio UDP. User Datagram
n Protocol (UDP).

UDP has an 8
TCP has a (20-60) bytes
Header bytes fixed-
variable length header.
Length length header.

UDP is
TCP is heavy-weight.
Weight lightweight.

It’s a
Uses handshakes such as SYN, connectionless
Handshaking ACK, SYN-ACK protocol i.e. No
Techniques handshake

TCP doesn’t support UDP supports


Broadcasting Broadcasting. Broadcasting.

UDP is used
TCP is used by HTTP,
by DNS, DHCP,
HTTPs , FTP , SMTP and Teln
TFTP, SNMP , RI
et .
Protocols P, and VoIP.

UDP connection
The TCP connection is a byte
is a message
stream.
Stream Type stream.

Overhead Low but higher than UDP. Very low.


Transmission Control Protocol User Datagram
Basis (TCP) Protocol (UDP)

This protocol is
used in situations
where quick
This protocol is primarily
communication is
utilized in situations when a
necessary but
safe and trustworthy
where
communication procedure is
dependability is
necessary, such as in email, on
not a concern,
the web surfing, and in military
such as VoIP,
services.
game streaming,
video, and music
Applications streaming, etc.

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.
 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.
 Vulnerable to attacks: UDP is vulnerable to denial-of-service attacks , where an
attacker can flood a network with UDP packets, overwhelming the network and
causing it to crash.
 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.
How is UDP used in DDoS attacks?
A UDP flood attack is a type of Distributed Denial of Service (DDoS) attack where an
attacker sends a large number of User Datagram Protocol (UDP) packets to a target
port.
 UDP Protocol : Unlike TCP, UDP is connectionless and doesn’t require a handshake
before data transfer. When a UDP packet arrives at a server, it checks the specified
port for listening applications. If no app is found, the server sends
an ICMP “destination unreachable” packet to the supposed sender (usually a random
bystander due to spoofed IP addresses).
 Attack Process :
o The attacker sends UDP packets with spoofed IP sender addresses to random
ports on the target system.
o The server checks each incoming packet’s port for a listening application
(usually not found due to random port selection).
o The server sends ICMP “destination unreachable” packets to the spoofed
sender (random bystanders).
o The attacker floods the victim with UDP data packets, overwhelming its
resources.
 Mitigation : To protect against UDP flood attacks, monitoring network traffic for
sudden spikes and implementing security measures are crucial. Organizations often
use specialized tools and services to detect and mitigate such attacks effectively.
UDP Pseudo Header
 The purpose of using a pseudo-header is to verify that the UDP packet has reached its
correct destination
 The correct destination consist of a specific machine and a specific protocol port
number within that machine
UDP pseudo header
UDP Pseudo Header Details
 The UDP header itself specify only protocol port number.thus , to verify the
destination UDP on the sending machine computes a checksum that covers the
destination IP address as well as the UDP packet.
 At the ultimate destination, UDP software verifies the checksum using the destination
IP address obtained from the header of the IP packet that carried the UDP message.
 If the checksum agrees, then it must be true that the packet has reached the intended
destination host as well as the correct protocol port within that host.
User Interface
A user interface should allow the creation of new receive ports, receive operations on
the receive ports that returns the data octets and an indication of source port and
source address, and an operation that allows a datagram to be sent, specifying the
data, source and destination ports and address to be sent.
IP Interface
 The UDP module must be able to determine the source and destination internet
address and the protocol field from internet header
 One possible UDP/IP interface would return the whole internet datagram including
the entire internet header in response to a receive operation
 Such an interface would also allow the UDP to pass a full internet datagram complete
with header to the IP to send. the IP would verify certain fields for consistency and
compute the internet header checksum.
 The IP interface allows the UDP module to interact with the network layer of the
protocol stack, which is responsible for routing and delivering data across the
network.
 The IP interface provides a mechanism for the UDP module to communicate with
other hosts on the network by providing access to the underlying IP protocol.
 The IP interface can be used by the UDP module to send and receive data packets
over the network, with the help of IP routing and addressing mechanisms.
Conclusion
The User Datagram Protocol (UDP) is an important Transport Layer protocol in the
Internet Protocol (IP) suite, identified for its speed and efficiency due to its
connectionless and lightweight design. While UDP lacks TCP’s stability and error-
checking features, it used in applications that need low latency and real-time
performance, such as streaming, online gaming, and DNS lookups. Its simplicity and
support for broadcast and multicast broadcasts make it a useful tool for specialized
applications, despite its vulnerability to data loss and network congestion.
Introduction of Message Queue Telemetry Transport Protocol (MQTT)

Message Queuing Telemetry Transport, or MQTT, is a communications protocol


designed for Internet of Things devices with extremely high latency and restricted low
bandwidth. Message Queuing Telemetry Transport is a perfect protocol for machine-
to-machine (M2M) communication since it is designed specifically for low-
bandwidth, high-latency settings.
What is Message Queue Telemetry Transport Protocol(MQTT)?
MQTT is a simple, lightweight messaging protocol used to establish communication
between multiple devices. It is a TCP-based protocol relying on the publish-subscribe
model. This communication protocol is suitable for transmitting data between
resource-constrained devices having low bandwidth and low power requirements.
Hence this messaging protocol is widely used for communication in
the IoT Framework.
Publish-Subscribe Model
This model involves multiple clients interacting with each other, without having any
direct connection established between them. All clients communicate with other
clients only via a third party known as a Broker.
MQTT Client and Broker
Clients publish messages on different topics to brokers. The broker is the central
server that receives these messages and filters them based on their topics. It then
sends these messages to respective clients that have subscribed to those different
topics. The heart of any publish/subscribe protocol is the MQTT broker. A broker can
handle up to thousands of concurrently connected MQTT customers, depending on
how it is implemented. All communications must be received by the broker, who will
then sort them, ascertain who subscribed to each one, and deliver the messages to the
clients who have subscribed. All persistent customers’ sessions, including missed
messages and subscriptions, are likewise kept by the Broker.
Publish-Subscribe Model
Hence client that has subscribed to a specific topic receives all messages published on
that topic.
Here the broker is central hub that receives messages, filters them, and distributes
them to appropriate clients, such that both message publishers, as well as subscribers,
are clients.
Working of MQTT
MQTT’s publish/subscribe (pub/sub) communication style, which aims to maximise
available bandwidth, is an alternative to conventional client-server architecture that
communicates directly with an endpoint. In contrast, the client who transmits the
message (the publisher) and the client or clients who receive it (the subscribers) are
not connected in the pub/sub paradigm. Third parties—the brokers—manage the
relationships between the publishers and subscribers because they don’t communicate
with one another directly.
Publishers and subscribers, which denote whether a client is publishing messages or
has subscribed to receive messages, are examples of MQTT clients. The same MQTT
client can be used to accomplish these two features. A publish occurs when a client or
device want to submit data to a server or broker.
The term “subscribe” refers to the reversal of the procedure. Several clients can
connect to a broker under the pub/sub paradigm and subscribe to subjects that interest
them.

MQTT
When a broker and a subscribing client lose contact, the broker will store messages in
a buffer and send them to the subscriber whenever the broker is back up and running.
The broker has the right to cut off communication with subscribers and send them a
cached message containing publisher instructions if the publishing client abruptly
disconnects from the broker.
“Publishers send the messages, subscribers receive the messages they are interested
in, and brokers pass the messages from the publishers to the subscribers,” reads an
IBM write-up describing the pub/sub paradigm. MQTT clients, such as publishers and
subscribers, can only speak with MQTT brokers. Any device or programme that runs
a MQTT library can be a MQTT client, ranging from microcontrollers like the
Arduino to entire application servers housed in the cloud.
Characteristics of MQTT
 Lightweight: MQTT is designed to be lightweight, making it suitable for use in aid-
restrained environments inclusive of embedded systems and low-strength devices.
The protocol minimizes bandwidth and processing overhead, enabling green
communication even on restricted networks.
 Publish-Subscribe Model: In the publish-subscribe version, clients (publishers) send
messages to subjects, and different clients (subscribers) acquire messages from
subjects of interest. This decoupling of producers and purchasers permits for flexible
and dynamic conversation styles.
 Quality of Service (QoS) Levels: MQTT supports exclusive stages of message
delivery warranty, referred to as Quality of Service (QoS). QoS levels range from 0 to 2,
providing various stages of reliability and message transport guarantees, relying at the
utility necessities.
 Retained Messages: MQTT lets in agents to store retained messages on topics, making
sure that new subscribers acquire the maximum latest message posted on a subject
right now after subscribing. This characteristic is beneficial for fame updates and
configuration settings.
 Last Will and Testament (LWT): MQTT clients can specify a Last Will and Testament
message to be posted by way of the broker in the occasion of an sudden consumer
disconnect. This function affords a mechanism for detecting patron failures and
dealing with them gracefully.
 Security: MQTT helps various protection mechanisms, consisting of Transport Layer
Security (TLS) encryption and authentication mechanisms which include
username/password and consumer certificates. These capabilities make certain the
confidentiality, integrity, and authenticity of messages exchanged over MQTT
connections.
Advantages of MQTT
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.
 Lightweight protocol that is quick to create and allows for efficient data transport
 Minimal data packet usage, resulting in low network usage
 Effective data dispersion
 The effective use of remote sensing and control
 Prompt and effective message delivery
 Minimises power consumption, which is beneficial for the linked devices, and
maximises network capacity.
 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.
Disadvantages of MQTT
 When compared to Constrained Application Protocol (CoAP), MQTT has slower send
cycles.
 Resource discovery in MQTT is based on flexible topic subscription, while resource
discovery in CoAP is based on a reliable system.
 MQTT lacks encryption. Rather, security encryption is accomplished by TLS/SSL
(Transport Layer Security/Secure Sockets Layer).
 Building an internationally scalable MQTT network is challenging.

WebSocket
WebSocket is bidirectional, a full-duplex protocol that is used in the same
scenario of client-server communication, unlike HTTP which starts
from ws:// or wss://. It is a stateful protocol, which means the connection between
client and server will stay alive until it gets terminated by either party (client or
server).
After closing the connection by either of the client or 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 makes the handshaking and decides 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 decides to keep a new
connection alive, this new connection will be known as WebSocket. Once the
communication link is established and the connections are opened, message exchange
will take place in bidirectional mode until the connection persists between client-
server.
If anyone of them (client-server) dies or decide to close the connection then it
is closed by both the party. The way in which the 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 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.

 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 aWebSocketchannel.

 Gaming application: In a Gaming application, you might focus on that, data is


continuously received by the server, and without refreshing the UI, it will take effect
on the screen, UI gets automatically refreshed without even establishing the new
connection, so it is very helpful in a Gaming application.

 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 but 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.
The IoT system can only perform and transfer information when it’s in online
mode, which means the devices in IoT must be safely connected to communication
networks. The question that arises is how these devices can connect and communicate
with each other. The answer lies in PROTOCOLS. Protocols enable these devices to
communicate effectively, and new protocols continue to be introduced regularly. In
this article, we will discuss the IoT network requirements, and the different types of
protocols used in IoT, and provide a brief description of commonly used protocols in
the Internet of Things.

Why do we need IoT Protocols?


IoT protocols are essential for enabling seamless and efficient communication
between Internet of Things (IoT) devices, applications, and services. They serve as the
rules and standards that govern how devices in an IoT ecosystem exchange data and
interact with each other. The need for IoT protocols arises due to several reasons:
Interoperability: In IoT, devices come from various manufacturers, and they may use
different communication technologies and data formats. IoT protocols ensure that
devices from different vendors can communicate and work together seamlessly,
fostering interoperability and creating a unified IoT ecosystem.
Efficient Communication: IoT protocols are designed to optimize data transmission
and reduce unnecessary overhead, leading to efficient use of resources like power and
bandwidth. This efficiency is crucial, especially for IoT devices with limited
processing capabilities and battery life.
Security: IoT devices often handle sensitive data and are vulnerable to cybersecurity
threats. IoT protocols incorporate security mechanisms like encryption,
authentication, and data integrity checks to ensure secure communication and protect
against unauthorized access.
Scalability: IoT deployments can involve a large number of devices spread across
wide areas. IoT protocols are designed to handle scalability, allowing the network to
accommodate a growing number of devices without compromising performance.
Low Power Consumption: Many IoT devices are battery-powered or operate in
energy-constrained environments. IoT protocols, especially those designed for low-
power communication, help extend the battery life of devices and minimize energy
consumption.
Real-time Communication: Some IoT applications, such as industrial automation and
healthcare monitoring, require real-time data exchange. IoT protocols cater to such
scenarios and ensure timely delivery of critical information.
Standardization: IoT protocols are standardized to ensure consistency and
compatibility across different implementations. This standardization facilitates the
development of a diverse range of IoT devices and applications while ensuring they
can work together smoothly.
Data Management: IoT protocols define how data is structured, transmitted, and
processed, facilitating efficient data management and analysis. Proper data handling is
essential for making informed decisions and deriving meaningful insights from IoT-
generated data.
In conclusion, IoT protocols are the backbone of the IoT ecosystem, providing the
rules and guidelines necessary for devices to communicate effectively, securely, and
reliably. They play a critical role in creating a cohesive and interoperable IoT
environment, enabling the realization of the full potential of IoT technologies across
various industries and applications.

IoT Networks Requirments


Some mandatory requirements to build an IoT network are listed below:
 Scalable i.e. can connect a large number of devices
 Highly reliable
 Support data transmission in real time with minimized delays
 Protect data flows
 Capable of configuring applications
 Traffic management and monitoring at device level
 It should be cost-effective so that large number of devices can be connected.
IoT Protocol Types
Although, there exist a large number of IoT protocols are used in IoT. but here we will
be discussing some widely used protocols in the Internet of Things which are listed
below:
 MQTT (message queue telemetry transport)
 DDS (data distribution service)
 AMQP (advance message queuing protocol)
 Bluetooth
 Zigbee
 Wi-Fi
 Cellular
 LoRaWAN
So let’s discuss these protocols in detail.
MQTT Protocol
MQTT is a lightweight protocol specifically designed for sending data from sensors to
middleware and applications. It operates on top of TCP/IP, ensuring reliable data
delivery. MQTT consists of three main components: Subscriber, Publisher, and
Broker. Let’s explore how these components work together in the basic workflow of
this protocol, where the publisher generates and transmits information to subscribers
through a broker.
Understanding MQTT
MQTT, short for Message Queue Telemetry Transport, is an IoT protocol that excels
in lightweight data transfer. Its primary purpose is to enable efficient communication
by transmitting data from sensors to middleware and applications.

Reliable Data Delivery


MQTT leverages TCP/IP as its underlying technology, ensuring dependable and
secure data delivery. This reliability is essential for real-time and critical IoT
applications.
The Three Main Components
MQTT comprises three key components: Subscriber, Publisher, and Broker, each with
specific roles.
Subscribers receive data from the publisher through the broker, facilitating seamless
data flow.
The Basic Workflow
In MQTT’s basic workflow, the publisher is responsible for generating and
transmitting information.
The broker acts as an intermediary, managing the data and delivering it to the relevant
subscribers.
LWM2M
Lightweight M2M (LWM2M) is a protocol designed specifically for managing
and communicating with IoT devices in a resource-constrained environment. It is a
part of the Open Mobile Alliance (OMA) Lightweight M2M protocol suite. LWM2M
aims to provide a standardized and efficient way to manage devices and their data in
IoT deployments.
LWM2M employs a client-server architecture, where IoT devices act as clients
and communicate with a management server. The protocol operates over various
underlying transport protocols, such as CoAP (Constrained Application Protocol) and
UDP, which contributes to its lightweight and low-power characteristics. With its
small overhead and optimized message format, LWM2M is suitable for devices with
limited processing power, memory, and battery life.
One of the key advantages of LWM2M is its extensive range of device
management capabilities. It allows for remote device provisioning, firmware updates,
monitoring of device status, and reporting of various device parameters. LWM2M
also defines a well-organized object and resource model, providing a standardized
way to represent device information and functionality. This model simplifies device
management and enables interoperability between different IoT platforms and
vendors.
Overall, Lightweight M2M is a crucial protocol for the efficient and scalable
management of IoT devices in constrained environments. Its lightweight nature,
standardized data representation, and robust device management capabilities make it
an ideal choice for a wide range of IoT applications, including smart cities, industrial
IoT, and healthcare.

DDS (Data Distribution Service)


DDS, which stands for Data Distribution Service, is a powerful protocol
widely used in IoT for its scalability, real-time capabilities, and high-performance
machine-to-machine communication. This versatile protocol can be implemented in
both IoT devices and cloud environments. DDS operates with two primary layers that
contribute to its efficient functioning:
DCPS (Data-Centric Publish Subscriber)
The DCPS layer is responsible for delivering information to the subscribers in the
DDS ecosystem.
It ensures seamless data distribution, enabling real-time communication among
devices and applications.
DLRL (Data Local Reconstruction Layer)
The DLRL layer serves as an interface to support the functions of DCPS.
It plays a vital role in data reconstruction, enabling devices and applications to
interact effectively within the DDS environment.
AMQP
AMQP stands for Advanced Message Queuing Protocol. It is a messaging protocol
used in the application layer of the OSI model, which is a standard way of organizing
how different parts of the internet work together. AMQP’s processing involves three
main components, each following specific rules.
Exchange: This component receives messages and places them into queues. It acts as
a mediator that ensures messages are delivered to the right destination.
Message Queue: The message queue stores the messages until they are safely
processed by client applications. It acts as a buffer, holding messages until they can be
handled by the intended recipients.
Binding: The binding defines the relationship between the exchange and the message
queue, essentially connecting the two components. It ensures that messages from the
exchange are correctly routed to the appropriate message queue for processing.
In summary, AMQP is a sophisticated messaging protocol used to enable efficient and
reliable communication between different parts of a system or network. It relies on
three main components: the exchange for receiving and directing messages, the
message queue for temporary storage, and the binding to establish the link between
the exchange and the message queue. These components work together to ensure
smooth message delivery and processing in various applications and systems.
BLE (Bluetooth Low Energy)
Bluetooth and Bluetooth Low Energy (BLE) are both wireless communication
protocols used in the Internet of Things (IoT) to enable data exchange between
devices over short distances. While they share some similarities, they have distinct
characteristics and applications.
BLE, also known as Bluetooth Smart, is a variation of Bluetooth designed
specifically for low-power and energy-efficient IoT applications. BLE operates in the
same 2.4 GHz frequency band as Bluetooth but uses a different modulation scheme,
resulting in reduced power consumption. This makes BLE well-suited for IoT devices
that run on limited battery power and need to operate for extended periods.
BLE is commonly used in a wide range of IoT devices, including wearable
devices, smart sensors, and other IoT-enabled gadgets. It enables intermittent data
transmission, allowing devices to remain in a low-power sleep mode for most of the
time and only wake up to transmit or receive data when needed. This characteristic
greatly extends the battery life of BLE-enabled devices.
In summary, both Bluetooth and BLE are essential IoT protocols for short-
range wireless communication. Bluetooth is suitable for applications that require
higher data transfer rates and real-time communication, while BLE is ideal for low-
power IoT devices that need to conserve energy and operate for extended periods on
limited battery power. The choice between Bluetooth and BLE depends on the
specific requirements and power constraints of the IoT application at hand.
Zigbee Protocol
Zigbee 3.0 is another important protocol we will explore. It was created by the
Zigbee Alliance, and it introduced a universal language called Dotdot for IoT devices.
This language enables smart devices to communicate seamlessly and securely across
various networks by understanding each other’s commands and data.
Zigbee 3.0 offers several key features:
Low Power: It is designed to be energy-efficient, making it suitable for IoT devices
that need to conserve battery life and operate for extended periods.
Low Data Rates: Zigbee 3.0 falls into the category of wireless protocols that offer low
data transfer rates. It is ideal for applications where high bandwidth is not a
requirement.
Industrial Use: Zigbee 3.0 is commonly used in industrial settings, where reliable and
low-power communication between devices is essential for efficient operations.
Based on IEEE 802.15.4 Standard: Zigbee 3.0 follows the IEEE 802.15.4 standard,
which defines the physical and media access control layers for low-rate wireless
personal area networks (LR-WPANs).
Frequency and Range: Zigbee 3.0 operates at a frequency of about 2.4 GHz, allowing
for efficient and widespread communication. Its range typically varies from 10 to 100
meters, depending on the environment and interference.
Data Rate: The data rate of Zigbee 3.0 is around 250 kbps, enabling sufficient data
exchange for various IoT applications without overwhelming the devices with data
traffic.
In summary, Zigbee 3.0 is a reliable and energy-efficient IoT protocol widely used in
industrial settings. Its low-power characteristics, low data rates, and adherence to the
IEEE 802.15.4 standard make it a suitable choice for a range of IoT devices and
applications where efficient and secure communication is crucial.
LoraWAN
LoRaWAN, which stands for Long Range Wide Area Network, is a wireless
communication protocol specifically designed for long-range, low-power IoT
applications. It is a part of the LoRa (Long Range) technology ecosystem and is
optimized to provide connectivity for IoT devices spread over large geographic areas.
Key features of LoRaWAN as an IoT protocol:
Long Range: LoRaWAN is known for its exceptional long-range capabilities,
allowing IoT devices to communicate over several kilometers in open areas. This
extended range makes it ideal for applications that require connectivity across vast
distances, such as smart agriculture, asset tracking, and smart city deployments.
Low Power: One of the significant advantages of LoRaWAN is its low power
consumption. IoT devices using LoRaWAN can operate on batteries for years without
needing frequent replacements, making it suitable for remote and hard-to-reach
locations where power sources may be limited.
Wide Area Coverage: LoRaWAN’s wide area coverage enables the creation of large-
scale IoT networks with minimal infrastructure. Fewer gateways can cover vast
regions, reducing the cost of network deployment and maintenance.
Scalability: LoRaWAN is highly scalable, allowing the network to accommodate a
massive number of IoT devices. It can support millions of connected devices while
maintaining efficient data transfer and minimal interference.
Secure Communication: LoRaWAN incorporates advanced encryption and
authentication mechanisms to ensure secure communication between IoT devices and
the network server, safeguarding data privacy and integrity.
Suitable for Low Data Rate Applications: LoRaWAN is most effective in applications
that do not require high data transfer rates. It is ideal for transmitting small amounts of
data at regular intervals, making it perfect for sensors, meters, and other low-
bandwidth IoT devices.
In summary, LoRaWAN is a robust and cost-effective IoT protocol tailored for long-
range, low-power, and scalable communication. Its ability to cover extensive areas
and support a vast number of devices with minimal power consumption makes it an
excellent choice for diverse IoT applications where long-distance connectivity and
efficiency are critical.
Z-wave
Z-Wave is a popular wireless communication protocol designed specifically for home
automation and Internet of Things (IoT) applications. It is a proprietary protocol
developed by Z-Wave Alliance, a consortium of companies working to standardize
and promote the adoption of Z-Wave technology in smart homes.
Key features of Z-Wave as an IoT protocol:
Mesh Networking: Z-Wave operates on a mesh networking topology, where each Z-
Wave device (node) acts as a repeater, extending the range and enhancing the
reliability of the network. This mesh architecture allows devices to communicate with
each other directly or through neighboring nodes, ensuring robust and efficient
communication even in larger homes.
Low Power Consumption: Z-Wave is engineered to be power-efficient, making it
well-suited for battery-powered devices like smart sensors and door locks. Devices
can operate for extended periods on a single battery charge or with minimal power
usage.
Interoperability: Z-Wave devices from different manufacturers can seamlessly
communicate with each other due to strict certification standards maintained by Z-
Wave Alliance. This ensures interoperability and compatibility, allowing users to
create a diverse and integrated smart home ecosystem.
Wide Range of Devices: Z-Wave supports a wide range of smart home devices,
including lighting controls, thermostats, security sensors, door locks, and more. The
extensive selection of Z-Wave devices available in the market enables users to create
comprehensive and customizable smart home solutions.
Secure Communication: Z-Wave utilizes AES-128 encryption to ensure secure
communication between devices. This encryption helps protect sensitive information
and prevents unauthorized access to the network.
Easy Installation: Z-Wave devices are designed for easy installation and setup. Many
Z-Wave devices can be added to the network simply by pressing a button or scanning
a QR code, making the smart home setup process user-friendly and straightforward.
In summary, Z-Wave is a reliable, low-power, and interoperable IoT protocol tailored
for home automation and smart home applications. Its mesh networking architecture,
wide range of devices, and secure communication ensure seamless integration and
enhanced convenience in creating smart and connected homes. As a result, Z-Wave
has gained significant popularity in the smart home industry and continues to be a
prominent IoT protocol for home automation.
Thread
Thread is an open, secure, and low-power wireless communication protocol
specifically designed for Internet of Things (IoT) applications. It is a reliable mesh
networking protocol developed by the Thread Group, an organization consisting of
industry leaders collaborating to promote the adoption and interoperability of Thread
technology.
Key features of Thread as an IoT protocol:
Mesh Networking: Thread operates on a mesh networking architecture, where each
device in the network (node) acts as a router, relaying messages to other devices. This
mesh topology ensures robust and efficient communication, even in large-scale IoT
deployments.
Low Power Consumption: Thread is optimized for low power consumption, making it
suitable for battery-operated IoT devices. Devices can remain in sleep mode for
extended periods, conserving energy and prolonging battery life.
IPv6 Support: Thread natively supports IPv6, enabling direct and seamless integration
with the internet. This feature allows Thread devices to communicate with other IPv6-
enabled devices and cloud services, expanding the IoT ecosystem’s reach.
Secure Communication: Thread incorporates advanced security mechanisms,
including AES encryption and device authentication, to ensure secure communication
and protect data privacy in the network.
Interoperability: Thread promotes interoperability between different manufacturers’
devices, adhering to a standardized certification process. This allows users to build
multi-vendor IoT systems with confidence in seamless communication.
Easy Setup: Thread is designed to be user-friendly, offering easy setup and
configuration. Devices can be added to the network through simple user interactions,
such as scanning a QR code or pressing a button, streamlining the IoT device
integration process.
Reliable and Scalable: Thread’s mesh networking ensures a reliable connection, even
if some nodes experience temporary connectivity issues. Additionally, the protocol is
scalable, supporting large IoT networks with thousands of devices.
In summary, Thread is a robust and secure IoT protocol that excels in low-power
mesh networking, enabling efficient and reliable communication among IoT devices.
Its support for IPv6 and interoperability standards ensures seamless integration with
other IoT ecosystems and the internet. With its focus on power efficiency, security,
and scalability, Thread is an increasingly popular choice for various IoT applications,
including smart homes, industrial automation, and smart cities.
Matter
Matter, formerly known as Project CHIP (Connected Home over IP), is a new and
promising IoT protocol designed to enhance smart home interoperability and
connectivity. It is developed collaboratively by major technology companies,
including Apple, Google, Amazon, and the Connectivity Standards Alliance (CSA,
formerly known as the Zigbee Alliance). Matter aims to create a unified, secure, and
reliable standard for smart home devices to communicate seamlessly with each other
and integrate into various ecosystems.
Key features of Matter as an IoT protocol:
Interoperability: Matter focuses on promoting interoperability among different smart
home devices, regardless of the manufacturer. This means that Matter-compliant
devices will work together smoothly, eliminating the need for separate ecosystems or
proprietary bridges.
IP-Based Protocol: Matter is built on IP (Internet Protocol), specifically using IPv6,
which enables direct communication between devices and the internet. This allows for
easy integration with cloud services and enhances remote access and control of smart
home devices.
Secure Communication: Security is a core aspect of Matter’s design. It implements
the latest encryption standards and secure communication practices, protecting users’
data and privacy. This is crucial for smart home devices that handle sensitive
information and perform essential functions like door locks and security cameras.
Wide Range of Devices: Matter is intended to support a broad spectrum of smart
home devices, including lights, thermostats, door locks, smart speakers, and more.
This inclusivity ensures that a diverse set of devices can seamlessly interact and work
together within the smart home ecosystem.
Easy Setup and Control: Matter aims to provide a user-friendly setup process,
allowing consumers to effortlessly add new devices to their smart homes.
Additionally, it focuses on creating a cohesive and intuitive user experience across
various device types and brands.
Open Source and Collaborative: Matter is open-source, allowing developers to
contribute to its development and implementation. The collaborative nature of
Matter’s development ensures that it reflects the needs and feedback of a wide range
of stakeholders in the IoT industry.
In summary, Matter is a promising IoT protocol that strives to create a standardized
and interoperable smart home ecosystem. By focusing on IP-based communication,
security, and ease of use, Matter aims to simplify the integration and control of smart
home devices, making the smart home experience more accessible and enjoyable for
consumers. As the adoption of Matter grows and more devices become compatible, it
has the potential to revolutionize the smart home industry and set new standards for
IoT connectivity and interoperability.
Wi-Fi
In LAN environments, the most used type of connectivity is Wi-Fi. It is the
technology that is used in radio wireless networking of devices. Below are some
features of this protocol
 Fast data transfer is offered by this protocol
 It can be used to process large amount of data
 It is based on IEEE 802.11 standard
 Frequencies are of about 2.4 GHz and 5 GHz bands
 Range is approximately 50 m.
 Data rate are about 150 – 200 Mbps and can offer up to maximum of 600 Mbps.
Cellular
Cellular technology forms the foundation of every mobile phone network. It is also
utilized in Internet of Things (IoT) applications that require communication over long
distances. These applications benefit from cellular communication technologies like
2G, 3G, 4G, and the upcoming 5G, which promise even faster and more reliable
connectivity.
Here are some important features of cellular technology:
Capable of Transferring Large Amount of Data: Cellular technology can handle
significant amounts of data, making it suitable for applications that require the
exchange of large files or real-time streaming.
High Power Consumption: However, using cellular technology can consume more
power compared to other IoT protocols. As a result, it may not be the best choice for
devices with limited battery life or those that need to operate for extended periods
without frequent recharging.
Ideal for Projects with Low Data Transfer: Cellular technology is most effective for
projects that transmit small amounts of information at regular intervals, as this
minimizes power consumption and allows devices to operate efficiently.
The cellular technology used in different generations has its respective standards and
characteristics:
 2G standards include GSM, EDGE, and GPRS.
 3G standards include UMTS and HSPA.
 4G standard is known as LTE.
Frequencies for these standards can be around 900, 1800, 1900, and 2100 MHz,
depending on the region and service provider. The range of communication varies for
different 2G and 3G technologies, with GSM covering about 35 km and HSPA
extending to approximately 200 km.
Data rates also differ among these standards: GPRS offers speeds ranging from 35 to
170 Kbps, EDGE provides 120 to 384 Kbps, UMTS supports 384 Kbps to 2 Mbps,
HSPA offers speeds of 600 Kbps to 10 Mbps, and LTE provides data rates between 3
to 10 Mbps.
In summary, cellular technology provides a robust and widely accessible means of
communication for both mobile phones and IoT devices. Its capability to transfer
large data sets is valuable, but it should be used judiciously in projects where power
consumption needs to be carefully managed. The various standards, frequencies, and
data rates cater to different use cases and connectivity requirements, making cellular
technology a versatile option for a range of IoT applications.
Comparison of IoT Protocols
In summary, this table provides a comparison of all protocols according to various
aspects.

Message encoding in IoT involves converting data into a format that can be efficiently
transmitted and correctly interpreted by devices within an IoT system. Here’s an
overview of message encoding techniques used in IoT:
Basics of Message Encoding
 Purpose: Ensure data integrity, security, and efficiency during transmission.
 Techniques: Use various methods to convert data into a suitable format for
communication.
Common Encoding Schemes in IoT
1. JSON (JavaScript Object Notation)
o Characteristics: Lightweight, easy to read and write, widely used for data
interchange.
o Usage: Commonly used for encoding data between IoT devices and cloud
applications.
2. XML (eXtensible Markup Language)
o Characteristics: More verbose than JSON, supports complex data structures
and metadata.
o Usage: Used when the data structure is complex and needs to include
metadata.
3. Protobuf (Protocol Buffers)
o Characteristics: Developed by Google, more compact and efficient than JSON
and XML, supports schema definition.
o Usage: Ideal for scenarios where bandwidth and processing power are limited.
4. CBOR (Concise Binary Object Representation)
o Characteristics: Binary encoding format, compact, efficient, and suitable for
IoT applications.
o Usage: Used for efficient data serialization in resource-constrained
environments.
Key Considerations for Encoding in IoT
1. Efficiency: The encoding scheme should minimize data size to save bandwidth and
storage.
2. Complexity: The complexity of data structures and the need for metadata should
guide the choice of encoding.
3. Interoperability: The encoding format should be compatible with different devices and
systems.
4. Security: Ensure encoded data can be securely transmitted and decoded.
Example: Encoding Sensor Data
Consider a scenario where temperature and humidity data from a sensor need to be
transmitted to a cloud application.
Implementation in IoT Systems
1. Data Collection: Sensors collect raw data.
2. Encoding: Data is encoded using an appropriate scheme (e.g., JSON, Protobuf).
3. Transmission: Encoded data is transmitted over the network to the cloud or another
IoT device.
4. Decoding: The receiver decodes the data back into its original format for processing.
JSON stands for JavaScript Object Notation is a lightweight and human-readable
format for storing and exchanging data. It is a format for structuring data. This format
is used by different web applications to communicate with each other. It has become
the actual standard for data communication across web applications due to its
simplicity and flexibility.
In this JSON tutorial, we will provide you with the fundamentals of JSON, JSON
Syntax including objects, arrays, values, keys, and string formats, JSON topics
including parsing JSON in various programming languages, using JSON for web
APIs, and data handling of large JSON datasets, enabling you to create, parse, and
leverage JSON data effectively.

What is JSON?
JSON, short for JavaScript Object Notation, makes sharing data simple and
straightforward. Created by Douglas Crockford, it's designed for easy reading and
writing by humans, and easy parsing and generating by computers. Its main goal was
to make a text format that's good at showing simple data like lists and text, and really
useful for websites.
JSON is special because it's very clear and easy to use, and it uses a ".json" file
ending to show that a file is in this format. This makes JSON great for both people
and programs to work with.

Data Types that JSON supports:


According to the JSON standards, values in JSON must be one of the following data
types:
 Strings
 Numbers
 Object (JSON Object)
 Array
 Booleans
 Null
Why use JSON?
JSON is used in a variety of contexts, primarily for data interchange between servers
and web applications: Here are the reasons:
 Language Independence : Though it is derived from a subset of JavaScript, yet it
is Language independent . Thus, the code for generating and parsing JSON data can
be written in any other programming language.
 Human-readable Format : It is Human-readable and writable.
 Lightweight Data Interchange Format : It is a lightweight text-based data interchange
format which means, it is simpler to read and write when compared to XML.
 Easy Parsing and Generation : Allows conversion of parse JSON data into native data
structures and vice versa easily, simplifying the process of working with data.
JSON Syntax
In JSON , data is primarily stored in two structures: objects and arrays . Here's a
detailed breakdown of the syntax for each:
1. Using 'Objects'
 Objects in JSON are collections of key/value pairs enclosed in curly braces {} .
 Each key is a string (enclosed in double quotes " ) followed by a colon : , and
the key/value pairs are separated by commas (,) .
Example: {"firstName": "John", "lastName": "Doe", "age": 30}
2. Using 'Arrays'
 Arrays are ordered lists of values, enclosed in square brackets [] .
 Values within an array are separated by commas (,) .
Useful JSON Tools
 Effortlessly transform JSON to CSV with our user-friendly tools! Simplify your data
handling and analysis.
 Use our JSON Formatter and Validator to format and beautify your JSON code.
Advantages of JSON
 Readability: JSON closely resembles JavaScript object syntax, making it easy for
humans to understand and write.
 Lightweight: Compared to XML, JSON has a smaller footprint, leading to faster data
transmission and processing.
 Language Independence: JSON is not tied to any specific programming language.
Most programming languages have libraries to parse and generate JSON data.
 Flexibility: JSON's flexible structure can accommodate various data types and
complex data hierarchies.
Limitations of JSON
 The main limitation is that there is no error handling . If there was a slight mistake in
the script then you will not get the structured data.
 It becomes quite dangerous when you used it with some unauthorized browsers . Like
JSON service return a JSON file wrapped in a function call that has to be executed by
the browsers if the browsers are unauthorized then your data can be hacked.
 It has limited supported tools that we can use during the development.
Working with JSON in Applications
JSON's true power lies in its ability to seamlessly exchange data between
applications. Here are some common use cases:
 APIs (Application Programming Interfaces): APIs often use JSON to format data
requests and responses. This makes it easier for different applications to communicate
and share information.
 Client-Server Communication: Web applications frequently use JSON to send data
from the browser (client) to the server and vice versa. JSON's lightweight nature
ensures efficient data transfer.
 Data Storage: JSON can be used to store configuration settings, user preferences, or
any other structured data in a file.
Message encoding in IoT involves converting data into a format that can be efficiently
transmitted and correctly interpreted by devices within an IoT system. Here’s an
overview of message encoding techniques used in IoT:
Basics of Message Encoding
 Purpose: Ensure data integrity, security, and efficiency during transmission.
 Techniques: Use various methods to convert data into a suitable format for
communication.
Common Encoding Schemes in IoT
1. JSON (JavaScript Object Notation)
o Characteristics: Lightweight, easy to read and write, widely used for data
interchange.
o Usage: Commonly used for encoding data between IoT devices and cloud
applications.
2. XML (eXtensible Markup Language)
o Characteristics: More verbose than JSON, supports complex data structures
and metadata.
o Usage: Used when the data structure is complex and needs to include
metadata.
3. Protobuf (Protocol Buffers)
o Characteristics: Developed by Google, more compact and efficient than JSON
and XML, supports schema definition.
o Usage: Ideal for scenarios where bandwidth and processing power are limited.
4. CBOR (Concise Binary Object Representation)
o Characteristics: Binary encoding format, compact, efficient, and suitable for
IoT applications.
o Usage: Used for efficient data serialization in resource-constrained
environments.
Key Considerations for Encoding in IoT
1. Efficiency: The encoding scheme should minimize data size to save bandwidth and
storage.
2. Complexity: The complexity of data structures and the need for metadata should
guide the choice of encoding.
3. Interoperability: The encoding format should be compatible with different devices and
systems.
4. Security: Ensure encoded data can be securely transmitted and decoded.
Example: Encoding Sensor Data
Consider a scenario where temperature and humidity data from a sensor need to be
transmitted to a cloud application.
Implementation in IoT Systems
1. Data Collection: Sensors collect raw data.
2. Encoding: Data is encoded using an appropriate scheme (e.g., JSON, Protobuf).
3. Transmission: Encoded data is transmitted over the network to the cloud or another
IoT device.
4. Decoding: The receiver decodes the data back into its original format for processing.
By choosing the right encoding scheme, IoT systems can optimize data transmission,
ensure compatibility across devices, and maintain data integrity.
Would you like to explore any specific encoding technique or application in more
detail?
Protocol Buffers (Protobuf) IoT message encoding
Protocol Buffers (Protobuf) is a method developed by Google for serializing
structured data. It is a compact and efficient binary format that is ideal for IoT
applications where bandwidth and processing power are limited. Here’s a detailed
overview of how Protobuf is used for message encoding in IoT:
Key Features of Protobuf
 Compact Format: Protobuf uses a binary format that is more efficient in terms of size
compared to text-based formats like JSON or XML.
 Schema Definition: Messages are defined using a .proto file, which specifies the
structure and data types.
 Language Agnostic: Supports multiple programming languages, making it versatile
for different IoT systems.
 Backward and Forward Compatibility: Ensures that new fields can be added without
breaking existing deployments.
Protobuf in IoT
1. Schema Definition:
o Create a .proto file that defines the structure of the messages.
o Example schema for a sensor data message:
}
2. Compiling the Schema:
o Use the protoc compiler to generate code in the desired programming
language.
3. Encoding Data:
o Use the generated code to create and serialize messages.
o Example in Python:
4. Decoding Data:
o The receiver uses the same schema to deserialize the data back into a
structured format.

Advantages of Using Protobuf in IoT


 Efficiency: The compact binary format reduces the amount of data transmitted, saving
bandwidth.
 Speed: Faster serialization and deserialization compared to text-based formats.
 Structure: Ensures a well-defined structure that can be strictly enforced.
 Compatibility: Simplifies the process of updating and maintaining IoT systems with
backward and forward compatibility.
Use Cases
 Sensor Networks: Efficiently transmitting sensor data to gateways or cloud services.
 Real-Time Monitoring: Ensuring quick and reliable data exchange in systems that
require real-time responses.
 Inter-Device Communication: Enabling different IoT devices to communicate
efficiently with each other.
Protobuf’s efficiency and flexibility make it a powerful tool for encoding messages in
IoT applications, especially in resource-constrained environments.

You might also like