Network routing in 3D

A small equipment rack holding stacked network switches and patch panels connected by colourful patch cables.Drag to turn

A computer network is a set of linked devices that exchange data in packets, and routing is how routers choose the path each packet takes to its destination address.

Devices, links and packets in a server rack

A network connects devices such as servers, switches and routers with copper cable, optical fibre or radio. Data is split into packets, small units with a header holding source and destination addresses plus a payload. In a rack, servers usually connect to a top-of-rack switch, which links onward to routers.

A switch forwards frames inside one local network using hardware addresses. A router forwards packets between networks using IP addresses.

How a router picks the next hop

A router keeps a routing table, a list of address prefixes with a next hop for each. A prefix such as 10.1.0.0/16 means the first 16 bits of the address are fixed. The router picks the matching entry with the longest prefix, a rule called longest prefix match.

Tables are filled by hand or by routing protocols, where routers exchange information with neighbours. OSPF is common inside an organisation and BGP between organisations. Each hop lowers the packet's time-to-live counter by one, and the packet is dropped at zero, which stops endless loops.

Worked example: one packet, three table entries

A router has three entries: 10.0.0.0/8 to port A, 10.1.0.0/16 to port B, and 0.0.0.0/0 to port C. A packet arrives for 10.1.5.9. It matches the /8 entry (first 8 bits are 10), the /16 entry (first 16 bits are 10.1) and the default entry.

The longest match is /16, so the packet leaves by port B. A packet for 10.200.1.1 matches only /8 and /0, so it leaves by port A. A /24 prefix leaves 32 - 24 = 8 host bits, giving 2^8 = 256 addresses, or 254 usable hosts after removing the network and broadcast addresses.

Common misconceptions

Switches and routers are often treated as the same device. They work at different layers, though many products combine both functions. Packets of one transfer also need not follow one fixed route, since each router decides independently.

Bandwidth is the data rate in bits per second. Latency is the delay for one packet to arrive. A fast link can still have high latency.

Where routing shows up in practice

Data centres link racks of servers through switches and routers. Home routers apply the same ideas, using a default route to an internet provider. Electrical engineers meet the topic in cabling choices, switch power budgets and signal quality on fibre and copper links.

Key terms

Packet
A small unit of data with a header containing addresses and a payload carrying the content.
Router
A device that forwards packets between networks using IP addresses and a routing table.
Switch
A device that forwards frames within one local network using hardware addresses.
Routing table
A list of address prefixes, each paired with the next hop or port to use.
Prefix
The fixed leading bits of an address, written with a slash and a length such as /16.
Default route
The entry 0.0.0.0/0, used when no more specific prefix matches.
Time-to-live
A counter in the packet header that falls by one at each router and discards the packet at zero.

Common questions

What does the /16 in 10.1.0.0/16 mean?

It says the first 16 bits are the network part. The remaining 16 bits identify hosts within that network.

What is a default route?

It is the entry 0.0.0.0/0, which matches any address. A router uses it only when no longer prefix matches.

Why does time-to-live exist?

Routing errors can send a packet in a loop. The counter drops by one at each router, so a looping packet is discarded instead of circulating forever.

Learn this with a tutor

Sidechair's AI tutor will teach this topic in 3D. Join the waitlist for early access.

We'll only email you about Sidechair. Read our privacy policy.