Various Types of Framing Methods in Data Link Layer

Various Types of Framing Methods in Data Link Layer –

Framing is a highlight point association between two PCs or gadgets comprises of a wire wherein information is communicated as a surge of bits. Be that as it may, these frames should be outlined into perceivable squares of data. Framing is an element of the data link layer. It gives a path to a sender to communicate a bunch of bits that are significant to the recipient. Ethernet, token ring, frame transfer, and other information connect layer advancements have their own edge structures. Frames have headers that contain data, for example, blunder checking codes.

At Data Link Layer, it extricates message from sender and give it to collector by giving sender’s and receiver’s location. The upside of utilizing outlines is that information is separated into recoverable pieces that can undoubtedly be checked for defilement.

Types of Framing –

Framing are of two types –

1.) Fixed Sized Framing
2.) Variable Sized Framing

Fixed-sized Framing – In Fixed size framing size of the frame is fixed so the frame length acts as delimiter of the frame. Thus, it doesn’t need extra limit bits to recognize the beginning and end of the frame.

Example − ATM cells.

Variable  Sized Framing – In variable size framing the size of each frame to be communicated might be unique. So extra mechanisms are kept to mark the end of one frame and the starting of the next frame.

Example – Used in local area networks.

There are two ways to define frame delimiters in variable sized framing −

  • Length Field − A length field is used to find out the size of the frame. It is used in Ethernet (IEEE 802.3).
  • End Delimiter (ED)− A pattern is used as a delimiter to find out the size of frame. It is used in Token Rings. If that pattern comes in the data it creates a problem, then this situation is solved using two methods –
    • Byte Stuffing − A byte is stuffed in the message to differentiate from the delimiter. This is also called character-oriented framing.
    • Bit Stuffing − A pattern of bits of random length is stuffed in the message to differentiate from the delimiter. This is also called bit – oriented framing

Applications of Bit Stuffing –

1. synchronize several channels before multiplexing
2. rate-match two single channels to each other
3. run length limited coding

Run length limited coding – It is the technique to limit the number of continuous bits of the same value(i.e., binary value) in the data to be communicated. A bit of the opposite value is inserted after the maximum number of allowed consecutive bits.

Problems in Framing –

  • Identifying beginning of the frame: When an frame is communicated, each station should have the option to distinguish it. Station recognize frames by paying special mind to uncommon arrangement of pieces that denotes the start of the frame for example SFD (Starting Frame Delimeter).
  • How station recognize a frame: Every station tune in to interface for SFD design through a consecutive circuit. In the event that SFD is identified, successive circuit alarms station. Station checks objective location to acknowledge or dismiss frame.
  • Identifying end of edge: When to quit reading the frame.

Example of bit stuffing – Bit sequence: 110101111101011111101011111110 (without bit stuffing)
Bit sequence: 110101111100101111101010111110110 (with bit stuffing)
After 5 consecutive 1-bits, a 0-bit is stuffed. Stuffed bits are marked bold.

C Program for Bit stuffing

#include<stdio.h>
int main()
{
  int i=0,count=0;
  char databits[80];
  printf("Enter Data Bits: ");
  scanf("%s",databits);
  printf("Data Bits Before Bit Stuffing:%s",databits);
  printf("\nData Bits After Bit stuffing :"); 
  for(i=0; i<strlen(databits); i++)
  {
     if(databits[i]=='1') 
        count++;
     else
        count=0;
     printf("%c",databits[i]); 
     if(count==5)
     { 
        printf("0");
        count=0;
     } 
  } 
return 0;
 }

 

Output of the Program:

Enter Data Bits: 101111111000 Data Bits Before Bit Stuffing:101111111000 Data Bits After Bit stuffing :1011111011000

C Program for Byte stuffing

#include<stdio.h>             
#include<string.h>         
int main(){
        char a[20],b[20];
        int i,n,j;
        char f,s;
        printf("Enter the size of the frame : ");
        scanf("%d",&n);
        n=n*2;
        printf("\nEnter the characters in frame : \n");
        for(i=0;i<n;i++)
                scanf("%c",&a[i]);
        printf("\n FRAME \n ");
        for(i=0;i<n;i++)
                printf("%c",a[i]);
        j=0;
        for(i=0;i<n;i++)
        {
                if(a[i]=='f')
                {
                        b[j]='s';
                        j++;
                        b[j]=a[i];

                }
                else if(a[i]=='s')
                {
                        b[j]='s';
                        j++;
                        b[j]=a[i];
                }
                else
                        b[j]=a[i];

                j++;
        }
        printf("\n RESULT \n");
        printf("f");
        for(i=0;i<j;i++)
        {
                printf("\n");
                printf("%c",b[i]);
        }
        printf("\nf");
        
    return 0;
}

learn more about byte stuffing from here.

Conclusion

We have successfully seen various Framing Methods in Data Link Layer. If you have any doubt feel free to ask us in the comments section.

Related Articles

Leave a Reply