In data transmission and telecommunication, bit stuffing (also known—uncommonly—as positive justification) is the insertion of noninformation bits into data. Stuffed bits should not be confused with overhead bits.
Bit stuffing is used for various purposes, such as for bringing bit streams that do not necessarily have the same or rationally related bit rates up to a common rate, or to fill buffers or frames. The location of the stuffing bits is communicated to the receiving end of the data link, where these extra bits are removed to return the bit streams to their original bit rates or form. Bit stuffing may be used to synchronize several channels before multiplexing or to rate-match two single channels to each other.
Applications include Plesiochronous Digital Hierarchy and Synchronous Digital Hierarchy.
Another use of bit stuffing is for run length limited coding: to limit the number of consecutive bits of the same value in the data to be transmitted. A bit of the opposite value is inserted after the maximum allowed number of consecutive bits. Since this is a general rule the receiver doesn't need extra information about the location of the stuffing bits in order to do the destuffing.
This is done to create additional signal transitions to ensure reliable transmission or to escape special reserved code words such as frame sync sequences when the data happens to contain them.
Applications include Controller Area Network, HDLC, and Universal Serial Bus.
Bit stuffing does not ensure that the payload is intact (i.e. not corrupted by transmission errors); it is merely a way of attempting to ensure that the transmission starts and ends at the correct places. Error detection and correction techniques are used to check the frame for corruption after its delivery and, if necessary, the frame will be resent.
Zero-bit insertion is a particular type of bit stuffing (in the latter sense) used in some data transmission protocols. It was popularized by IBM's SDLC (later renamed HDLC), to ensure that the Frame Sync Sequence (FSS) never appears in a data frame. An FSS is the method of frame synchronization used by HDLC to indicate the beginning and/or end of a frame.
The name relates to the insertion of only 0 bits. No 1 bits are inserted to limit sequences of 0 bits.
The bit sequence "01111110" containing six adjacent 1 bits is commonly used as a "Flag byte" or FSS.
To ensure that this pattern never appears in normal data, a 0 bit is stuffed after every five 1 bits in the data. This typically adds 1 stuffed bit to every 32 random payload bits, on average. Note that this stuffed bit is added even if the following data bit is 0, which could not be mistaken for a sync sequence, so that the receiver can unambiguously distinguish stuffed bits from normal bits.
A similar scheme is used in the Universal Serial Bus, but for a different reason: to ensure sufficient clock edges. Low- and full-speed USB data is sent NRZI encoded: a 0 bit causes a signal transition, while a 1 bit causes no change. The receiver must count the time between transitions to determine the number of 1 bits, and if that time is too long, the receiver can lose count. USB stuffs a 0 bit (causing a transition) after every 6 consecutive 1 bits; this guarantees at least one transition every 7 bit times. (A (0,6) RLL code.)
Full article ▸