Packet
In short: A single, self-contained unit of data sent over a network — consists of a header (control data) and payload.
In more detail: Larger amounts of data are split into several packets before transmission, which are routed through the network independently of each other and reassembled at the recipient. At layer 2 one tends to speak of frames, at layers 3/4 of packets — but in everyday language the terms are often used synonymously.
In Depth
A typical packet structure (simplified, for an IP packet with a TCP payload):
+------------------+------------------+------------------+
| IP header | TCP header | Payload |
| (source/dest IP,| (source/dest | (the actual |
| TTL, protocol) | port, flags) | data) |
+------------------+------------------+------------------+
This principle is called encapsulation: each OSI layer adds its own header in front of the payload of the layer above — an HTTP request is thus successively wrapped in a TCP header, then an IP header, then an Ethernet frame header before it leaves the cable as an electrical signal. At the recipient the process runs in reverse (“decapsulation”) — each layer removes its own header and passes the rest on to the next higher layer.
The maximum size of a packet is limited (maximum transmission unit, MTU, usually 1500 bytes in Ethernet) — larger amounts of data are automatically “fragmented” by the sender into several packets, each with its own header, and reassembled in the right order at the recipient using a sequence number.
Why fragmentation can be problematic
Fragmentation at the IP level is technically possible, but is considered inefficient and is usually avoided in practice: if even one of the fragments is lost, with UDP the entire original packet has to be resent, not just the missing fragment. Modern systems therefore use “Path MTU Discovery” — they determine the smallest MTU along the entire transmission path in advance and adjust the packet size directly so that no fragmentation is needed along the way. A packet chosen too large that still may not be fragmented (because the “Don’t Fragment” flag is set in the header) is discarded instead, and the sender receives an ICMP error message (“fragmentation needed”).
Header fields in detail
Besides the source and destination address, an IP header contains further important control information: the TTL (time to live, prevents endless loops in routing by being reduced by 1 at every router passed, with the packet being discarded when it reaches 0), the protocol field (reveals whether TCP, UDP or another protocol follows in the rest of the packet) and a checksum for error detection. With a TCP packet, the TCP header additionally contains the source/destination port, sequence number and various flags (SYN, ACK, FIN, RST) that control the connection state.