How computers work

Local network: router, switch, Wi-Fi

A home network connects a desktop, a laptop, a phone, a printer and a network storage box to each other and to the internet. Inside it, devices talk using Ethernet frames addressed by MAC addresses, while the router is the border: anything addressed to the outside world it sends to the internet provider, swapping the private addresses for its own. Let’s go through each box and follow what happens when you open a website.

Open in 3D →

The apartment and what’s connected in it

The scale of this level is an 11 × 7 m apartment: a hallway, a study and a living room; the devices in the model are enlarged. The network has five end devices: the PC, the NAS and the printer are wired to a switch, while the laptop and the phone connect over Wi-Fi to the access point inside the router. The chain to the outside world: switch → router → ONT → optical fiber → provider.

Everything inside the apartment is a single local area network (LAN) with addresses 192.168.1.0/24. The “/24” notation means that the first 24 bits of the address (192.168.1) are shared by the whole network, while the last byte tells devices apart — from .1 to .254. The router is usually .1; in the model the PC is .10, the NAS .20, the printer .30, and the laptop and phone .40 and .41.

The private ranges 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 (RFC 1918) are specifically reserved for internal networks. Anyone can use them, which is why they are not routed on the internet. Your 192.168.1.10 and the same address at your neighbor’s are not a conflict: these are different networks, separated by their own routers.

A home network is surprisingly similar to an office or a data center machine hall: the same Ethernet, IP, switching and routing, just with five devices instead of five thousand. Once you understand the apartment, the other levels are easier to grasp.

Layers: frame, packet, segment

It’s convenient to split the networking job into layers. The bottom one is physical: how to transmit bits (voltage in copper, flashes of light, radio waves). Above it is the data link layer — Ethernet or Wi-Fi: delivering a frame to a neighbor within one network by MAC address. Higher up is the network layer, IP: delivering a packet across many networks by IP address. Higher still is the transport layer, TCP or UDP: port numbers, data ordering, resending what was lost. And on top are applications: HTTP, SMB, IPP, DNS.

The layers nest inside each other like envelopes (encapsulation). The browser prepares an HTTP request, TCP adds a header with ports (20 bytes), IP one with addresses (20 bytes in IPv4), Ethernet one with MAC addresses (14 bytes) plus a checksum at the end (4 bytes). A regular Ethernet frame holds no more than 1500 bytes of payload (the MTU), so a large file is cut into thousands of packets.

Each device looks only at “its own” envelope. A switch reads only the Ethernet header and has no idea what’s inside. A router removes the Ethernet envelope, reads the IP address, decides where to send it next and puts on a new Ethernet envelope for the next hop. That’s why MAC addresses change at every hop of the path, while the sender’s and receiver’s IP addresses travel the whole way — unless NAT rewrites them.

Each frame is preceded by an 8-byte preamble that synchronizes the receiver, and followed by a mandatory gap 12 bytes long. Together with the headers, this eats about 6%: out of 1 Gbit/s, roughly 940 Mbit/s of useful data remains — exactly what speed tests show on a gigabit connection.

Addresses: MAC, IP and ports

A MAC address is 48 bits, written as six pairs of hexadecimal digits (a4:5e:60:00:00:10). The first three bytes are the manufacturer’s code; the factory assigns the rest. A MAC is needed only within a single network: the router doesn’t forward it any further, and a website on the internet never sees your MAC. Modern phones and laptops by default make up a random MAC for each Wi-Fi network, so they can’t be tracked by it between cafés and airports.

An IP address (IPv4) is 32 bits, written as four numbers from 0 to 255. Unlike a MAC, it reflects a location in the network, like a postal address: the prefix shows which network the device belongs to. That’s exactly why internet routers don’t need to know about every device — it’s enough to know where to send entire prefixes.

