Skip to content
World 1 · Packets: Breaking a Message Apart · 13 min

Headers and payload

An address on every piece

Teaching this? Open projector mode

A packet has two parts, like a parcel with a label.

  • The payload is the actual data being carried, such as a slice of a photo.
  • The header is the label: who sent it, where it is going and what number it is in the sequence.

Routers read the header to decide where to send the packet next. They do not need to look at the payload at all. A header typically holds fields such as:

  • Source address: where the packet came from.
  • Destination address: where it is going.
  • Sequence number: which piece of the message this is (added by TCP, World 5).
  • Time to live (TTL): a counter that stops lost packets wandering forever (World 2).
  • Checksum: a small number for spotting damage (next lesson).

Layers and wrapping. Sending data is split into jobs, and each job is done by a layer. The simple TCP/IP model has four, from top to bottom:

  • Application: the program's own language, such as HTTP for the Web or DNS for names.
  • Transport: splits the data up and keeps track of it, using TCP or UDP, and uses port numbers to say which program the data is for.
  • Internet: addresses the packet and routes it across networks. This is IP, the Internet Protocol.
  • Link: moves the packet over one hop, on Wi-Fi or an Ethernet cable.

As data goes down the layers, each layer adds its own header, like putting a letter in an envelope, then putting the envelope in a box, then putting the box in a mailbag. This is called encapsulation. The receiver unwraps the layers in the opposite order. That is why one packet carries a port number, an IP address and a hardware address together.

The address on the packet: IP. An IPv4 address is 32 bits, written as four numbers from 0 to 255 separated by dots, such as 192.0.2.42. Each number is stored in 8 bits (one byte). 32 bits give 2³² = 4,294,967,296 possible addresses, about 4.3 billion. That sounded like plenty in the 1980s. It is not enough for every phone, laptop and sensor in the world.

Two things came to the rescue:

  • IPv6 uses 128 bits, which gives about 3.4 × 10³⁸ addresses. Its addresses are written in hexadecimal with colons, such as 2001:db8::42, and zeros can be shortened with a double colon.
  • Private addresses and NAT. Some ranges are reserved for use inside a home or company and are never sent across the Internet: 10.0.0.0 to 10.255.255.255, 172.16.0.0 to 172.31.255.255 and 192.168.0.0 to 192.168.255.255. Your router shares one public address among all your devices with a trick called NAT (network address translation). This is why millions of homes can all use 192.168.1.x at once.

Two kinds of address. A device also has a MAC address, a six-pair hexadecimal number such as 00:1A:2B:3C:4D:5E that identifies its network hardware. A good way to remember the difference: the IP address says where a device is on the network right now, and the MAC address says which piece of hardware it is. IP carries a packet across the Internet; the MAC address is used for the final hop on your local network. A port is a different thing again: a number from 0 to 65,535 that says which program on the device the data is for. You will meet ports in World 5.

Putting it together: a packet's journey is a sequence of hops. At each hop the link layer uses a hardware address for that one hop, while the IP address stays the same from start to finish.

Loading 3D lab…
Check yourself

How many bits is an IPv4 address?

Check yourself

What kind of address is 192.168.1.20?

Check yourself

What does the time-to-live (TTL) field protect against?

Check yourself

Which part of a packet does a router mainly read to decide where to send it?

0 of 5 required activities complete. Finish each task and quiz.Next lesson →
My notes
Only saved in this browserAll my notes →

Report a mistake

What is wrong?
0 / 2000 · at least 10 characters
Sent along with your report
  • Page
  • About Headers and payload — How the Internet Works · internet/headers-and-payload
Plus your browser type. Reports go to our support system; see the privacy notice.