0% found this document useful (0 votes)
25 views67 pages

UNIT-2 - CN, Computer Networking Notes

The document discusses data security and data integrity, defining data security as the protection of data from unauthorized access and data integrity as the assurance that data is accurate and consistent. It outlines the advantages and disadvantages of both concepts, including cost, complexity, and the importance of compliance with regulations. Additionally, it covers error detection methods such as parity bits and cyclic redundancy checks, along with the Hamming code for error correction.

Uploaded by

Madhuri Patil
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)
25 views67 pages

UNIT-2 - CN, Computer Networking Notes

The document discusses data security and data integrity, defining data security as the protection of data from unauthorized access and data integrity as the assurance that data is accurate and consistent. It outlines the advantages and disadvantages of both concepts, including cost, complexity, and the importance of compliance with regulations. Additionally, it covers error detection methods such as parity bits and cyclic redundancy checks, along with the Hamming code for error correction.

Uploaded by

Madhuri Patil
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

UNIT - 2

Data Security & Data


Integrity
What is Data Security?
Data security refers to the prevention of data from unauthorized users. It is only allowed to access the
data to the authorized users. In the database, the DBA or head of the department can access all the
data. Some users are only allowed to retrieve data, whereas others are allowed to retrieve and modify
the data.

Advantages of Data Security

•Protection Against Breaches: It controls access to save data as it has firewalls as well as Data
encryption to avoid breaches of sensitive information.

•Compliance with Regulations: To ensure that an organization monitors data security measures and
proactively adheres to pertinent data protection laws, such as GDPR, and HIPAA among others, strong
Data Security measures are to be put in place.

•Preservation of Reputation: Protecting the data, then will help the organizations minimize the losses
due to cases like hacker attacks and or data leaks while at the same time avoiding any bad reputation
that may be resulting from such incidents.
Disadvantages of Data Security

•Cost: About Data Security, it can go a long way in protecting an organization’s data and information;
however it can be very costly since it involves the procurement of more hardware and software,
personnel to monitor and update the system and time to ensure that every possible loophole is closed.

•Complexity: The management and maintenance of data security can be intricate and rather
challenging, more so in large organizations where data is constantly flowing through the organization
both internally and externally and through a huge number of entry points that are potential targets to
intruders.

•Potential for Reduced Accessibility: While most types of security measures focus on the ways of
preventing unauthorized access, they can create problems for gaining access to data for other
legitimate purposes within a business.
What is Data Integrity?
Data integrity is defined as the data contained in the database is both correct and consistent. For this
purpose, the data stored in the database must satisfy certain procedures (rules). The data in a
database must be correct and consistent. DBMS provides different ways to implement such types of
constraints (rules).
It can be implemented by rules i.e., Primary Key, Secondary Key, Foreign Key. This improves data
integrity in a database.

Advantages of Data Integrity

•Accurate Decision-Making: Ensuring data integrity enables people to make excellent decisions
by using factual information hence promoting success.

•Consistency Across Systems: Data Integrity stabilizes data in the chain so that whenever it is
accessed it has not transformed or been impaired in any way.

•Compliance and Auditability: As a rule, keeping data unalterable is mandatory to meet the
requirements, while it helps auditors along with compliance personnel greatly while
investigating stuff.
Disadvantages of Data Integrity

•Vulnerability to Human Error: It may be also affected through human interference through
wrong data entry in the computer, or through alteration of data by a human being, which results
in wrong information.

•Complexity in Management: Data Integrity must be protected with the means of data handling
management and often, it is a challenging task in large and evolving organizations.

•Dependence on Technology: Data Integrity is accomplished with the help of various


technological tools and systems and hence exposes the data integrity to problems related to
failure or misconfiguration.
Data Security Data Integrity

Data security refers to the prevention of data corruption through the use of controlled access
Data integrity refers to the quality of data, which assures the data is complete and has a whole structure.
mechanisms.

Its motive is the protection of data. Its motive is the validity of data.

Its work is to only the people who should have access to the data are the only ones who can access the
Its work is to check the data is correct and not corrupt.
data.

It refers to making sure that data is accessed by its intended users, thus ensuring the privacy and
It refers to the structure of the data and how it matches the schema of the database.
protection of data.

Some of the means to preserve integrity are backing up, error detection, designing a suitable user
Some of the popular means of data security are authentication/authorization, masking, and encryptions.
interface, and correcting data.

It relates to the physical form of data against accidental or intentional loss or misuse and destruction. It relates to the logical protection (correct, complete, and consistent) of data.

It avoids unauthorized access to data. It avoids human error when data is entered.

It can be implemented by following the rules:


It can be implemented through :
• Primary Key
• user accounts (passwords)
• Foreign Key
• authentication schemes
• Relationship
Error Detection
Error is a condition when the receiver’s information does not match the sender’s. Digital signals suffer
from noise during transmission that can introduce errors in the binary bits traveling from sender to
receiver. That means a 0 bit may change to 1 or a 1 bit may change to 0.
Data (Implemented either at the Data link layer or Transport Layer of the OSI Model) may get
scrambled by noise or get corrupted whenever a message is transmitted. To prevent such errors,
error- detection codes are added as extra data to digital messages. This helps in detecting any errors
that may have occurred during message transmission.

Types of Errors
1. Single-Bit Error
2. Multiple-Bit Error
3. Burst Error
Single-Bit Error
A single-bit error refers to a type of data transmission error that occurs when one bit (i.e., a single
binary digit) of a transmitted data unit is altered during transmission, resulting in an incorrect or
corrupted data unit.
Multiple-Bit Error
A multiple-bit error is an error type that arises when more than one bit in a data transmission is
affected. Although multiple-bit errors are relatively rare when compared to single-bit errors, they can
still occur, particularly in high-noise or high-interference digital environments.
Burst Error
When several consecutive bits are flipped mistakenly in digital transmission, it creates a burst error.
This error causes a sequence of consecutive incorrect values.
Error Detection Methods
To detect errors, a common technique is to introduce redundancy bits that provide additional
information. Various techniques for error detection include:
•Parity Bit Method

•Checksum

•Cyclic Redundancy Check (CRC)

Parity Bit Method


What is parity bit?
A parity bit is an extra bit that is added to the message bits or data-word bits on the sender side. Data-
word bits along with parity bits is called a codeword. The parity bit is added to the message bits on the
sender side, to help in error detection at the receiver side.
Parity Bit Method
A parity bit is an extra bit included in the binary message to make a total number of 1’s either odd or
even. Parity word denotes the number of 1’s in a binary string. There are two parity systems – even and
odd parity checks.
Simple Parity Check

Simple-bit parity is a simple error


detection method that involves adding
an extra bit to a data transmission. It
works as:
•1 is added to the block if it contains an
odd number of 1’s, and

•0 is added if it contains an even


number of 1’s

This scheme makes the total number


of 1’s even, that is why it is called even
parity checking.
Even Parity: Total number of 1’s in the given data bit should be even. So if the total number of 1’s in
the data bit is odd then a single 1 will be appended to make total number of 1’s even else 0 will be
appended(if total number of 1’s are already even). Hence, if any error occurs, the parity check circuit
will detect it at the receiver’s end. Let’s understand this with example, see the below diagram .

In the above image, as we can see the data bits are ‘1011000’ and since this is even parity check that
we’re talking about, 1 will be appended as the parity bit (highlighted in red) to make total count of
1’s even in the data sent. So here, our parity bit is 1. If the total count of 1 in the given data bits were
already even, then 0 would’ve been appended.
Odd Parity

In odd parity system, if the total number of 1’s in the given


binary string (or data bits) are even then 1 is appended to
make the total count of 1’s as odd else 0 is appended. The
receiver knows that whether sender is an odd parity
generator or even parity generator. Suppose if sender is an
odd parity generator then there must be an odd number
of 1’s in received binary string. If an error occurs to a
single bit that is either bit is changed to 1 to 0 or 0 to 1,
received binary bit will have an even number of 1’s which
will indicate an error.
Take reference from fig(1.1) and rather than appending
the 1 as parity bit, append 0 because total number of 1’s
are already odd.
Advantages of Simple Parity Check

•Simple parity check can detect all single bit error.

•Simple parity check can detect an odd number of errors.

