IMPLEMENT DATA LINK LAYER FRAMING METHOD BIT STUFFING
import java.io.*;
public class bitst
{
public static void main(String args[]) throws IOException
{
int temp;
int data[]=new int[8];
int flag[]=new int[5];
int fdata[]=new int[25];
int fidata[]=new int[25];
int fidata[]=new int[25];
DataInputStream obj= new DataInputStream(System.in);
System.out.println("Enter the Data Bits.....");
for (int i=0;i<8;i++)
{
data[i] = Integer.parseInt(obj.readLine());
}
{
data[i] = Integer.parseInt(obj.readLine());
}
System.out.println("Enter Flag Bits.....");
for (int i=0;i<5;i++)
{
flag[i] = Integer.parseInt(obj.readLine());
}
{
flag[i] = Integer.parseInt(obj.readLine());
}
int idx=0;
for (int i=0;i<5;i++)
{
fdata[idx++] = flag[i];
}
for (int i=0;i<8;i++)
{
fdata[idx++] = data[i];
}
for (int i=0;i<5;i++)
{
fdata[idx++] = flag[i];
}
for (int i=0;i<8;i++)
{
fdata[idx++] = data[i];
}
for (int i=0;i<5;i++)
{
fdata[idx++] = flag[i];
}
{
fdata[idx++] = flag[i];
}
int fidx=0,count=0;
for(int i=0;i<idx;i++)
{
fidata[fidx++]=fdata[i];
{
fidata[fidx++]=fdata[i];
if(fdata[i]==1)
count++;
else
count=0;
if(count==5)
{
fidata[fidx++]=0;
count=0;
}
}
System.out.print("Stuff Data : ");
for(int i=0;i<fidx;i++)
{
System.out.print(fidata[i]);
}
count++;
else
count=0;
if(count==5)
{
fidata[fidx++]=0;
count=0;
}
}
System.out.print("Stuff Data : ");
for(int i=0;i<fidx;i++)
{
System.out.print(fidata[i]);
}
int k;
int mycount=0;
int mysecondcount=0;
int mydata[]=new int[25];
for(k=0;k<fidx;k++)
{
mydata[mysecondcount++]=fidata[k];
int mycount=0;
int mysecondcount=0;
int mydata[]=new int[25];
for(k=0;k<fidx;k++)
{
mydata[mysecondcount++]=fidata[k];
if(fidata[k]==1)
mycount++;
else
mycount=0;
mycount++;
else
mycount=0;
if(mycount==5)
{
mycount=0;
k++;
}
{
mycount=0;
k++;
}
}
int j=mysecondcount;
System.out.println(" ");
System.out.print("Inverse : ");
for(int g=0;g<j;g++)
{
System.out.print(mydata[g]);
}
}
}
System.out.println(" ");
System.out.print("Inverse : ");
for(int g=0;g<j;g++)
{
System.out.print(mydata[g]);
}
}
}
output:-
0 comments:
Post a Comment