In
data transmission
Data communication, including data transmission and data reception, is the transfer of data, signal transmission, transmitted and received over a Point-to-point (telecommunications), point-to-point or point-to-multipoint communication chann ...
and
telecommunications
Telecommunication, often used in its plural form or abbreviated as telecom, is the transmission of information over a distance using electronic means, typically through cables, radio waves, or other communication technologies. These means of ...
, bit stuffing (also known—uncommonly—as positive justification) is the insertion of non-information
bits into
data
Data ( , ) are a collection of discrete or continuous values that convey information, describing the quantity, quality, fact, statistics, other basic units of meaning, or simply sequences of symbols that may be further interpreted for ...
. Stuffed bits should not be confused with
overhead bits.
Bit stuffing is used for various purposes, such as for bringing
bit stream
A bitstream (or bit stream), also known as binary sequence, is a sequence of bits.
A bytestream is a sequence of bytes. Typically, each byte is an 8-bit quantity, and so the term octet stream is sometimes used interchangeably. An octet may ...
s that do not necessarily have the same or rationally related
bit rate
In telecommunications and computing, bit rate (bitrate or as a variable ''R'') is the number of bits that are conveyed or processed per unit of time.
The bit rate is expressed in the unit bit per second (symbol: bit/s), often in conjunction ...
s 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
A data link is a means of telecommunications link, connecting one location to another for the purpose of transmitting and receiving digital information (data communication). It can also refer to a set of electronics assemblies, consisting of a t ...
, 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
In telecommunications and computer networking, multiplexing (sometimes contracted to muxing) is a method by which multiple analog or digital signals are combined into one signal over a shared medium. The aim is to share a scarce resource� ...
or to rate-match two single channels to each other.
Another use of bit stuffing is for
run length limited
Run-length limited (RLL) is a line coding technique that is used to send arbitrary data over a communications channel with bandwidth limits. RLL codes are defined by four main parameters: ''m'', ''n'', ''d'', ''k''. The first two, ''m''/''n'', r ...
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 de-stuffing. This is done to create additional signal transitions to ensure reliable reception or to escape special reserved code words such as frame
sync sequences when the data happens to contain them.

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
In information theory and coding theory with applications in computer science and telecommunications, error detection and correction (EDAC) or error control are techniques that enable reliable delivery of digital data over unreliable communi ...
techniques are used to check the frame for corruption after its delivery and, if necessary, the frame will be re-sent.
Zero-bit insertion
The
NRZI coding scheme transmits a 0 bit as a signal transition, and a 1 bit as no change. In this case, bit stuffing is most easily described as the insertion of a 0 bit after a long run of 1 bits.
It was popularized by IBM's
SDLC (later renamed
HDLC
High-Level Data Link Control (HDLC) is a communication protocol used for transmitting data between devices in Telecommunications, telecommunication and Computer network, networking. Developed by the International Organization for Standardization ...
), and is also used in Low- and full-speed
USB
Universal Serial Bus (USB) is an industry standard, developed by USB Implementers Forum (USB-IF), for digital data transmission and power delivery between many types of electronics. It specifies the architecture, in particular the physical ...
.
After a long sequence of 1 bits there would be no transitions in the transmitted data, and it would be possible for the transmitter and receiver clocks to lose synchronisation. By inserting a 0 after five (SDLC) or six (USB) consecutive 1 bits the transmitter guarantees a maximum of six (SDLC) or seven (USB) bit times between transitions. The receiver can synchronise its clock against the transitions to ensure proper data recovery.
In SDLC the transmitted bit sequence "01111110" containing six adjacent 1 bits is the
Flag byte. Bit stuffing ensures that this pattern can never occur in normal data, so it can be used as a marker for the beginning and end of the frame without any possibility of being confused with normal data.
[Kevin R. Fall and W. Richard Stevens, ''TCP/IP Illustrated Volume 1: The Protocols'', Second Edition, Addison-Wesley, 2012, Kindle Edition loc 3505]
The main disadvantage of bit-stuffing is that the
code rate
In telecommunication and information theory, the code rate (or information rateHuffman, W. Cary, and Pless, Vera, ''Fundamentals of Error-Correcting Codes'', Cambridge, 2003.) of a forward error correction code is the proportion of the data-stre ...
is unpredictable; it depends on the data being transmitted.
''Source: from
Federal Standard 1037C
Federal Standard 1037C, titled Telecommunications: Glossary of Telecommunication Terms, is a United States Federal Standard issued by the General Services Administration pursuant to the Federal Property and Administrative Services Act of 1949, ...
in support of
MIL-STD-188
MIL-STD-188 is a series of U.S. military standards relating to telecommunications.
Purpose
Faced with "past technical deficiencies in telecommunications systems and equipment and software…that were traced to basic inadequacies in the appl ...
''
See also
*
Consistent Overhead Byte Stuffing
References
{{reflist
Line codes
Synchronization