•Implementation: Simple Parity Check is easy to implement in both hardware and software.

•Minimal Extra Data: Only one additional bit (the parity bit) is added per data unit (e.g., per byte).

•Fast Error Detection: The process of calculating and checking the parity bit is quick, which allows
for rapid error detection without significant delay in data processing or communication.

•Single-Bit Error Detection: It can effectively detect single-bit errors within a data unit, providing
a basic level of error detection for relatively low-error environments.
Disadvantages of Simple Parity Check
•Single Parity check is not able to detect even no. of bit error.

•For example, the Data to be transmitted is 101010. Codeword transmitted to the receiver is
1010101 (we have used even parity).
Let’s assume that during transmission, two of the bits of code word flipped to 1111101.
On receiving the code word, the receiver finds the no. of ones to be even and hence no error, which is a
wrong assumption.
In the above example, the data bits has been changed but as we can see the total count of
1’s remain to be even, the error can’t be detected even though the message’s meaning has
been changed. You can visualize the same for odd parity check the number of 1’s will remain
odd, even if the data bits have been changed and the odd parity check won’t be able to
detect error.
Cyclic Redundancy Check
Cyclic Redundancy Check or CRC is a method of detecting accidental changes/errors in the
communication channel. CRC uses Generator Polynomial which is available on both sender and
receiver side.
An example generator polynomial is of the form like x3 + x + 1. This generator polynomial represents
key 1011. Another example is x2 + 1 that represents key 101.
There are two primary variables in CRC:
•n: Number of bits in data to be sent from sender side
•k: Number of bits in the key obtained from generator polynomial.

Encoded Data Generation from Generator Polynomial (Sender Side)

• The binary data is first augmented by adding k-1 zeros in the end of the data.

• Then, modulo – 2 binary division is used to divide binary data by the key and remainder of division
is stored.

At last the the remainder is appended at the end of the data to form the encoded data which is later
sent.
Checking Error in Transmission (Receiver Side)

•After receiving the data, to check if the data is error free, perform the modulo-2 division again.

•If the remainder is 0, then there are not errors, otherwise, the data is faulty and contain
transmission errors.

Examples:

Case 1: No error in transmission


Data = 100100, Generator Polynomial (Key) = x3 + x2 + 1 (1101)
Sender Side

The remainder is 001. Thus the data sent is 100100001.


Receiver Side
Code word received at the receiver side 100100001

The remainder is 0, hence the data received has no errors.


CRC Implementation – O(n) Time and O(n) Space
Case 2: Error in Transmission
Data = 100100, Generator Polynomial (Key) = x3 + x2 + 1
(1101)
Sender Side

The remainder is 001. Thus the data sent is 100100001.


Receiver Side
Let there be an error and code word received at the
receiver side 100000001.

As the remainder is not 0, hence there is some error


detected in the receiver side.
Hamming Code
Hamming code is an error-correcting code used to ensure data accuracy during transmission or
storage. Hamming code detects and corrects the errors that can occur when the data is moved or
stored from the sender to the receiver. This simple and effective method helps improve the reliability
of communication systems and digital storage. It adds extra bits to the original data, allowing the
system to detect and correct single-bit errors. It is a technique developed by Richard Hamming in the
1950s.
What is Redundant Bits?
Redundant bits are extra binary bits that are generated and added to the information-carrying bits of
data transfer to ensure that no bits were lost during the data transfer. The number of redundant bits
can be calculated using the following formula:
2r ≥ m + r + 1
where,
•m is the number of bits in input data

•r is the number of redundant bits.

Suppose the number of data bits is 7, then the number of redundant bits can be calculated as
= 24 ≥ 7 + 4 + 1 Thus, the number of redundant bits is 4.
Types of Parity Bits
A parity bit is a bit appended to a data of binary bits to ensure that the total number of 1’s in the data is
even or odd. Parity bits are used for error detection. There are two types of parity bits:
•Even Parity Bit: In the case of even parity, for a given set of bits, the number of 1’s are counted. If that
count is odd, the parity bit value is set to 1, making the total count of occurrences of 1’s an even
number. If the total number of 1’s in a given set of bits is already even, the parity bit's value is 0.

