0% found this document useful (0 votes)
7 views

Lecture 10

The document discusses Hamming codes, which are linear block codes used for error correction. It defines key terms like code rate and Hamming distance. It explains that Hamming codes use specific bit positions as check bits, and that the values of the check bits can be used to detect and correct single bit errors.

Uploaded by

Ayush
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lecture 10

The document discusses Hamming codes, which are linear block codes used for error correction. It defines key terms like code rate and Hamming distance. It explains that Hamming codes use specific bit positions as check bits, and that the values of the check bits can be used to detect and correct single bit errors.

Uploaded by

Ayush
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Error Correction: Hamming codes

• A frame consists of m data (i.e., message) bits and r redundant (i.e. check) bits.
• In a block code
• the r check bits are computed solely as a function of the m data bits with which they are associated
• In a systematic code
• the m data bits are sent directly, along with the check bits, rather than being encoded themselves
before they are sent.
• In a linear code
• the r check bits are computed as a linear function of the m data bits.
• Let the total length of a block (codeword) be n (i.e., n = m + r).
• This is referred to as an (n,m) code.
• An n-bit unit containing data and check bits is referred to as an n bit codeword
• The code rate, or simply rate
• is the fraction of the codeword that carries information that is not redundant, or m/n
• They might be 1/2 for a noisy channel, in which case half of the received information is redundant
• or close to 1 for a high-quality channel, with only a small number of check bits added to a large
message.
Error Correction: Hamming codes
• Given any two codewords that may be transmitted or received—say, 10001001 and 10110001
• it is possible to determine how many corresponding bits differ.
• To determine how many bits differ
• just XOR the two codewords and count the number of 1 bits in the result

• Hamming distance: 10001001 <convert from one to the other using 3 sing bit changes> 10110001
• The number of bit positions in which two codewords differ is called the Hamming distance
• Significance:
• if two codewords are a Hamming distance d apart, it will require d single-bit errors to convert one into
the other.
• In most data transmission applications, all 2m possible data messages are legal
• but due to the way the check bits are computed, not all of the 2n possible codewords are used.
• when there are r check bits, only the small fraction of 2m /2n or 1/2r of the possible messages will be legal
codewords.
• It is the sparseness with which the message is embedded in the space of codewords that allows the receiver
to detect and correct errors -> very unlikely that multiple errors in a codeword will change the codeword
into another valid codeword
Example
n=4 To correct single bit error
0000
0001
0010
m=3
0011
000 0100 Example codewords (with distance = 2):
001 0101 0000, 0101, 0110 …
010 0110
011 0111 0000 -> (1 bit error) -> 0100 -> (1 bit error) -> 0101
100 1000
101 1001 Example codewords (with distance = 3):
110 1010 0000, 0111, …
111 1011
1100 0000 -> (1 bit error) -> 0100 -> (1 bit error) -> 0101 -> (1 bit error) -> 0111
1101
1110
1111

Not all will be legal/valid codewords


Error Correction: Hamming codes
• To ‘reliably’ detect d errors
• you need a distance d + 1 code
• (i.e, two codewords should differ by d+1 bits)
• because with such a code there is no way that d single-bit errors can change a valid codeword into another
valid codeword.
• When the receiver sees an illegal codeword, it can tell that a transmission error has occurred.
• to correct d errors
• you need a distance 2d + 1 code
• (i.e, two codewords should differ by 2d+1 bits)
• because that way the legal codewords are so far apart that even with d changes the original codeword is
still closer than any other codeword.
• Suppose we want to design a code with m message bits and r check bits that will allow all single errors to be
corrected. Given m, what is the lower limit (minimum) on the number of check bits needed to correct single
errors?
• Each of the 2m legal messages has n illegal codewords at a distance of 1 from it. (Why??)
• These are formed by systematically inverting each of the n bits in the n-bit codeword formed from it.
• Thus, each of the 2m legal messages requires n + 1 bit patterns (itself and the other n illegal codewords at
a distance of 1 from it) dedicated to it -> that can be concluded that it is original message.
• Since the total number of bit patterns is 2n, we must have (n + 1)2m <= 2n.
• Using n = m + r, this requirement becomes
Error Correction: Hamming codes
• Hamming codes the bits of the codeword are numbered consecutively, starting with bit 1 at the
left/right end, bit 2 to its immediate right/left, and so on.
• The bits that are powers of 2 (1, 2, 4, 8, 16, etc.) are check bits.
• The rest (3, 5, 6, 7, 9, etc.) are filled up with the m data bits.
Error Correction: Hamming codes
• Suppose the original data/message is 1010 which is to be sent.
• Total number of data/message bits ‘m' = 4
• Number of redundant bits r : 2r >= m+r+1
• 2r >= 4+r+1
• Therefore, the value of r is 3 that satisfies the above relation. Total number of bits = m+r = 4+3 = 7;
• Determining the position of the redundant bits
• The number of redundant bits is 3
• The three bits are represented by r1, r2, r4.
• The position of the redundant bits is calculated with corresponds to the raised power of 2.
• their corresponding positions are 1, 21, 22
• The position of r1 = 1, the position of r2 = 2 , the position of r4 = 4
Error Correction: Hamming codes
• Determining the Parity bits
• Determining the Parity bits
• Determining r2 bit
• Determining the r1 bit:
• The r1 bit is calculated by performing a parity check • The r2 bit is calculated by performing a parity check on
on the bit positions whose binary representation the bit positions whose binary representation includes 1
includes 1 in the first position. in the second position

• the bit position that includes 1 in the first position • the bit positions that includes 1 in the second position are
are 1, 3, 5, 7. 2, 3, 6, 7.
• We perform the even-parity check at these bit • we perform the even-parity check at these.
positions. • The total number of 1 at these bit positions
• The total number of 1 at these bit positions corresponding to r2 is odd, therefore, the value
corresponding to r1 is even, therefore, the of the r2 bit is 1.
value of the r1 bit is 0.
Error Correction: Hamming codes
• Determining the Parity bits
• Data transferred
• Determining the r4 bit:
• The r4 bit is calculated by performing a parity check
on the bit positions whose binary representation
includes 1 in the third position.

• Error: Assume the 4th bit (check bit) is changed


from 0 to 1 at the receiving end
• Parity bits/check bits are recalculated at the
receiving end.

• the bit positions that includes 1 in the third position


are 4, 5, 6, 7.
• We perform the even-parity check at these bit
positions.
• The total number of 1 at these bit positions
corresponding to r4 is even, therefore, the
value of the r4 bit is 0.
Error Correction: Hamming codes
Sent

Received 1 0 1 1 0 1 0 Error in 4th bit

Recalculation of Parity bits at the receiving end and compare with the received parity bits

r1 = 0 (recalculation), 0 (received) r2 = 0 (recalculation), 1 (received) r4 = 1 (recalculation), 1 (received)

If r4r2r1 is 000, then no error


else, decimal representation of r4r2r1 (i.e., 100 = 4) gives you
the bit position where the error is

You might also like