Upload
ashishagarwal
View
235
Download
0
Embed Size (px)
Citation preview
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
1/13
EXPERIMENT NO: 1. (a)
NAME OF THE EXPERIMENT:Character Stuffing.
AIM:Implement the data link layer framing methods such as character, character stuffing.
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 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
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
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
2/13
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
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
3/13
archana
enter position
3
enter the character
h
frame after stuffing:
dlestxardlehdlechanadleetx
VIVA QUESTIONS:
1.What is character stuffing?
2.What is the use of character stuffing?
3.__________ is analogous to bit stuffing.
4.___________ are the delimiters for character stuffing
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 Stuffing and also De-stuff
and the Character Stuffing, 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
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
4/13
Problem statement2
Write a c program for character stuffing and destuffing
Test case
Input and Output
Problem statement 3
Implement the DataLinklayer framing methods such as Character stuffing
Test case
Input and Output
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
5/13
Problem statement 4
Write a program for Character Stuffing Flow Chart
Test caseInput and Output
Problem Statement: 5
Write a program to stuff string to another string at the beginning
Test case
Input and Output
Problem statement: 6
Write a program to stuff a substring into a main string at position end
Test case
Input and Output
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
6/13
Problem statement 7
Write a program to stuff substring into a string at specified position
Test case
Input and Output
Problem statement 8
Write program to find 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
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
7/13
EXPERIMENT NO: 1. (b)
NAME OF THE EXPERIMENT:Bit Stuffing.
AIM:Implement the data link layer framing methods such as and bit stuffing.
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 flag byte. When ever the senders data link layer
encounters five consecutive ones in the data, it automatically stuffs a 0 bit into the out going
bit stream. This bit stuffing is analogous to character stuffing, in which a DLE is stuffed 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
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
8/13
Step 5:Initialize i=0, j=0,count =0
Step 6:repeat step (7 to 22) until i
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
9/13
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 stuffing the frame is:1111101111111
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
10/13
VIVA QUESTIONS:
1.What is bit stuffing?
2.What is the use of bit stuffing?
3.with bit stuffing the boundary b/w 2 frames can be unambiguously recognized by
------------------------
4.-------------------- is analogous to character stuffing
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 stuffing
Problem statement 1
To add 0 to each set of 5 ones i.e. after every five 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
stuffed one and unstuffed one should be displayed
Test Cases
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
11/13
Input and Output
Problem statement 3:
Write a program of bit stuffing after for every 5 consecutive ones it becomes zero
Test Cases
Input and Output
Problem statement 4
Write a program of bit stuffing after for every 5 consecutive ones it becomes zero
Test Cases
Input and Output
Problem statement 5:
Write a C program to performs bit stuffing/de-stuffing on an input data stream
Test Cases
Input and Output
Problem statement 6:
5 MLR INSTITUTE of TECHNOLOGY Hyd A.Y 2014-15
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
12/13
Write a program Bit Stuffing in C Language Programming with Stuffed 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 Stuffing.
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 five
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
8/12/2019 Computer Networks Lab Manual l on 5.7.14 (1)
13/13
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 haiand 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