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 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: 0001001 Receiver Checksum is not equal to 0. Therefore, STATUS: ERROR DETECTED
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course