Networks and the web · A level · OCR H446 1.3.3, AQA 7517 4.9.3.1, Eduqas A500QS 2.2 · about 25 min
Packet switching, routers and gateways, URLs, fully qualified domain names and DNS.
[1 mark]Which of these are found in a packet's header? Choose all that apply.
Tick every answer that is true.
[1 mark]When should a gateway be used rather than a router?
[1 mark]In the URL https://www.bbc.co.uk/news, what is the fully qualified domain name?
[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.
The resolver asks the authoritative name server for bugbot.exampleThe resolver caches the IP address and returns it to the computerThe resolver asks a root name serverThe resolver asks the top-level domain server for .exampleThe computer asks its resolverThe 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.
[1 mark]Which is an advantage of packet switching over circuit switching?
[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)packet
The payloads are joined in sequence number order 1, 2, 3, whatever order they arrived in.
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.
# 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.