A port is a 16-bit number (0–65535) identifying a program inside a device. A server listens on a well-known port: 443 for HTTPS, 445 for SMB shared folders, 631 for IPP printing, 53 for DNS. A client picks a temporary port for itself (in the demo — 51515, 51000, 52000). The addresses and ports of both sides together with the protocol uniquely identify a connection, which is why a single PC can hold hundreds of connections at once.

How do you find a MAC from an IP? With the ARP protocol. The computer sends a broadcast frame to the whole network (destination MAC ff:ff:ff:ff:ff:ff): “Who has 192.168.1.20? Tell 192.168.1.10.” Only the NAS answers; the rest silently ignore it. The answer is kept in the ARP cache for a few minutes, so the question isn’t asked for every packet.

If the destination address is outside its own network, the computer looks up the MAC not of the server but of the gateway — the router at 192.168.1.1 — and hands the packet to it: “deliver it onward yourself.” This rule — your own address and network mask plus a default gateway — is all the routing there is on an ordinary computer’s side.

The provider, fiber and the ONT

The internet comes into the apartment over optical fiber: a glass strand with a core about 9 µm in diameter inside 125 µm of cladding — thinner than a human hair — under a protective coating. Light is kept inside the core by total internal reflection: the cladding’s refractive index is slightly lower. The glass is so transparent that at wavelengths of 1310–1550 nm it loses only 0.2–0.35 dB per kilometer: half the power still remains after roughly 9–15 km.

Home fiber is usually built on PON technology (passive optical network), most often GPON. “Passive” means there are no electronics between the home and the provider: the fiber from the district node branches out through glass 1:32 or 1:64 splitters in the stairwell or on the floor. Toward subscribers flows a 2.5 Gbit/s stream at a wavelength of 1490 nm, and back — 1.25 Gbit/s at 1310 nm; the two wavelengths travel in opposite directions through the same fiber without interfering. The reach is up to 20 km.

Downstream, the provider sends one shared stream to all the ONTs in the tree, and each one takes only the frames carrying its own identifier; the data is encrypted so a neighbor can’t read someone else’s. Upstream this won’t work — the signals would collide in the splitter — so the district OLT hands the ONTs a schedule: who may transmit and in which microseconds. That adds a little to the latency on the first hop. The next generation, XGS-PON, gives 10 Gbit/s in both directions over the same fibers at other wavelengths.

The ONT (optical network terminal) is a small box at the apartment entrance: a laser and a photodetector on one side, an Ethernet port on the other. It turns light into electrical signals and back, and registers with the OLT by its serial number. The ONT is often built right into the provider’s router. Where there’s no fiber in the apartment, the internet arrives over twisted pair from a switch in the basement (FTTB) or over a TV cable (DOCSIS).

The tree’s 2.5 Gbit/s is shared by all its subscribers, so a “1 Gbit/s” plan on GPON means “up to” a gigabit. In practice this is rarely noticeable: an average subscriber’s load is a few megabits per second, and the peaks of different apartments don’t coincide.

In the model, “Provider” is everything beyond the ONT: the OLT, routers, the exit to the internet. It has given the router the address 100.64.12.7. Where the fiber goes after leaving the building is covered on the “Region” level.

The router: network border and NAT

A home “router” is actually several devices in one case: a router proper (deciding where to send an IP packet), a 4-port LAN switch, a Wi-Fi access point, a DHCP server, a DNS forwarder and a firewall. Inside is a small 2–4-core processor running Linux, plus hardware blocks that speed up packet forwarding.

The heart of a router is its routing table. In a home router it’s tiny: “192.168.1.0/24 — to the LAN port; everything else (the default route 0.0.0.0/0) — to the provider through the WAN port.” The router doesn’t let broadcast frames, such as ARP requests, past itself: each network stays a separate broadcast domain, and the neighbors’ questions don’t clutter the internet.

