Professional Documents
Culture Documents
Submitted by-
B.Tech
5ECE1-Y
Index
S.N Categor Ex Name of Pa Date Date of Max Marks Signat
o. y of p. Experim ge Allotme Evaluat . Obtain ure of
Assignm No. ent No. nt of ion Mar ed Facult
ent Experim ks y
ent
1. Mandator 1. To design a
y system that
constructs
Experime Hamming
nt* codes using
any
simulation
platform or
any
programmi
ng
language.
AIM:
To design a system that constructs Hamming code using any simulation platform or any
programming language.
Software Used:
Online Python Compiler
THEORY-
Hamming Codes
In digital communication system, the data transfer should be error free and with high
accuracy. The data errors often result in the loss of important or secure data. To overcome
this issue, a scientist named Richard W Hamming formulated an algorithm to detect and
correct single-error correcting binary codes. His research paper was published in 1950 and
later these codes were popularized as Hamming Code.
The basic concept of Hamming Code is to add Parity bits to the data stream to verify that the
data received is correct or matches with the input. These bits are transmitted in such a way
that they identify where the error has occurred in the data stream and rectify it.
Parity bits –
A parity bit is a bit appended to a data of binary bits to ensure that the total number of 1’s
in the data is even or odd. Parity bits are used for error detection. There are two types of
parity bits:
1. Even parity bit:
In the case of even parity, for a given set of bits, the numbers 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 numbers 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.
CODE:
def calcRedundantBits(m):
# Use the formula 2 ^ r >= m + r + 1
# to calculate the no of redundant bits.
# Iterate over 0 .. m and return the value
# that satisfies the equation
for i in range(m):
if(2**i >= m + i + 1):
return i
def posRedundantBits(data, r):
# Redundancy bits are placed at the positions
# which correspond to the power of 2.
j = 0
k = 1
m = len(data)
res = ''
# If position is power of 2 then insert '0'
# Else append the data
for i in range(1, m + r+1):
if(i == 2**j):
res = res + '0'
j += 1
else:
res = res + data[-1 * k]
k += 1
SIMULATION-
OUTPUT:
APPLICATIONS-
The applications of Hamming Code are:
CONCLUSION:
Hence, we have successfully constructed the Hamming codes using python language. On this
coding process we have basically defined four function i.e… for calculating reductant bit,
second for to identify the position of reductant bits, third one is to find weather it has odd
number of 1’s or even number of 1’s in parity bit according to parity bit position, and last one
is used to find the position of error Bit of any present in transferred data.
MARKING SCHEME
Designing 3
concept (D)
Application 2
of
Knowledge(
A)
Performance( 3
P)
Result(G) 2
Total Marks 10