Type Here to Get Search Results !

Implement on a data set of characters the three CRC polynomials CRC 12, CRC 16 and CRC CCIP

 Generate CRC code for a given data frame Algorithm

1. A string of n as is appended to the data unit. The length of predetermined divisor is n+ 1.

2. The newly formed data unit 1. A string of n as is appended to the data unit. The length of predetermined divisor is n+ 1.

       i.e. original data + string of n as are divided by the divisor using binary division and remainder is obtained. This remainder is called CRC.

3. Now, string of n Os appended to data unit is replaced by the CRC remainder (which is also of n bit).

4. The data unit + CRC is then transmitted to receiver.

5. The receiver on receiving it divides data unit + CRC by the same divisor & checks the remainder.

6. If the remainder of division is zero, receiver assumes that there is no error in data and it accepts it.

7. If remainder is non-zero then there is an error in data and receiver rejects it.


PROGRAM:


#include<stdio.h> 

#include<math.h> 

main()

{


int i,j,k,m,n,cl;

char a[10],b[100],c[100];

clrscr();

printf("\n ENTER POLYNANOMIAL:");

scanf("%s",a);

printf("\n ENTER THE FRAME:");

scanf("%s",b); m=strlen(a); 

n=strlen(b);

for(i=0;i<m;i++) /* To eliminat first zeros in polynomial */

{

if(a[i]=='1')

{

m=m-i; 

break;

}

}

for(k=0;k<m;k++) /* To Adjust the polynomial

*/ a[k]=a[k+i];




cl=m+n-1;

 


for(i=0;i<n;i++) /* To copy the original frame to c[]*/

 c[i]=b[i];

for(i=n;i<cl;i++) /* To add n-1 zeros at the end of frame */

 c[i]='0';

c[i]='\0'; /*To make it as a string */

for(i=0;i<n;i++) /* To set polynomial remainder at end of c[]*/ 

if(c[i]=='1')

{

for(j=i,k=0;k<m;k++,j++)

 if(a[k]==c[j])

c[j]='0';

else c[j]='1';

}

for(i=0;i<n;i++) /* To copy original data in c[] */ 

c[i]=b[i]; 

printf("\n THE MESSAGE IS: %s",c);

getch();

}


INPUT/OUTPUT:


ENTER POLYNANOMIAL:1011 ENTER THE FRAME:10011101 THE MESSAGE IS: 10011101011


ENTER POLYNANOMIAL:00101 ENTER THE FRAME:10101011 THE MESSAGE IS: 1010101101

 



Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Featured post

M

M