Implementing Checksum using Python
The checksum is a kind of error Detection method in Computer Networks. This method used by the higher layer protocols and makes use of Checksum Generator on the Sender side and Checksum Checker on the Receiver side. In this article, we will be implementing the checksum algorithm in Python.
Refer to the below articles to get detailed information about the checksum
Steps to implement the algorithm.
Step 1: Generate Checksum ( Sender Side )
- The message is divided into 4 sections, each of k bits.
- All the sections are added together to get the sum.
- The sum is complemented and becomes the Checksum.
- The checksum is sent with the data.
Step 2: Checksum Checker ( Receiver Side )
- The message is divided into 4 sections of k bits.
- All sections are added together to get the sum.
- The generated checksum is added to the sum of all sections.
- The resulting sum is complemented.
After following these steps, if the checksum of receiver side and the checker side are added and complemented and the result is equal to zero, the data is correct and is therefore accepted. Otherwise, an error is detected and the data is rejected.
Below is the implementation of the above approach:
SENDER SIDE CHECKSUM: 10000101 RECEIVER SIDE CHECKSUM: 01111010 Receiver Checksum is equal to 0. Therefore, STATUS: ACCEPTED