MyShop's shoes page is not sent whole, in one big delivery. The page is cut into small pieces first.
Cut, sent, put back together
- The server cuts the page into packets: small pieces that each carry the destination IP address and a sequence number (the piece's place in the order).
- Each packet is passed on by routers: devices that read the destination IP address, then pass the packet one step closer to that destination. The Wi-Fi router in your home is one of them. Packets of the same page can take different roads and arrive in any order.
- The browser waits until it has every sequence number, then puts the packets back in order by number. If a packet got lost on the way, the browser tells the server which number has not arrived, and the server sends that packet again.
Because packets are small, many people can share one road and take turns. And when one packet is lost, only that packet is sent again, not the whole page.
💡 The name of the rule
The rule for numbering the packets, putting them back in order and asking again for lost ones is called TCP. TCP is usually the one used when you open a web page, although you never see it. Some sites use QUIC, a newer rule that does the same job.
TL;DR: A page is cut into packets (small numbered pieces). Routers (devices along the way) pass each packet on, and packets can take different roads. The browser then puts the packets back in order by number. A lost packet is sent again.
⚡ Cut into packets
Meaning: Before it sends a page, the server cuts the page into packets: small pieces that each carry the destination IP address and a sequence number (the piece's place in the order). Routers are the devices that pass the packets on: a router reads the destination IP address, then passes the packet one step closer to that destination. The Wi-Fi router in your home is one of them.
⚡ They arrive in any order
Meaning: Packets of the same page can take different roads and arrive in any order. The browser waits until it has every sequence number, then puts the packets back in order by number.
⚡ When one gets lost
Guess first: a page is sent as packets #1 to #4, and #3 gets lost on the way. What is sent again?
Only packet #3. The browser tells the server which number has not arrived, and the server sends that packet again.
Meaning: So the whole page never has to be sent again. The rule for numbering the packets, putting them back in order and asking again for lost ones is called TCP.