Character Stuffing
Character Stuffing
1. AIM: Implement the data link layer farming methods such as character, character stuffing.
4. THEORY:
The framing method gets around the problem of resynchronization after an error by having each frame start with the
ASCII character sequence DLE STX and this sequence DLE ETX. If the destination ever losses the track of the frame
boundaries all it has to do is look for DLE STX or DLE ETX characters to figure out. The data link layer on the receiving
end removes the DLE before the data are given to the network layer. This technique is called character stuffing
5. ALGORITHM: Begin
Step 7: print invalid position and read again the position, pos
Step 8: end if
Step 10: Initialize the array b , b[0…5] as ‟d‟, ‟l‟, ‟e‟, ‟s‟ ,‟t‟ ,‟x respectively
Step 14: initialize b array,b[j],b[j+1]…b[j+6] as„d‟, „l‟, „e‟ ,‟ch, ‟d‟, „l‟,„e‟respectively
Step 15 : increment j by 7, i.e j=j+7
End
EndSOURCE CODE:
6. PROGRAM
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
void main()
int i=0,j=0,n,pos;
char a[20],b[50],ch;
clrscr();
printf("enter string\n");
scanf("%s",&a);
n=strlen(a);
printf("enter position\n");
scanf("%d",&pos);
if(pos>n)
scanf("%d",&pos);
ch=getche();
b[0]='d';
b[1]='l';
b[2]='e';
b[3]='s';
b[4]='t';
b[5]='x';
j=6;
while(i<n)
if(i==pos-1)
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]=ch;
b[j+4]='d';
b[j+5]='l';
b[j+6]='e';
j=j+7;
{
b[j]='d';b[j+1]='l';b[j+2]='e';
j=j+3;}
b[j]=a[i];
i++;
j++;}
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]='e';
b[j+4]='t';
b[j+5]='x';
b[j+6]='\0';
printf("%s",b);
getch();
7. RESULT:
Byte stuffing is the process of adding 1 extra byte whenever there is a flag or escape character in the
text