•Odd Parity Bit: In the case of odd parity, for a given set of bits, the number of 1’s are counted. If that
count is even, the parity bit value is set to 1, making the total count of occurrences of 1’s an odd
number. If the total number of 1’s in a given set of bits is already odd, the parity bit's value is 0.

Algorithm of Hamming Code


Hamming Code is simply the use of extra parity bits to allow the identification of an error.
Step 1: Write the bit positions starting from 1 in binary form (1, 10, 11, 100, etc).
Step 2: All the bit positions that are a power of 2 are marked as parity bits (1, 2, 4, 8, etc).
Step 3: All the other bit positions are marked as data bits.
Step 4: Each data bit is included in a unique set of parity bits, as determined its bit position in binary
form:

•Parity bit 1 covers all the bits positions whose binary representation includes a 1 in the least significant
position (1, 3, 5, 7, 9, 11, etc).

•Parity bit 2 covers all the bits positions whose binary representation includes a 1 in the second position
from the least significant bit (2, 3, 6, 7, 10, 11, etc).

•Parity bit 4 covers all the bits positions whose binary representation includes a 1 in the third position
from the least significant bit (4–7, 12–15, 20–23, etc).

•Parity bit 8 covers all the bits positions whose binary representation includes a 1 in the fourth position
from the least significant bit bits (8–15, 24–31, 40–47, etc).

•In general, each parity bit covers all bits where the bitwise AND of the parity position and the bit
position is non-zero.
Step 5: Since we check for even parity set a parity bit to 1 if the total number of ones in the positions it
checks is odd. Set a parity bit to 0 if the total number of ones in the positions it checks is even.
Determining The Position of Redundant Bits
A redundancy bits are placed at positions that correspond to the power of 2. As in the above
example:
•The number of data bits = 7

•The number of redundant bits = 4

•The total number of bits = 7+4=11

•The redundant bits are placed at positions corresponding to power of 2 that is 1, 2, 4, and 8

•Suppose the data to be transmitted is 1011001 from sender to receiver, the bits will be placed as
follows:
Determining The Parity Bits According to Even Parity
•R1 bit is calculated using parity check at all the bits positions whose binary representation includes
a 1 in the least significant position. R1: bits 1, 3, 5, 7, 9, 11

•To find the redundant bit R1, we check for even parity. Since the total number of 1’s in all the bit
positions corresponding to R1 is an even number. So, the value of R1 (parity bit’s value) = 0.

•R2 bit is calculated using parity check at all the bits positions whose binary representation includes a
1 in the second position from the least significant bit. R2: bits 2,3,6,7,10,11
•To find the redundant bit R2, we check for even parity. Since the total number of 1’s in all the bit
positions corresponding to R2 is odd the value of R2(parity bit’s value)=1

•R4 bit is calculated using parity check at all the bits positions whose binary representation
includes a 1 in the third position from the least significant bit. R4: bits 4, 5, 6, 7
• To find the redundant bit R4, we check for even parity. Since the total number of 1’s in all the bit
positions corresponding to R4 is odd so the value of R4(parity bit’s value) = 1

•R8 bit is calculated using parity check at all the bits positions whose binary representation includes a
1 in the fourth position from the least significant bit. R8: bit 8,9,10,11

•To find the redundant bit R8, we check for even parity. Since the total number of 1’s in all the bit
positions corresponding to R8 is an even number the value of R8(parity bit’s value)=0. Thus, the data
transferred is:
Error Detection and Correction
Suppose in the above example the 6th bit is changed from 0 to 1 during data transmission, then it gives
new parity values in the binary number:
For all the parity bits we will check the number of 1's in their respective bit positions.
•For R1: bits 1, 3, 5, 7, 9, 11. We can see that the number of 1's in these bit positions are 4 and that's
even so we get a 0 for this.

•For R2: bits 2,3,6,7,10,11 . We can see that the number of 1's in these bit positions are 5 and
that's odd so we get a 1 for this.

•For R4: bits 4, 5, 6, 7 . We can see that the number of 1's in these bit positions are 3 and that's odd so
we get a 1 for this.

