Saturday, January 28, 2017

Bit Stuffing Simulation

Networking  >> Bit Stuffing Simulation Program


In bit stuffing processing, we add 0 after five consecutive 1's in databits.

#include<stdio.h>
int main()
{
 int i=0,count=0;
 char databits[80];

 printf("Enter Data Bits: ");
 scanf("%s",databits);

 printf("Data Bits Before Bit Stuffing:%s",databits);
 printf("\nData Bits After Bit stuffing :");
 
 for(i=0; i<strlen(databits); i++)
 {
    if(databits[i]=='1')
        count++;
    else
        count=0;
printf("%c",databits[i]);
  if(count==5)
    {
        printf("0");
        count=0;
    }
 }
 return 0;
}

Output of the Program:

Enter Data Bits: 101111111000
Data Bits Before Bit Stuffing:101111111000
Data Bits After Bit stuffing :1011111011000

Back to Networking Page >


No comments:

Post a Comment