Streaming data packets

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Streaming data packets

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which describes streaming data packets?
A The server sends packets continuously and the viewer plays them as they arrive
B The viewer must download the whole file before playback can start
2. Streaming sends data from a server to how many viewers per stream?
A Every device on the network at once
B One viewer (one-to-one)
3. A video player pauses to load more packets before it carries on playing. What is this called?
A Buffering
B Hashing
4. Which is an example of on-demand streaming?
A Watching a sports match as it happens, with the stream sent out in real time
B Choosing a recorded show on a streaming service and pressing play
5. Which transport protocol is often used for streaming because it favours speed over guaranteed delivery?
A UDP
B TCP

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1buffering AThis describes broadcasting. Streaming sends packets from a server to one viewer, not to every device.
2adjust bitrate BThe player pauses and stores incoming packets ahead of playback, so a slow or late packet does not stop the video
3Streaming is often sent with UDP because dropping a late packet is better than pausing to resend it Cstream_type = on-demand
4On-demand streaming sends a stored file to one viewer, who can start playing it before the whole file has arrived Dprotocol = UDP
5Streaming: download the entire file first, then press play EThis describes downloading, not streaming. Streaming plays packets as they arrive, without waiting for the whole file.
6Streaming sends the same packets to every device on the network at once FThe server lowers or raises the amount of data sent each second to match the viewer's current connection speed

Definitions

streaming

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
stream = openStream(url, protocol="___")
2.
buffer = 1.5 if ______ < 2: pause()
3.
packet = latest if isLive ____ nextOne
4.
if bandwidth _ bitrate: bitrate = bitrate / 2
5.
while stream.isOpen: packet = stream.receive() ____(packet)

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A buffer = []
B for packet in stream:
C buffer.pop(packet)
D if len(buffer) >= 3:
E play(buffer.pop(0))
Question 2
A speed = measure_speed()
B bitrate = 4000
C if speed < bitrate:
D bitrate = 8000
Question 3
A buffering = False
B while buffering:
C wait_for_packets()
D buffering = len(buf) < 3
Question 4
A def play_stream(server)
B packet = server.next()
C show(packet)
D return packet
Question 5
A mode = 'live'
B start = 0
C stream_from(start)

Answer Key

Streaming data packets
Section A: Quick Questions
Q1
A — The server sends packets continuously and the viewer plays them as they arrive
Q2
B — One viewer (one-to-one)
Q3
A — Buffering
Q4
B — Choosing a recorded show on a streaming service and pressing play
Q5
A — UDP
Section B: Match the Pairs
Q1
buffering → The player pauses and stores incoming packets ahead of playback, so a slow or late packet does not stop the video
Q2
adjust bitrate → The server lowers or raises the amount of data sent each second to match the viewer's current connection speed
Q3
Streaming is often sent with UDP because dropping a late packet is better than pausing to resend it → protocol = UDP
Q4
On-demand streaming sends a stored file to one viewer, who can start playing it before the whole file has arrived → stream_type = on-demand
Q5
Streaming: download the entire file first, then press play → This describes downloading, not streaming. Streaming plays packets as they arrive, without waiting for the whole file.
Q6
Streaming sends the same packets to every device on the network at once → This describes broadcasting. Streaming sends packets from a server to one viewer, not to every device.
Section C: Definitions
Q1
streaming — Sending packets continuously from a server to one viewer, who plays them as they arrive instead of waiting for the whole file to download.
Section D: Fill in the Blanks
Q1
stream = openStream(url, protocol="UDP")
Q2
buffer = 1.5 if buffer < 2: pause()
Q3
packet = latest if isLive else nextOne
Q4
if bandwidth < bitrate: bitrate = bitrate / 2
Q5
while stream.isOpen: packet = stream.receive() play(packet)
Section E: Spot the Error
Q1
C — Streamed packets are added to the buffer as they arrive so they can be played shortly after. It should be buffer.append(packet), not pop(packet).
Q2
D — When the connection is slower than the bitrate, the stream should drop to a lower bitrate to avoid buffering. Raising it to 8000 makes the problem worse. It should be a lower value such as 1000.
Q3
A — The player starts out buffering, so the flag must start as True. If it starts as False, the while loop never runs and no packets are collected before playback.
Q4
A — A function definition must end with a colon. It should be def play_stream(server):
Q5
B — A live stream is happening right now, so a viewer joins at the current moment with now(). Starting at 0 is how an on-demand video behaves, not a live one.