The worksheetDownload the PDF
Answers

A12.3 How the Internet works

Networks and the web · A level · OCR H446 1.3.3, AQA 7517 4.9.3.1, Eduqas A500QS 2.2 · about 25 min

BugBotLab

What this lesson is about

Packet switching, routers and gateways, URLs, fully qualified domain names and DNS.

Questions 6 marks in all

  1. [1 mark]Which of these are found in a packet's header? Choose all that apply.

    Tick every answer that is true.

    1. ASource IP address
    2. BDestination IP address
    3. CPacket sequence number
    4. DTime to live
    5. EThe web page's text
    Answer: A, B, C, D. The header holds the addressing and control information; the web page's text is part of the payload.
  2. [1 mark]When should a gateway be used rather than a router?

    1. AWhen the networks being joined use different protocols
    2. BWhen the two networks use the same protocols
    3. CWhen a device needs a private IP address
    4. DWhen a domain name must be registered
    Answer: A. A router joins networks with the same protocols; a gateway translates between networks that use different protocols.
  3. [1 mark]In the URL https://www.bbc.co.uk/news, what is the fully qualified domain name?

    Answer: www.bbc.co.uk. The FQDN includes the host name (www) as well as the domain name (bbc.co.uk); the scheme and path are not part of it.
  4. [1 mark]Put the steps of a DNS lookup for lessons.bugbot.example, with nothing cached, in order.

    Number the lines 1 to 5 to put them in the right order.

    1. The resolver asks the authoritative name server for bugbot.example
    2. The resolver caches the IP address and returns it to the computer
    3. The resolver asks a root name server
    4. The resolver asks the top-level domain server for .example
    5. The computer asks its resolver
    Answer:
    The computer asks its resolver
    The resolver asks a root name server
    The resolver asks the top-level domain server for .example
    The resolver asks the authoritative name server for bugbot.example
    The resolver caches the IP address and returns it to the computer

    Each server refers the resolver one step further down the hierarchy until the authoritative server gives the address.

  5. [1 mark]Which is an advantage of packet switching over circuit switching?

    1. ALinks are shared by many conversations, and packets can be routed around a failed link
    2. BData always arrives in the order it was sent
    3. CThe delay is always constant
    4. DA dedicated path is reserved for the whole conversation
    Answer: A. Packet switching uses links efficiently and is resilient; circuit switching reserves a path, which keeps data in order with constant delay.
  6. [1 mark]What does this program print?

    packets = {3: 'ket', 1: 'pa', 2: 'c'}
    message = ''
    for n in sorted(packets):
        message = message + packets[n]
    print(message)
    Answer:
    packet

    The payloads are joined in sequence number order 1, 2, 3, whatever order they arrived in.

The task: put the packets back together

The Server on this mat sends one short message as four packets, one every 0.4 seconds, but not in order. Each packet is text in the form <number>/<total>:<payload>, for example 2/4:an take d. The number counts from 1, the total is how many packets make the message, and the payload is everything after the first colon (it may contain spaces). Listen with messages(), checking every 0.1 s, until you hold every packet. Then print two lines: - arrived in order: <numbers>, the packet numbers in the order they arrived, separated by single spaces; - message: <text>, the payloads joined in number order. The robot does not drive.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

wait(2)
for sender, text in messages():
    print(text)

The hint students can ask for: Split each packet at the first colon, then split the header at the slash to get its number and the total. Keep the payloads in a dictionary by number until you hold as many as the total says, then join them in number order.

A solution

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

payloads = {}
arrived = []
total = None
while total is None or len(payloads) < total:
    wait(0.1)
    for sender, text in messages():
        header, data = text.split(":", 1)
        number, count = header.split("/")
        payloads[int(number)] = data
        arrived.append(number)
        total = int(count)
print("arrived in order:", " ".join(arrived))
message = ""
for n in range(1, total + 1):
    message = message + payloads[n]
print("message:", message)

Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.