•For R8: bit 8,9,10,11 . We can see that the number of 1's in these bit positions are 2 and that's
even so we get a 0 for this.

•The bits give the binary number 0110 whose decimal representation is 6. Thus, bit 6 contains an error.
To correct the error the 6th bit is changed from 1 to 0.
Features of Hamming Code
•Error Detection and Correction: Hamming code is designed to detect and correct single-bit errors
that may occur during the transmission of data. This ensures that the recipient receives the same data
that was transmitted by the sender.

•Redundancy: Hamming code uses redundant bits to add additional information to the data being
transmitted. This redundancy allows the recipient to detect and correct errors that may have occurred
during transmission.

•Efficiency: Hamming code is a relatively simple and efficient error-correction technique that does not
require a lot of computational resources. This makes it ideal for use in low-power and low-bandwidth
communication networks.

•Widely Used: Hamming code is a widely used error-correction technique and is used in a variety of
applications, including telecommunications, computer networks, and data storage systems.

•Single Error Correction: Hamming code is capable of correcting a single-bit error, which makes it
ideal for use in applications where errors are likely to occur due to external factors such as
electromagnetic interference.

•Limited Multiple Error Correction: Hamming code can only correct a limited number of multiple
errors. In applications where multiple errors are likely to occur, more advanced error-correction
techniques may be required.
Advantages
•Hamming code can detect and correct single-bit errors, enhancing data reliability during transmission
and storage.

•It adds a minimal number of redundant bits to the original data, maintaining a good balance
between data integrity and overhead. The algorithm for generating and checking Hamming code is
straightforward and can be easily implemented in both hardware and software.

•By detecting and correcting errors, Hamming code ensures that the received data is accurate,
reducing the chances of data corruption.

•Hamming code is widely used in various fields such as computer memory (RAM), data storage
devices, and communication systems.

•Compared to more complex error correction codes, Hamming code provides a cost-effective solution
for applications where single-bit error correction is sufficient.
Disadvantages
•Hamming code can only correct single-bit errors. It is unable to correct multiple-bit errors, which
limits its effectiveness in environments with high error rates.

•While it can detect single-bit and some two-bit errors, Hamming code cannot detect all multiple-
bit errors. This reduces its reliability in certain applications.

•Although it uses fewer redundant bits compared to some other error correction methods, the
addition of these bits still increases the overall data size, which can be a drawback in
bandwidth- constrained environments.

•Implementing Hamming code requires additional hardware or software resources for


error detection and correction, which can be a limitation in resource-constrained systems.
Protocol Concept
Flow control is design issue at Data Link Layer. It is a technique that generally observes the proper flow
of data from sender to receiver. It is very essential because it is possible for sender to transmit data or
information at very fast rate and hence receiver can receive this information and process it. This can
happen only if receiver has very high load of traffic as compared to sender, or if receiver has power of
processing less as compared to sender. Flow control is basically a technique that gives permission to
two of stations that are working and processing at different speeds to just communicate with one
another. Flow control in Data Link Layer simply restricts and coordinates number of frames or amount
of data sender can send just before it waits for an acknowledgement from receiver. Flow control is
actually set of procedures that explains sender about how much data or frames it can transfer or
transmit before data overwhelms receiver. The receiving device also contains only limited amount of
speed and memory to store data. This is why receiving device should be able to tell or inform the
sender about stopping the transmission or transferring of data on temporary basis before it reaches
limit. It also needs buffer, large block of memory for just storing data or frames until they are
processed.
Techniques of Flow Control in Data Link Layer : There are basically two types of techniques
being developed to control the flow of data
1. Stop-and-Wait Flow Control : This method is the easiest and simplest form of flow control. In
this method, basically message or data is broken down into various multiple frames, and then
receiver indicates its readiness to receive frame of data. When acknowledgement is received, then
only sender will send or transfer the next frame. This process is continued until sender transmits EOT
(End of Transmission) frame. In this method, only one of frames can be in transmission at a time. It
leads to inefficiency i.e. less productivity if propagation delay is very much longer than the
transmission delay and Ultimately In this method sender sent single frame and receiver take one
frame at a time and sent acknowledgement(which is next frame number only) for new frame.
Advantages –
•This method is very easiest and simple and each of the frames is checked and acknowledged well.

