TP4 Flashcards

1
Q

Complete the Proxy.py code:
def producer(queue, baseURL, movieName, track_num):
manifest_url = ________________________________________
response = requests.get(____________)
manifest = ____________

track_num = int(track_num)

# Process the manifest
offsets = [ ]
i = 0
num_fragments = 50
current_track = 0
current_segment = 0
A

def producer(queue, baseURL, movieName, track_num):
manifest_url = baseURL + ‘/’ + movieName + ‘/manifest.txt’
response = requests.get(manifest_url)
manifest = response.content.decode()

track_num = int(track_num)

# Process the manifest
offsets = [ ]
i = 0
num_fragments = 50
current_track = 0
current_segment = 0
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Complete the Proxy.py code:
for j in range(____________________):
segment_url = baseURL + ‘/’ + movieName + ‘/’ + track
headers = {__________________________________________________________}
response = requests.get(__________,____________)
for chunk in response.iter_content(__________):
queue.put(_________)

A

for j in range(num_fragments):
segment_url = baseURL + ‘/’ + movieName + ‘/’ + track
headers = {“Range”: “bytes=” + str(offsets[j][0]) + “-“ + str(offsets[j][1])}
response = requests.get(segment_url, headers=headers)
for chunk in response.iter_content(CHUNK_SIZE):
queue.put(chunk)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Complete the Proxy.py code:
def consumer(queue, player_socket):
while True:
segment = queue.get()
player_socket._________(_________)
if segment == b’’:
break

A

def consumer(queue, player_socket):
while True:
segment = queue.get()
player_socket.sendall(segment)
if segment == b’’:
break

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Complete the Proxy.py code:
producer_thread = threading.Thread(target=_________, args=(______, ________, _________, _____))
consumer_thread = threading.Thread(target=_________, args=(_____, _________))
producer_thread._______()
consumer_thread.______()

producer_thread.\_\_\_\_\_()
consumer_thread.\_\_\_\_\_\_()
A

producer_thread = threading.Thread(target=producer, args=(queue, baseURL, movieName, track))
consumer_thread = threading.Thread(target=consumer, args=(queue, player_socket))
producer_thread.start()
consumer_thread.start()

producer_thread.join()
consumer_thread.join()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what’s the server function?

A

it is a standard http server that contains movies to be played.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what’s the proxy function?

A

Has two parts each executed by a thread; the two threads share a queue or buffer.
o Thread producer: gets segments from the content server using a TCP socket TC and
the HTTP protocol and puts them in the queue.
o Thread consumer: gets segments from the queue and writes its content to socket TP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what’s the client function?

A

shows the movie. Receives the byte stream through a socket TP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

which http command do we use in this project?

A

GET HTTP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly