You are on page 1of 13

EXPERIMENT NO: 1.

(a)
NAME OF THE EXPERIMENT: Character Stufng.
AIM: Implement the data link layer framing methods such as character, character stufng.
HARDWARE REQUIREMENTS: Intel based Desktop PC:-
RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.
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 the 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 fgure 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 stufng
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: fnd 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
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

Step 9: read the character, ch
Step 10: Initialize the array b , b[05] 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] asd, 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[1315]=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] asd, l,e ,e,t, x,\0
respectively
Step 24: print frame after stiufng
Step 25: print b
End
CREATE THE PROGRAM NAME
[m0033@agni cnlabprograms]$ vi exp1a.c
COMPILE THE PROGRAM:
[m0033@agni cnlabprograms]$ cc exp1a.c
OUTPUT:
[m0033@agni cnlabprograms]$ ./a.out
enter string
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

archana
enter position
3
enter the character
h
frame after stufng:
dlestxardlehdlechanadleetx
VIVA QUESTIONS:
1.What is character stufng?
2.What is the use of character stufng?
3.__________ is analogous to bit stufng.
4.___________ are the delimiters for character stufng
5.Expand DLE STX__________
6.Expand DLE ETX_________
PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS FOR WEEK : 1(Exp.1a)
Problem statement 1
Implement the data link layer framing methods such as Character Stufng and also De-stuf
and the Character Stufng, DLESTX and DLEETX are used to denote start and end of character
data
Test case
Input and Output
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

Problem statement2
Write a c program for character stufng and destufng
Test case
Input and Output
Problem statement 3
Implement the DataLinklayer framing methods such as Character stufng
Test case
Input and Output
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

Problem statement 4
Write a program for Character Stufng Flow Chart
Test case
Input and Output
Problem Statement: 5
Write a program to stuf string to another string at the beginning
Test case
Input and Output
Problem statement: 6
Write a program to stuf a substring into a main string at position end
Test case
Input and Output
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

Problem statement 7
Write a program to stuf substring into a string at specifed position
Test case
Input and Output
Problem statement 8
Write program to fnd out the length of a given string without using the library function strlen().
Test case
Input
ENTER A STRING : Welcome
Output
THE LENGTH OF THE STRING IS : 7
Problem statement 9
Write a program to the print the reverse of a given string
Test case
Input
ENTER A STRING : welcome
Output
THE STRING IN THE REVERSE ORDER: emoclew
Problem statement 10
Test case
Input and Output
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

EXPERIMENT NO: 1. (b)
NAME OF THE EXPERIMENT: Bit Stufng.
AIM: Implement the data link layer framing methods such as and bit stufng.
HARDWARE REQUIREMENTS: Intel based Desktop PC:- RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.
THEORY:
The new technique allows data frames to contain an arbitrary number if bits and allows
character codes with an arbitrary no of bits per character. Each frame begins and ends with
special bit pattern, 01111110, called a fag byte. When ever the senders data link layer
encounters fve consecutive ones in the data, it automatically stufs a 0 bit into the out going
bit stream. This bit stufng is analogous to character stufng, in which a DLE is stufed into
the out going character stream before DLE in the data
ALGORITHM:
Begin
Step 1: Read frame length n
Step 2: Repeat step (3 to 4) until i<n(: Read values in to the input frame (0s and 1s) i.e.
Step 3: initialize I i=0;
Step 4: read a[i] and increment i
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

Step 5: Initialize i=0, j=0,count =0
Step 6: repeat step (7 to 22) until i<n
Step 7: If a[i] == 1 then
Step 8: b[j] = a[i]
Step 9: Repeat step (10 to 18) until (a[k] =1 and k<n and count <5)
Step 10: Initialize k=i+1;
Step 11: Increment j and b[j]= a[k];
Step 12: Increment count ;
Step 13: if count =5 then
Step 14: increment j,
Step 15: b[j] =0
Step 16: end if
Step 17: i=k;
Step 18: increment k
Step 19: else
Step 20: b[j] = a[i]
Step 21: end if
Step 22: increment I and j
Step 23: print the frame after bit stufng
Step 24: repeat step (25 to 26) until i< j
Step 25: print b[i]
Step 26: increment i
End
CREATE THE NAME OF THE PROGRAM
[m0033@agni cnlabprograms]$ vi exp1a.c
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

COMPILE THE PROGRAM:
[m0033@agni cnlabprograms]$ cc exp1b.c
OUTPUT
[m0033@agni cnlabprograms]$ ./a.out
Enter frame length:12
Enter input frame (0's & 1's only):
1
1
1
1
1
1
1
1
1
1
1
1
After stufng the frame is: 1111101111111
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

VIVA QUESTIONS:
1.What is bit stufng?
2.What is the use of bit stufng?
3.with bit stufng the boundary b/w 2 frames can be unambiguously recognized by
------------------------
4.-------------------- is analogous to character stufng
5.Each frame begins and ends with a special bit pattern 01111110 called ---------
6. The senders data link layer encounters ----------------no of 1s consecutively
PROBLEM DEFINITIONS DIFFERENT FROM JNTU TOPICS FOR WEEK : 2(Exp.1b)
Week1a: Implement the data link layer framing methods such as bit stufng
Problem statement 1
To add 0 to each set of 5 ones i.e. after every fve consecutive 1s appear a zero
Test Cases
Input and Output
Problem statement 2
The input is in binary format and after 5 consecutive 1's a '0' should be inserted and both the
stufed one and unstufed one should be displayed
Test Cases
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

Input and Output
Problem statement 3:
Write a program of bit stufng after for every 5 consecutive ones it becomes zero
Test Cases
Input and Output
Problem statement 4
Write a program of bit stufng after for every 5 consecutive ones it becomes zero
Test Cases
Input and Output
Problem statement 5:
Write a C program to performs bit stufng/de-stufng on an input data stream
Test Cases
Input and Output
Problem statement 6:
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

Write a program Bit Stufng in C Language Programming with Stufed Number
Test Cases
Input and Output
Problem statement 7
Write a program in C to implement the data link layer framing methods such as Bit Stufng.
Test Cases
Input and Output
Problem statement 8:
Write a program in C to add one tab(\t) space to each set of 8 ones i.e. after every fve
consecutive 1s appear a one tab(\t) space.
Test Cases
Input and Output
Problem statement9
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

Write a program to convert a decimal number to its equivalent Bits format.
Test cases
Input
Enter a decimal number 4
Output
4 in bit format : 100
Problem statement10
Write a program in C to insert hai word into for every 9 consecutive 1s appear hai and add
the pattern i,e 01110 beginning and ending of the bit stream.
Test Cases
Input and Output
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15

You might also like