Menu

The Internet

Routing

A router is a device that connects networks together. Data travelling across the internet is split into packets, and a router takes each packet that arrives and forwards it on towards its destination.

Reading the packet header

Every packet carries a header, and inside that header is the destination IP address. When a packet reaches a router, the router reads that address to work out which network the packet is heading for. It does not make the decision using a MAC address: a MAC address identifies a piece of hardware on a local network, so it cannot tell a router where a device on a distant network is. Routing decisions are based on IP addresses.

Using the routing table

The router checks the destination IP address against its routing table. This is a list of the networks the router knows about, paired with the next router or link that leads towards each one. For example, a packet addressed to 203.0.113.42 arrives at a router holding this table:

Destination networkSend to
203.0.113.0Router A
198.51.100.0Router B
192.0.2.0Router C
any other addressRouter D

The destination address belongs to the network 203.0.113.0, so the router sends the packet to Router A.

A router reads the destination IP address 203.0.113.42 in a packet header, finds the network 203.0.113.0 in its routing table and sends the packet to Router A, one of four possible next hops.

One step at a time

A router does not need to know the whole path. It only chooses the next router on the way, and that router then makes its own decision from its own table. The packet hops from router to router until it reaches the network containing the destination device. You can think of a relay race: each runner only needs to know who to hand the baton to next, not every step of the course.

Practise this