EX - NO: 3b Design and Performance Analysis of Error Date: Control Encoder and Decoder Using Hamming Codes
EX - NO: 3b Design and Performance Analysis of Error Date: Control Encoder and Decoder Using Hamming Codes
EX - NO: 3b Design and Performance Analysis of Error Date: Control Encoder and Decoder Using Hamming Codes
NO: 3b
DATE:
THEORY
HAMMING CODES
Hamming codes can detect up to two and correct up to one bit errors. By contrast,
the simple parity code cannot correct errors, and can detect only an odd number of errors.
Hamming codes are special in that they are perfect codes, that is, they achieve the highest
possible rate for codes with their block length and minimum distance.
HAMMING DISTANCE BASED CHECKS
If we want to detect d bit errors in an n bit word we can map every n bit word
into a bigger n+d+1 bit word so that the minimum Hamming distance between each valid
mapping is d+1. This way, if one receives a n+d+1 word that doesnt match any word in the
mapping (with a Hamming x<= d+1 from any word in the mapping) it can successfully detect
it as an error word. Even more, d or fewer errors will never transform a valid word into
another, because the Hamming distance between each valid word is at least d+1, and such
errors only lead to invalid words that are detected correctly. Given a stream of m*n bits, we
can detect x<= d bit errors successfully using the above method on every n bit word. In fact,
we can detect a maximum of m*d errors if every n word is transmitted with maximum d
errors.
2m m + k + 1
Where
m = No. Of Bits Entered
k = Message Length
n = 2m - 1
n = Code Length
ADVANTAGES
Hamming proves that this is the most efficient use of parity checks for
single detection, correction and double detection since he maximizes the distance between
code words.
recreate data that has been corrupted over the wire (an error correcting code).
transmission.
DISADVANTAGES
They are relatively inefficient when sending small amounts of data, but they
They can only correctly locate one flipped bit for each codeword regardless
of its length. Therefore you almost always have to encode strings of length n with about n
parity checks in order to ensure accuracy of information.
Limitations are in the number of bits which can be restored, which is not
APPLICATIONS
Decode using Hamming code leads to correct the original signal from the
noise message.
CODING
%General
clc;
clear all;
close all;
n=7;
k=4;
msg=[1 0 1 0]
code=encode(msg,n,k,'hamming')
noisycode=rem(code+randerr(1,7,[0 1;0.7 0.3]),2)
newmsg=decode(noisycode,n,k,'hamming')
%Using matrix
clc;
clear all;
close all;
n=7;
k=4;
msg=randint(5,k,[0 1])
code=encode(msg,n,k,'hamming')
noisycode=rem(code+randerr(5,n,[0 1;0.7 0.3]),2)
newmsg=decode(noisycode,n,k,'hamming')
OUTPUT
%general
% using matrix
RESULT
Thus a Hamming code error control encoder and decoder for detecting the
transmission error was designed and the error correction in decoding sequence is also done
successfully.