# Haming Code and CRC Generator

Üniversite dönemlik proje olarak yapılmıştır. Cihazların haberleşmesinde veya Ağ haberleşmesinde kullanılan veri doğrulama ve kontrol mekanizmalarından olan Haming Code ve CRC Kodların nasıl hesaplandığını gösteren programdır. Temel yapıda hesaplanmasını içerir. LookUp table yöntemi ile hesaplamalar daha kolay yapılabilirdi fakat bu program ile hesaplamanın tüm adımları tek tek yapılarak aşamalar halinde gösterilmiştir.

Sistem İçi Programlar, Programlama Dilleri ve Kullanılan Yapılar

• Visual Basic

1. AÇIKLAMA
• Network de bir aygıttan bilgi transfer edilirken verini doğru ulaşması gerekir..
• Kaynaktan bilgi transferinde .Hat üzerindeki parazitten etkilenerek veride bozulma olur.
• Bunun için gönderilen verinin doğruluğunu test ettirecek bir sistem gerekir.

Bu sistemler CRC Generator ve Hamig Code dur.

Proje Sunum gereği İngilizce yayınlandı. O yüzden yayınladığım İngilizce Notları ile aşağıda yayınlayacağım.

1. INTRODUCTION

• Network must be able to transfer data from one device two another with complete accuracy.
• However, due two many reasons (e.g line noise) anytime data are transmitted from source to destination, They can corrupt in channel.
• In fact, it is more likely that some part of a message will be damaged in transmission than the entire contents (data) will arrive undamaged.
• Reliable system must have a mechanism for detecting and correcting such errors.

How these Algorithms work?

A. CRC (binary division)

• CRC is very effective error detection method.
1. CRC can detect all burst errors affect an odd number of bits.
2. CRC can detect all burst errors of length less than or equal to the length to the degree of the polynomial.
3. CRC can detect with a very high probability burst errors of length greater than the degree of the degree of the polynomial.
4. 99.97 percent success.

• The redundancy bits used by CRC are derived by dividing the data by a predetermined divisor; and the remainder is the CRC.
• CRC must have two qualities
1. It must have exactly one less bit than the divisor
2. Appending it to the end of the data string must make the resulting bit sequence exactly divisible by the divider.

• A string of n 0’s is appended to the data the number n is one less than the number of bit in the predetermined divisor, which is n+1 bits.
• This new data unit is divided by the divisor using a process called binary division. The remainder resulting from this division is the CRC.
• The CRC of n bits derived in step 2 replaces the appended 0’s at the end of the data unit.
• The data unit arrives at the receiver data first, followed by CRC. The receiver treats the whole string as a unit and divides it by the same divisor that was used to find the CRC remainder.

B. HAMMING CODE
• It can be applied to data units of length and uses the relationship between data and redundancy bits.
a. Redundancy bits can be added to the end of the data unit OR interspersend with the orginal data, as shown below;

• Each “r” bits is the VRC bit for one (different) combination of data bits.
Each data bit may be included in more than one VCR calculation.
r1: bits 1,3,5,7,9,11,….
r2: bits 2,3,6,7,10,11…
r4: bits 4,5,6,7………..
r8: bits 8,9,10,11……..

• The pattern behind this strategy;

• r1 bit is calculated using all bit positions whose binary representation includes a 1 in the rightmost position.
• r2 bit calculated using all bit position with a 1 in the second position and so on…

• Calculating the r values: The parity value of each combination is the value of the corresponding r bit.

• Total transmittable unit is m+r

• So, r must be able to indicate at least m+r+1 different states

1. One states for “no error”
2. m+r states indicate the location of error of the m+r possibilities
• r bits can indicate 2r different state
• 2r >= m+r+1