Wednesday, March 23, 2016

Difference between byte stream and bit stream

Leave a Comment

So far I thought they are the same as bytes are made of bits and that both side needs to know byte size and endiannes of the other side and transform stream accordingly. However Wikipedia says that byte stream != bit stream (https://en.wikipedia.org/wiki/Byte_stream ) and that bit streams are specifically used in video coding (https://en.wikipedia.org/wiki/Bitstream_format). In this RFC https://tools.ietf.org/html/rfc107 they discuss these 2 things and describe Two separate kinds of inefficiency arose from bit streams.. My questions are:

  • what's the real difference between byte stream and bit stream?
  • how bit stream works if it's different from byte stream? How does a receiving side know how many bits to process at a given time?
  • why is bit stream better than byte stream in some cases?

4 Answers

Answers 1

This is a pretty broad question, I'll have to give the 10,000 feet view. Bit streams are common in two distinct usages:

  • very low-level, it is the fundamental way that lots of hardware operates. Best examples are the data stream that comes off a hard disk or a optical disk or the data sent across a transmission line, like a USB cable or the coax cable or telephone line through which you received this post. The RFC you found applies here.

  • high-level, they are common in data compression, a variable number of bits per token allows packing data tighter. Huffman coding is the most basic way to compress. The video encoding subjects you found applies here.

what's the real difference between byte stream and bit stream?

Byte streams are highly compatible with computers which are byte-oriented devices and the ones you'll almost always encounter in programming. Bit streams are much more low-level, only system integration engineers ever worry about them. While the payload of a bit stream is often the bytes that a computer is interested in, more overhead is typically required to ensure that the receiver can properly interpret the data. There are usually a lot more bits than necessary to encode the bytes in the data. Extra bits are needed to ensure that the receiver is properly synchronized and can detect and perhaps correct bit errors. NRZ encoding is very common.

The RFC is quite archeological, in 1971 they were still hammering out the basics of getting computers to talk to each other. Back then they were still close to the transmission line behavior, a bit stream, and many computers did not yet agree on 8 bits in a byte. They are fretting over the cost of converting bits to local bytes on very anemic hardware and the need to pack as many bits into a message as possible.

How does a receiving side know how many bits to process at a given time?

The protocol determines that, like that RFC does. In the case of a variable length bit encoding it is bit values themselves that determine it, like Huffman coding does.

why is bit stream better than byte stream in some cases?

Covered already I think, because it is better match for its purpose. Either because the hardware is bit-oriented or because variable bit-length coding is useful.

Answers 2

BYTE Stream

A byte stream is a term used to represent a computing technique that allows for sending data along a particular path. Here, instead of the individual ones and zeros, known as binary digits or bits, units that are the size of eight bits, known as a byte, are sent along the pathway. It is also sometimes referred to as a character stream, since most of the characters that make up a natural language alphabet, numbers and so forth are represented by such 8-bit units. The path, or entities involved in the transfer of data, are somewhat abstract, as they may represent a file being accessed by a program, data being processed within a program, or data traveling over a network.

For a byte stream to be most effective, it flows through a dedicated and reliable path sometimes referred to as a pipe, or pipeline. Such a path has to be reliable to ensure the output is accurate. In one respect, when considering computer programming, the pipe is the path that connects the various aspects of a program so that as data is being processed from input, it can be passed to another part of the program, onto another, and so on, until it reaches output.

Another type of pipeline can be used by certain operating systems to take data, such as the contents a file, and run it through multiple different programs to produce some output. This is useful with text processing applications, made effective by way of a character byte stream to pass the data along. One of the most common uses of a byte stream, then, is for a computer's operating system when it is accessing data in a file.

In early computer networking, some systems made a distinction between a byte and what's also called an octet. Since an octet is also a computing unit comprised of eight bits, the terms are sometimes used interchangeably, though on those older systems, they are not the same thing. As a result, however, the octet stream is a term also used when speaking of a byte stream, though primarily with regards to computer networking. One such example, "application/octet-stream," is the multipurpose Internet mail extensions (MIME) type for delivering any sort of binary data over a network.

When it comes to sending a byte stream over a computer network, a reliable bi-directional transport layer protocol, such as the transmission control protocol (TCP) used on the Internet, is required. These are referred to as a byte stream protocol. Other serial data protocols used with certain types of hardware components, such as the universal asynchronous receiver/transmitter (UART) technique, is a serial data channel that also uses a byte stream for communication. In this case, the byte, or character, is packaged up in a frame on the transmitting end, where an extra starting bit and some optional checking bits are attached and then separated back out of the frame on the receiving end. This technique is sometimes referred to as a byte-oriented protocol.

Byte Streams in Java

As we already know, streams help us to sequentially accessing a file or data. A byte stream accesses a file ‘byte by byte’ that is suitable for any type of data but in some cases it’s not recommended to use byte stream. For example, if the file is using a unicode encoding and a character in the file is represented with two bytes, the byte stream will treat these separately and we will need to do the conversion our-self.

Does ‘Byte Streams’ support Unicode characters ?

Yes, byte streams supports bytes thus supports anything that can be represented using bytes..i.e. text, photos, videos ..etc. The thing to be considered here is that everything that is to be manipulated using byte streams needs to follow some rules of coding and decoding to a combination of 0 and 1’s.

BIT Stream

Definition: A Bitstream refers to binary bits of information (1's and 0's) transferred from one device to another.

However, in Home Theater applications, Bitstream refers to a digitally-encoded Dolby Digital or DTS -related compressed audio signal from a source component (such as a DVD, Blu-ray, or HD-DVD player, HD-Cable, or HD-Satellite Box) to a Preamp/Processor (either standalone or built into a Home Theater Receiver) for decoding and distribution to the amplifier stage for final sound reproduction, in analog form, by the loudspeakers.

The Bitstream can be sent via Digital Optical, Digital Coaxial, or HDMI interface.

Also Known As: Bit Stream, Digital Bitstream, Audio Bitstream

Examples: DVD or Blu-ray disc player "X" contains a Dolby Digital or DTS soundtrack that is Encoded as digital bits on the disc. The DVD player must read this encoding, transfer the encoded signal in Bitstream form via digital optical, digital coaxial, or HDMI connection to Home Theater Receiver "Y" that has a Dolby Digital or DTS Decoder. The Receiver, in turn, converts the digitally encoded Dolby Digital or DTS bitstream into the proper channel assignment in an analog form, then amplified, so that it can be heard by the listener through Loudspeakers.

Answers 3

A bit is a single 1 or 0 in computer code, also known as a binary digit. The most common use for the bit stream is with the transmission control protocol, or TCP. This series of guidelines tells computers how to send and receive messages between each other. The World Wide Web and e-mail services, among others, rely on TCP guidelines to send information in an orderly fashion. Sending through the bit stream ensures the pieces arrive in the proper order and the message isn't corrupted during delivery, which could make it unreadable.So a bit stream sends one bit after another.

Eight bits make up a byte, and the byte stream transmits these eight-bit packets from computer to computer.

The packets are decoded upon arrival so the computer can interpret them.Thus a byte stream is a special case of bits sent together as a group in sequential order.For a byte stream to be most effective, it flows through a dedicated and reliable path sometimes referred to as a pipe, or pipeline. When it comes to sending a byte stream over a computer network, a reliable bi-directional transport layer protocol, such as the transmission control protocol (TCP) used on the Internet, is required. These are referred to as a byte stream protocol. Other serial data protocols used with certain types of hardware components, such as the universal asynchronous receiver/transmitter (UART) technique, is a serial data channel that also uses a byte stream for communication. In this case, the byte, or character, is packaged up in a frame on the transmitting end, where an extra starting bit and some optional checking bits are attached and then separated back out of the frame on the receiving end. This technique is sometimes referred to as a byte-oriented protocol.

Taking a general life example,suppose you have a lot of match sticks to send.Then you could send them one stick after the other,one at a time.. or you could pack a few of them in a match box and send them together ,one matchbox after the other in sequence.the first is like bitstream and the latter like bytestream.

Thus it all depends on what the hardware wants or is best suited for..If your hand is small and you cant accept matchboxes but you still want matchsticks then you take them one at a time or else take the box.Also byte streams are better in a sense that every bit does not need to be checked and data can be sent in batches of 8,.if any of it fails the entire 8bits can be re sent.

Answers 4

Too add to the other good answers here:

A byte stream is a type of bit stream. A byte stream describes the bits as meaningful "packages" that are 8 bits wide.

Certain (especially low-level) streams may be agnostic of meaning in each 8 bit sequence. It would be a poor description to call these "byte streams"

Similar to how every Honda Civic is a car, but not every car is a Honda Civic...

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment