Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

chapter9-Security

Data verification is essential to ensure that errors occurring during transmission do not lead to the use of incorrect data. Methods like parity checks and checksums are used for error detection, with parity checks being simple but limited, while checksums provide a more robust solution but cannot locate errors. The parity block check method enhances error detection and correction capabilities by identifying the exact location of errors in the data.

Uploaded by

Nourhene Aouidi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

chapter9-Security

Data verification is essential to ensure that errors occurring during transmission do not lead to the use of incorrect data. Methods like parity checks and checksums are used for error detection, with parity checks being simple but limited, while checksums provide a more robust solution but cannot locate errors. The parity block check method enhances error detection and correction capabilities by identifying the exact location of errors in the data.

Uploaded by

Nourhene Aouidi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Why is data verification needed?

When data is sent from one device to another, errors can happen. These errors might
flip a bit in the data (turn a 1 into a 0, or vice versa). To avoid using bad or incorrect data,
we need ways to check if the data got messed up during transmission.

Parity Check (Simplest Method)

A parity check is a simple way to verify data. Here's how it works:

1. What is parity?

2. Parity means "evenness" or "oddness." We check if the number of 1s in a group


of bits is even or odd.

3. How does it work?


a. Each piece of data is sent as a group of 7 bits (e.g., 1010011).
b. Before sending the data, the sender adds an extra bit (called the parity
bit). This makes the total number of 1s in the group either even (even
parity) or odd (odd parity), depending on the agreed rule.
4. Example (Even Parity):
a. Data: 1010010 (3 ones — odd count).
b. To make it even, add a parity bit: 1. So the data becomes 10100101
c. If the number of 1s was already even, the parity bit would be 0.
5. Checking at the Receiver:
a. The receiver checks the number of 1s in the 8-bit data (7 bits + parity bit).
b. If the number of 1s is even (as expected), the data is accepted. If not, the
receiver knows there’s an error.

What’s the problem with parity checks?

Parity checks only detect some errors. If two bits flip (e.g., 1 becomes 0 twice), the
parity will still look correct, even though the data is wrong. So it’s not perfect but works
for simple cases.
Checksum Method

The checksum method is a way to check if data was corrupted during transmission. It
works by using a summary number (the checksum) calculated from the data.

How it Works at the Sender

1. Group the Data into Blocks:


a. The data to be sent is divided into blocks (e.g., chunks of bytes).
b. Example: Data is 10101011 11001100 10010011.
2. Add the Blocks Together:
a. The sender adds up all the blocks as if they are binary numbers.
b. Let’s add these binary numbers:
10101011 (block 1)
11001100 (block 2)
10010011 (block 3)
--------

3. Calculate the Checksum:


a. The checksum is derived from the sum, often by truncating or taking the
complement.
b. Example: In an 8-bit system, the checksum could be the last 8 bits of the
sum (11110100).
4. Send Data + Checksum:
a. The sender sends the data blocks along with the calculated checksum:
i. Data: 10101011 11001100 10010011
ii. Checksum: 11110100

How it Works at the Receiver

1. Receive Data and Checksum:


a. The receiver gets the data blocks and the checksum.
2. Recalculate the Checksum:
a. The receiver adds up the data blocks the same way the sender did:
markdown
Copier le code
10101011 (block 1)
11001100 (block 2)
10010011 (block 3)
--------

111110100 (sum)

less
- It calculates the checksum (e.g., taking the last 8 bits:
`11110100`).

3. Compare the Checksums:


a. The receiver compares its calculated checksum to the one sent by the
sender:
i. If they match: The data is assumed to be correct.
ii. If they don’t match: An error occurred during transmission.

Example of an Error

• Suppose the data sent was:


o Data: 10101011 11001100 10010011
o Checksum: 11110100
• During transmission, one bit in the second block gets flipped (11001100
becomes 11000100).
• Receiver recalculates:

10101011 (block 1)
11000100 (block 2 - with error)
10010011 (block 3)
--------
111100011 (new sum)

o Receiver calculates a different checksum: 11110011.


• Mismatch detected! The checksum doesn’t match, so the receiver knows an
error occurred.
Limitations of Checksum

1. Can’t Find Exact Error Location:


a. The checksum only detects that there’s an error, but it doesn’t tell where
the error is.
2. Misses Some Errors:
a. If multiple errors cancel each other out (e.g., flipping bits that balance the
checksum), the method won’t detect the issue.

Why Use a Checksum?

• Simple to implement and works well for basic error detection.


• Used in networking protocols like TCP/IP to ensure data integrity.

Parity Block Check (Detecting and Fixing Errors)

This method uses a table (or matrix) of bits to make error detection more precise:

1. At the sender:
a. Imagine the data is arranged in rows (one row per byte).
b. A parity bit is added to each byte (row) as before.
c. Then, an extra byte (the parity byte) is created by adding parity bits for
each column in the matrix.
d. The sender sends all the data + the parity byte.
2. At the receiver:
a. The receiver checks parity for each row and each column.
b. If one bit in the data is wrong, the row and column checks will point to the
exact location of the error.
3. Fixing errors:
a. Once the receiver identifies the error, it can correct the flipped bit and
recover the correct data.

Example: Parity Block Check

Suppose we are sending these 7 bytes (7-bit codes):


Bit Position 1 2 3 4 5 6 7 Parity (Row)
Byte 1 0 1 0 0 1 0 1 1
Byte 2 1 0 1 0 0 1 1 0
Byte 3 0 1 1 0 0 1 0 1
Byte 4 1 0 0 1 0 1 1 0
Byte 5 0 1 0 0 1 1 0 1
Byte 6 1 1 0 1 0 0 1 0
Byte 7 0 0 1 1 1 0 0 1
Parity (Col) 1 0 0 0 1 0 1
1. Each row gets a parity bit based on the number of 1s in the row.
2. An additional row (parity byte) is added for the columns.
3. The receiver uses these to detect and fix errors.

Final Notes

• Parity checks: Simple, quick, but can miss some errors.


• Checksum: Detects errors over larger blocks but can’t fix them.
• Parity block check: More complex but can detect and fix single-bit errors.

You might also like