Nothing Special   »   [go: up one dir, main page]

Implement On A Data Set of Characters The Three CRC polynomials-CRC 12, CRC 16, CRC CCIP

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

PROGRAM :2

Aim: Implement on a data set of characters the three CRC polynomials- CRC
12,CRC 16, CRC CCIP.
Source Code:
#include<stdio.h>
#include<conio.h>
void main()
{
char s[100],p[100],d[30];
int k,len,i;
clrscr();
printf("enter frame");
gets(s);
printf("enter gen");
gets(d);
k=strlen(d)-1;
len=strlen(s);
strcpy(p,s);
for(i=len;i<len+k;i++)
p[i]='0';
p[i]='\0';
printf("msg after appending %d zero bits:",k);
puts(p);
printf("order of process is :\n");
while(strlen(p)>k)
{
if(p[0]=='1')
for(i=0;d[i]!='\0';i++)
p[i]=(p[i]-'0')^(d[i]-'0')+'0';
else
for(i=0;p[i]!='\0';i++)
p[i]=p[i+1];
puts(p);
}
strcat(s,p);
CN&OS LAB MANUAL

puts("transmitted frame is:");


printf("\t \t");
puts(s);
getch();

Output:
CRC 12 as Generator:
enter frame110100100100100100100101
enter gen110000000111
msg after appending 11 zero bits:11010010010010010010010100000000000
order of process is :
00010010001110010010010100000000000
0010010001110010010010100000000000
010010001110010010010100000000000
10010001110010010010100000000000
01010001101110010010100000000000
1010001101110010010100000000000
0110001100000010010100000000000
110001100000010010100000000000
000001100111010010100000000000
00001100111010010100000000000
0001100111010010100000000000
001100111010010100000000000
01100111010010100000000000
1100111010010100000000000
0000111011100100000000000
000111011100100000000000
00111011100100000000000
0111011100100000000000
111011100100000000000
001011100011000000000
01011100011000000000
1011100011000000000
0111100010110000000
CN&OS LAB MANUAL

111100010110000000
001100010001000000
01100010001000000
1100010001000000
0000010000110000
000010000110000
00010000110000
0010000110000
010000110000
10000110000
transmitted frame is:
11010010010010010010010110000110000

CRC 16 as Generator:
enter frame11010010010101010101010001001
enter gen1100000000000101
msg after appending 15 zero
bits:11010010010101010101010001001000000000000000
order of process is :
00010010010100000101010001001000000000000000
0010010010100000101010001001000000000000000
010010010100000101010001001000000000000000
10010010100000101010001001000000000000000
01010010100001111010001001000000000000000
1010010100001111010001001000000000000000
0110010100001010010001001000000000000000
110010100001010010001001000000000000000
000010100001000110001001000000000000000
00010100001000110001001000000000000000
0010100001000110001001000000000000000
010100001000110001001000000000000000
10100001000110001001000000000000000
01100001000111011001000000000000000
CN&OS LAB MANUAL

1100001000111011001000000000000000
0000001000111110001000000000000000
000001000111110001000000000000000
00001000111110001000000000000000
0001000111110001000000000000000
001000111110001000000000000000
01000111110001000000000000000
1000111110001000000000000000
0100111110001101000000000000
100111110001101000000000000
010111110001111100000000000
10111110001111100000000000
01111110001110110000000000
1111110001110110000000000
0011110001110011000000000
011110001110011000000000
11110001110011000000000
00110001110010010000000
0110001110010010000000
110001110010010000000
000001110010000100000
00001110010000100000
0001110010000100000
001110010000100000
01110010000100000
1110010000100000
0010010000100101
010010000100101
transmitted frame is:
11010010010101010101010001001010010000100101

CN&OS LAB MANUAL

CCITT as Generator:
enter frame1101011010100101
enter gen100010000001
msg after appending 11 zero bits:110101101010010100000000000
order of process is :
010111101011010100000000000
10111101011010100000000000
00110101011110100000000000
0110101011110100000000000
110101011110100000000000
010111011111100000000000
10111011111100000000000
00110011111000000000000
0110011111000000000000
110011111000000000000
010001111001000000000
10001111001000000000
00000111001100000000
0000111001100000000
000111001100000000
00111001100000000
0111001100000000
111001100000000
011011100001000
11011100001000
01010100001100
1010100001100
0010000001110
010000001110
10000001110
transmitted frame is:
110101101010010110000001110

CN&OS LAB MANUAL

You might also like