Network and server: how data finds its way and comes back
When a browser requests a page, the data passes through the network card, cables, the routers of a dozen companies, and an undersea cable, and then through the kernel and the server program — all in a fraction of a second. This works because the network is divided into layers, and each one solves a single task without knowing anything about the others. Let’s go through the layers in order, figure out where delays come from, and take a look inside a server program.
Layers and envelopes
Network communication works like nested envelopes. The application writes an HTTP request. The transport layer (TCP) puts a piece of the request into an envelope with port numbers and a sequence number. The network layer (IP) puts that into an envelope with the sender’s and recipient’s IP addresses. The link layer (Ethernet or Wi-Fi) puts it into an envelope with the MAC addresses of neighboring devices. The physical layer turns the bits into voltages in a cable, flashes of light in optical fiber, or radio waves.
Each node along the way opens only “its own” envelopes. A switch looks only at the MAC address, a router at the IP address, and only the end computers get down to TCP and HTTP. Thanks to this, you can replace Wi-Fi with fiber or HTTP/1.1 with HTTP/3 without touching the other layers.
Let’s count the overhead. The Ethernet header is 14 bytes plus a 4-byte checksum, IPv4 is 20 bytes (IPv6 is 40), TCP is 20 bytes, usually 32 with options. The maximum IP packet size in a typical network (MTU) is 1,500 bytes, so the payload in one TCP segment is about 1,448–1,460 bytes. Another 20 bytes on the wire are taken up by the preamble and the gap between frames. In total, of the 1,538 bytes that travel along the wire, about 95% are useful.
The classic OSI model describes seven layers, but in practice the internet lives by the four-layer TCP/IP model: link, network, transport, and application. TLS encryption sits between the transport and application layers.
See also: Local network: router, switch, Wi-Fi
Ethernet and Wi-Fi: neighbors on the network
Within a single local network, devices communicate using Ethernet frames. Every network interface has a MAC address — 48 bits, the first 24 of which identify the manufacturer. A switch remembers which MAC it has seen behind which port and forwards a frame only to the right port; a frame with an unknown address is sent out of all ports.
To send a packet to an IP address on its own network, a computer must learn the recipient’s MAC. To do this, it broadcasts an ARP request to everyone: “Who has address 192.168.1.1? Reply to me.” The owner of the address replies, and the answer is remembered for a few minutes. If the destination address is outside the network, the frame is sent to the MAC of the router — the default gateway.
Speeds: Gigabit Ethernet transmits a 1,538-byte frame in 12.3 µs, 2.5 Gbit/s in 5 µs; a Category 6 cable handles up to 10 Gbit/s over 55 m. Wi-Fi 6 and 7 promise gigabits, but the radio channel is shared among all devices, and neighbors’ networks and walls interfere, so the real speed is several times lower and the latency is unstable — from a few to tens of milliseconds.
In the Local network model you can see how a frame finds its way by MAC addresses inside an apartment and how the router becomes the boundary: broadcast ARP requests don’t pass through it, and everything addressed to the outside it sends to the internet provider.
IP and routing: an address for the whole planet
An IPv4 address is 32 bits, written as four numbers: 93.184.216.34. That is only 4.3 billion addresses, and the free ones ran out in the 2010s. NAT comes to the rescue: all devices at home have private addresses like 192.168.x.x, and the router replaces them with a single public address and remembers which reply to return to whom. Providers often do the same thing again (CGNAT). IPv6, with 128-bit addresses, solves the problem for good; according to Google’s statistics, by 2025 about half of its users reached it over IPv6.
Each router makes its decision independently: it looks at the destination address, finds the longest matching prefix in its routing table (for example, 93.184.0.0/16 — “via port 3”), and sends the packet onward. The packet doesn’t know its route in advance. To keep packets from circling forever in case of an error, the header has a TTL counter that is decremented at every router; when it reaches zero, the packet is discarded. The traceroute utility uses this to reveal the path.
The internet is a network of networks: more than 70,000 autonomous systems (providers, clouds, large companies), each with its own address blocks. Between them runs the BGP protocol: each network announces to its neighbors which addresses it can deliver to, and chooses routes according to its own rules and agreements. The global IPv4 table in 2025 is about a million prefixes. A mistake in one company’s BGP announcements can “hijack” traffic for half the world — it has happened.
Networks exchange traffic in two ways: paid transit (a large provider carries your traffic anywhere) and peering — direct exchange, often free of charge, at internet exchange points (IX). At the Region level in the model you can see how a home provider’s network and a data center connect through an IX.
See also: City and region: how networks connect
TCP and UDP: a reliable stream on top of unreliable packets
IP guarantees nothing: packets are lost when queues overflow, arrive out of order, and are sometimes duplicated. TCP builds a reliable, ordered byte stream on top of this. A connection begins with a three-way handshake: the client sends a SYN with a random initial number, the server replies with a SYN-ACK, and the client with an ACK. This costs one full round trip (RTT) before data transfer can begin.
Every byte of the stream has a sequence number. The receiver acknowledges what it has received (ACK) and reassembles the segments in the correct order by their numbers. If an acknowledgment doesn’t arrive in time, or three identical acknowledgments arrive in a row, the sender retransmits the lost segment. The receiver’s window says how much more data it is ready to accept — this way a fast server doesn’t swamp a slow phone.
The subtlest part is congestion control. The sender doesn’t know the capacity of the path, so it starts cautiously: 10 segments (about 14 KB) in the first round trip, then doubles every RTT (slow start) until it encounters losses. The CUBIC algorithm (the default in Linux) and Google’s BBR look for the optimal speed in different ways. An important consequence follows: with an RTT of 100 ms, even on a gigabit link the first few hundred kilobytes take several round trips — latency matters more than bandwidth.
UDP is the opposite: just ports, a length, and a checksum, with no guarantees. It is used where a late packet is worse than a lost one: voice and video calls, games, DNS. QUIC is also built on UDP — a new transport in which reliability, encryption, and many independent streams are implemented in the program itself rather than in the OS kernel. HTTP/3 runs on top of QUIC.
See also: The operating system: who shares out the processor, memory and devices
DNS: the internet’s phone book
People remember names, but routers only know IP addresses. DNS turns the name example.com into an address. It is a distributed hierarchical database. At the top are the root servers: 13 names from a to m, behind which stand more than fifteen hundred instances around the world with the same addresses (anycast — a packet reaches the nearest one). The root knows the servers of the top-level zones (.com, .ru, .org), and those know the servers of specific domains.
Your computer usually doesn’t walk the hierarchy itself. It asks a recursive resolver — at the provider, in the router, or a public one (1.1.1.1, 8.8.8.8). If the answer isn’t in its cache, the resolver asks the root (“who is responsible for .com?”), then the .com server (“who is responsible for example.com?”), then the domain’s authoritative server (“what is the address of example.com?”), and returns the answer.
Each answer has a time to live (TTL) — from seconds to a day, and everything along the way caches it: the browser, the OS, the router, the resolver. That is why a name is usually resolved in 0–20 ms from the cache, while a full lookup takes tens to hundreds of milliseconds. DNS queries go over UDP to port 53, one packet there and one back; modern browsers can encrypt them over HTTPS (DoH) so that the provider can’t see which sites you open.
DNS is also a traffic management tool. Large sites and content delivery networks (CDNs) respond with different addresses depending on where the request came from, directing the user to the nearest server. That is why the same site is served from different computers in Moscow and in New York.
TLS: encryption and authentication
Without encryption, any node along the way — the Wi-Fi operator in a café, the provider, a router — can read and modify the data. TLS solves two problems: it encrypts the stream and proves that you are talking to example.com itself and not an impostor. Today more than 90% of web traffic goes over HTTPS.
A TLS 1.3 handshake takes one round trip. In its very first message, the client sends the ciphers it supports and its half of an elliptic-curve Diffie–Hellman key exchange on the X25519 curve. The server replies with its half, and both sides independently compute the same shared secret, which was never sent over the network. Since 2024, Chrome and Firefox add the post-quantum algorithm ML-KEM to the exchange, so that traffic recorded today can’t be decrypted by future quantum computers.
In the same reply, the server sends a certificate — a document stating “such-and-such key belongs to example.com,” signed by a certificate authority — and signs the handshake with its private key. The browser checks the chain of signatures up to one of roughly 150 root certificates built into the OS or browser, and checks the name and validity period. The free certificate authority Let's Encrypt issues 90-day certificates automatically, which is what made HTTPS ubiquitous.
After that, data is encrypted with a symmetric cipher — AES-GCM or ChaCha20-Poly1305. Processors have special AES instructions, and a single core encrypts several gigabytes per second, so encryption costs almost nothing. Only the handshake with its public-key operations is expensive — which is why sessions are resumed, and on reconnection TLS 1.3 allows data to be sent immediately, without waiting (0-RTT).
HTTP: request and response
HTTP is the language the browser uses to talk to the server. A request consists of a method (GET — retrieve, POST — send data), a path (/index.html), headers (Host: example.com, Accept-Language: ru, cookie), and possibly a body. A response consists of a status code (200 — all good, 301 — moved, 404 — not found, 500 — server error), headers (content type, caching rules), and a body — HTML, an image, JSON.
HTTP/1.1 (1997) sends requests as text and, within a single connection, strictly one after another, so browsers opened 6 connections per site. HTTP/2 (2015) switched to binary frames and multiplexing: dozens of requests travel in parallel over a single TCP connection, and headers are compressed. But if one TCP segment is lost, all streams wait — TCP is obliged to deliver bytes in order.
HTTP/3 (2022) moves everything onto QUIC over UDP. Streams are independent: a lost packet delays only its own stream. The transport and encryption handshakes are combined — a connection is established in one round trip instead of two, and on a repeat visit in zero. QUIC survives a change of network: the phone switched from Wi-Fi to mobile data, the IP address changed, and the connection carries on.
Pages themselves are served from a cache as close to the user as possible. Content delivery networks (CDNs) keep copies of images, scripts, and even entire pages on servers in hundreds of cities. A request from Moscow to an American site is often served by a server in Frankfurt or in Moscow itself, and only what can’t be cached travels across the ocean.
See also: Inside the browser: from HTML bytes to pixels on the screen · Server: a computer for the data center
Where latency comes from
Latency is made up of four parts. Propagation: light in optical fiber travels at about 200,000 km/s — 5 µs per kilometer, which is a physical limit. Serialization: the time to push a packet onto the link — 1,500 bytes at 1 Gbit/s take 12 µs, at 100 Mbit/s 120 µs. Processing in nodes: routers spend microseconds. Queuing: if a link is busy, the packet waits in a buffer — from zero to hundreds of milliseconds.
In the model at the Internet and Earth level, the cable route from our city to a server in New York is about 9,600 km: overland to Frankfurt and London, then an undersea cable across the Atlantic. The straight line between the cities is 7,500 km, but cables run along roads and coastlines. One way takes about 49 ms, there and back about 98 ms. Via low-orbit satellites it comes out to about 80 ms, via a geostationary satellite more than half a second.
RTT is multiplied by the number of round trips the protocols need. A new HTTPS connection across the ocean: DNS (if not cached), TCP — one round trip, TLS — another, the request and the first response — another one. Three or four round trips of 100 ms each mean 0.3–0.4 s before the first byte of the page, even before all the images and scripts. That is why CDNs, connection reuse, HTTP/3, and 0-RTT are so important: cutting the number of round trips is more effective than speeding up the link.
Another common cause of “slow internet” is bufferbloat: a router with a huge queue holds packets for hundreds of milliseconds when the link is loaded (a download, a video call). The bandwidth may be excellent, yet games and calls become unusable. Modern routers fight this with queue management algorithms (fq_codel, CAKE).
See also: Internet and Earth: cables and satellites · Continent: backbones between cities
The network card and the OS kernel
A network card is a separate controller on the board (usually connected to the chipset) or a PCIe card in a server. The OS kernel allocates ring queues of descriptors and packet buffers in memory in advance. When sending, the driver puts a reference to a ready packet into the queue and “rings” the card; the card fetches the bytes from memory by itself via DMA, adds the Ethernet checksum, and puts it on the wire.
When receiving, the card writes packets into pre-allocated buffers via DMA and signals this with an interrupt. Under heavy load, an interrupt for every packet would drown the processor, so Linux uses NAPI: after the first interrupt, the driver turns interrupts off and picks up packets in batches, polling the queue until it is empty.
At 100 Gbit/s, about 8 million full-size packets arrive per second — 120 nanoseconds for each, a few hundred core clock cycles. To cope, the card takes over part of the work: it computes TCP and IP checksums, splits large blocks of data into segments (TSO) and merges received ones (GRO), and distributes connections across the queues of different processor cores by a hash of the addresses (RSS). For extreme workloads, the network stack is moved out of the kernel entirely, into a user program (DPDK) or into the card itself.
In the Server model, a 2 × 100 Gbit/s server network card is connected to a switch in its rack, and that switch to the data center’s network core. A home computer usually gets by with a 1–2.5 Gbit/s controller, and that is more than enough: the bottleneck is almost always further away — in the Wi-Fi or in the provider’s link.
See also: The operating system: who shares out the processor, memory and devices
A server program: thousands of connections at once
A server program is an ordinary process that asks the kernel via system calls: socket() — create a socket, bind() — bind it to port 443, listen() — start accepting connections. The kernel performs the TCP handshakes itself and places ready connections in a queue, and the program takes them with the accept() call and gets a descriptor for reading and writing.
A naive server creates a thread per connection: the thread reads the request, waits for the database to respond, and writes the response. This is simple, but 10,000 connections mean 10,000 threads, each with its own stack and context switches. Modern servers (nginx, Node.js, servers written in Go and Rust) use an event loop: one thread per core and the epoll mechanism in Linux or IOCP in Windows, which reports which of thousands of sockets are ready for reading or writing. The thread handles only the ready ones and never blocks.
Processing a request usually passes through several links. A load balancer at the entrance to the data center distributes connections among hundreds of servers and often terminates TLS itself. A reverse proxy (nginx) serves static files and passes everything else to the application server. That server checks authorization, makes requests to the cache and the database, and generates HTML or JSON. All of this happens inside the data center, where the RTT between servers is tens to hundreds of microseconds.
A good server program takes into account that anything can break: every call to the database or another service has a timeout, requests are retried with pauses, and under overload, excess requests are rejected immediately rather than piling up. A large service is thousands of such servers in several data centers, and a user’s request may pass through dozens of internal services before the response comes back.
See also: Server: a computer for the data center · Data center: where websites live · Databases and apps: how to find one row among billions