# Checksum Algorithm in Networking

__Checksum Algorithm:__

The **Checksum** is an error-detecting method that is applied to the higher layer protocols. In this technique, the generator subdivides the data unit into equal segments of n bits. These segments are added using 1’s complement method in a way such that the result is also n-bit long. The sum is then 1’s complemented and appended to the data unit as redundant bits that are called the **Checksum field**.

The receiver subdivides the data unit into segments of n bits. The segments are then added using 1’s complement method such that the result is n bit long. The result is then 1’s complement. If it is zero then the data unit is correct, otherwise, there must be some error within it.

## Steps of Checksum generation:

1. Data unit is divided into k-segments, each having n-bits.

2. All segments are added using 1’s complement method to get the sum having n-bits.

3. The sum is 1’s complemented and that is called Checksum.

4. the checksum is appended at the end of the data unit and is finally transmitted.

## Steps of Checksum detection:

1. Data unit is divided into k-segments each having n bits.

2. All segments and the checksum are added using 1’s complement method to get the sum having n-bits.

3. The sum is 1’s complemented to get the result.

4. If the result is zero then the data is accepted otherwise, the data is rejected assuming that the error has been introduced.