Techknow Study

DLL framing

6:21:00 PM vikas 0 Comments Category :



WAP in C/C++ to implement DLL framing method by bit stuffing.


THEORY & CONCEPT-:
Each frame begins and ends with a special bit pattern called a flag byte [01111110].

• Whenever sender data link layer encounters five consecutive ones in the data stream, it
automatically stuffs a 0 bit into the outgoing stream.

• When the receiver sees five consecutive incoming ones followed by a 0 bit, it automatically destuffs the 0 bit before sending the data to the network
layer.





PROGRAM in C/ C++-:


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
  char text[100],text1[100];
  int k,n,count=0,i,j,p;
  clrscr();
  printf("Enter text at sender end:");
  gets(text);
  n=strlen(text);
  for(k=0;k<=n;k++)
   {
    text1[k]=text[k];
   }
  for(i=0;i<n;i++)
  {
  if(text[i]=='1')
    count++;
    if(text[i]=='0')
    count=0;
     if(count==5)
     {
      p=1+1;
      for(j=n+1;j>p;j++)
      {text[j]='0';}
      n++;
      count=0;
     }
  }
  printf("Bit stuffed code is:");
  printf("01111110");
  for(k=0;k<strlen(text);k++)
  printf("%c",text[k]);
  printf("01111110");
  printf("\n Text at reciever end:");
  for(k=0;k<=n-1;k++)
  {
    printf("%c",text1[k]);
  }
  getch();
}




RELATED POSTS

0 comments