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.
