Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
Table of contents
1.
Introduction
2.
What is Framing in Computer Network?
3.
What is Framing in the Data Link Layer?
4.
How does Framing Work?
5.
What are Frames in Computer Networks?
6.
Parts of a Frame
7.
Problems in Framing
8.
Types of Framing in Computer Networks
8.1.
1. Fixed-size Framing
8.2.
2. Variable size Framing
9.
Approaches of Framing in Computer Networks
10.
Advantages of Framing in Data Link Layer
11.
Frequently Asked Questions
11.1.
What is framing in networking?
11.2.
What is frame and its types in computer network?
11.3.
Why are frames used in networking?
11.4.
Is framing done by the data link layer?
12.
Conclusion
Last Updated: Mar 27, 2024
Easy

Framing in Data Link Layer

Author Nikunj Goel
3 upvotes

Introduction

Framing is a point-to-point connection between two computers or devices consisting of a wire where data is transmitted as a stream of bits. However, these bits must be framed into discernible blocks of information. Framing is a function of the data link layer.

Data transmission involves the synchronized transmission of bits from the source to the destination in the physical layer. This section will focus on point-to-point data transmission between two devices. The data link layer receives packets from the network layer and then adds source and destination addresses to packets. They are converted into frames in the data link layer. When the frame size becomes large, a packet is divided into a small frame. These smaller-sized frames enable error control and flow control more efficiently.

Framing in Data Link Layer

This blog will discuss framing in computer networks.

What is Framing in Computer Network?

Framing in a computer network uses frames to send/receive the data. The data link layer packs bits into frames such that each frame is distinguishable from another. 

The data link layer prepares a packet for transport across local media by encapsulating it with a header and a trailer to create a frame. 

The frame is defined as the data in telecommunications that moves between various network points. 

Usually, a frame moves bit-by-bit serially and consists of a trailer field and header field that frames the information. These frames are understandable only by the data link layer.

What is Framing in the Data Link Layer?

Framing is a point-to-point connection between two devices that consists of a wire in which data is transmitted as a stream of bits. 

framing in data link layer

Let’s understand this from the given diagram. 

We have given two devices with an adaptor attached to each one. This adaptor will be sending the data into signals which will flow through the cable and will be received by the physical layer of other devices.  

How does Framing Work?

Framing works by breaking data into smaller, manageable units called frames. Each frame consists of a header (containing control information) and a payload (the actual data). The sender adds the header and sends the frame over the network. The receiver then extracts the header, processes the data, and checks for errors to ensure proper delivery. This process allows for efficient and reliable data transmission between devices.

Framing is essential for efficient data transfer because it allows for error detection and recovery. By dividing the data into smaller frames, if any frame is lost or corrupted during transmission, only that specific frame needs to be retransmitted rather than the entire data packet. Additionally, the header information helps in error checking and ensuring that the data is delivered accurately to the intended recipient. This process ensures reliable communication between devices in a network.

What are Frames in Computer Networks?

Frames in computer networks refer to the data units at the data link layer (Layer 2) of the OSI model. They encapsulate packets from the network layer (Layer 3) and add control information like headers and trailers for transmission over the physical medium. Frames facilitate reliable and efficient communication between devices in a network.

Parts of a Frame

  1. Frame Header: It consists of the frame's source and destination address.
     
  2. Payload Field: It contains the message to be delivered.
     
  3. Flag: It points to the starting and the ending of the frame.
     
  4. Trailer: It contains the error detection and correction bits. 
Parts of a Frame

The physical layer doesn’t know anything about the frames. It takes individual bits and converts them into equivalent signals before sending them. Now, the receiving device's physical layer has to convert these bits into frames, but certain problems need to be discussed before that.

Problems in Framing

The problems faced in framing are:

  1. Locating at the beginning of the frame
  2. How will the station notice a frame
  3. Locating end of frame

Types of Framing in Computer Networks

Framing is further divided into two types:

1. Fixed-size Framing

In this type of framing, the size of the frame is fixed, and hence the frame length acts as a delimiter of the frame.  

This framing doesn’t require the additional boundary bits to identify the frame's start and end - for example: If a device is sending 200 bits of data and the 50 bits of frame size is fixed, then after receiving the 50 bits of data, the receiver will automatically know that the next 50 bits are of frame two and so on.

Drawback: It goes through internal fragmentation when the data size is less than the frame size. Padding is a solution to avoid such a situation.

2. Variable size Framing

Variable size framing is a method of dividing data into frames where each frame can have a different size. In this approach, the length of each frame is determined dynamically based on the amount of data that needs to be transmitted at a given time. For example, It is possible that out of 200 bits of data, 100 bits constitute frame 1, 25 bits constitute frame two, and the rest bits constitute frame 3.

