Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

International Journal of Computer Applications (0975 – 8887)

Volume 154 – No.2, November 2016

Single-Bit Parity Detection and Correction using


Hamming Code 7-Bit Model
Wirda Fitriani Andysah Putera Utama Siahaan
Faculty of Computer Science Faculty of Computer Science Faculty of Computer Science
Universitas Pembangunan Universitas Pembangunan Universitas Pembangunan
Panca Budi Panca Budi Panca Budi
Jl. Jend. Gatot Jl. Jend. Gatot Subroto Jl. Jend. Gatot Subroto Km.
Subroto Km. 4,5 Km. 4,5 Sei Sikambing, 4,5 Sei Sikambing,
Sei Sikambing, 20122, Medan, 20122, Medan, Sumatera
20122, Medan, Sumatera Utara, Indonesia Utara,
Sumatera Utara, Indonesia Indonesia

ABSTRACT 2. THEORIES
In the world of technology is already integrated into the 2.1 Data Transmission
network must have a data transmission process. Sending and The data transmission is the process of sending data from one
receiving data communications systems do not avoid mistakes. data source to a data receiver using an electronic device. To
Packets of data sent from the server to the client computer perform data transmission requires the medium, this medium
always have an error in transmission. These shipments have itself has several kinds such as buses, cables commonly found
leaks that occur due to changes in voltage, frequency or on the computer, while the external computer in the
impact. One of the methods used to detect and correct errors transmission of data can use external cables (Wired) and Wi-Fi
in data transmission is the Hamming method. This method (Wireless).
will check bit errors in delivery. Hamming is to do the process
at fault detection, and then the error will be corrected so that Wired Cable
the arrangement of the bits will go back to the bit sequence Wired cable is used to perform the data transmission process
before the data is sent. With the application of this method, the directly; there are several kinds of which are as follows:
data transmission process will avoid mistakes. Data will be
• Wired UTP or commonly known as Unshielded
saved to the destination.
Twisted Pair cable is used for transmitting over a
General Terms computer network such as in the office or cafe. In
Data Transmission addition to UTP, STP (Shielded Twisted Pair) in
which there are several wires in one bundle can also
Keywords be used to transmit data.
Hamming Code, Error Detection • Coaxial cable which consists of two kinds of
conductors separated by using an insulator.
1. INTRODUCTION
Delivery of a message from someone that is confidential or • Fiber Optics is commonly called FO, where a cable
personal to others or the desired person is a way to change the that can transmit information by passing data using
message to be sent into a code word so the secret message can light waves.
be read only by the sender and the person concerned. The
Wireless
theory is used to change a secret message into a code word or
Wireless communication is having telecommunications using
otherwise change the code word becomes the message is the
electromagnetic waves instead of cable media. Nowadays
theory Encoding [1]. Encoding is the process of adding binary
wireless technology has developed rapidly. It can be seen by
numbers of n-m characters in each code to form a code word.
the increasing number of cellular phone use, besides
Decoding is the process of outlining a code word into a
developing wireless technology is also used for integrated into
message [7][8]. The examples of encoding and decoding
the same network. Wireless, also known as Media
techniques are repetition and Hamming. In the encoding form
Transmission Wireless is unguided, can only transmit data
of repetition code, the code word obtained by repeating a
without too much obstacles. The cast of data on the network is
message that has been modified in the form k times as much
typically done using a tool known as the antenna or
code. In Hamming encoding, the code word is obtained by
transceiver. Some of the wireless are:
adding the binary numbers on every message that has been
modified as K characters [9][10]. Meanwhile, in the form of • Radio
repetition code decoding, the message is obtained by dividing
the total code word K parts. In decoding such as Hamming • Microwave
code, the message was obtained by deleting the code word • Infra Red
before by K character. To determine the received message is
equal to sent it needs to be checked, and the error correcting • Bluetooth
code word is received, i.e., the specific ways to obtain the • NFC
actual message.

12
International Journal of Computer Applications (0975 – 8887)
Volume 154 – No.2, November 2016

Table 1 shows the limit of bit length. The total check-bits


obtained depends on the bit length. For example, if the bit
length is seven then the check-bit is 11. The following
illustration will describe how it works.
p = 7
cb = 2𝑛 − 𝑛 − 1 > 7
= 21 − 1 − 1
= 0<7

cb = 2𝑛 − 𝑛 − 1 > 7
= 22 − 2 − 1
= 1<7

Fig. 1 Transmission Process


