A computer on Net A sends the message MEET YOU AT THE WHARF AT 9 to a computer on Net B, across a network of seven routers (R1 to R7). The message is split into seven numbered packets. Press Play, or Step one tick at a time, and follow them: the panel on the right says what each router does, shows the routing table it used, and the packet it handled.
- Choose a preset in the title bar: a normal day, a link going down, congestion, a router failing, or packets whose TTL runs out.
- Or make your own change at any time: click a link to break it, congest it or restore it, and click a router to see its routing table, make it fail or bring it back.
- Click a packet to follow it. The pale band shows the route the routers would send the next packet along, from R1 to Net B.
The key ideas
- Packet switching: data is split into packets, each sent separately. Each one may take a different route, the links are shared with everyone else's packets, and the packets are put back together in order at the destination.
- A packet has a header (the source IP address, the destination IP address, the sequence number, here "3 of 7", and the time to live), a payload (the piece of the data) and a trailer (here a checksum, to check for errors; Cambridge IGCSE puts the error check and the end-of-packet marker in the trailer).
- A router reads each packet's destination IP address, finds the destination network in its routing table, and sends the packet to the next hop that table gives. It doesn't know the whole route: each router only decides the next step.
- Routing tables are kept up to date by the routers themselves. Here they use a distance-vector protocol, as RIP does: each router tells its neighbours its cost to every network, and picks, for each network, the neighbour with the lowest link cost plus that neighbour's cost. After a change, the news spreads one hop per update until the tables converge.
- TTL (time to live), also called the hop limit: each router takes one off. A router that takes it to 0 drops the packet and sends a time exceeded message back to the sender, so a packet can't circle for ever. (Computers usually start at 64 or 128; here it's 8, or 3 in the TTL preset.)
- Reassembly: packets can arrive out of order, or not at all. The destination sorts them by sequence number, notices a gap, and asks for the missing packet again (a simplified TCP: real TCP acknowledges what has arrived, and the sender re-sends anything not acknowledged in time).
- Circuit switching, by contrast, sets up one dedicated path for the whole communication before sending (as the old telephone network did): the data arrives in order, but the path is reserved even when nothing is being sent, and if it breaks the call is lost.
Simplified: the costs are delays in ticks; routers here send their tables only when they change (real RIP also sends them every 30 seconds, and counts hops rather than adding costs; OSPF works out routes from a map of the whole network instead); each router can send one packet per tick down each link; and the network names and IP addresses are from the ranges kept for documentation or private use.
Common exam mistakes
"The router sends the packet along the whole route." Each router only chooses the next hop; the next router decides again, from its own table.
"All the packets follow the same route." In packet switching each packet is routed separately. If a link fails or gets busy, later packets go another way, which is why they can arrive out of order.
"Packets that arrive out of order are errors." They are normal. The sequence number lets the destination put them back in order.
"The header holds the data." The header holds the addresses, the sequence number and the TTL; the data is the payload.
"TTL is a time in seconds." In IP it is a count of hops: each router takes one off.
Exam-style questions and answers
1. Describe the structure of a data packet. [4]
Answer. A header containing the destination address, the source (originator's) address and the packet (sequence) number; the payload, the actual data being sent; a trailer containing an error check (such as a checksum or CRC) and a way of identifying the end of the packet.
2. Explain how packet switching sends a file across the internet. [5]
Answer. The file is split into packets, each with a header. Each packet is sent separately; each router reads the destination address and sends the packet on to the next router along the best available route, so packets may take different routes. The packets can arrive in a different order; the receiving computer uses the sequence numbers to put them back in order. If a packet is missing, it is requested again.
3. Explain why the packets of one message might arrive out of order. [2]
Answer. Each packet is routed independently, so they may take different routes (for example after a link fails or becomes congested), and some routes take longer than others; a lost packet that is sent again arrives later still.
4. State the purpose of the time to live (hop limit) in a packet's header. [2]
Answer. Each router reduces it by one; when it reaches zero the packet is discarded. This stops packets that can't be delivered (for example caught in a routing loop) from circulating for ever and using up the network.
5. Give one benefit and one drawback of packet switching compared with circuit switching. [2]
Answer. Benefit: the links are shared and used efficiently, and packets can be re-routed round a failed or busy link. Drawback: packets can arrive out of order or be delayed, so they must be reassembled, and the delay varies (a problem for live video or voice).
Objective: describe how data is broken into packets and transmitted using packet switching, the structure of a packet (header, payload, trailer) and the role of a router (Cambridge IGCSE Computer Science 0478, 2.1 Types and methods of data transmission); packet switching and circuit switching, and the role of routers (Cambridge AS & A Level Computer Science 9618, AS 2.1 Networks including the internet); and the TCP/IP protocols, with routing between networks and reassembly by TCP (9618 A Level 14.1 Protocols and 14.2 Circuit switching, packet switching).
Where this fits
- AP: AP Computer Science Principles
- AQA: AQA A Level Computer Science (7517)
- Cambridge: Cambridge IGCSE Computer Science (0478); Cambridge A Level Computer Science (9618); Cambridge AS Level Computer Science (9618); Cambridge A Level Information Technology (9626) Goes beyond Cambridge IGCSE Computer Science (0478): Routing tables and distance-vector updates go beyond 0478, which only says a router controls a packet's route.
Goes beyond Cambridge A Level Computer Science (9618): Routing tables and distance-vector routing go beyond 9618, which asks for the router's role and packet switching.
Goes beyond Cambridge AS Level Computer Science (9618): Routing tables and distance-vector routing go beyond 9618, which asks for the router's role and packet switching.
- IB: IB Computer Science HL; IB Computer Science SL Goes beyond IB Computer Science SL: Static and dynamic routing (A2.3.4) is HL only.
- NCEA Level 2 Digital Technologies: 91895 Use advanced techniques to develop a network; 91895 Use advanced techniques to develop a network
- NCEA Level 3 Digital Technologies: 91905 Use complex techniques to develop a network; 91905 Use complex techniques to develop a network
- Pearson Edexcel International: Edexcel International GCSE Computer Science (4CP0); Edexcel International A Level Information Technology Goes beyond Edexcel International GCSE Computer Science (4CP0): Routing tables, TTL and re-routing go beyond 4CP0, which only says data is sent in packets.
Goes beyond Edexcel International A Level Information Technology: Routing tables and distance-vector updates go beyond IAL IT.
- USDP: USDP Computer Science