# Error Detection

There is always the chance that data has been corrupted (changed in some way) during transmission.

This is true regardless of the distance of transmission.

To avoid having corrupted data it is really important that computers check for errors and correct them wherever possible.

There are several methods of error checking, with some being more effective than others.

## Parity Check

An extra bit (parity bit) added to a string of binary code to ensure the number of 1-bits are either even or odd, depending upon the parity check system used.

Method

1. The sending and receiving computers agree the protocol to be used (even or odd)
2. The sending computer adds the correct parity bit to the binary data (either an extra 1 or 0)
3. The sending computer sends the binary data, including the parity bit
4. The receiving computer checks to make sure the overall parity of the data received is as agreed (an even or odd number of 1 bits)
5. If the parity of the data is incorrect, the receiving computer will request that the data is transmitted again

Drawbacks of parity checks

• If two bits are transposed (change places) then the computer could be fooled into thinking the data is correct and not corrupted
• If two random bits change state then the system could also be fooled

### Parity Block

This method of error checking is similar to a traditional parity check except the data is arranged in a virtual table with parity bits added to each row and column.

A single corrupted bit can be spotted at the intersection of a corrupted row and column.

Multiple corrupted bits would also flaw this system.

## Checksum

A block of data is sent alongside a calculated checksum value.

The receiving computer also calculates what it believes should be the checksum.

The checksum values are then compared to see if an error has occurred during transmission.

Method

1. The sending computer uses the block of data to be sent, and a predefined mathematical algorithm, to calculate a checksum value
2. The sending computer sends the data, plus the checksum value
3. The receiving computer uses the data it receives to also calculate what it believes should be the checksum, using the same mathematical algorithm
4. The two checksum values are compared by the receiving computer
5. Due to the nature of the algorithm, it is highly unlikely that corruption has occurred if the checksum values match
6. If the checksum values don’t match, the receiving computer requests that the data is transmitted again

## Check Digit

A check digit is the final digit in a code of numbers.  It is calculated from all the other digits in the code.  It’s purpose is to spot human errors on data entry.

Check digits are often found in barcodes, product codes or ISBN book numbers.

There are many different mathematical algorithms that can be used to calculate a check digit.  Different industries will have their own preferred method.

Method

1. The check digit is calculated and added to the barcode, packaging, product code etc at the point of manufacture
2. A human types the long numerical code into a computer, e.g. the cashier will type the barcode number when a scanner fails or packaging is damaged
3. The computer calculates what it believes should be the check digit, based on the numbers entered by the human
4. The computer then compares it’s calculated check digit with the check digit typed in by the human (the last digit in the long code)
5. If the two don’t match, then the human has made an error when typing in the numerical code, e.g. barcode number
6. The human will be asked by the computer to re-enter the numerical code

Benefits

Good for spotting human errors such as:

• Incorrect digit entered
• Transposition error (two numbers change order)
• Omitted digit or extra digit

## Automatic Repeat ReQuests (ARQ)

This form of error detection uses a system of acknowledgements and timeouts. Automatic Repeat ReQuests are often used to ensure reliable transmissions over an unreliable service.

Acknowledgements are messages sent from a receiving device back to the original sending device.

The acknowledgement can be negative or positive.

A positive acknowledgement means that the data was received and it passed an error check.

A negative acknowledgement means that the data was received but it cannot be used as it failed an error check.  It needs to be sent again.

The timeout is a predetermined period of time that the sending device will wait to get some form of acknowledgement for the data it sent.

If no acknowledgement is received after the timeout, the device will sent the data again.  This continues automatically until an acknowledgement is received, or the maximum number of re-sends occur.

Method

1. The sending computer transmits a block of data
2. The sending computer waits a period of time to see if the receiving computer acknowledges receipt of the data
3. After no acknowledgement for a set period of time, a timeout occurs which triggers the data to be automatically resent by the sending computer
4. This will continue until the receiving computer acknowledges the data has been received, or a max number of re-sends occurs

## Echo Check

With an echo check, the receiving computer sends a copy of the data immediately back to the sending computer for comparison.

The sending computer compares the two sets of data to check if any errors occurred during the transmission process.

If an error has occurred, the data will be transmitted again.

Drawback of echo checks

• If the two sets of data are different you will have no way of knowing whether the error occurred when originally sent, or when it was sent back
• Echo checks require a lot of extra data to be transmitted

Test your knowledge of error detection with our quick quiz.