error detection and correction - wordpress.com · 2020. 4. 9. · check digit example 2 •to check...

21
Error Detection and Correction

Upload: others

Post on 25-Mar-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Error Detection and Correction

Page 2: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Error Detection and correction• Introduction

•When digital data is transmitted it is subject to communication faults due to :

• Broken /damaged wires

• Interference

• Thus errors may be introduced during transmission from the source to a receiver

• Error detection techniques allow detecting such errors

• Error correction enables to reconstruct the original data in case of errors.

2

Page 3: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Why do we need to check for errors1. To detect impairments introduced into data while it

is transmitted from source to destination

• To prevent the transfer of incorrect information to the

destination

• Wrong decisions may be taken based on incorrect information.

2. To ensure reliable delivery of data across vulnerable

networks

• To make sure that information has reached its destination.

3

Page 4: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Methods to detect data transmission errors

• Error detection techniques allow detecting errors occurring

during data transmission

• Some error detection methods :

•Parity checking

•Automatic Repeat reQuest (ARQ)

•Checksum

•Check Digit.

4

Page 5: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Parity checking

•A parity bit is a bit that is added to a group of bits

being transmitted to ensure that the total number of

bits with value 1 is even or odd

•Even Parity: total number of 1 bits = even

•Odd parity: total number of 1 bits = odd

5

Page 6: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Parity check• An error-checking technique that sets an extra bit (called a parity bit) to a

string of binary data being transmitted between two devices

Data Parity bit

Two types of parity check

• Even parity (Total number of 1’s is an even number)

• Odd parity (Total number of 1’s is an odd number).

6

1 0 0 1 0 0 1 1?

Page 7: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Parity Check Examples

•Assume even parity check is being used• What will be the parity bit set for the following data items

7

1 0 1 0 1 0 1?

1 1 1 1 1 1 1?

0 0 0 0 0 0 0?

1 1 0 0 0 0 1?

Page 8: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Parity Check Examples - Answers

•Assume even parity check is being used• What will be the parity bit set for the following data items

8

1 0 1 0 1 0 10

1 1 1 1 1 1 11

0 0 0 0 0 0 00

1 1 0 0 0 0 11

Page 9: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Problems with Parity Check9

•Parity check detects an error when one bit is in error

•What happens if there are two bits in error?

•Example

•Will the error be detected?

•Parity check will not work if two bits (or an even

number of bits) are in error.

Page 10: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Automatic Repeat Request (ARQ)

• Method used to check whether data has been correctly transmitted

• Uses Acknowledgement and Timeout

• Acknowledgement is a message sent by the receiver indicating that data

has been received correctly

• Timeout is the time that the sender will wait before an acknowledgement

is received

• If receiver does not send back an acknowledgement to the sender before

timeout occurs, then sender automatically resends the message.

10

Page 11: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Automatic Repeat Requests (ARQ)

•ARQ is an error correction method

• It uses error-detection methods (parity, checksum) and

positive and negative acknowledgments from the receiver

•When the sender receives a negative acknowledgments ,

the sender retransmits the message automatically.

11

Page 12: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Checksum

• A simple error-detection scheme used when sending a block of data from one

device to another

• To check that the data received is exactly the same as that was sent

• To ensure that the data has not been changed or corrupted during transmission.

• Data is sent in blocks (several bytes at a time)

• The checksum of the block is calculated

• e.g. checksum = sum of all bytes being sent

• The checksum is added at the end of the block of data and sent together.

12

Page 13: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

How does checksum work?

• The checksum is a number calculated using a formula based on the number of bits in the message being sent

• Data and checksum are stored and sent together

• The receiving device applies the same formula to the message and recalculates the checksum

• The two values are compared - the received checksum must be the same as that calculated one

• Any difference signifies an error has occurred - the receiver can assume that the message has been corrupted

• A request is made to send the data block again

13

Page 14: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Check Digit

• This is an extra digit added to a number

• The check digit is calculated from the digits of the number itself

• The computer re-calculates and validates the check digit when the

number is input

• If the calculated check digit is same as the existing one it means that the

number is valid

• Else it means that an error has occurred while inputting the number

• The number should be input again

14

Page 15: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Check DigitExample 1

• To calculate the check digit for the ISBN “0 - 2 0 1 - 5 3 0 8 2 - ?

• (i) the position of each digit is considered:

• “10 9 8 7 6 5 4 3 2 1” ← digit position

• 0 - 2 0 1- 5 3 0 8 2 - ? ← Number

• (ii) Each digit is then multiplied by its digit position and the totals added together

• (0x10) + (2x9) + (0x8) + (1x7) + (5x6) + (3x5) + (0x4) + (8x3) + (2x2)

• = 0 + 18 + 0 + 7 + 30 + 15 + 0 + 24 + 4 = 98

• (iii) The total is then divided by 11 and the remainder, if any, is subtracted from 11 to give the check digit.

• 98 ÷ 11 = 8 remainder 10

• 11 – 10 = 1

• This gives a check digit of “1”

• Final ISBN becomes“0 -2 0 1 - 5 3 0 8 2 –1”

15

Page 16: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Check Digit

Example 2

• To check the correctness of a check digit the computer re-calculates it as follows:

• The ISBN to check is: 0 - 1 3 1 5 - 2 4 4 7 - X

• (i) The position of each digit is considered:

• 10 9 8 7 6 5 4 3 2 1 ← digit position

• 0 -1 3 1 -5 2 4 4 7 -X ← number

• (ii) Each digit is then multiplied by its digit position and the totals added together

• (0x10) + (1x9) + (3x8) + (1x7) + (5x6) + (2x5) + (4x4) + (4x3) + (7x2) + (Xx1)

• = 0 + 9 + 24 + 7 + 30 + 10 + 16 + 12 + 14 + 10 (recall that X = 10) = 132

• (iii) The total is then divided by 11; if there is no remainder then the check digit is correct:

• 132 ÷ 11 = 12 remainder 0

• Hence the check digit is correct

16

Page 17: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Types of errors that Check Digit can identify

•Check digits can identify 3 types of error:

• (1) if 2 digits have been inverted

• e.g. 2 3 4 5 9 instead of 2 3 5 4 9

• (2) an incorrect digit entered

• e.g. 2 3 5 5 9 instead of 2 3 5 4 9

• (3) a digit completely missed out

• e.g. 2 3 5 9 instead of 2 3 5 4 9

17

Page 18: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Homework 1

There are various methods used to detect errors that can occur during data transmission and storage.

Describe each of the following error detection methods.

Parity check --------------------------------------------------------------------------------------

Check digit -----------------------------------------------------------------------------------------

Checksum ------------------------------------------------------------------------------------------

Automatic Repeat request (ARQ) ------------------------------------------------------------

18

Page 19: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Homework 2

The contents of three binary registers (A, B and C) have been transmitted from one computer to another. Even parity has been used as an error detection method.

The outcome after transmission is:

Register A and Register C have been transmitted correctly.

Register B has been transmitted incorrectly.

Complete the Parity bit for each register to show the given outcome.

19

Page 20: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

Homework 3

Computer Science Workbook

Page 14 Question 4 a, b, c

Textbook (Williams)

Chapter 2 Activity 2.2 – 2.3

20

Page 21: Error Detection and Correction - WordPress.com · 2020. 4. 9. · Check Digit Example 2 •To check the correctness of a check digit the computer re-calculates it as follows: •The

21