Networking is built in layers. Each layer does one job and trusts the layer below it to do its job. You'll hear about the 7-layer OSI model, but in practice four layers matter:
| Layer | Job | Examples |
|---|---|---|
| Application | What the programs are saying | HTTP, DNS, SMTP |
| Transport | Getting data between two programs, reliably or quickly | TCP, UDP |
| Network | Getting packets between two machines across many networks | IP |
| Link | Getting bits across one physical hop | Wi-Fi, Ethernet |
When you send a request, each layer wraps the data from the layer above in its own envelope, like putting a letter in an envelope, then in a box, then on a truck. The other side unwraps them in reverse. You'll often hear "layer 4" (transport) and "layer 7" (application), for example for load balancers. Those numbers come from the 7-layer OSI model, where transport is layer 4 and application is layer 7.
IP addresses
Every machine on a network has an IP address, like 198.51.100.14 (IPv4) or
2001:db8::1 (IPv6). IPv4 has only about 4.3 billion addresses, which ran out years
ago; IPv6 has more than we'll ever need.
A packet carries a source and a destination address. Routers pass it along, one hop at a time. No router knows the whole path; each one only knows which neighbour is closer to the destination. Packets from the same request can take different routes, and the receiving side puts them back in order (that's the transport layer's job).
Private addresses and NAT
Your laptop probably has an address like 192.168.1.20. That's a private address: it only
means something inside your home network, and millions of homes use the same ones. Your home
router has one public address and uses NAT (network address translation) to swap the
private address for its public one on the way out, and back on the way in.
So the server sees your router's public address, not your laptop's. The same idea is used inside data centres: servers talk over private addresses, and only a few machines (like load balancers) face the internet.
Key idea: application, transport, network and link layers each do one job. IP addresses identify machines; routers move packets hop by hop. Private addresses stay inside a network, and NAT maps them to a public one.