Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Error-Detecting Codes - Checksums
When bits are transmitted over the computer network, they are subject to get corrupted due to interference and network problems. The corrupted bits lead to spurious data being received by the receiver and are called errors.
Error detection techniques are responsible for checking whether any error has occurred in the frame that has been transmitted via network. They do not determine the number of error bits or the type of error, but simply detect the presence of corruption.
For error detection, the sender needs to send some additional redundant bits along with the data bits. The receiver performs necessary checks based upon these additional bits. If it finds that the data is free from errors, it removes the redundant bits before passing the message to the upper layers.
There are three main techniques for detecting errors in frames: Parity Check, Checksum, and Cyclic Redundancy Check (CRC).
What is a Checksum?
A checksum is a block code method where a checksum value is created based on the data values in the data blocks to be transmitted using a specific algorithm and appended to the data. When the receiver gets this data, a new checksum is calculated and compared with the existing checksum. A non-match indicates an error has occurred during transmission.
How Checksum Works
For error detection by checksums, data is divided into fixed-sized frames or segments and processed using 1's complement arithmetic:
-
Sender's End − The sender adds all the segments using 1's complement arithmetic to get the sum. It then complements the sum to get the checksum and sends it along with the data frames.
-
Receiver's End − The receiver adds the incoming segments along with the checksum using 1's complement arithmetic to get the sum and then complements it.
If the final result is zero, the received frames are accepted; otherwise they are discarded as corrupted.
Example
Suppose the sender wants to transmit 4 frames of 8 bits each: 11001100, 10101010, 11110000, and 11000011.
Step 1: Add frames using 1's complement arithmetic 11001100 + 10101010 ----------- 01110110 (carry = 1) + 00000001 (add carry) ----------- 01110111 + 11110000 ----------- 01100111 (carry = 1) + 00000001 (add carry) ----------- 01101000 + 11000011 ----------- 00101011 (carry = 1) + 00000001 (add carry) ----------- 00101100 Step 2: Complement the sum to get checksum Sum = 00101100 Checksum = 11010011
The sender transmits the data frames along with the checksum 11010011.
At the receiver end, all frames including the checksum are added using 1's complement arithmetic. The result is complemented and found to be 00000000. Since the result is zero, the receiver assumes no error has occurred.
Advantages and Limitations
| Advantages | Limitations |
|---|---|
| Simple to implement and understand | Cannot detect all types of errors |
| Low computational overhead | Cannot correct errors, only detect them |
| Works well for random single-bit errors | May miss errors in specific bit patterns |
Conclusion
Checksums provide a simple and efficient method for error detection in network communications using 1's complement arithmetic. While they cannot correct errors or detect all error patterns, they offer a good balance between simplicity and effectiveness for many networking applications.
