The document discusses error correction techniques in computer networks, focusing on backward and forward error correction methods. It explains Hamming code, its application in detecting and correcting single-bit errors, and the calculation of redundant bits required for error correction. Additionally, it provides examples of encoding and error detection using Hamming code, emphasizing the importance of parity bits in ensuring data integrity.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
7 views
CN_CDT12
The document discusses error correction techniques in computer networks, focusing on backward and forward error correction methods. It explains Hamming code, its application in detecting and correcting single-bit errors, and the calculation of redundant bits required for error correction. Additionally, it provides examples of encoding and error detection using Hamming code, emphasizing the importance of parity bits in ensuring data integrity.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19
U18CS503 Computer Networks
Classroom Discussion Topic
W4 – L3-CDT12 Topic: Error Correction
Dr. Syed Abdul Moeed
Dept of CSE Kakatiya Institute of Technology and Science, Warangal, TS, India After completion of this lecture, students will be able to… LO1. understand the techniques in error correction ERROR CORRECTION • Error Correction codes are used to detect and correct the errors when data is transmitted from the sender to the receiver. • Error Correction can be handled in two ways: • Backward error correction: Once the error is discovered, the receiver requests the sender to retransmit the entire data unit. • Forward error correction: In this case, the receiver uses the error-correcting code which automatically corrects the errors. • A single additional bit can detect the error, but cannot correct it. • For correcting the errors, one has to know the exact position of the error. For example, If we want to calculate a single- bit error, the error correction code will determine which 51 one of bits is in error. To achieve this, we have to add some additional redundant bits. • Suppose r is the number of redundant bits and d is the total number of the data bits. The number of redundant bits r can be calculated by using the formula: 2r>=d+r+1 • The value of r is calculated by using the above formula. For example, if the value of d is 4, then the possible smallest value that satisfies the above relation would be 3.
• To determine the position of the bit which is in
error, a technique developed by R.W Hamming is Hamming code which can be applied to any length of the data unit and uses the relationship between data units and redundant units. • Parity bits: The bit which is appended to the original data of binary bits so that the total number of 1s is even or odd.
• Even parity: To check for even parity, if the total
number of 1s is even, then the value of the parity bit is 0. If the total number of 1s occurrences is odd, then the value of the parity bit is 1.
• Odd Parity: To check for odd parity, if the total
number of 1s is even, then the value of parity bit is 1. If the total number of 1s is odd, then the value of parity bit is 0. Algorithm of Hamming code:
• An information of 'd' bits are added to the
redundant bits 'r’ to form d+r.
• The location of each of the (d+r) digits is assigned a
decimal value.
• The 'r' bits are placed at the positions 20,21,22,23,24,25
....
• At the receiving end, the parity bits are recalculated.
The decimal value of the parity bits determines the position of an error. • Messages (frames) consist of m data (message) bits and r redundancy bits, yielding an n = (m+r)-bit codeword. • Hamming Distance. Given any two codewords, we can determine how many of the bits differ. Simply exclusive or (XOR) the two words, and count the number of 1 bits in the result. • Significance? If two codewords are d bits apart, d errors are required to convert one to the other. • A code's Hamming Distance is defined as the minimum Hamming Distance between any two of its legal codewords (from all possible codewords). Example • Suppose there are two strings 1101 1001 and 1001 1101. • 11011001 ⊕ 10011101 = 01000100. • Since, this contains two 1s, the Hamming distance, d(11011001, 10011101) = 2. HAMMING CODE • Hamming code is a set of error-correction codes that can be used to detect and correct bit errors that can occur when computer data is moved or stored. Hamming code is named for R. W. Hamming of Bell Labs. • The hamming code uses the number of redundant bits depending on the number of information bits in the message. • Let n be the number of information or data bits, then the number of redundant bits P is determined from the following formula 53 • For example, if 4-bit information is to be transmitted, then n=4. The number of redundant bits is determined by the trial and error method. • Let P=2, we get,
• The above equation implies 4 not greater than or equal
to 7. So let’s choose another value of P=3.
• Now, the equation satisfies the condition. So number of
redundant bits, P=3. • In this way, the number of redundant bits is selected for the number of information bits to be transmitted. Choosing the location of redundant bits • For the above example, the number of data bits n=4, and the number of redundant bits P=3. • So the message consists of 7 bits in total that are to be coded. Let the rightmost bit be designated as bit 1, the next successive bit as bit 2 and so on. • The seven bits are bit 7, bit 6, bit 5, bit 4, bit 3, bit 2, bit 1. • In this, the redundant bits are placed at the positions that are numbered corresponding to the power of 2, i.e., 1, 2, 4, 8,… • Thus the locations of data bit and redundant bit are D4, D3, D2, P3, D1, P2, P1. • Assigning the values to redundant bits • Now it is time to assign bit value to the redundant bits in the formed hamming code group. The assigned bits are called a parity bit. • Each parity bit will check certain other bits in the total code group. It is one with the bit location table, as shown below. 1--001 2--010 3--011 4--100 5--101 6--110 7--111 • Parity bit P1 covers all data bits in positions whose binary representation has 1 in the least significant position(001, 011, 101, 111, etc.). Thus P1 checks the bit in locations 1, 3, 5, 7, etc..
• Parity bit P2 covers all data bits in positions whose binary
representation has 1 in the second least significant position(010, 011, 110, 111, etc.). Thus P2 checks the bit in locations 2, 3, 6, 7, etc. • Parity bit P3 covers all data bits in positions whose binary representation has 1 in the third least significant position(100, 101, 110, 111, etc.). Thus P3 checks the bit in locations 4, 5, 6, 7, etc.
• Each parity bit checks the corresponding bit locations and
assign the bit value as 1 or 0, so as to make the number of 1s as even for even parity and odd for odd parity. Example2: Encode a binary word 11001 into the even parity hamming code. Given, number of data bits, n =5.
To find the number of redundant bits,
Let us try P=4.
The equation is satisfied and so 4 redundant bits are selected.
So, total code bit = n+P = 9 The redundant bits are placed at bit positions 1, 2, 4 and 8. Construct the bit location table. To determine the parity bits For P1: Bit locations 3, 5, 7 and 9 have three 1s. To have even parity, P1 must be 1. For P2: Bit locations 3, 6, 7 have two 1s. To have even parity, P2 must be 0. For P3: Bit locations 5, 6, 7 have one 1s. To have even parity, P3 must be 1. For P4: Bit locations 8, 9 have one 1s. To have even parity, P4 must be 1. Thus the encoded 9-bit hamming code is 111001101. How to detect and correct the error in the hamming code? After receiving the encoded message, each parity bit along with its corresponding group of bits are checked for proper parity. While checking, the correct result of individual parity is marked as 0 and the wrong result is marked as 1. After checking all the parity bits, a binary word is formed taking the result bits for P1 as LSB. So formed binary word gives the bit location, where there is an error. Example2 Let us assume the even parity hamming code from the above example (111001101) is transmitted and the received code is (110001101). Now from the received code, let us detect and correct the error. To detect the error, let us construct the bit location table.
Checking the parity bits
For P1 : Check the locations 1, 3, 5, 7, 9. There is three 1s in this group, which is wrong for even parity. Hence the bit value for P1 is 1. For P2 : Check the locations 2, 3, 6, 7. There is one 1 in this group, which is wrong for even parity. Hence the bit value for P2 is 1. For P3 : Check the locations 3, 5, 6, 7. There is one 1 in this group, which is wrong for even parity. Hence the bit value for P3 is 1. For P4 : Check the locations 8, 9. There are two 1s in this group, which is correct for even parity. Hence the bit value for P4 is 0. The resultant binary word is 0111. It corresponds to the bit location 7 in the above table. The error is detected in the data bit D4. The error is 0 and it should be changed to 1. Thus the corrected code is 111001101. Reflection spot
1. Why do we require hamming codes?
Error correction 2. Hamming codes can be used for both single-bit error and burst error detection and correction. a) True b) False
False Lecture Level practice Problems (LLPs)
LLP1 (on LLO1): Which technique is used for error correction?
LLP2 (on LLO2): Which is the most efficient error correction
method? Further Reading
1. Textbook: Andrew S.Tannenbaum, David J.Wetherall,
(Ebook) Cognitive Therapy of Substance Abuse by Aaron T. Beck, Fred D. Wright, Cory F. Newman, Bruce S. Liese ISBN 9780898621150, 9781572306592, 9781593859060, 0898621151, 1572306599, 1593859066 - Download the ebook now for instant access to all chapters