A packet is a small block of data with a header attached that says where it came from and where it is going, so a network can deliver it independently of every other block. Anything you send over the internet, from a web page to a video call, is split into many packets and put back together at the other end.
What is inside a packet
Every packet has two parts: a header and a payload.
- Header: control information for the network. In an IPv4 packet it holds the source and destination addresses (32 bits each), a Time to Live, a protocol number saying what the payload is, and a total length. RFC 791 sets the minimum IPv4 header at 20 bytes.
- Payload: the data being carried. Often this is itself a TCP or UDP unit with its own header, followed by your application data.
Routers read only the header to decide where to send a packet next. They don't need to understand the payload.
The fields that matter
| Field | Size | What it does |
|---|---|---|
| Source address | 32 bits (IPv4), 128 bits (IPv6) | Who sent the packet, so replies can come back. |
| Destination address | 32 bits (IPv4), 128 bits (IPv6) | Where routers should deliver it. |
| Time to Live (IPv4) / Hop Limit (IPv6) | 8 bits | Reduced at each router. When it reaches zero the packet is discarded, which stops packets circling forever. |
| Protocol (IPv4) / Next Header (IPv6) | 8 bits | Says what follows the IP header, for example TCP or UDP. |
| Total Length (IPv4) / Payload Length (IPv6) | 16 bits | How long the packet or payload is, in bytes. |
RFC 791 says a datagram whose Time to Live is zero "must be destroyed", and RFC 8200 describes the same rule for the IPv6 Hop Limit. The IPv6 header is a fixed 40 bytes, which is 20 bytes more than the minimum IPv4 header.
Packets are wrapped in layers
One packet usually contains several nested headers. When a browser fetches a page over HTTP, the data is wrapped like this on its way out:
- The application data (for example an HTTP request).
- A TCP header in front of it. TCP calls this unit a segment. Its header carries source and destination port numbers, a sequence number, an acknowledgment number, flags such as SYN and ACK, a window size and a checksum. Without options it is 20 bytes (RFC 9293).
- An IP header in front of that, with the addresses. The result is the IP packet. RFC 9293 says each TCP segment is sent as an IP datagram.
- A link-layer header for the local network, such as Ethernet. On Ethernet the type field is
0800hexadecimal for IPv4 (RFC 894). This outer wrapper is a frame, and it is rebuilt at every hop while the IP packet inside is passed along.
The IP address gets the packet across the internet, and the port number gets the data to the right program on the destination machine. For how the layers are organised, see the TCP/IP model explained.
Why data is split into packets
The internet is built on packet switching: the network treats each packet as an independent unit. RFC 791 says the protocol "treats each internet datagram as an independent entity unrelated to any other internet datagram." That has practical consequences:
- Many conversations share the same links, because packets from different senders can be interleaved.
- Packets from one conversation can take different routes if the network changes.
- One lost packet can be resent without resending the whole transfer, if the protocol on top supports it.
The cost is that packets can arrive out of order, arrive twice or not arrive. IP does not fix that. TCP numbers its data so the receiver can reorder it and ask for missing pieces. UDP does neither, so an application using it has to cope.
How big is a packet?
The IPv4 Total Length field is 16 bits, so RFC 791 allows a datagram of up to 65,535 bytes. In practice the limit comes from the link. The maximum size a link can carry is its MTU (maximum transmission unit). RFC 894 states that "the maximum length of an IP datagram sent over an Ethernet is 1500 octets" (octet means byte), so 1500 bytes is the usual ceiling on home and office networks. Other limits from the standards:
- RFC 791: all IPv4 hosts must accept datagrams up to 576 bytes, whole or in fragments.
- RFC 8200: every IPv6 link must have an MTU of at least 1280 bytes.
- RFC 894: the minimum data field on Ethernet is 46 bytes, and shorter payloads are padded with zeros. The padding is not part of the IP packet.
A packet larger than the next link's MTU has to be broken up. IPv4 allows routers to fragment it, using the Fragment Offset field to mark each piece's position. In IPv6, RFC 8200 says that fragmentation is done only by the source node, not by routers on the path.
Worked example: sending 4,000 bytes over TCP
Assume an Ethernet link with a 1500-byte MTU, IPv4, and no IP or TCP options. The arithmetic:
IP header 20 bytes
TCP header 20 bytes
Room for data 1500 - 40 = 1460 bytes per packet
4000 bytes of data:
packet 1 1460 bytes of data
packet 2 1460 bytes of data
packet 3 1080 bytes of data (4000 - 2920)
Three data packets, plus the packets that set up the connection and the acknowledgments coming back. The 1460-byte figure is the maximum segment size (MSS), the largest chunk of data TCP puts in one segment. The two sides normally agree it when the connection starts. If no MSS is announced, RFC 9293 says to assume 536 bytes for IPv4 (576 minus 40).
How to see real packets
A packet capture tool shows them directly. Wireshark and tcpdump are the usual choices, and both record the headers described above. The ping command is the simplest way to send a packet of known size and see whether it comes back; the options are covered in the ping command guide. If packets are going missing, see how to test for and fix packet loss.
Capture only on networks you own or have permission to monitor. A capture can contain other people's traffic and, if the traffic is not encrypted, readable content.
Frequently asked questions
- What is the difference between a packet and a frame?
- A packet is the unit handled by the network layer (IP), with source and destination IP addresses. A frame is the unit on a single link such as Ethernet, and it wraps a packet for one hop. Each router removes the old frame and builds a new one for the next link, while the packet inside stays the same apart from fields such as the hop count.
- What is the difference between a packet and a segment?
- A segment is the unit of TCP data. RFC 9293 describes each TCP segment as being sent inside an IP datagram, so a TCP segment is the payload of one IP packet. UDP's unit is usually called a datagram.
- How big is a network packet?
- An IPv4 packet can be at most 65,535 bytes by the length field in RFC 791, but on Ethernet the limit is a 1500-byte IP packet (RFC 894), so most packets you see are 1500 bytes or smaller. Small ones, such as a 40-byte TCP acknowledgment with no data, are common too.
- Do packets always arrive in order?
- No. IP treats each packet as independent of the others (RFC 791), so packets can take different routes, arrive out of order or be dropped. TCP numbers its data and reorders or resends it; UDP leaves that to the application.