A packet is a small amount of data sent over a network, such as a LAN or the Internet. Similar to a real-life package, each packet includes a source and destination as well as the content (or data) being transferred. When the packets reach their destination, they are reassembled into a single file or another contiguous block of data.
While the exact structure of a packet varies between protocols, a typical packet includes two sections — a header and payload. Information about the packet is stored in the header. For example, an IPv6 header includes the following fields:
- Source address (128 bits) - IPv6 address of the packet origin
- Destination address (128 bits) - IPv6 address of the packet destination
- Version (4 bits) - "6" for IPv6
- Traffic class (8 bits) - priority setting for the packet
- Flow label (20 bits) - optional ID that labels the packet as part of a specific flow; used to distinguish between multiple transmissions from a single origin
- Payload length (16 bits) - size of the data, defined in octets
- Next header (8 bits) - ID of the header following the current packet; may be TCP, UDP, or another protocol
- Hop limit (8 bits) - maximum number of network hops (between routers, switches, etc) before the packet is dropped; also known as "TTL" in IPv4
The payload section of a packet contains the actual data being transferred. This is often just a small part of a file, webpage, or other data transmission, since individual packets are relatively small. For example, the maximum size of an IP packet payload is 65,535 bytes, or 64 kilobytes. The maximum size of an Ethernet packet or "frame" is only 1,500 bytes or 1.5 kilobytes.
Packets are intended to transfer data reliably and efficiently. Instead of transferring a large file as a single block of data, sending smaller packets helps ensure each section is transmitted successfully. If a packet is not received or is "dropped," only the dropped packet needs to be resent. Additionally, if a data transfer encounters network congestion due to multiple simultaneous transfers, the remaining packets can be rerouted through a less congested path.