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

prefetch

This chapter presents key concepts of intercommunication between programs runnin


g on di?erent computers in the network. It introduces elements of network progra
mming and concepts involved in creating network applications using sockets. The
chapter introduces the java.net package containing various classes re-quired for
creating sockets and message commun
import java.util.*;
import java.io.*;
class CRC
{
public static void main(String args[])
{
int i,j,ne,t=0,m=0;
int a[]=new int[20];
int b[]=new int[20];
int c[]=new int[20];
int x[]=new int[20];
int divisor[]=new int[20];
Scanner s=new Scanner(System.in);
System.out.println("Sender data");
System.out.println("enter length of data");
int n=s.nextInt();
System.out.println("enter data bits(0 & 1)");
for(i=0;i<n;i++)
{c[i]=s.nextInt();a[i]=c[i];}
System.out.println("enter length of divisor");
int d=s.nextInt();
System.out.println("enter divisor bits(0 & 1)");
for(i=0;i<d;i++)
{divisor[i]=s.nextInt();b[i]=divisor[i];}
ne=n+d-1;
for(i=n;i<ne;i++)
a[i]=0;
while(ne>=d)
{i=0;t=0;
if(a[i]==1)
{
while(i<d)
{
a[i]=a[i]^b[i];
i++;
}
}
if(a[0]==0)
{
for(j=0;j<ne-1;j++)
{
a[j]=a[j+1];
if(b[j]>=a[j])
t++;
}
ne--;
}
}
if(t<=d)
{

System.out.println("add this at the end of sender data");


for(i=0;i<t;i++)
{System.out.print(a[i]);
c[n+i]=a[i];
}
}
System.out.println("\nsender side data is :");
for(i=0;i<n+t;i++)
System.out.print(c[i]);
//complete sender side data
//reciever data entry
System.out.println("\n");
System.out.println("Reciever data");
System.out.println("enter length of data");
int l=s.nextInt();
System.out.println("enter data bits(0 & 1)");
for(i=0;i<l;i++)
{x[i]=s.nextInt();}
while(l>=d)
{i=0;t=0;
if(x[i]==1)
{
while(i<d)
{
x[i]=x[i]^b[i];
i++;
}
}
if(x[0]==0)
{
for(j=0;j<l-1;j++)
{
x[j]=x[j+1];
if(b[j]>=x[j])
t++;
}
l--;
}
}
if(t<=d)
{
System.out.println("remainder of reciever side data");
for(i=0;i<t;i++)
{System.out.print(x[i]);
if(x[i]==0)
m++;
}
}
if(m==t)
System.out.println("\nthis is correct data");
else
System.out.println("\nthere is error in data");
}
}ication using two di?erent protocols. It provides s

You might also like