cb = 2𝑛 − 𝑛 − 1 > 7
= 23 − 3 − 1
Figure 1 shows the OSI model. It is a description for layered = 4<7
communications and computer network protocol design. It
was developed as part of the Open Systems Interconnection
cb = 2𝑛 − 𝑛 − 1 > 7
(OSI) initiative. In its most basic form, it divides network
architecture into seven layers which, from bottom to top, are = 24 − 4 − 1
the Physical, Data-Link, Network, Transport, Session, = 11 > 7
Presentation, Application Layers.
The calculation run continuously until reach cb > p. For bit
2.2 Hamming Code length = 7, there will be four check-bits to check the bit data.
Hamming code is an error correction system that uses parity Table 2. Bit example
bits to correct the mistake [3][6]. Beside Hamming Code,
there are many other systems in a more efficient error 1 0 0 1 0 0 0
correction method to correct data error consists of many bits 1 2 3 4 5 6 7
[4][5]. Parity of method is to check the the codes that exist.
Linear error-correction code has various limitations error. On
Hamming Code, only one mistake can be repaired. For a two- Table 3. Data and parity
bit mistake, it can be only detected.
x x 1 x 0 0 1 x 0 0 0
Hamming method is a frequently used error detection and
1 2 3 4 5 6 7 8 9 10 11
correction method. This method is quite simple. This method
uses XOR logic operation in the detection and correction of
errors. The tested data is a row of binary numbers of data Table 2 shows the original data consists of seven bits only.
transmitted. Hamming code will check the error from the first When it is transmitted, the Hamming code adds some extra
to the last bit, so the method is also called a linear error bits to mark the position. Since the bit length is seven bits, the
correcting code. Hamming code method works by inserting result will be 11 bits as shown in Table 3.
several pieces of check bits to data at a specific position. The
number of check bits inserted depending on data length. 3. METHODOLOGY
𝑛
𝑐𝑏 = 2 − 𝑛 − 1 > 𝑝 (1) Normally, a frame consists of m bits of data and r redundant,
Where: or check bits. Take the total length of n (n = m + r). An n-bit
cb : checkbit value unit containing data and check-bit often attributed as the n bit
n : total checkbits code word. In most data transmission applications, all 2m data
p : bit length messages are legal data. However, as regards the method of
calculating the check bits, not all 2n used. If specified
Table 1. Check Bit and Total Bit algorithm to calculate the check bits, it will be possible to
make a complete list of the legal codewords. From this list can
Check-Bit Total Bit Position be searched two codewords its minimum Hamming distance.
This distance is the Hamming distance of the complete code.
1 0 1
Assume two codewords: 10001001 and 10110001. This part
2 1 2 determine how many bits are related differently. In this case,
3 4 4 there are three different bits. To determine just do
EXCLUSIVE OR operation on the second codeword, and
4 11 8 count the number of 1 bits in operating results. Hamming
5 26 16 distance is the number of bit positions in which two
codewords differ. The thing to note is that when two separate
6 57 32 codewords with Hamming distance d, it will take a single bit
7 120 64 error d to convert from the one into the other. The properties
of error detection and error recovery of a code depend on its
8 247 128 Hamming distance. To detect d errors, it needs a code with d +
1 because of the code as it was unlikely that d single-bit errors
can change a valid codeword into another valid codeword.

13
International Journal of Computer Applications (0975 – 8887)
Volume 154 – No.2, November 2016

When the recipient sees an invalid codeword, there has been Bit 1 0 0 1 0 0 0
an error in transmission. Likewise, to correct d errors, it needs
a code within 2d + 1 because it was declared legal codeword Position 1 2 3 4 5 6 7
can be separated even with d changes, the original codeword
will be closer than the other, then the error recovery can be The bit length is 7 represented by p.
determined uniquely.
p = 7
As a simple example for error detection code, download a
code in which a single parity bit is added to the data. The cb = 2𝑛 − 𝑛 − 1 > 7
parity bit is chosen so that the number of 1 bits in the
codeword becomes even (or odd). For example, if 10110101 is = 21 − 1 − 1
delivered in even-numbered parity by adding a bit at the = 0<7
edges, then the data was 101101011, while the even-numbered
10110001 parity becomes 101100010. A code with a single cb = 2𝑛 − 𝑛 − 1 > 7
parity bit has a distance of 2 because any single-bit error
produces a codeword with parity wrong. = 22 − 2 − 1
The following steps are done to calculate the hamming code = 1<7
as cited from Tim Downey from Florida International
University [2]. The key to the Hamming Code is the use of cb = 2𝑛 − 𝑛 − 1 > 7
extra parity bits to allow the identification of a single error. = 23 − 3 − 1
Create the codeword as follows:
= 4<7
• Mark all bit positions that are powers of two as
parity bits. (positions 1, 2, 4, 8, 16, 32, 64, etc.) cb = 2𝑛 − 𝑛 − 1 > 7
• All other bit positions are for the data to be encoded. = 24 − 4 − 1
(positions 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17,
etc.) = 11 > 7
• Each parity bit calculates the parity for some of the After the calculation, the total check-bits is 4 check-bits.
bits in the code word. The position of the parity bit
determines the sequence of bits that it alternately Parity x x 1 x 0 0 1 x 0 0 0
checks and skips. Position 1 2 3 4 5 6 7 8 9 10 11
• Position 1: check 1 bit, skip 1 bit, check 1 bit, skip 1
bit, etc. (1,3,5,7,9,11,13,15,...) There will be four check-bits must be inserted to the bit data.
• Position 2: check 2 bits, skip 2 bits, check 2 bits, The total length will be 11 bits (𝑏𝑖𝑡𝑑𝑎𝑡𝑎 + 𝑏𝑖𝑡𝑝𝑎𝑟𝑖𝑡𝑦). The
skip 2 bits, etc. (2,3,6,7,10,11,14,15,...) bits are still unknown. There is a technique to replace the x
with 0 or 1.
• Position 4: check 4 bits, skip 4 bits, check 4 bits,
skip 4 bits, etc. (4,5,6,7,12,13,14,15,20,21,22,23,...) Table 4. Data extraction

• Position 8: check 8 bits, skip 8 bits, check 8 bits, Pos Binary Parity Data
skip 8 bits, etc. (8-15,24-31,40-47,...) 11 1011 0
• Position 16: check 16 bits, skip 16 bits, check 16 10 1010 0
bits, skip 16 bits, etc. (16-31,48-63,80-95,...)
9 1001 0
• Position 32: check 32 bits, skip 32 bits, check 32
bits, skip 32 bits, etc. (32-63,96-127,160-191,...) 8 1000 x
Set a parity bit to 1 if the total number of ones in the positions 7 0111 1
it checks is odd. Set a parity bit to 0 if the total number of 6 0110 0
ones in the positions it checks is even.
5 0101 0
4. EVALUATION 4 0100 x
4.1 Transmit 3 0011 1
This section describes the calculation of the Hamming code.
Assume the data to transmit is the character of H. The bit 2 0010 x
value of the character is 01001000. Since the Hamming code 1 0001 x
uses 7 bits in this research, the bit value of H is 1001000. The
following calculation will explain how the character is
transmitted. Table 4 shows the extraction from the previous parity data.
This step is to determine the value of x whether 0 or 1. The
Character : H method is to calculate how many “1” in each index of binary
Decimal : 72 data (Parity not included).
Binary : 1001000

14
International Journal of Computer Applications (0975 – 8887)
Volume 154 – No.2, November 2016

Table 5. Parities value Table 8. Parities value

Parity Value Amount Parity Value Amount


x1 0 there are 2 of 1 x1 1 there are 3 of 1
x2 0 there are 2 of 1 x2 0 there are 2 of 1
x3 1 There are 1 of 1 x3 0 There are 1 of 1
x4 0 There are 0 of 1 x4 0 There are 0 of 1