•This method is also very accurate.


Disadvantages –
•This method is fairly slow.

•In this, only one packet or frame can be sent at a time.

•It is very inefficient and makes the transmission process very slow.
2. Sliding Window Flow Control : This method is required where reliable in-order delivery of
packets or frames is very much needed like in data link layer. It is point to point protocol that
assumes that none of the other entity tries to communicate until current data or frame transfer gets
completed. In this method, sender transmits or sends various frames or packets before receiving any
acknowledgement. In this method, both the sender and receiver agree upon total number of data
frames after which acknowledgement is needed to be transmitted. Data Link Layer requires and uses
this method that simply allows sender to have more than one unacknowledged packet “in-flight” at
a time. This increases and improves network throughput. and Ultimately In this method sender sent
multiple frame but receiver take one by one and after completing one frame acknowledge(which is
next frame number only) for new frame.
Advantages –
•It performs much better than stop-and-wait flow control.

•This method increases efficiency.

•Multiples frames can be sent one after another.

Disadvantages –
•The main issue is complexity at the sender and receiver due to the transferring of multiple frames.

•The receiver might receive data frames or packets out the sequence.
There are two types of sliding window protocol
• Go-Back-N (GBN)
• Selective Repeat (SR).

Go-Back-N (GBN) Protocol is a method used in networking to send data in a reliable way. It
uses something called a sliding window, which means the sender can send multiple packets at a
time without waiting for each one to be acknowledged. But here’s the catch—if even one packet
gets lost or has an error, the sender will go back and re-send that packet and all the ones after it,
even if some were received correctly.
Let’s say the sender sends packet 1, 2, 3, 4, and 5. If packet 3 gets lost, the receiver won’t accept 4
and 5. So, the sender has to go back and re-send 3, 4, and 5 again. That’s why it’s called Go-Back-N.
Here are 3 simple features of GBN:
1. Sender Window Size (WR)
It is N itself. If we say the protocol is GB10, then Ws = 10. N should be always greater than 1 in order
to implement pipelining. For N = 1, it reduces to the Stop and Wait protocol.
Efficiency Of GBN = N/(1+2a)
where,
a = Tp/Tt
Tp = Propagation Delay
Tt = Transmission Delay of sender
What will be the efficiency if processing delay, queuing delay and transmission delay of
acknowledgement is not zero?
Efficiency = N * (Useful time) / (Total Time)
where, useful time=Tt
Total time = Tt + 2 * Tp + Pr + Pq + Tt(ack)
where,
Tt =Transmission delay of sender side
Tp = Propagation Delay
Pr = Processing Delay
Pq = Queuing Delay
Tt(ack) = Transmission Delay of
Acknowledgement If B is the bandwidth of the
channel, then Effective Bandwidth or Throughput
= Efficiency * Bandwidth
= (N/(1+2a)) * B
2. Receiver Window Size (WR)
In the GB-N the receiver window size is one always. i.e. WR is always 1 in GBN.

3. Acknowledgements

In flow control, acknowledgments (ACKs) are signals sent by the receiver to the sender to confirm
that data packets have been successfully received. When the sender transmits data, it waits for an
acknowledgment before sending more. This process helps ensure that data is received correctly. If
an acknowledgment isn't received within a certain time, the sender assumes the packet was lost
and retransmits it.
There are 2 kinds of acknowledgements namely:
•Cumulative Ack: One acknowledgement is used for many packets. The main advantage is traffic is
less. A disadvantage is less reliability as if one ack is the loss that would mean that all the packets
sent are lost.

