Networking
Every pipeline is a network program. A Spark job reads from S3 over HTTPS, an Airflow worker opens a TCP connection to PostgreSQL, Kafka clients resolve broker names through DNS, and you reach the production box over SSH through a VPN. When a job “hangs”, the cause is very often a DNS lookup, a firewall rule, a subnet route or a TLS certificate, not your code. This section teaches the handful of layers, addresses and protocols you meet every day, each with a step-by-step animation of what actually goes over the wire.
One request, down and up the stack
Networking software is built in layers. Each layer solves one problem and hands the result to the layer below, wrapping the data in its own header, like putting a letter in an envelope and that envelope in a bigger one.
| STEP | LAYER | ADDS | ADDRESSES IN IT | UNIT |
|---|---|---|---|---|
| 01 | Application | HTTP request | Host: api.shop.com | DATA |
| 02 | Transport | TCP header | port 52114 → 443 | SEGMENT |
| 03 | Internet | IP header | 192.168.1.42 → 203.0.113.10 | PACKET |
| 04 | Link | Ethernet header + checksum | 3c:22:fb:7a:10:9e → gateway's MAC | FRAME |
| 06 | all, in reverse | headers removed | each layer checks the address meant for it | DATA |
- Two models of the same stack. OSI has 7 layers and is the vocabulary; TCP/IP, what real systems implement, merges them into 4.
- Your program builds an HTTP request, GET /orders. To every layer below, it is just bytes of data.
- The transport layer prepends a TCP header with source and destination ports. Now it is a segment.
- The internet layer prepends an IP header with source and destination IP addresses. Now it is a packet.
- The link layer adds an Ethernet header with the MAC addresses of this one hop, plus a checksum trailer. Now it is a frame.
- The frame leaves as bits. Each router along the way builds a new frame for the next hop; the IP packet inside travels end to end.
- The receiver unwraps in reverse: link, then IP, then TCP each check and strip their header, and the web server reads GET /orders.
| TCP/IP layer | OSI layers | What lives here | Address it uses |
|---|---|---|---|
| Application | 7, 6, 5 | HTTP, DNS, SSH, TLS, PostgreSQL wire protocol | URL, hostname |
| Transport | 4 | TCP, UDP, QUIC | port |
| Internet | 3 | IP, ICMP (ping) |
IP address |
| Link | 2, 1 | Ethernet, Wi-Fi, ARP | MAC address |
You will still hear OSI numbers every day: an L4 load balancer routes by IP and port without reading the request, an L7 load balancer or WAF reads the HTTP path and headers, and “L2 network” means machines that reach each other directly by MAC address.
Three kinds of address
| Address | Example | Scope | Analogy |
|---|---|---|---|
| MAC | 3c:22:fb:7a:10:9e |
Burned into the network card. Only meaningful inside one local network (one hop). | A face, known in this room |
| IP | 192.168.1.42, 2001:db8::42 |
Where the machine sits on the network. Changes when it joins another network. | A street address |
| Port | 22, 53, 443, 5432 |
Which program on that machine. A number from 0 to 65535. | An apartment number |
A connection is identified by five values: protocol, source IP, source port, destination IP and destination port. ARP links the layers: to send a frame to 192.168.1.1, your machine broadcasts “who has 192.168.1.1?” and caches the MAC that answers. IPv4 addresses are 32 bits and nearly used up; IPv6 uses 128 bits and carries a large and growing share of internet traffic. See IP addressing for subnets and CIDR.
Pages in this section
Concepts
| Page | What you learn |
|---|---|
| IP addressing | IPv4 and IPv6, private ranges, ports, subnets and CIDR, the default gateway and NAT. |
| DHCP | How a machine gets its IP, gateway and DNS servers: Discover, Offer, Request, Acknowledge, and leases. |
| Firewalls | Stateless vs stateful filtering, security groups, default deny and egress rules. |
| VPN | Tunnels and encapsulation, WireGuard and IPsec, site-to-site vs remote access, and zero-trust alternatives. |
Protocols
| Page | What you learn |
|---|---|
| TCP/IP | How TCP’s handshake, acknowledgments and teardown make a reliable byte stream. |
| UDP | Datagrams without a connection, why DNS, video and QUIC use it, and a side-by-side comparison with TCP. |
| DNS | How a name becomes an IP: resolvers, root, TLD and authoritative servers, record types and TTL caching. |
| HTTP | Requests, responses, methods, status codes, caching, and head-of-line blocking from HTTP/1.1 to HTTP/3. |
| HTTPS | TLS 1.3: the one-round-trip handshake, certificates and chains of trust. |
| SSH | Encrypted remote shells, public-key login, known_hosts, and tunnels to private databases. |
A good order: IP addressing, TCP/IP, UDP, DNS, HTTP, HTTPS, then the rest as you need them.
Common mistakes
- Debugging the wrong layer. Work bottom up: is there an IP and a route (
ip addr,ip route)? Does the name resolve (dig)? Is the port reachable (nc -zv)? Only then look at TLS and HTTP. - Mixing up “can’t resolve”, “connection refused” and “timeout”. Refused means the host answered and nothing listens on that port; a timeout usually means a firewall silently dropped the packet.
- Thinking
localhostis the same everywhere. Inside a container,localhostis the container itself, not your laptop or the database next to it.
Try it
A five-minute lab on any Linux machine (on macOS use ifconfig and netstat -rn instead of ip):
ip -br addr # your interfaces, IPs and prefix lengths
ip route | grep default # your default gateway
ping -c 3 1.1.1.1 # reach an IP directly
ping -c 3 example.com # same, but a DNS lookup happens first
traceroute 1.1.1.1 # every router (hop) on the way
python3 -m http.server 8000 # start a web server, then in a second terminal:
curl -v http://localhost:8000/ # watch the request and response
ss -tlnp | grep 8000 # which process listens on port 8000Learning Resources
- Computer Networking: A Top-Down Approach (8th ed.), Kurose and Ross: the standard textbook
- High Performance Browser Networking: Ilya Grigorik, free online
- Beej’s Guide to Network Programming: sockets from first principles
- OSI model and Internet protocol suite: Wikipedia overviews of both layer models