Search code examples
computer-science

Confusion with bit streaming


I'm learning Computer Science, and I've been stuck at a question for the past 2 hours, I don't know how to even start solving this, so if anyone could explain the process of solving the problem, then I'd hopefully be able to solve it myself. Thank you.

"Consider a bit-streaming scenario for a video where the following apply:

  • The buffer size is 1 MiB.
  • The low watermark is set at 100 KiB.
  • The high watermark is set at 900 KiB.
  • The incoming date rate is 1 Mbps.
  • The video display rate is 300 Kbps.

Assume that the video is playing and that the buffer content has dropped to the low-watermark. The media player sets the controls for data input to begin again.

Calculate the amount of data that will be input in two seconds to the buffer and the amount of data that will be removed from the buffer in the same time period.

Repeat this calculation for 4, 6, 8, 10, and 12 seconds.

From this data, estimate when the buffer will have filled up to the high-watermark.

Assuming that the incoming transmission is halted at this time, calculate how long it will be before the buffer content has again fallen to the low-watermark level"


Solution

    1. The buffer size is 1 MiB.
    2. The low watermark is set at 100 KiB.
    3. The high watermark is set at 900 KiB.
    4. The incoming date rate is 1 Mbps.
    5. The video display rate is 300 Kbps.

    Meaning of each unit:

    1. MiB - Mebi Byte
    2. KiB - Kibi Byte
    3. Mbps - Mega bits per second
    4. Kbps - Kilo bits per second

    We have bits and Bytes, for easier calculations, we have to convert them to the same base. You should know that converting bits to bytes means dividing by 8, and to convert a byte to a bit you multiply by 8. AKA 1 bit = 1/8 Byte or 1 Byte = 8 bit. Since diving by 8 is ugly, we multiply and convert Bytes into bits

    1 MiB = 1024 KiB = 8192 kbit

    100 Kib = 100 KiB = 800 kbit

    900 KiB = 900 KiB = 7200 kbit

    1 Mbps = 1000 Kbps = 1000 kbit per second

    300 Kbps = 300 Kbps = 300 kbit per second

    Now to explain what low and high watermark is, if you are struggling with that as well.

    If the current video buffer that the player uses gets bellow the low watermark, that signals to the video player that it should get more frames/content from the source. Once the buffer reaches high watermark, it means that the video player has enough frames/content to keep playing for a little bit, so to use less of the internet connection, overload the source, it stops until it drops below the low watermark again.

    Now you just have to calculate by the instructions:

    • Incoming rate is 1 Mbps or 1000 kbit per second, that means that each second of getting the content, the buffer will increase by 1000kbit.
    • Video display is 300 Kbps or 300kbit per second, that means that each second of using the content, the buffer will decrease by 300kbit