Bit Stuffing program in C| Framing Methods

Implement the data link layer framing methods such as character, character-stuffing and bit stuffing.

Experiment No:1(a): BIT STUFFING

Hardware Requirements: Intel based Desktop PC:RAM of 1GB

Software Requirement: Turbo C / Turbo C++

Theory:

Bit stuffing is the new technique which allows data frames to contain an arbitrary number if bits and allow character code with an arbitrary no. of bits per character. Each frame begins and ends with special bit pattern, 01111110, called a flag byte. Whenever the sender’s data link layer encounters five consecutive 1’s in the data, it automatically stuffs/ Append /Add 0 bit into outgoing bit stream.

Bit stuffing

SOURCE CODE:

 

#include<stdio.h>

#include<string.h>

void main()

{

int a[20],b[30],i,j,k,count,n;

printf("Enter frame length:");

scanf("%d",&n);

printf("Enter input frame (0's & 1's only):");

for(i=0;i<n;i++)

scanf("%d",&a[i]);

i=0; count=1; j=0;

while(i<n)

{

if(a[i]==1)

{

b[j]=a[i];

for(k=i+1;a[k]==1 && k<n && count<5;k++)

{

j++;

b[j]=a[k];

count++;

if(count==5)

{

j++;

b[j]=0;

}

i=k;

}}

else

{

b[j]=a[i];

}

i++;

j++;

}

printf("After stuffing the frame is:");

for(i=0;i<j;i++)

printf("%d",b[i]);

}

OUTPUT:

Enter Frame Length: 5

Enter input Frame (0’s & 1’s only):1

1

1

1

1

After stuffing the frame is: 111110

OUTPUT CONSOLE:

Bit Stuffing Output






Comments

  1. Not truly, We entitle that devise main in-steal of the a multiple of backs a decorous interesting impact for you to tutor's head. We would lease that volition dapper & easy bid cure-summations for you to factory beliefs and properly. IR Repeater

    ReplyDelete

Post a Comment

Search related post on google