Networks · GCSE · OCR J277 1.3.1, Edexcel 1CP2 4.1.5 · about 15 min
Bandwidth, transfer time calculations, what slows a network, and measuring latency with a ping.
[1 mark]How many seconds does a 25 MB file take to send at 10 Mbps?
[1 mark]What is bandwidth?
[1 mark]Why is a home internet connection often slower in the evening?
[1 mark]What is latency?
[1 mark]How many megabytes per second is a 100 Mbps connection?
Ping the Server three times. For each ping, send ping, time how long until a reply arrives using clock(), and print ping <n>: <seconds> s, rounded to two decimal places. Then print average: <seconds> s, also rounded to two decimal places.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect()
The hint students can ask for: For each ping, take a clock reading, send, then wait in small steps until a reply arrives, and take the clock reading again. The difference is the round trip. Collect them so you can average them at the end.
from bugbot import *
connect()
times = []
for n in [1, 2, 3]:
start = clock()
send("ping")
reply = None
while reply is None:
wait(0.02)
for sender, text in messages():
reply = text
took = clock() - start
times.append(took)
print(f"ping {n}: {took:.2f} s")
print(f"average: {sum(times) / len(times):.2f} s")
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.