Bit Stuffing in C/C++ Language Program with Stuffed Number CS1305- NETWORK LAB

 

Step by step Algorithm: Start the Bit stuffing program
An input string is accepted from the user and saved in ‘a’.
In the program if consecutive 1’s for more than 5 bits, then a ‘0’ is passed after the fifth ‘1’.
This form is the bit stuffed number.
At the receiver side the added ‘0’ is removed and original string is restored
Finally it gives the unstuffed string
BIT Stuffing
In the stuffing process the data should be sent specified in step, whenever 5 consecutive ones come a zero should be appended. In the case of unstuffy check for zero after 5 consecutive ones and remove it . Thus we fount original information

Source Code in C programming CS1305- NETWORK LAB
#include<stdio.h>
main()
{ char a[10];
int count=0,i=0,j,l,k=0;
printf("Enter the input string");
scanf("%s",a);
L=strlen(a);
for(i=0;i<l;i++)
if(a[i]=='1')
{ k=i;
count=0;
while(a[k]=='1')
{ count+=1;
k++;
if(count==5)
{ for(j=l+1;j>k;j--)
{ a[j]=a[j-1];
} a[k]='0';
l++;
break;
}
i=k;
}
}
printf("\n The bitstuffed string is %s",a);
//getch();
k=0;
for(i=0;i<=l;i++)
{ if(a[i]=='1')
{
k=i;
count=0;
while(a[k]=='1')
{ count+=1;
k++;
if(count==5)
{
for(j=k;j<l+1;j++)
{
a[j]=a[j+1];
} l--;
a[l+1]='0';
break;
} }
i=k-1;
} }
printf("String after unstuffing %s\n",a);
}

Output CS1305- NETWORK LAB
Enter the input string 111111011
The bit stuffed string is 111110011
String after unstuffing is 11111011 


bit stuffing and destuffing program in computer networks,byte stuffing and destuffing program in c,bit stuffing algorithm computer networks,bit stuffing program in c using files,bit stuffing in computer networks

No comments:
Write comments