100% found this document useful (1 vote)
359 views

Implement The Data Link Layer Framing Methods Such As and Bit Stuffing

The document discusses bit stuffing, a data link layer framing method. It explains that bit stuffing inserts a 0 bit after every sequence of 5 consecutive 1 bits to avoid losing synchronization. The document provides pseudocode to implement a bit stuffing algorithm that reads an input frame, checks for sequences of 5 1's, inserts 0 bits as needed, and outputs the stuffed frame. It includes a short C program that implements the bit stuffing algorithm.

Uploaded by

Vyshnavi Mereti
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
100% found this document useful (1 vote)
359 views

Implement The Data Link Layer Framing Methods Such As and Bit Stuffing

The document discusses bit stuffing, a data link layer framing method. It explains that bit stuffing inserts a 0 bit after every sequence of 5 consecutive 1 bits to avoid losing synchronization. The document provides pseudocode to implement a bit stuffing algorithm that reads an input frame, checks for sequences of 5 1's, inserts 0 bits as needed, and outputs the stuffed frame. It includes a short C program that implements the bit stuffing algorithm.

Uploaded by

Vyshnavi Mereti
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/ 3

5/2/23, 1:49 PM Implement the data link layer framing methods such as and bit stuffing.

- Lab Manual

Implement The Data Link Layer Framing


Methods Such As And Bit Stuffing.
 At February 13, 2018    Computer Network,

Implement the data link layer framing methods such as and bit stuffing.

Introduction to bit stuffing framing method used in Data Link layer:


The new technique allows data frames to contain an arbitrary number of bits and
allows character codes with an arbitrary no of bits per character. Each frame begins
and ends with the special bit pattern, 01111110, called a flag byte. Whenever the
sender's data link layer encounters five consecutive ones in the data, it automatically
stuffs a 0 bit into the outgoing bit stream. This bit stuffing is analogous to character
stuffing, in which a DLE is stuffed into the outgoing character stream before DLE in
the data.

Program Algorithm:
Begin
Step 1: Read frame length n
Step 2: Repeat step (3 to 4) until i<n(: Read values into the input frame (0’s and
1’s) i.e.
Step 3: initialize I i=0;
Step 4: read a[i] and increment i
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
https://programingmanual.blogspot.com/2018/02/implement-data-link-layer-framing.html 1/3
5/2/23, 1:49 PM Implement the data link layer framing methods such as and bit stuffing. - Lab Manual

Step 22: increment I and j


Step 23: print the frame after bit stuffing
Step 24: repeat step (25 to 26) until i< j
Step 25: print b[i]
Step 26: increment i
End

Program Code: // BIT Stuffing program


#include<stdio.h>
#include<string.h>
void main()
{
int a[20],b[30],i,j,k,count,n;
printf("Enter frame length:");
scanf("%d",&n);
printf("Enter input frame (0's & 1's only):");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
i=0; count=1; j=0;
while(i<n)
{
if(a[i]==1)
{
b[j]=a[i];
for(k=i+1;a[k]==1 && k<n && count<5;k++)
{
j++;
b[j]=a[k];
count++;
if(count==5)
{
j++;
b[j]=0;
}
i=k;
}}
else
{
b[j]=a[i];
}
i++;
j++;

https://programingmanual.blogspot.com/2018/02/implement-data-link-layer-framing.html 2/3
5/2/23, 1:49 PM Implement the data link layer framing methods such as and bit stuffing. - Lab Manual

}
printf("After stuffing the frame is:");
for(i=0;i<j;i++)
printf("%d",b[i]);
}

Program Output:
Enter frame length:5
Enter input frame (0's & 1's only):
1
1
1
1
1
After stuffing the frame is:111110
------------------
(program exited with code: 6)
Press return to continue

https://programingmanual.blogspot.com/2018/02/implement-data-link-layer-framing.html 3/3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy