Cyclic Redundancy Check program in C | CRC
Write a program to compute CRC code for the polynomials CRC-12, CRC-16 and CRC CCIP
Name of Experiment: Cyclic Redundancy Check
Hardware Requirements: Intel based Desktop
PC:RAM of 1GB
Software Requirement: Turbo C / Turbo C++
Theory:
Cyclic Redundancy Checks fall into the same category as parity
bits, check digits, and checksums: Their use is to
detect transmission errors. Depending on the error model assumed (i.e., what
types of transmission errors are to be expected, which typically depends on the
transmission media), different forms of checking are appropriate.
This technique involves binary division of the data bits being sent. The
divisor is generated using polynomials. The sender performs a division
operation on the bits being sent and calculates the remainder. Before sending
the actual bits, the sender adds the remainder at the end of the actual bits.
Actual data bits plus the remainder is called a codeword. The sender transmits
data bits as code-words. At the other end, the receiver performs division
operation on code-words using the same CRC divisor. If the remainder contains
all zeros the data bits are accepted, otherwise it is considered as there some
data corruption occurred in transit.
SOURCE CODE:
// Program for Cyclic Redundancy Check
int gen[4],genl, frl, rem[4];
void main ( )
{
int i,j,fr[8],dupfr[11],recfr[11],tlen,flag;
frl=8; genl=4;
printf ("Enter frame:\n");
for (i=0; i<frl; i++)
{
scanf ("%d", &fr[i]);
dupfr[i]=fr[i];
}
printf("Enter generator:\n");
for (i=0; i<genl;i++)
scanf ("%d", &gen[i]);
tlen=frl+genl-1;
for(i=frl;i<tlen;i++)
{
dupfr[i] =0;
}
remainder(dupfr);
for (i=0; i<frl; i++)
{
recfr[i]=fr[i];
}
for(i=frl,j=1;j<genl;i++,j++)
{
recfr[i]=rem[j];
}
remainder(recfr);
flag=0;
for(i=0;i<4;i++)
{
if(rem[i]!=0)
flag++;
}
if (flag==0)
{
printf ("Frame is received correctly\n");
}
else
{
printf ("The received frame is wrong\n");
}
}
remainder (int fr[])
{
int k,k1,i,j;
for(k=0;k<frl;k++)
{
if (fr[k]==1)
{
k1=k;
for (i=0,j=k;i<genl;i++,j++)
{
rem[i]=fr[j]^gen[i];
}
for(i=0;i<genl;i++)
{
fr[k1]=rem[i];
k1++;
}
}
}
return 0;
}
OUTPUT CONSOLE:
}
Create this charitable of companions you consideration about precisely what therefore grief-favored beside contemplates to most of these tows which are fact produced. IR Repeater
ReplyDelete