Private addresses can’t be let out onto the internet: nobody would be able to deliver a reply to 192.168.1.10. So the router performs NAT — more precisely, address and port translation. In the demo, the PC’s packet 192.168.1.10:51000 → 203.0.113.80:443 leaves the router as 100.64.12.7:40001 → 203.0.113.80:443, and the mapping is recorded in the NAT table. When the server replies to 100.64.12.7:40001, the router finds the entry and returns the packet to the PC, restoring the original address and port.

A side effect of NAT is protection by default: a packet from outside with no matching entry has nowhere to go, and the router drops it. That’s why, to make a home NAS reachable from the internet, you need “port forwarding” — a permanent entry in the NAT table. But NAT is not a full-fledged firewall: the real protection is the filtering rules that work alongside it.

Note the address 100.64.12.7. It comes from the 100.64.0.0/10 range — this, too, isn’t a public address but a “carrier-grade NAT” address (CGNAT, RFC 6598). There are only about 4.3 billion IPv4 addresses, they ran short long ago, and many providers put one more NAT on their side: dozens or hundreds of subscribers go out under a single public address. Hence double NAT, difficulties with incoming connections — and one of the reasons to move to IPv6.

The “PC → website” scenario in the demo shows all these steps: the PC’s ARP cache already knows the router’s MAC, the switch forwards the frame to port 8, the router translates the address, the ONT turns the frame into light, and the reply comes back through the NAT table.

How a device gets an address: DHCP and DNS

When a device joins the network, it knows nothing yet — neither its own IP nor the gateway’s address. It broadcasts a DHCP Discover request; the router answers with an offer (Offer), the device requests it (Request), and the router confirms (Ack). These four messages take milliseconds, and the device receives its address, the network mask, the gateway address 192.168.1.1, the DNS server addresses and a lease time — usually a day, after which the lease is renewed.

The router remembers which address it gave to which MAC and tries to hand out the same one again. For the printer and the NAS it’s handy to pin an address (a “DHCP reservation”) so that settings on other devices don’t break after the router reboots.

People write names, but the network works with addresses. DNS turns a name into an address. The computer asks a DNS server (often the router itself pretends to be one, forwarding questions to the provider): “What is the address of example.com?” If the provider’s recursive server doesn’t remember the answer, it asks along a chain: the root servers, the .com zone servers and finally the domain’s authoritative server. The answer is cached for the time set by the domain owner (the TTL) — from minutes to a day — so most often the answer comes from a cache in 1–20 ms.

Inside the apartment, devices find each other even without a DNS server: printers and NAS boxes announce themselves via mDNS (Bonjour) — multicast messages on port 5353 that everyone on the network hears. That’s how a phone “sees” a printer without any setup.

The switch and twisted pair

A switch connects wired devices and forwards frames between ports by MAC address. Its main mechanism is self-learning. A frame arrives on port 1 with sender MAC …:00:10 — the switch notes: “this address is behind port 1.” Then it looks at the destination MAC: if it’s already in the table, it sends the frame only to the right port; if not, it floods it to all ports except the incoming one. Broadcast frames are always flooded.

In the “PC → NAS” scenario you can watch the table fill up from scratch: the first ARP request goes out to all ports, but the NAS’s reply goes directly, because the switch has already learned where the PC is. Entries age and are usually removed after 5 minutes without traffic — that’s how the switch finds out about moved cables.

A modern switch is full duplex: each port transmits and receives at the same time, and devices on different ports don’t get in each other’s way. A frame is delayed inside it by a few microseconds. Old hubs repeated everything to every port, and devices collided on the shared medium — which is why hubs are long gone.

Cat6 twisted pair is four pairs of copper conductors twisted at different rates. The signal travels over a pair differentially: “plus” on one wire, “minus” on the other. External interference is induced equally on both wires, and the receiver, subtracting one signal from the other, cancels it out; the twisting evens out the pickup along the whole length. Gigabit Ethernet uses all four pairs simultaneously in both directions.

