Haming
Haming
Haming
January 2021
Page -2
TABLE OF CONTENTS
STRING
STRING
ASCII
HAMMING CODE
ABSTRACT
REDUNDANT
Parity bits .............................................................................................
Determining the position of redundant bits
Determining the Parity bits ...................................................................
ERROR DETECTION AND CORRECTION
CODE IMPLEMENTATION IN JAVA
STRING PART:
STRING PART:
CONCLUSION
String
Page -3
ASCII:
ASCII abbreviated from American Standard Code for Information
Interchange, is a character encoding standard for electronic
communication. ASCII codes represent text in computers,
telecommunications equipment, and other devices. Most modern
character-encoding schemes are based on ASCII, although they
support many additional characters.
Hamming Code
Abstract
The Hamming code is a well-known error correction code and can
correct a single error in an input vector of size n bits by adding
logn parity checks. A new parallel implementation of the code is
presented, using a hierarchical structure of n processors in logn
layers. All the processors perform similar simple tasks, and need
only a few bytes of internal memory.
Redundant bits
Redundant bits are extra binary bits that are generated and added
to the information-carrying bits of data transfer to ensure that no
bits were lost during the data transfer.
The number of redundant bits can be calculated using the
following formula:
2^r ≥ m + r + 1
where, r = redundant bit, m = data bit
Suppose the number of data bits is 7, then the number of
redundant bits can be calculated using:
= 2^4 ≥ 7 + 4 + 1
Thus, the number of redundant bits= 4
Parity bits
In the case of even parity, for a given set of bits, the number of
1’s are counted. If that count is odd, the parity bit value is set to
1, making the total count of occurrences of 1’s an even
number. If the total number of 1’s in a given set of bits is
already even, the parity bit’s value is 0.
2. Odd Parity bit:
In the case of odd parity, for a given set of bits, the number of
1’s are counted. If that count is even, the parity bit value is set
to 1, making the total count of occurrences of 1’s an odd
number. If the total number of 1’s in a given set of bits is
already odd, the parity bit’s value is 0.
To find the redundant bit R1, we check for even parity. Since
the total number of 1’s in all the bit positions corresponding to
R1 is an even number the value of R1 (parity bit’s value) = 0
To find the redundant bit R2, we check for even parity. Since
the total number of 1’s in all the bit positions corresponding to
R2 is odd the value of R2(parity bit’s value) =1
To find the redundant bit R4, we check for even parity. Since
the total number of 1’s in all the bit positions corresponding to
R4 is odd the value of R4(parity bit’s value) = 1
Page -9
To find the redundant bit R8, we check for even parity. Since
the total number of 1’s in all the bit positions corresponding to
R8 is an even number the value of R8(parity bit’s value) =0.
Thus, the data transferred is:
Page -10
‘
The bits give the binary number as 0110 whose decimal
representation is 6. Thus, the bit 6 contains an error. To correct
the error, the 6th bit is changed from 1 to 0.
Page -11
String part:
Given a string of character the task is to convert each character
of a string into the equivalent binary number.
For example:
Input: GFG
Output: 1000111 1000110 1000111
Input: geeks
Output: 1100111 1100101 1100101 1101011 1110011
Examples:
Page -12
Input:
message bit = 0101
r1 r2 m1 r4 m2 m3 m4
0 1 0 1
Output:
Generated codeword :
r1 r2 m1 r4 m2 m3 m4
0 1 0 0 1 0 1
Explanation:
Initially r1, r2, r4 is set to '0'.
r1 = xor of all bits position
which has '1' in its 0th-bit position
r2 = xor of all bits
which has '1' in its 1st-bit position
r3 = xor of all bits
which has '1' in its 2nd-bit position
Output:
Generated hamming code
r1 = 0
r2 = 1
r4 = 0
0100101
Page -13
Conclusion:
So in this article, we have seen how to convert a String to binary
bit data and the hamming code technique works for error
detection and correction in a data packet transmitted over a
network. The Hamming code is a well-known error-correcting
code.