Cyclic Redundancy Check Error Detection Method CS1305- NETWORK LAB

Step by step CRC Algorithm: start the CRC program
Accept the string to be transmitted as ‘text’ and a key value for CRC as ‘key’
CRC function is called
a) (key -1) number 0’s are appended to the text and text key division operation is performed.
b) The remainder is appended to the tet and transmitted
The Transmitted message can be checked for consistency by calling the CRCD function again and a passing the transmitted message and key again
a) If the remainder is 0. And error is displayed
b) Else error message is displayed
SEE the BASIC string option in C program with pointer character
Finally terminate the Cyclic Redundancy Check Error Detection Method program

CRC Source code programming C language CS1305- NETWORK LAB
#include<stdio.h>
char text[100];
char key[100];
char rem[100];
void crc()
{ int i,j;
int keylen,textlen;
char temp[100];
strcpy(temp,text);
keylen=strlen(key);
for(i=0;i<keylen-1;i++)
strcat(temp,"0");
textlen=strlen(temp);
strncpy(rem,text,keylen);
while(i!=textlen)
{
if(rem[0]=='0')
{
strcpy(rem,&rem[1]);
rem[keylen-1]=temp[++i];
rem[keylen]='0';
continue;
} for(j=0;j<keylen;j++)
rem[j]=((rem[j]-'0')^(key[j]-'0'))+'0';
} }
main()
{
int i;
int choice;
while(1)
{
printf("\n menu:\n 1.crc\n 2.check crc\n 3.exit \n");
printf("enter ur choice");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("enter i/p string");
scanf("%s",text);
printf("enter key");
scanf("%s",key);
crc();
printf("transmitted msg %s\n",strcat(text,rem));
break;
case 2:
printf("enter i/p string");
scanf("%s",text);
printf("enter key");
scanf("%s",key);
crc();
for(i=0;i<strlen(key)-1;i++)
if(rem[i]=='1')
break;
if(i==strlen(key)-1)
printf("there is no error in string");
else
printf("there is error in string");
break;
case 3:
exit(0); } }
printf("\n"); }

OUTPUT CS1305- NETWORK LAB CRC
MENU
1. CRC
2. Check CRC
3. Exit
Enter the choice: 1
Enter the input string: 11110
Enter key: 10
Transmitted message: 1111100
MENU
1. CRC
2. Check CRC
3. Exit
Enter the choice: 2
Enter the input string: 1111100
Enter Key: 10
There is no error in the string

Result:
Thus the program for CRC computation was created and executed successfully.

Post a Comment

0 Comments