Over the same cables, 2.5 and 5 Gbit/s work up to 100 m, and 10 Gbit/s over Cat6 up to 55 m (over Cat6a, up to 100 m). The length limit comes less from overall attenuation than from the fading of high frequencies and crosstalk between pairs: over a longer run the receiver can no longer reliably recover the symbols. For longer distances, there’s fiber.

Wi-Fi: radio, shared airtime and standards

Wi-Fi is radio communication in the 2.4, 5 and 6 GHz bands. The access point in the router connects the radio to the wired network: it converts Wi-Fi (802.11) frames into Ethernet frames and back, so to the rest of the network the laptop and phone are participants with a MAC and IP just like the PC. In the “Wi-Fi → printer” demo, the phone’s frame goes over the air to the router, then by wire to the switch and on to the printer.

The main difference from a wire is the shared airtime. At any moment only one device transmits on a channel while the others wait: listen to the air, wait a random pause, transmit, wait for an acknowledgment. So the channel’s speed is split among everyone, and a slow client at the edge of coverage occupies the air the longest and slows down the rest. Wi-Fi 6 partly solves this with OFDMA: the channel is sliced into groups of subcarriers, and the access point serves several clients in a single transmission.

Speed is determined by the channel width (20–320 MHz), the modulation (how many bits each symbol carries: up to 10 bits in Wi-Fi 6, 1024-QAM; 12 bits in Wi-Fi 7, 4096-QAM) and the number of spatial streams (antennas). A phone with two antennas on Wi-Fi 6 with a 160 MHz channel has a link rate of 2.4 Gbit/s, but actually gets about 1 Gbit/s near the access point and several times less through two walls. Figures like “Wi-Fi 7 — 46 Gbit/s” are the theoretical maximum for 16 streams, which no phone has.

Choosing a band is a trade-off. 2.4 GHz goes through walls better, but it has only three non-overlapping 20 MHz channels, shared by all the neighbors, Bluetooth and microwave ovens. 5 GHz has more channels and speed but penetrates concrete worse. 6 GHz (Wi-Fi 6E and 7) has wide, free channels but even shorter range, and this band isn’t permitted in every country. Wi-Fi 7 (802.11be, since 2024) can work in several bands at once (MLO), which reduces latency.

Everyone around can hear radio, so Wi-Fi frames are encrypted — with WPA2 or the stronger WPA3. The network password is never sent over the air: from it and random numbers, both sides compute the session keys.

The practical takeaway: the PC, the TV and the NAS are better connected by wire — it’s more stable and doesn’t share airtime. In a large apartment, instead of one powerful router, people install several access points (mesh), linked by wire or a dedicated radio channel.

The PC, the NAS and the printer

The PC is wired to port 1 of the switch and has received the address 192.168.1.10. Its network controller on the motherboard (1–5 Gbit/s) builds frames by itself and uses DMA to put received ones straight into memory. Double-clicking the PC opens the “Workstation” level.

A NAS is network-attached storage: a small computer with 2–8 drives and Linux inside. It shares folders over the SMB protocol (TCP port 445) or NFS, and stores photos from phones, backups and a media library. The drives are usually combined into RAID: in RAID 1 data is mirrored onto two drives; in RAID 5 and 6 it’s spread out together with parity information, and losing one (or two) drives doesn’t destroy the data.

An important caveat: RAID is not a backup. It saves you from a drive failure, but not from accidental deletion, ransomware or a fire: all of that is instantly “mirrored” too. The 3-2-1 rule: three copies of the data, on two different kinds of media, one of them outside the home.

A network printer has its own IP address and accepts jobs over the IPP protocol (port 631) — HTTP adapted for printing; it announces itself via mDNS, so phones find it on their own. In the “Wi-Fi → printer” scenario, the phone already knows the printer’s MAC, and the frame goes directly through the router and switch without leaving the apartment.

Copy speed to a NAS is limited by the weakest link: a gigabit port gives about 110–118 MB/s, a modern hard drive 200–280 MB/s, an SSD gigabytes per second. That’s why for an SSD-based NAS a 2.5 or 10 Gbit/s network makes sense.

