0% found this document useful (0 votes)
4 views3 pages

Data Link Layer Framing Techniques

The document outlines a program that implements data link layer framing methods, specifically character stuffing and bit stuffing. It includes source code examples for both methods, demonstrating how to handle input frames by adding specific characters or bits to prevent data misinterpretation. The outputs of the programs are also provided, showing the results of the stuffing processes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Data Link Layer Framing Techniques

The document outlines a program that implements data link layer framing methods, specifically character stuffing and bit stuffing. It includes source code examples for both methods, demonstrating how to handle input frames by adding specific characters or bits to prevent data misinterpretation. The outputs of the programs are also provided, showing the results of the stuffing processes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

PROGRAM: 1

Aim: To implement the data link layer framing method such as


Character stuffing and Bit stuffing.

Character Stuffing:

Source Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char frame[50],temp[50]="DLESTX";
int i,j=6;
clrscr();
printf(" Enter input character ");
gets(frame);
strcat(temp,frame);
for(i=0;frame[i]!='\0';i++)
{
if((frame[i]=='D'&&frame[i+1]=='L'&&frame[i+2]=
='E')||(frame[i]==" "))
{
strcat(temp,"DLE");
j=j+3;
}
temp[j++]=frame[i];
}
strcat(temp,"DLEETX");
printf("\n The stuffed frame is : \n\t");
puts(temp);}

Output:

Enter input character FDGHDLE

The stuffed frame is:


DLESTXFDGHDLEDLEDLEETX

CN&OS LAB MANUAL


Bit Stuffing:

Source Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i;
int frame[20],temp[30],n,j=0,count=0;
clrscr();
printf("\n Enter the length of the input frame:");
scanf("%d",&n);
printf("\n Enter the bit frame\n\t");
for(i=0;i<n;i++)
scanf("%d",&frame[i]);

CN&OS LAB MANUAL


for(i=0;i<n;i++)
{
if(frame[i]==1)
count++;
else
count=0;
temp[j++]=frame[i];
if(count==5)
{
temp[j++]=0;
count=0;
}
}
printf("\n Stuffed frame is \n");
for(i=0;i<j;i++)
printf("%d",temp[i]);}

Output:

Enter the length of the input frame:7


Enter the bit frame
1
1
1
1
1
1
1

Stuffed frame is
11111011

CN&OS LAB MANUAL

You might also like