Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
Checksum
3.
Working of Checksum
3.1.
Sender's Side
3.2.
Data Transmission
3.3.
Receiver's Side
4.
Example
5.
Advantages of Checksum
6.
Disadvantages of Checksum
7.
Frequently Asked Questions
7.1.
What is the checksum?
7.2.
What are the advantages of using checksum?
7.3.
What is the main difference between single-bit error and burst error?
7.4.
What is the difference between the Checksum and the CRC?
7.5.
What are the two ways of handling error correction?
8.
Conclusion
Last Updated: Mar 27, 2024

What is Checksum

Author Sagar Mishra
0 upvote
Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

Introduction

Hey Ninjas! We know the importance of errors in coding. It can lead to many mistakes in the output. Error detection techniques came into existence to handle these kinds of issues. Checksum is one of the methods of error detection in computer networks.

what is checksum

In this blog, we will discuss the topic of Checksum in detail. Let's start.

Checksum

Let's first decode the meaning of Checksum. The name itself says that Checksum means it will check the sum. A checksum is a value that denotes the number of bits in a message. DevOps use it to detect any high-level errors with data transmissions sent by the sender.

The checksum is used to identify the damage or loss to the data at the time of transmission. The sender uses a Checksum generator to calculate the checksum, and the receiver uses the checksum checker.

Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

Working of Checksum

The complete process of checking whether there is a loss of message or not occurs at both sender's and receiver's side. We will start from the sender's side.

Sender's Side

At the sender's side, the following steps take place:

  1. Break the message into 'k' number of blocks and 'n' bit for each block.
     
  2. Add all the 'k' data blocks.
     
  3. Suppose, while adding, you encountered a carry, add it to the sum of the 'k' data blocks.
     
  4. To get the checksum, do the 1's complement.

Data Transmission

  1. The calculated checksum will be merged with the original data/message.
     
  2. The process of sending the message to the receiver starts.

Receiver's Side

  1. Break the bits of the message received from the sender into the 'k' number of blocks.
     
  2. Now add all the blocks along with the checksum.
     
  3. Perform the 1's complement to the result.
     
  4. Now, there are two conditions:

    1. If the result is 0, the message has no loss/ error.
       
    2. If the result is not 0, the message has a loss/error.

Example

Let's take an example to understand the process in a better way. Suppose we have 10011001 11100010 00100100 10000100.

Step 1: Let's break it into blocks of size 8-bit. 

step 1

Step 2: Now, we will add all the blocks together using the binary addition rule.

        1  0  0  1  1  0  0  1       (Block 1)

        1  1  1  0  0  0  1  0       (Block 2)

        0  0  1  0  0  1  0  0       (Block 3)

        1  0  0  0  0  1  0  0       (Block 4)

———————————————

1  0  0  0  1  0  0  0  1  1        


As you can see, we have a carry in the above step, so we have to wrap the carry in the resultant sum. Let go.

        0  0  1  0  0  0  1  1     

                                1  0     

   ——————————

        0  0  1  0  0  1  0  1


Step 3: Now, we will perform the 1's complement.

        0  0  1  0  0  1  0  1

         ————————————

        1  1  0  1  1  0  1  0        (Checksum)
 

Step 4: The sender will attach this checksum value to the original message but in a different block, as shown below.

Step 4

Now, this message will be sent to the receiver along with the checksum. This is the receiver's responsibility to check if there are errors in the message. To do so, the receiver follows the below steps.

Step 5: At the receiver's end, the receiver will collect the message and perform the binary addition to all the bits present in the message along with the checksum.

        1  0  0  1  1  0  0  1       (Block 1)

        1  1  1  0  0  0  1  0       (Block 2)

        0  0  1  0  0  1  0  0       (Block 3)

        1  0  0  0  0  1  0  0       (Block 4)

        1  1  0  1  1  0  1  0       (Checksum)

   ——————————————

1  0  1  1  1  1  1  1  0  1  


Again, there is a carry, so we will again wrap the carry in the next step.

        1  1  1  1  1  1  0  1 

                                1  0  

   —————————————

        1  1  1  1  1  1  1  1


Step 6: The receiver will again do the 1's complement.

        1  1  1  1  1  1  1  1

   ————————————

        0  0  0  0  0  0  0  0         (1's complement)
 

Step 7If the result is 0, the message has no loss/ error. Hence, there is no error in this message.

Advantages of Checksum

Let's discuss some of the advantages of using the checksum.

  • The checksum detects all the errors involving an odd number of bits.
     
  • It detects most of the errors involving an even number of bits.
     
  • It also verifies the identity and file source by verifying the checksum values.

Disadvantages of Checksum

Now, we will discuss some of the disadvantages of using the checksum.

  • Using checksum can be a difficult process.
     
  • It takes some extra time to verify checksum values.
     
  • The checksum process can be fooled by the parties who can manipulate the checksum values.

Frequently Asked Questions

What is the checksum?

Checksum is an error detection technique that is used to identify the damage or loss to the data at the time of transmission. 

What are the advantages of using checksum?

The checksum detects all the errors involving an odd and even number of bits. It also verifies the identity and file source by verifying the checksum values.

What is the main difference between single-bit error and burst error?

In a single-bit error, only one bit of a data block is changed from 1 to 0 or 0 to 1. In burst error, two or more bits of a data block are changed from 0 to 1 or 1 to 0.

What is the difference between the Checksum and the CRC?

The difference between them is checksum can detect a single-bit change in the data, while the CRC can detect double digits errors.

What are the two ways of handling error correction?

Error correction is handled in two ways: Forward error correction and Backward error correction.

Conclusion

This article discusses the topic of What is Checksum in detail. We have seen the definition, working, sample example, and pros and cons of the Checksum.

We hope this blog has helped you enhance your knowledge of the What is Checksum. If you want to learn more, then check out our articles.

And many more on our platform Coding Ninjas Studio.

Refer to our Guided Path to upskill yourself in DSACompetitive ProgrammingJavaScriptSystem Design, and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio!

But suppose you have just started your learning process and are looking for questions from tech giants like Amazon, Microsoft, Uber, etc. In that case, you must look at the problemsinterview experiences, and interview bundles for placement preparations.

However, you may consider our paid courses to give your career an edge over others!

Happy Learning!

Previous article
Complements
Next article
Fixed and Floating-Point Representation
Live masterclass