Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to implement the checksum method. The implementation has two par

ID: 3762691 • Letter: W

Question

Write a program to implement the checksum method.

The implementation has two parts:

a. Calculating the checksum at the sender

b. Verifying the checksum at the receiver

Calculating the checksum at the sender :

Inputs: 4 data each consisting of 16-bit (binary)

Output: Checksum of 16-bit (binary)

Example: http://mathforum.org/library/drmath/view/54379.html

Verifying the checksum at the receiver Inputs:

4 data each is consisting of 16-bit and their 16-bit checksum

Output: Checksum for 4 data each is consisting of 16-bit and their 16-bit checksum

If checksum is equal to 0s, your data is not corrupted

If checksum is not equal 0s, your data is corrupted

Explanation / Answer

#include<stdio.h>

char m[50],g[50],r[50],q[50],temp[50]; void caltrans(int);

void crc(int);

void calram();

void shiftl();

int main()

{

            int n,i=0;         char ch,flag=0;             printf("Enter the frame bits:");             while((ch=getc(stdin))!=' ')

            m[i++]=ch;     n=i;

            for(i=0;i<16;i++)        m[n++]='0';             m[n]='';

            printf("Message after appending 16 zeros:%s",m);             for(i=0;i<=16;i++)      g[i]='0';

            g[0]=g[4]=g[11]=g[16]='1';g[17]='';           printf(" generator:%s ",g);

            crc(n);

            printf(" quotient:%s",q);    caltrans(n);

            printf(" transmitted frame:%s",m); printf(" Enter transmitted freme:");

            scanf(" %s",m);

            printf("CRC checking ");     crc(n);

            printf(" last remainder:%s",r);             for(i=0;i<16;i++)        if(r[i]!='0')

            flag=1;            else

            continue;        if(flag==1)

            printf("Error during transmission");

            else

printf(" Received freme is correct");

} void crc(int n)

{

            int i,j; for(i=0;i<n;i++)             temp[i]=m[i]; for(i=0;i<16;i++)             r[i]=m[i];

            printf(" intermediate remainder ");             for(i=0;i<n-16;i++)

            {

                        if(r[0]=='1')

                        {

                                    q[i]='1';                                    calram();

                        }

                        else

                        {

                                    q[i]='0';

                                    shiftl();

                        }

                        r[16]=m[17+i];                        r[17]='';

                        printf(" remainder %d:%s",i+1,r);                 for(j=0;j<=17;j++)                  temp[j]=r[j];

            }

            q[n-16]='';

} void calram()

{

            int i,j; for(i=1;i<=16;i++)

r[i-1]=((int)temp[i]-48)^((int)g[i]-48)+48;

} void shiftl()

{

            int i;    for(i=1;i<=16;i++)      r[i-1]=r[i];

} void caltrans(int n)

{

            int i,k=0;         for(i=n-16;i<n;i++)     m[i]=((int)m[i]-48)^((int)r[k++]-48)+48;        m[i]='';

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote