A bitstream (or bitstream), also known as a binary sequence, is a sequence of bits.
A bytestream is a sequence of bytes. Typically, each byte is an 8-bit quantity (octets), and so the term octet-stream is sometimes used interchangeably. An octet may be encoded as a sequence of 8 bits in multiple different ways (see endianness) so there is no unique and direct translation between bytestreams and bitstreams.
Bitstreams and bytestreams are used extensively in telecommunications and computing. For example, synchronous bitstreams are carried by SONET, and Transmission Control Protocol transports an asynchronous bytestream.
In practice, bitstreams are not used directly to encode bytestreams; a communication channel may use a signaling method that does not directly translate to bits (for instance, by transmitting signals of multiple frequencies) and typically also encodes other information such as framing and error correction together with its data.
The term bitstream is frequently used to describe the configuration data to be loaded into a field-programmable gate array (FPGA). Although most FPGAs also support a byte-parallel loading method as well, this usage may have originated based on the common method of configuring the FPGA from a serial bit stream, typically from a serial PROM or flash memory chip. The detailed format of the bitstream for a particular FPGA is typically proprietary to the FPGA vendor.
In mathematics, several specific infinite sequences of bits have been studied for their mathematical properties; these include the Baum–Sweet sequence, Ehrenfeucht–Mycielski sequence, Fibonacci word, Kolakowski sequence, regular paper folding sequence, Rudin–Shapiro sequence, and Thue–Morse sequence.
On most operating systems, including Unix-like and Windows, standard I/O libraries convert lower-level paged or buffered file access to a bytestream paradigm. In particular, in Unix-like operating systems, each process has three standard streams, which are examples of unidirectional bytestreams. The Unix pipe mechanism provides bytestream communications between different processes.
Compression algorithms often code in bitstreams, as the 8 bits offered by a byte (the smallest addressable unit of memory) may be wasteful. Although typically implemented in low-level languages, some high-level languages such as Python and Java offer native interfaces for bitstream I/O.
One well-known example of a communication protocol that provides a byte-stream service to its clients is the Transmission Control Protocol (TCP) of the Internet protocol suite, which provides a bidirectional bytestream.
The Internet media type for an arbitrary bytestream is application/octet-stream. Other media types are defined for bytestreams in well-known formats.