Bit Stuffing

Difference with Bit Banging?

Bit stuffing is the insertion of non-information bits into data. Stuffed bits should not be confused with overhead bits.

Byte Stuffing / Character Stuffing is exactly the same thing except we stuff bytes instead of bits.

Why?

Some communication protocols use specific bit sequences to mark the start and end of a data frame (e.g., 01111110 for a frame delimiter in HDLC or PPP). Bit stuffing prevents accidental creation of these control sequences within the actual data.

  • Ahh, imagine you send data and there’s consecutive 1’s in the data. Without bit stuffing, you would accidentally read it as a flag.

How does bit stuffing work exactly?

When the transmitter detects five consecutive 1s in the data, it automatically inserts a 0 after these five 1s. The receiver, upon receiving the data, also looks for five consecutive 1s. If a 0 follows, it is removed (unstuffed), reconstructing the original data.