Checksum
Checksum
It uses Checksum generator on the sender side and Checksum checker on the
receiver side to check the errors.
Example:
Number of messages transmitted: 2
Elements to calculate Checksum:
1011
1110
****SENDER SIDE****
SUM IS: 2121
CHECKSUM IS: 2122
****RECEIVER SIDE****
SUM IS: 2121
CHECKSUM IS: 0
Testcase 1: In this case, we enter “2” as the length of the string and “1011” and
“0111” as array elements to calculate the checksum.
1011
0111
****SENDER SIDE****
CHECKSUM IS:1123
****RECEIVER SIDE****
SUM IS:1122
CHECKSUM IS:0
Testcase 2: In this case, we enter “4” as the length of the string and
“10110101”, “11000111”, “01101100” and “00001111” as array elements to
calculate the checksum.
10110101
11000111
01101100
00001111
****SENDER SIDE****
CHECKSUM IS:22212424
****RECEIVER SIDE****
SUM IS:22212423
CHECKSUM IS:0
1. Error-correcting code
A code used in digital communications to detect and correct errors parallelly
that occur during data transmission.
2. Redundant bits
The extra bits added to a message to enable error detection and correction.
Hamming code uses redundancy to detect and correct errors in transmitted
messages
To calculate redundant bits, we can use the expression
2r>=d+r+1, here d = data bits and r = redundant bits
4. Parity bit
An extra bit added to a message to check for errors. The number of 1s in the
message finds the parity bit's value.
Parity bits are of two types
Odd parity: Here, the count of 1's should be odd
Even Parity: Here, the count of 1's should be even
5. Single-bit error
An error that occurs when only one bit of a message is incorrect. Hamming
code can detect and correct single-bit errors.
6. Hamming distance
Hamming distance is the count of the number of bit positions in which two code
messages differ. Hamming distance is used to find the minimum number of
parity bits required for error detection and correction
7. Generator matrix
A matrix used to generate the parity bits for a Hamming code. The generator
matrix calculates the parity bits for a given code word.
8. Check matrix
A matrix used to check for errors in a Hamming code. The check matrix
calculates the syndrome for a given received message.
9. Burst error
An error that occurs when multiple bits in a message are incorrect. Hamming
code is not able to correct burst errors. It only detects them.
Examples of Hamming Code in Computer Networks
Generation of hamming Code
Suppose we have a 4-bit message that we want to transmit: 111011. Now
we apply the above steps in this hamming code example.
To calculate the parity bits, we use the formula,
As the number of 1's at all bit positions corresponding to r1 is odd, the value of
r1=1
Similarly, we calculate r2 with the help of a parity check. The positions are
identified by selecting only those bit indexes whose binary form includes a
1 in the 2nd index from the least significant bit. Thus the bit positions are 2,
3, 6, 7, and 10, and the corresponding value for r2=1, considering even
parity.
Similarly, for r3: The positions are identified by selecting only those bit
indexes whose binary form includes a 1 in the 3rd index from the least
significant bit. Bit positions are 4, 5, 6, and 7 with the value of r4=0 to
satisfy even parity.
For r4: The positions are identified by selecting only those bit indexes
whose binary form includes a 1 in the 4th index from the least significant
bit. Bit positions are 8, 9 and 10 with the value of r8=0 to satisfy even
parity.
Now putting all the parity bit values in the message, we get the Hamming
code as 1110110011 for this hamming code example.