Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; SEOFriendlyImages has a deprecated constructor in /home/tutorig3/public_html/wp-content/plugins/seo-image/seo-friendly-images.class.php on line 2

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /home/tutorig3/public_html/wp-content/themes/mts_interactive/options/php-po/php-po.php on line 185
Checksum Error Detection Tutorial With Example - Tutorialwing

# Checksum Error Detection Tutorial With Example

In the previous tutorial, we studied about the parity check scheme of error detection. Here, we will continue studying the error detection techniques. So, we will study about checksum error detection method.

## What is a Checksum?

It is a count of the no of bits in a transmission unit that is included with the unit so that the receiver can check to see whether the same numbers of bits have arrived. If the counts match, it’s assumed that the complete transmission was received. if not, an error is detected.

### 1. How to Calculate Checksum?

Now, we will see how to calculate checksum at sender and receiver side.

##### At the sender side
• Divide data into K chunks of n bit each.
• Take the compliment of the result.
• Result will be sent with the data as a checksum.

1’s Complement addition: If the result has a carry bit add carry with LSB (Least Significant Bit) of the result.

Let’s take an example to understand it.

Suppose data is 01110011, we divide the data into 4 bit chunks. So, n = 4. Since total number of digits in data is 8. So, there will be 2 chunks of data ( 0111 and 0011 ).

0 1 1 1
0 0 1 1
———
1 0 1 0
———
Result (1010) has no carry bit. Now, take 1’s compliment. It will be 0101. So, checksum = 0101.
The data that will be sent = 011100110101

Note – If result has carry bit(s) after addition, it is simply discarded.

Now, after receiving data from sender, receiver will divide the data into n bit chunks. Note that there is also checksum appended with data. So, there will be K + 1 chunks.

• Then, take the compliment of the result.
• If all the bits in result is 0, then, accept the data.
• Else, discard the data because there is an error.

In previous example, the sender sent 011100110101. Also, data were divided into 4 bits chunk.

So, after receiving result, the result will be divided into chunks of 4 bit. So, chunks will be 0111, 0011 and 0101.

Adding all chunks using 1’s complement –

0 1 1 1
0 0 1 1
0 1 0 1
————–
1 1 1 1
————–
Now, taking the compliment of the result(1111), we will get 0000. So, there is no error.

### 2. Checksum using Decimal Digits

Now, we will see about checksum error detection technique using decimal digits. At first, we will see how to calculate checksum using decimal digits. Then, use it to detect error during transfer.

As we know,
Code word: Data bits appended with checksum.

Here, we will divide the data into different chunks of 2 digits. Then, we will add these chunks.

##### At Sender Side:

Suppose sender wants to send the data 713093 to receiver. Then, we will first the divide the data into chunks of 2 digits. So, chunks will be 71, 30 and 93. The result is of 2 digits. So, take the maximum number created using 2 digits i.e. 99.
Now, we will subtract the result from 99. Subtract result from 99

Checksum is 04. So, append the checksum with data to create codeword. Thus, code word is 71309304. Now, we will send this code word to receiver.

Now, we will divide the data into chunks of 2 digits. So, chunks will be 74, 33, 93 and 04.

Leaving the checksum part(04), Adding other chunks – Now, subtract the result from highest 2 digit number (i.e. 99). Difference from highest 2 digit number

Note that checksum calculated is 97. But, we received checksum 04. So, there is an error in the code word we received. Hence, it will be discarded.

### 3. Drawback of Checksum

We have seen how to perform checksum error detection. Now, we will see what are the drawbacks of checksum –

• Vertical bit errors can not be detected.

Let’s take an example to understand what vertical bits are –

Suppose sender wants to send 713093. So, it will divide the data into chunks of 2 digits. Then, add these chunks. Now, subtract the result from highest 2 digit number i.e. 99. So, Subtract from highest 2 digit number

We got 04 as checksum. So, codeword will be 71309304. This will be sent to receiver.

Now, dividing the data into chunks of 2 digits, it will be 74, 30, 90 and 04.

Leaving checksum (04) and adding other chunks – Subtracting the result from highest 2 digit number – Subtracting from 2 digit number

Thus, there is a mismatch in the received code word. But, since the checksum is calculated to be same in both. The error is not detected in the received message.

Thus, if the noise modifies the data in such a way that the vertically placed bits cancel each other and the calculated checksum is equal to the received checksum, such errors cannot be detected. These are known as vertical bits.

### 4. Performance of Checksum

Till now, we have seen different examples of checksum error detection technique. Now, we have a clear about what a checksum is.

Now, we will go through performance of checksum error detection –

• Detects all errors involving an odd number of bits as well as most errors involving an even number of bits.
• However, if one or more bits of a segment are damaged and the corresponding bit or bits of opposite value in a second segment are also damaged, the sum of those columns will not change and the receiver will not detect an error.

Thus, we studied about the checksum error detection scheme. In the incoming tutorial, we will learn about the Code Redundancy check.