Packets, IP and TCP: how data gets there
Why:You’ll see that a page doesn’t travel whole but in pieces, and why it still arrives correctly. Afterwards you can explain an IP address, a port, a lost packet and the TCP handshake in plain words.
20 minutes
Read by speech synthesis (Qwen3-TTS); the voice is not a person’s.
A packet is a piece of data with a header: where from, where to, which number. IP delivers packets by address with no guarantees; TCP numbers and resends.
A page travels in pieces
When you open a page, it doesn’t arrive in one parcel. The data is cut into small pieces, packets, and each one travels on its own. Compare it with moving house: you don’t load everything into one enormous freight car, you pack it in boxes, number them and send them in different trucks. At the other end the boxes are opened in numeric order.
A packet has a header, like a parcel’s label: where from, where to and which number it is. And it has its contents: the piece of data itself. The size is limited: a packet usually carries fifteen hundred bytes, which is about one and a half kilobytes. A hundred kilobyte page is about seventy packets, and a megabyte picture is about seven hundred.
Move the loss slider on the diagram. The network isn’t perfect: packets are sometimes lost or arrive in the wrong order, and the receiver still puts the whole together.
from 203.0.113.7:51514 → to 198.51.100.20:443 | packet #3 of 10 | data: “d expert”
203.0.113.7 and 198.51.100.20 are the addresses of the nodes (the usual way to write examples). The number after the colon is the port: port 443 takes secure web traffic (HTTPS), and your computer chooses the sender’s port.
Sent in this round: packets 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. Arrived, in order of arrival: 3, 4, 7, 2, 1, 6, 10, 9. Lost: 5, 8. The receiver reports which numbers are missing, and the sender sends them again.
What the receiver has put together: Land surveyor and expert witness▒▒ landowners sett▒▒ boundaries.
Packets sent in all: 13 for 10 in the text. Extra work caused by loss: 3.
Check yourself: what is a packet made of?
A header (where from, where to, which number) and contents (a piece of data).
Why cut it into packets
Telephone service used to work differently: for the length of a call you were given a whole line, and nobody else used it. That line sat idle while you were silent, and dropped if even one section broke.
A packet network is more economical. Packets from different people go along the same lines, mixed together. If some node breaks, packets go around it by another road. This idea was invented in the early 1960s by Paul Baran in the United States and Donald Davies in Britain, and the internet grew on it.
Packets are passed along by routers: nodes that look at the receiver’s address in the header and decide whom to hand the packet to next. No router knows the whole route, each knows only where to hand it on. That’s why the packets of one message can take different paths and arrive out of order.
IP: the address of a node
Every device on the network needs an address, or there’s no telling where to take a packet. That address is called an IP address. In the IPv4 protocol it’s four numbers from 0 to 255 separated by dots, for example 198.51.100.20. There are about 4.3 billion such addresses in all, and they ran short of the planet’s devices long ago.
That’s why there’s IPv6, where an address is much longer and is written in hexadecimal, for example 2001:db8::1. There are practically endless addresses in it, and today both protocols work side by side.
At home you usually have one “outside” address given by your provider, and a router that hands the devices inside the house addresses of their own, of the form 192.168.…. The inside addresses can’t be seen from outside.
An important property of IP: it delivers on a best-effort basis. A packet can be lost, arrive twice or arrive out of order. There are no guarantees, and that’s a deliberate decision: it keeps the network simple and fast.
Check yourself: why was IPv6 needed when there’s IPv4?
IPv4 has about 4.3 billion addresses, and they aren’t enough for every device. An IPv6 address is longer, and the number of addresses is practically unlimited.
Ports: which program
An IP address brings a packet to the right computer. But many programs run on a computer, and the packet has to go to the right one: the browser, the mail program, a game. For that there’s a port: a number from 0 to 65535. The address is the building, and the port is the apartment.
Some ports are standard: 80 for the plain web (HTTP), 443 for the secure web (HTTPS), 25 for sending mail, 53 for DNS. The browser fills them in itself, which is why you don’t see a port in a site’s address. In the address https://example.com:8443/ the port is shown explicitly, because it’s not the standard one.
TCP: reliability on top of unreliability
IP doesn’t guarantee delivery, and we need the page to arrive whole and in order. That’s the job of TCP, the reliable transport protocol that works on top of IP. It does four things:
- Sets up a connection. The client and the server first agree, in a three-step “handshake”: the client says SYN (“let’s talk”), the server replies SYN-ACK (“agreed”), the client replies ACK (“received”). Only then does data flow.
- Numbers the packets.
- Confirms what arrived: the receiver reports exactly what got through.
- Resends what was lost: if there’s no confirmation, the sender sends the packet again. You saw this on the diagram.
TCP also takes care not to flood the receiver or overload the network: it starts carefully and speeds up as long as everything goes smoothly.
There’s another approach, UDP: it simply sends packets with no guarantees and no confirmations. It’s faster and fits where a late packet is no longer needed: in a video call, in DNS queries, in games.
An important consequence of the handshake: before the first byte of the page moved, at least one round trip had passed. The speed of light in optical fiber is finite, so a site on the other side of the planet opens with a delay that no price plan can beat. That is one of the reasons sites are placed closer to their visitors.
Check yourself: how do IP and TCP differ?
IP delivers packets by address on a best-effort basis, with no guarantees. TCP on top of it numbers the packets, confirms what arrived and resends what was lost, so the data arrives whole and in order.
Practice
You’re in the era of 1996. Your site will be opened over a modem, at about 3.6 kilobytes a second. Fifty kilobytes take almost fourteen seconds to load, and that is already long. That’s why every page had a budget: how much it could weigh.
A page weight table has been added under the heading. Work out how much the text, the logo, the main picture and the pictures for your services, products or people weigh (you described them in the brief). Write the numbers in kilobytes. If you have no picture, say so. The last row is the total, and it must fit in 50 kilobytes.
How many packets is that? Divide the weight by one and a half kilobytes: 40 kilobytes is about 27 packets.
What was wrong with 1996
A budget of 50 kilobytes forced you to economize: compress pictures, give up what you didn’t need. It was a discipline imposed by necessity, and it hasn’t gone out of date: today slow mobile networks and expensive data make the same economy important for millions of people. What has gone out of date is counting by eye, because today the browser has tools for it: we’ll open them in the last lesson of the part.
Practice
Preparing your page…
Test
Question 1 of 6
Cards
These cards go into your review once you finish the lesson.
What is a packet?
Answer
A small piece of data (usually up to 1,500 bytes) with a header: from, to, number. Every page travels the network in packets.
What is an IP address?
Answer
The address of a node on the network. In IPv4 it is four numbers from 0 to 255 separated by dots, and in IPv6 it is longer: there are enough addresses for everyone.
What is a port for?
Answer
An IP address finds the computer, and a port finds the program on it: 80 for HTTP, 443 for HTTPS, 25 for mail.
What does TCP do?
Answer
It makes an unreliable network reliable: it numbers packets, confirms what arrived and resends what was lost.
How does the TCP handshake work?
Answer
Three steps: the client sends SYN, the server replies SYN-ACK, the client replies ACK. Then the data flows.
Sources
- How does the Internet work? (MDN) CC BY-SA, in English
- Internet protocol suite (Wikipedia) CC BY-SA, in English
- Packet switching (Wikipedia) CC BY-SA, in English
- RFC 9293: Transmission Control Protocol (TCP) link only, in English
- Computer Networks: A Systems Approach link only, in English
Videos
The Internet: Packets, Routing & Reliability (Code.org, “How the internet works”, 2 of 5)
The video loads from youtube-nocookie.com only when you press play.
Next
You now know: packets and packet switching, IP addresses and TCP.