Table 5 show the value of every parity. There is rule to Table 8 show the value of every parity. The value is different
determine the value.If the amount is even then the value is 0 from the first before the error. Until now, it is proved there
and if the amount is odd then the value is 1. was a modification of the bit value. It means the data is not
retrieved perfectly.
Table 6. Data and parity
Table 9. Error position
Position Insertion
T. Parity R. Parity Error Pos
1 x1 1 0 0 1 0 0 0
x 0 1 1
2 x1 1 0 0 1 0 0 0
2 0 0 0
x x 1 0 1
4 x1 1 0 0 1 0 0 0
2 3
x x 0 0 0
8 x1 1 0 0 1 x4 0 0 0
2 3 Error Position : 1010
Result 0 0 1 1 0 0 1 0 0 0 0
Position Index : 5
Table 6 shows the final result of the data and parity formation. The Hamming code detected the error in the fifth position as
There are 11 bits now after the parity addtion. determined previously. It is proved that the method works to a
significant condition.
New Binary : 00110010000
5. CONCLUSION
4.2 Receive By the test results and discussion programs that do, it can be
This section tries to detect and fix the error from previous concluded that the method of Hamming code can detect bit
binary string. The following calculation describes the full errors in the file received by the receiver file. The checking is
explanation of the Hamming. Assume that the error is set to done by comparing the value of the check bits with the
the fifth bit. original value of bits that exist in the file. Methods hamming
Set Error : 00111010000 (the 5th) code can make corrections damage bits as a bit, or it is called
Bit Received : 1101000 single bit error detection. It is the unfortunate method of
Hamming code can not detect if there is more than one-bit
error. Error detected just as much as the pieces only error even
Bit 1 1 0 1 0 0 0 though possessed more than one.
Position 1 2 3 4 5 6 7
6. FUTURE SCOPE
The next research is needed to expand the single error parity
Table 7. Data extraction checking to the multi-error parity checking. The Hamming
code is limited to one error only. If multi-error or burst error
Pos Binary Parity Data happens, Hamming can only detect the single error. By
11 1011 0 composing the block system, it lets the computer program
perform the multi-error checking.
10 1010 0
9 1001 0 7. REFERENCES
[1] R. S. Geiger and A. Lampinen, "Old Against New, or a
8 1000 x Coming of Age? Broadcasting in an Era of Electronic
7 0111 1 Media," Journal of Broadcasting & Electronic Media,
vol. 58, no. 3, pp. 333-341, 2014.
6 0110 0
[2] T. Downey, "Calculating the Hamming Code," Florida
5 0101 1 International University, 25 2 2016. [Online]. Available:
4 0100 x http://users.cis.fiu.edu/~downeyt/cop3402/hamming.html
. [Accessed 1 10 2016].
3 0011 1
[3] K. P. Debalina Roy Choudhury, "Design of Hamming
2 0010 x Code Encoding and Decoding Circuit Using
1 0001 x Transmission Gate Logic," International Research
Journal of Engineering and Technology, vol. 2, no. 7, pp.
1165-1169, 2015.
Table 7 shows the extraction from the previous parity data.

15
International Journal of Computer Applications (0975 – 8887)
Volume 154 – No.2, November 2016

[4] E. S. Abuelyaman and A.-A. S. Al-Sehibani, Check Bit Precomputation for Memories," Journal of
"Optimization of the Hamming Code for Error Prone Semiconductor Technology and Science, vol. 12, no. 4,
Media," International Journal of Computer Science and pp. 418-425, 2012.
Network Security, vol. 8, no. 3, pp. 278-285, 2008.
8. AUTHOR PROFILE
[5] R. W. Hamming, "Error Detection and Error Correction Wirda Fitriani was born in Medan, Indonesia, in 1979. She
Codes," Bell Systems Tech. Journal, vol. 29, no. 1, pp. received the S.Kom. degree in computer science from
147-160, 1950. Universitas Pembangunan Panca Budi, Medan, Indonesia, in
[6] Z. Ramadhan and A. P. U. Siahaan, "Stop-and-Wait ARQ 2005, She joined the Department of Engineering, Universitas
Technique for Repairing Frame and Acknowledgment Pembangunan Panca Budi, as a Lecturer in 2008, and in 2014,
Transmission," International Journal of Engineering she entered the post-graduate university, AMIKOM,
Trends and Technology, vol. 38, no. 7, pp. 384-387, 2016. Yogyakarta. She is now studying for her master degree. She
has become a writer in several conferences. She is still
[7] N. Shep and P. Bhagat, "Implementation of Hamming working as a System Support at PT. Buana Varia Komputama,
code using VLSI," International Journal of Engineering Medan.
Trends and Technology, vol. 4, no. 2, pp. 186-190, 2013.
Andysah Putera Utama Siahaan was born in Medan,
[8] D. R. Choudhury and K. Podder, "Design of Hamming Indonesia, in 1980. He received the S.Kom. degree in
Code Encoding and Decoding Circuit Using computer science from Universitas Pembangunan Panca Budi,
Transmission Gate Logic," International Research Medan, Indonesia, in 2010, and the M.Kom. in computer
Journal of Engineering and Technology, vol. 2, no. 7, pp. science as well from the University of Sumatera Utara,
1165-1169, 2015. Medan, Indonesia, in 2012. In 2010, he joined the Department
[9] H. Saleh, "Design of Hamming Encoder and Decoder of Engineering, Universitas Pembangunan Panca Budi, as a
Circuits For (64, 7) Code and (128, 8) Code Using Lecturer, and in 2012 became a researcher. He is applying for
VHDL," Journal of Scientific and Engineering Research, his Ph.D. degree in 2016. He has written several international
vol. 2, no. 1, pp. 1-15, 2015. journals. He is now active in writing papers and joining
conferences.
[10] S. Cha and H. Yoon, "Efficient Implementation of Single
Error Correction and Double Error Detection Code with

IJCATM : www.ijcaonline.org 16

You might also like