Bit Stuffing in Computer Networks

Bit Stuffing in Computer Networks

In this tutorial you are going to learn about Bit Stuffing in Computer Networks.


Before diving into the topic bit stuffing, let's see what is bit-oriented approach. In bit-oriented approach, it simply views the frames as a collection of bits. So, a frame is viewed as a collection of bits and the well-known bit oriented protocol is HDLC, High-Level Data Link Control protocol.

In the frame format of HDLC, we have a beginning sequence which is of eight bits, a header which is of 16 bits, the variable length body, followed by the CRC - the cyclic redundancy check of 16 bits and finally the ending sequence of eight bits. The beginning sequence and ending sequence are of eight bits and they are one and the same.

Bit Stuffing in Computer Networks

Bit Stuffing

Suppose, if A1 is the sender and this sender is going to send some data, it is obviously a group of bits. There will be the beginning sequence and there will be the ending sequence and we know the beginning sequence and the ending sequence in HDLC will be 01111110.

Bit Stuffing in Computer Networks

The sender A1 is going to send some data to the receiver A2. Here, the common protocol they agree upon for framing is HDLC. So, if it is HDLC, obviously the beginning sequence will be 01111110 and the ending sequence will also be 01111110.

If A1 is going to send some data, there will be a beginning sequence followed by other fields and there will be an ending sequence. So in this case, this data is being sent and it is received by the receiver and the receiver accepts this frame because there is no problem with the group of bits that are transmitted.

A scenario which has some problems:

Bit Stuffing in Computer Networks

Suppose if B1 is the sender and it is going to send some group of bits. Here you can see the beginning sequence, the ending sequence and the data part.

The problem here is that there is a bit pattern in the data which resembles the beginning sequence or the ending sequence. In this case when the receiver B2 receives this group of bits, it understands that this is the end of the frame and therefore this is the frame which leads to framing error. But actually, this is not the frame that was created by the sender.

This is the problem which has to be handled. The problem statement is if the beginning sequence or the ending sequence appear in the data part then the receiver may misunderstand that this is the end of the frame. So, we are required to rectify this issue and the solution for this problem is bit stuffing.

We are going to stuff a bit when we receive five consecutive ones, a zero is going to be stuffed after five consecutive ones. Suppose, if the sender is receiving the data from the upper layer and if the sender sees that there are five consecutive ones, it is going to stuff a zero after the fifth consecutive one. That's it, the problem is resolved.

Here the receiver knows the beginning sequence and the ending sequence, and when it sees the data part, if it finds a zero after five consecutive ones, it removes that zero and constructs the original data. So the process of inserting zero after five consecutive ones is called bit stuffing. The sender will do this bit stuffing and the receiver will undo this bit stuffing.

This article on Bit Stuffing in Computer Networks is contributed by Rajnish Kumar. If you like TheCode11 and would like to contribute, you can also write your article to us. Here is our mail id -

Previous Post Next Post

Contact Form