Sei sulla pagina 1di 7

EX.

NO: 3b

DESIGN AND PERFORMANCE ANALYSIS OF ERROR

DATE:

CONTROL ENCODER AND DECODER


USING HAMMING CODES
AIM
To design a Hamming code error control encoder and decoder for detecting the

transmission error and perform the error correction in decoding sequence.


SOFTWARE TOOL REQUIRED

MATLAB Version 7.1

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.

In telecommunication a Hamming code is a family of linear error-correcting


code. Hamming codes can detect and correct single-bit errors. In other words, the Hamming
distance between the transmitted and received code-words must be zero for reliable
communication. Alternatively, it can detect (but not correct) up to two simultaneous bit
errors. Hamming code works by the formula

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.

When transmitting data, the Hamming code apparently allows you to

recreate data that has been corrupted over the wire (an error correcting code).

Hamming code is a mathematical trick to correct up to 4 lost bits in a serial

transmission.
DISADVANTAGES

They are relatively inefficient when sending small amounts of data, but they

get increasingly inaccurate as the number of bits increases.

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

more than 4. If more than 4 bits are lost, retransmission is required.

APPLICATIONS

It is used in favour of the "parity bit" in modern memory chips.

Theory of Operation. Calculations; Cadence Details; Summary of Results;

Cost Analysis, Computing and Telecommunication.


PROCEDURE

Set the code length n.

Define the message Length.

Assign the message.

Encode the above mentioned using Hamming Code.

Add a Randomly generated noise or define it manually.

Decode using Hamming code leads to correct the original signal from the

noise message.

Display the Result.

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.

Potrebbero piacerti anche