Checksum

is a simple method of detecting errors in data

Created by

Poliana Belo

Priscylla Silva / @killpiu

Psycho Mantys / @psycho_mantys

Checksum Definition

A checksum is a simple type of redundancy check that is used to detect errors in data.

Redundancy Check Definition

A redundancy check is a number that is calculated from a file or a segment thereof and then appended to that file or segment for the purpose of comparing with a recalculation by another computer or at a later date in order to detect and correct errors that might occur during any phase of the storage or transmission of the file or segment.


The most simple types of redundancy checks are checksums.

Overview

Errors frequently occur in data when:

  • it is written to a disk
  • it is transmitted across a network
  • or otherwise manipulated

Why use methods for error detection?

The errors are typically very small, for example, a single incorrect bit, but even such small errors can greatly affect the quality of data, and even make it useless.

Example of use

IP, TCP and UDP protocols

Message

Checksum Algorithm

The sender follows these steps:

  • The unit is divided into "K" sections, each of "N" bits.
  • All sections are added.
  • The sum is complemented and becomes the checksum.
  • The checksum is sent with the data.

The receiver follows these steps:

  • The unit is divided into "K" sections, each of "N" bits.
  • All sections are added to get the sum.
  • The sum is complemented.
  • If the result is zero, the data are accepted.

Example 1/2

Suppose the following block of 16 bits is to be sent using a checksum of 8 bits.

10101001   00111001

The numbers are added 
                           10101001    
                           00111001
                       -------------
Sum	                   11100010
Checksum                   00011101        ; complemented

The pattern sent is 10101001 00111001 00011101

Example 2/2

Now suppose the receiver receives the pattern sent in is:

10101001   00111001   00011101

When the receiver adds the three sections, it will get all 1s, which, after complementing, is all 0s and shows that there is no error.

 
			10101001
			00111001    
			00011101 
Sum		        11111111  
Complement              00000000  

Means that the pattern is OK.

Advantages and Disadvantages

Advantages

  • The main advantages relate to the size and ease of computation (in the form of processor time and bandwidth).
  • Most networks that employ this technique uses a checksum of 16 or 32 bits and generates a single checksum for an entire package.

Disadvantages

  • The checksum has the disadvantage of not detecting all common mistakes.
  • Among the types of errors that cannot be detected by simple checksum algorithms are:
    • Reordering of the bytes.
    • Inserting or deleting zero-valued bytes.
    • Multiple errors that cancel each other out.

Example of error that cannot be detected

Example of a checksum can fail to detect transmission errors: Invert the value of the second bit of each data item produces the same checksum.

Example of Error

THE END

By
Poliana Belo
Priscylla Silva / @killpiu
Psycho Mantys / @psycho_mantys

Begin