•Independent Ack: If every packet is going to get acknowledgement independently then the
reliability is high here but a disadvantage is that traffic is also high since for every packet we are
receiving independent ack.
Now let’s understand what actually happens in GBN with the help of an example.
Look at the diagram below (imagine it for now). The sender window size is 4.
Let’s assume we have many sequence numbers available, just to explain better.
The sender sends packets 0, 1, 2, and 3.
The receiver gets packets 0 and 1 and sends back acknowledgments.
Now the receiver is expecting packet 2, and the sender’s window moves ahead to send packets 4
and 5.
Now, suppose packet 2 gets lost in the network.
The receiver will ignore all the packets after 2 (like 3, 4, 5), because it is still waiting for packet 2.
On the sender side, each packet has a timer. When the timer for packet 2 runs out (because no
ACK came), the sender will go back to packet 2 and re-send packets 2 to 5.
That’s why it’s called Go-Back-N.
Go back means the sender goes back N packets from the last packet sent (not from where the loss
happened) in the unacknowledged part of the window, and re-sends all of them.
Example of GBN Protocol
Let’s take an example of GB4.
The sender window size is 4, so we need at least 4 sequence numbers to label each packet in the
window.
Now suppose the receiver has received all the packets 0, 1, 2, and 3 sent by the sender. So, it is
now waiting for packet 0 again (we can’t use 4 here because we only have 4 sequence numbers as
N = 4).
Now imagine the acknowledgment for these 4 packets is lost in the network.
On the sender side, packet 0's timer will run out (timeout), so the sender will re-send all 4 packets
again.
The problem is: the receiver is now waiting for a new set of packets, starting from 0 again. But
instead, it receives duplicate packets (0, 1, 2, 3) — which it already accepted earlier.
To fix this, we need to add one extra sequence number.
Now, the receiver will be waiting for packet number 4, and when it receives the old duplicate
packets starting from 0, it can easily reject them.
This is explained with the help of the illustrations below. Trying with Sequence numbers
4.
Now, trying with one extra sequence number.

Now it is clear as to why we need an extra 1 bit in the GBN protocol.


Advantages of GBN Protocol

•Simple to implement and effective for reliable communication.

•Better performance than stop-and-wait protocols for error-free or low-error networks.

Disadvantages of GBN Protocol

•Inefficient if errors are frequent, as multiple frames might need to be retransmitted


unnecessarily.

•Bandwidth can be wasted due to redundant retransmissions.


Selective Repeat Protocol: Selective Repeat Protocol (SRP) is an error control method used in
computer networks to make sure that data packets are received correctly. In this protocol, the sender
divides the data into small packets and sends them to the receiver, each with a sequence number. The
receiver sends an acknowledgment (ACK) for every correct packet it receives. If the sender doesn’t get
an ACK for a certain packet, it resends only that specific packet, not the whole set. This makes SRP
more efficient than other protocols like Go-Back-N. It uses a window-based system where both sender
and receiver keep track of packets using a fixed-size window. If any packet is missing or has an error,
the receiver sends a negative acknowledgment (NACK) for that packet, and the sender retransmits just
that one. For example, if you're sending 10 photos on WhatsApp and only the 4th one fails to deliver,
your friend will ask for just that one again. This is how Selective Repeat works – smart and efficient!
Though it needs more memory and is a bit complex, it's very useful in systems like TCP where reliable
data transfer is needed.
Steps
Now let’s talk about the steps involved in the Selective Repeat Protocol (SRP) 👇
 Divide data into packets
The first step is to break the data into small parts called packets. Each packet is given a unique
number (sequence number). These numbers help to keep track of the packets.
 Send packets to the receiver
The sender now starts sending the packets to the receiver. When the receiver gets a packet properly,
it sends back an ACK (Acknowledgment) to inform the sender.
 Use of window (Sliding Window)
Both sender and receiver use a window. This window shows how many packets can be sent or
received at one time.
•The size of the window depends on the network speed.
•The sender updates the window after sending packets and after receiving ACKs from the receiver.
 Handling missing ACKs
If the sender does not get an ACK for any packet within a fixed time, it will resend only that packet,
not all packets.
The receiver only accepts packets that are within its window. If a packet comes from outside the
window, the receiver throws it away.
 Selective Acknowledgment (SACK)
If packets are received out of order or some are missing, the receiver sends a Selective ACK (SACK).
This tells the sender which packets are missing and need to be sent again.
 Repeat until done
This whole process continues until:
All data packets are sent successfully
OR the maximum number of retries (retransmissions) is reached.
Example
Let’s see how we can transmit data using the SRP. We divide our sample data into 6 data packets or
frames:

