The worksheetDownload the PDF
Answers

F10.3 Network performance

Networks · GCSE · OCR J277 1.3.1, Edexcel 1CP2 4.1.5 · about 15 min

BugBotLab

What this lesson is about

Bandwidth, transfer time calculations, what slows a network, and measuring latency with a ping.

Questions 5 marks in all

  1. [1 mark]How many seconds does a 25 MB file take to send at 10 Mbps?

    Answer: 20. 25 × 8 = 200 megabits, and 200 ÷ 10 = 20.
  2. [1 mark]What is bandwidth?

    1. AThe most data a connection can carry each second
    2. BThe length of a cable
    3. CThe number of devices on a network
    4. DThe delay before data arrives
    Answer: A. It is measured in bits per second.
  3. [1 mark]Why is a home internet connection often slower in the evening?

    1. AMore users are sharing the bandwidth
    2. BCables cool down at night
    3. CRouters switch off at night
    4. DServers run slower in the dark
    Answer: A. Everyone streaming at once shares the same connections.
  4. [1 mark]What is latency?

    1. AThe delay for data to travel from one device to another
    2. BThe total amount of data sent
    3. CThe number of packets lost
    4. DThe speed of the processor
    Answer: A. A ping measures it.
  5. [1 mark]How many megabytes per second is a 100 Mbps connection?

    Answer: 12.5. 8 bits in a byte: 100 ÷ 8.

The task: ping the server

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.

A solution

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.