Iot - Unit Iv
Iot - Unit Iv
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)
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.
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.
Transmission of data
3 – Network from one host to another, IP, ICMP, IGMP, OSPF,
Packets
Layer located in different etc.
networks.
Establishes Connection,
5 – Session Maintenance, Ensures
Data NetBIOS, RPC, PPTP, etc.
Layer Authentication and
Ensures security.
OSI stands for Open Systems TCP/IP stands for Transmission Control
Interconnection. Protocol/Internet Protocol.
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.
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??
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.
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?
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:
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.
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.
Communication
Serial (RS-232 or RS-485) Ethernet (TCP/IP)
Method
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)
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:
Transaction
2 Bytes Identifies the transaction.
Id
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.
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.
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.
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.
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.
Smaller, typically 20
Header Size Larger, 20-60 bytes
bytes
Yes, acknowledges
Transmission
receipt of data No
Acknowledgment
packets.
Network/Internet Layer(IP)
Network Access Layer
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.
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
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.
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.
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
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.
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)
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.
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.
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.
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.