Step by step: opening a website

Let’s put it all together. You typed a website address into the browser on the PC. Step 1: the browser asks DNS “what is the site’s IP?” and gets 203.0.113.80. Step 2: the PC sees that the address isn’t in 192.168.1.0/24, so the packet must be handed to the gateway 192.168.1.1. The gateway’s MAC is already in the ARP cache; if it weren’t, an ARP request to the whole network would come first.

Step 3: TCP opens the connection with three packets — SYN, SYN-ACK, ACK. The first one leaves in a frame where the sender MAC is the PC’s, the destination MAC is the router’s, and the IPs and ports are 192.168.1.10:51000 → 203.0.113.80:443. Step 4: the switch checks its table — the router’s MAC is behind port 8 — and forwards the frame there, without bothering the NAS and the printer.

Step 5: the router removes the Ethernet envelope, consults its routing table (default — to the provider) and performs NAT: the sender becomes 100.64.12.7:40001. The packet gets a new frame with the MACs of the router’s WAN port and the provider’s equipment. Step 6: the ONT turns the frame into light pulses and sends it up the fiber in the time slot assigned by the OLT. From there the packet travels through the city, the continent and maybe even an ocean — those are the next levels.

Step 7: the server’s reply arrives at 100.64.12.7:40001. The router finds the NAT entry, restores 192.168.1.10:51000 and puts the packet into a frame for the PC; the switch, already knowing the PC is behind port 1, delivers it. After TCP is set up comes the TLS key exchange (in TLS 1.3, one more round trip), and only then the HTTP request for the page itself. That’s why opening a site for the first time takes several round trips, not one.

Everything that happens inside the apartment takes tens of microseconds (not counting Wi-Fi, where waiting for the air can add milliseconds). Most of the time is spent traveling through external networks and on the server’s work.

IPv6: enough addresses for everyone

IPv6 is a new version of the protocol with 128-bit addresses, written as eight groups of hexadecimal digits (for example, 2001:db8:5:1::10). There are so many addresses that a provider gives each home an entire /56 or /64 subnet — billions of billions of addresses — and NAT becomes unnecessary: every device has its own global address.

Instead of ARP, IPv6 uses neighbor discovery (NDP) based on multicast messages, and a device can assign itself an address from the router’s announcement (SLAAC) — DHCP is optional. So that a device can’t be tracked by its address, the OS periodically changes temporary addresses used for outgoing connections.

Without NAT, protection comes from the router’s firewall: by default it lets in only replies to connections started from inside. This is the same behavior NAT provided “by accident,” only explicit and configurable.

By 2025, about half of users worldwide reach Google’s services over IPv6, but the share varies greatly between countries. For now IPv4 and IPv6 work side by side: a device tries both and uses whichever answered faster.

Common misconceptions

“My IP is 192.168.1.10.” That’s the address inside the apartment. Websites see the router’s address, and with CGNAT the provider’s shared address. The only way to learn your external address is to ask someone outside.

“The speed on the router box is my speed.” The box shows the sum of the maximum link rates of all bands. The real speed of a single phone is several times lower, and it’s shared by all the devices on the air.

“The more antennas a router has, the farther it reaches.” Transmitter power is limited by law. Antennas give more spatial streams and directionality, but they don’t punch through concrete. Moving the router to the center of the apartment or adding a second access point usually helps more.

“A switch and a router are the same thing.” A switch works inside one network using MAC addresses; a router connects different networks using IP addresses. At home they share one case, but at a provider or in a data center they are separate devices.

“A 5G network in the Wi-Fi list is 5G mobile.” “5G” in a Wi-Fi network’s name means the 5 GHz band. Mobile 5G is an entirely different technology, covered on the “Region” level.

Open in 3D →

All articles

Overviews

Logic: from transistor to arithmetic

Processor

Computer

Servers and data centers

Networks and the internet

Software