The worksheetDownload the PDF
Answers

F10.4 Network topologies

Networks · GCSE · OCR J277 1.3.1, Edexcel 1CP2 4.1.8 · about 20 min

BugBotLab

What this lesson is about

Star, bus, ring and mesh, and routing around a failure in a mesh of robots.

Questions 6 marks in all

  1. [1 mark]In a star topology, what happens if the central switch fails?

    1. ANo device can communicate
    2. BOnly one device is affected
    3. CData takes another route
    4. DNothing, the devices connect directly
    Answer: A. Every connection goes through the switch.
  2. [1 mark]Why is a mesh network very reliable?

    1. AThere are many routes, so data can go around a failed link
    2. BIt has a single central switch
    3. CIt uses less cable
    4. DData travels in one direction
    Answer: A. Redundant links give alternative routes.
  3. [1 mark]How many connections does a full mesh of 5 devices need?

    Answer: 10. 5 × 4 ÷ 2.
  4. [1 mark]In a bus topology, what happens if the backbone cable breaks?

    1. AThe whole network fails
    2. BOnly one device is affected
    3. CData goes the other way round
    4. DThe switch reroutes it
    Answer: A. Every device shares the one cable.
  5. [1 mark]In a ring topology, how does data travel?

    1. AFrom device to device around the loop, in one direction
    2. BThrough a central switch
    3. CAlong one shared cable to every device at once
    4. DDirectly between every pair of devices
    Answer: A. Each device passes data on to the next.
  6. [1 mark]What does this program print?

    links = {"A": ["B"], "B": ["A", "C"], "C": ["B"]}
    seen = ["A"]
    for robot in seen:
        for n in links[robot]:
            if n not in seen:
                seen.append(n)
    print(seen)
    Answer:
    ['A', 'B', 'C']

    A reaches B, then B reaches C.

The task: route around a failure

Write route(links, start, end) that returns the shortest route as a list of robots, using a breadth-first search. Print route: A-B-D-F style for the route from A to F, joining the names with -, and send the same text by radio. Then the link between D and F fails: remove it from both robots' lists, find the route again, and print after D-F fails: <route>.

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

links = {"A": ["B", "C"], "B": ["A", "D"], "C": ["A", "D", "E"], "D": ["B", "C", "F"], "E": ["C", "F"], "F": ["D", "E"]}

The hint students can ask for: Breadth-first search: keep a queue of robots to visit and a record of which robot you reached each one from. When it is done, follow that record back from the end to the start and reverse it.

A solution

from bugbot import *
connect()
links = {"A": ["B", "C"], "B": ["A", "D"], "C": ["A", "D", "E"], "D": ["B", "C", "F"], "E": ["C", "F"], "F": ["D", "E"]}

def route(links, start, end):
    came_from = {start: None}
    queue = [start]
    while queue:
        robot = queue.pop(0)
        for neighbour in links[robot]:
            if neighbour not in came_from:
                came_from[neighbour] = robot
                queue.append(neighbour)
    path = []
    robot = end
    while robot is not None:
        path.append(robot)
        robot = came_from[robot]
    path.reverse()
    return path

text = "route: " + "-".join(route(links, "A", "F"))
print(text)
send(text)
links["D"].remove("F")
links["F"].remove("D")
print("after D-F fails:", "-".join(route(links, "A", "F")))

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