In the basics you saw the five steps of opening a page, and a page cut into small packets. This lesson looks more closely at the second step (knocking on the door): how the browser and the server agree on a connection, and what keeps the packets complete.
The five steps, with their protocols
Here are the five steps with their technical names:
1. DNS "what is the IP of belajarweb.dev?" → 203.0.113.10
2. TCP SYN → SYN-ACK → ACK (handshake)
3. Request GET / HTTP/1.1
4. Response HTTP/1.1 200 OK + the page (HTML)
5. Render the browser draws the page on screen
HTTP/1.1 in lines 3 and 4 is the HTTP version.
DNS, TCP and HTTP (the language of requests and replies) are each called a protocol: a set of rules both sides agree on for talking. When the address starts with https://, there is one more handshake after the TCP handshake, for encryption (sealing what is inside the messages), called TLS.
TCP makes sure every packet arrives
TCP (Transmission Control Protocol) is the protocol that makes sure data arrives complete and in order. It does this in two ways:
- The three-way handshake. Before sending any data, the client sends SYN ("can we open a connection?"). The server answers SYN-ACK ("yes, are you ready?"). Then the client sends ACK ("ready"). ACK (acknowledge) means a receipt. After those three messages, the connection is open.
- Reorder and resend. The receiver puts the packets back in order by their numbers. The receiver also tells the sender which packets arrived. Any packet that didn't arrive is sent again.
UDP (User Datagram Protocol) works the opposite way: it just sends, with no handshake and no resending. UDP is faster, but a lost packet stays lost. UDP suits video calls and online games, where resending would come too late to help.
⚠️ What people get wrong about the internet
- The internet and the web are different things. The internet is the network: cables, routers and IP addresses. The web is the pages sent over HTTP on that network. Email and online games use the internet too, but they aren't the web.
- Latency is not bandwidth. Latency is how long one message takes to travel, in milliseconds (ms). Bandwidth is how much data per second, in Mbps (megabits per second). A 100 Mbps connection with 300 ms of latency still feels slow in a game, because every message still spends 300 ms on the road.
- Connections aren't always stable. The signal can drop while a request is still on its way. A good web app is ready for a failed request, for example with an error message and a retry button.
💡 HTTP/3 takes another road. Many sites now use HTTP/3, a version of HTTP that travels over QUIC, not TCP. QUIC is a newer protocol that uses UDP, but it still guarantees complete, in-order data like TCP does. QUIC also combines the connection handshake with the encryption handshake, to save time.
TL;DR: TCP is a protocol (a set of rules for talking) that opens a connection with a handshake of three messages: SYN, SYN-ACK, ACK. Then TCP puts the packets back in order by their numbers and resends the lost ones. UDP, another protocol, sends right away with no handshake and no resending: faster, with no guarantee. HTTP/3 (a newer version of HTTP) travels over QUIC, which uses UDP but still guarantees complete, in-order data.
⚡ The five steps have protocol names
Meaning: When you open a page, DNS finds the IP address, TCP opens a connection with a handshake, and HTTP is the language of requests and replies. Each one is called a protocol: a set of rules both sides agree on for talking. When the address starts with https://, there is one more handshake after the TCP handshake, for encryption (sealing what is inside the messages), called TLS.
⚡ The three-way handshake
Guess first: how many messages pass before TCP sends its first data?
Three: the client sends SYN ("can we open a connection?"), the server answers SYN-ACK ("yes, are you ready?"), and the client sends ACK ("ready").
Meaning: This is the three-way handshake. ACK means a receipt. After the handshake, the connection is open. TCP then puts the packets back in order by their numbers and resends the ones that didn't arrive.
⚡ UDP just sends
Guess first: UDP is a protocol that sends data right away, with no handshake. On a video call over UDP, a packet gets lost. Is that packet sent again?
No. UDP never resends a lost packet. On a video call, resending would come too late to help.
Meaning: UDP is faster, but a lost packet stays lost. HTTP/3 (a newer version of HTTP) travels over QUIC, which uses UDP but still guarantees complete, in-order data.
⚡ Latency is not bandwidth
Meaning: Latency is how long one message takes to travel, in milliseconds (ms). Bandwidth is how much data per second, in Mbps (megabits per second). A 100 Mbps connection with 300 ms of latency still feels slow in a game, because every message still spends 300 ms on the road.