UNIT-2 - CN, Computer Networking Notes
UNIT-2 - CN, Computer Networking Notes
•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.
•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.
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.
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
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
•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.
• 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:
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.
•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 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.
•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.
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.
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:
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.
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)