0% found this document useful (0 votes)
78 views5 pages

Character Stuffing

The document describes an experiment on implementing data link layer framing methods such as character stuffing. It discusses the aim, hardware/software requirements, theory, algorithm and program for a character stuffing method that inserts escape characters around inserted data to mark frame boundaries. The program takes a string as input, inserts a given character at a specified position, and outputs the framed string with escape characters added.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views5 pages

Character Stuffing

The document describes an experiment on implementing data link layer framing methods such as character stuffing. It discusses the aim, hardware/software requirements, theory, algorithm and program for a character stuffing method that inserts escape characters around inserted data to mark frame boundaries. The program takes a string as input, inserts a given character at a specified position, and outputs the framed string with escape characters added.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

EXPERMENT NO.

1. AIM: Implement the data link layer farming methods such as character, character stuffing.

2. HARDWARE REQUIREMENTS: Intel based Desktop PC:-RAM of 512 MB

3. SOFTWARE REQUIREMENTS: Turbo C / Borland C.

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 1: Initialize I and j as 0

Step 2: Declare n and pos as integer and a[20],b[50],ch as character

Step 3: read the string a

Step 4: find the length of the string n, i.e n-strlen(a)

Step 5: read the position, pos

Step 6: if pos > n then

Step 7: print invalid position and read again the position, pos

Step 8: end if

Step 9:read the character, ch

Step 10: Initialize the array b , b[0…5] as ‟d‟, ‟l‟, ‟e‟, ‟s‟ ,‟t‟ ,‟x respectively

Step 11: j=6;

Step 12: Repeat step[(13to22) until i<n

Step 13: if i==pos-1 then

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

Step 16: end if

Step 17: if a[i]==‟d‟ and a[i+1]==‟l‟ and a[i+2]==‟e‟ then

Step 18: initialize array b, b[13…15]=‟d‟, „l‟, „e‟ respectively

Step 19: increment j by 3, i.e j=j+3

Step 20: end if

Step 21: b[j]=a[i]

Step 22: increment I and j;

Step 23: initialize b array,b[j],b[j+1]…b[j+6] as„d‟, „l‟,„e‟ ,‟e‟,„t‟, „x‟,„\0‟respectively

Step 24: print frame after stiuffing

Step 25: print b

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)

printf("invalid position, Enter again :");

scanf("%d",&pos);

printf("enter the character\n");

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;

if(a[i]=='d' && a[i+1]=='l' && a[i+2]=='e')

{
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("\nframe after stuffing:\n");

printf("%s",b);

getch();

7. RESULT:

Figure 2: Output of Experiment 1.B


8. OBSERVATIONS :

Byte stuffing is the process of adding 1 extra byte whenever there is a flag or escape character in the
text

You might also like