The advantage of variable size framing is that it allows for more efficient use of network bandwidth. Smaller frames are used when less data needs to be transmitted, reducing overhead and increasing the efficiency of the data transfer. On the other hand, larger frames are used when there is a larger amount of data to be sent, which helps in maximizing data throughput.

Variable size framing is commonly used in various network protocols, especially those that require adaptive data transmission, such as streaming applications or real-time communication systems. This method enables the network to adapt to varying data requirements and optimize data transfer based on the current network conditions and data load.

In this type of framing, the size of each frame to be transmitted may vary; hence additional mechanisms are kept to mark the end of one frame and the start of the next frame. 

  1. Length Field- It is a component of the frame structure that indicates the length of the data or frame. This field is used to inform the receiving device how many bytes of data to expect in the frame. The specific format and placement of the length field within the frame can vary depending on the data link layer protocol being used.
     
  2. End Delimiter- It is a special sequence or character that marks the end of a frame. It is used to indicate to the receiving device that the entire frame has been received and that it can begin processing the received data.
     
  3. Byte – Stuffing- Byte stuffing, also known as character stuffing, is a technique used to prevent the occurrence of unintended control characters or reserved patterns in transmitted data frames. It involves the insertion of special control characters into the data to distinguish them from control characters used for signaling or framing purposes.
     
  4. Bit – Stuffing- Bit stuffing is a technique used to ensure that specific control bits or patterns within a data stream don't get confused with control bits used for signaling or framing purposes. It involves the insertion of extra bits into the data stream to distinguish them from control bits. The primary purpose of bit stuffing is to ensure that a receiver can accurately identify the start and end of data frames without confusion. This technique is often used in communication protocols to handle special bit sequences that might otherwise be misinterpreted.

Approaches of Framing in Computer Networks

In computer networks, framing refers to the process of delineating the boundaries of data units (frames) within the stream of bits transmitted over a communication channel. Several approaches are used for framing:

  1. Character Count: Delimits frames based on the count of characters or bytes. A specific character count or byte count signals the end of one frame and the beginning of the next.
  2. Flag Bytes: Uses special flag bytes or characters at the beginning and end of each frame. The flag bytes mark the start and end of the frame and help in synchronization.
  3. Byte Stuffing: Inserts special byte sequences (e.g., "ESC" byte) into the data field to distinguish it from control characters. Escaped characters allow the receiver to differentiate between control characters and data bytes.
  4. Bit Stuffing: Inserts additional bits into the data stream to ensure that the frame boundary can be identified. Certain bit patterns are inserted into the data to maintain synchronization and distinguish between data bits and control bits.
  5. Length Field: Includes a length field within the frame header, indicating the length of the frame. The receiver uses this length field to determine where the current frame ends and the next one begins.
  6. Clock-Based Timing: Relies on timing mechanisms to define frame boundaries. A predefined time interval or clock signal helps receivers identify the start and end of each frame.

Advantages of Framing in Data Link Layer

  • Frames are used continuously in the process of time-division multiplexing.
  • It facilitates a form for the sender to transmit a group of valid bits to a receiver.
  • Frames also contain headers that include information such as error-checking codes.
  • A Frame relay, token ring, ethernet, and other types of data link layer methods have their frame structures.
  • Frames allow the data to be divided into multiple recoverable parts that can be inspected further for corruption.
  • It provides a flow control mechanism that manages the frame flow such that the data congestion does not occur on slow receivers due to fast senders.
  • It provides reliable data transfer services between the layers of the peer network.

Frequently Asked Questions

What is framing in networking?

Framing in networking defines the boundaries of data units (frames) within bit streams, aiding in reliable data transmission and reception.

What is frame and its types in computer network?

Frames are data units at the data link layer. Types include Ethernet, Token Ring, and HDLC, each with specific formats and protocols.

Why are frames used in networking?

Frames facilitate efficient and reliable communication by encapsulating data, adding control information, and delineating boundaries, enabling error detection, flow control, and addressing in data transmission.

Is framing done by the data link layer?

Yes, framing is done by the data link layer in networking. It involves breaking data into smaller frames, adding headers and trailers, enabling reliable data transfer over the physical medium, and ensuring proper synchronization between sender and receiver.

Conclusion

This blog discussed Framing in Computer Networks and data link layers. Framing is a point-to-point connection between two devices that consists of a wire in which data is transmitted as a stream of bits. 

When the frame size becomes large, a packet is divided into a small frame. These smaller-sized frames enable error control and flow control more efficiently. 

Recommended Readings

 

Also check out some of the Guided Paths on topics such as Computer NetworksData Structure and AlgorithmsCompetitive Programming, etc. as well as some Contests, Test SeriesInterview Bundles, and some Interview Experiences curated by top Industry Experts only on Coding Ninjas Studio.

Live masterclass