Additionally, we’re assuming the window size for the receiver and sender is 2. Hence, we transmit
two frames and wait for the receiver to acknowledge the frames transmitted before sending the next
frames. In case of a missing or unacknowledged frame, we need to resend it before proceeding with
the next set of frames.
No Error in Transmission
Let’s start sending the packets using the SRP. We send the first two frames to the receiver and wait
for the acknowledgment:

As we can see, the receiver successfully received and acknowledged the first two data frames. One
crucial point is that when the sender sends a frame, it waits for a specific time to get a response. In
this case, we receive responses from the receiver within the waiting time of each frame. Hence, we
move on to the next 2 data frames.
Frame Is Lost
Let’s discuss a scenario when a frame is lost during the transmission:

Here, frame 2 is lost during the transmission. Hence, the sender waits for a specific amount of time to
get a response from the receiver. In this case, we received a negative acknowledgment for frame 2.
Therefore, we need to resend frame 2 before we proceed further:
Acknowledgment Is Lost
Let’s take a look at another situation when the acknowledgment of a frame is lost during transmission:

In this case, the


receiver successfully
receives frames 4 and
5, but the
acknowledgment of
frame 5 is lost. Hence,
the sender waits for a
specific amount of time
in order to receive an
acknowledgment for
frame 5. After the
waiting time is over,
the sender sends frame
4 again:
Advantages Disadvantages

Efficient retransmission of lost packets High complexity and difficult to implement

Sends SACKs for packets received out of order or


Requires more overhead due to the usage of SACKs
lost

Requires more buffering on both the sender and


Helps in reducing network delay
receiver sides

Provides high throughput May increase packet waiting time


Protocol correctness- Finite state machine
Protocol correctness in computer networks means that the protocol performs its task properly. It
ensures that all data is delivered correctly, in the right order, and without any errors. A correct
protocol also avoids problems like deadlocks (when the system gets stuck) or unnecessary delays. To
design and check if a protocol is working correctly, we use a concept called a Finite State Machine
(FSM). An FSM is a simple model that shows how a system moves between different states
depending on inputs or events. Each state represents a certain condition, like "waiting for
acknowledgment" or "sending a packet". When an event happens, such as receiving an
acknowledgment or a timeout, the FSM shifts to a new state and performs an action like resending
the packet. For example, in the Stop-and-Wait Protocol, the sender moves from "Ready to Send" to
"Waiting for ACK", and depending on whether an acknowledgment is received or not, it moves
forward. Using FSM helps in designing reliable and error-free protocols.

Finite State Machine (FSM) – What it is?


A Finite State Machine (FSM) is a mathematical model used to design and check how protocols
work. It's like a roadmap, showing how the system moves from one state to another when events
happen (like sending, receiving, or errors).
FSM has 4 main parts:
1. States – Different conditions like “waiting for ACK”, “sending packet”, “timeout” etc.
2. Input – Events like "packet received", "ACK received", or "timeout".
3. Transition – Movement from one state to another based on input.
4. Actions – What to do during the transition (like resend packet, update window, etc.)

Example:
FSM for Go-Back-N Protocol (Sender Side)
In the Go-Back-N protocol, the sender can send multiple packets (up to a window size) without
waiting for an ACK for each one. But if a packet is lost or an ACK is not received in time, the sender
goes back and retransmits all packets from that lost one onward.

FSM – Sender Side (in easy steps)


1. State: Ready to Send (Window not full)
Sender checks if window has space
If yes, it sends the next packet
Moves to “Waiting for ACK” (but still allowed to send more if window allows)
2. State: Waiting for ACK
After sending packets, the sender waits for ACKs
If correct ACK is received → Slide the window forward
If timeout occurs (no ACK for a packet) → Retransmit that packet and all after it in the window
3. Event: Timeout
Sender moves to a state where it retransmits all unacknowledged packets

FSM – Receiver Side (Simpler)


1. State: Waiting for expected packet
If correct packet received (in order) → Deliver it, send ACK
If out-of-order packet → Discard it, and send ACK for last correct packet

Example:
•Window size = 4
•Sender sends packets 0,1,2,3
•ACKs for 0 and 1 received, but 2 is lost
•Sender goes back and resends 2 and 3 (even if 3 was received, it is ignored)

You might also like