← All posts
7 min read

Packets: How Data Travels in Manageable Pieces

#technology#computer-science#packets#networking
📑 On this page

Sending a large photograph does not normally reserve one private wire and push the complete file as an indivisible object. The data is divided into smaller units that share network links with other traffic.

A packet is a structured unit containing payload plus control information used to deliver data across a network.

Packet switching lets many conversations use the same infrastructure efficiently and recover from local problems without repeating an entire large transfer.

Why not send one giant block?

Imagine one user transmitting a two-gigabyte file as one uninterruptible block. Everyone else sharing the link might wait until it finishes.

Smaller units allow interleaving:

video packet
chat packet
web packet
video packet
voice packet

Routers can buffer and forward each packet independently.

If one small packet is damaged or lost, a reliable higher layer can retransmit that portion instead of the complete file.

Packet size involves trade-offs. Tiny packets spend a larger percentage on headers; overly large packets may not fit a link and take longer to serialize.

Header and payload

A packet usually contains:

  • Header: delivery and control information
  • Payload: data carried for the next layer or application

An IP header contains fields such as:

  • Source address
  • Destination address
  • Protocol indicator
  • Lifetime limit
  • Length

The payload may be a TCP segment, UDP datagram, or another protocol.

That transport unit has its own header and application data.

This nesting is called encapsulation.

Link frame
└── IP packet
    └── TCP segment
        └── HTTP message bytes

Frames versus packets

The terms are sometimes used casually, but they refer to different layers.

  • A frame crosses one local link, such as Ethernet or Wi-Fi.
  • An IP packet can be routed across multiple networks.

At each router:

  1. The incoming link frame is received.
  2. The router extracts the IP packet.
  3. It decides the next link.
  4. It places the packet inside a new frame suitable for that link.

Local frame addresses change hop by hop. The IP destination normally continues toward the final host.

Packet switching

Traditional telephone circuits reserved a dedicated path for a call.

Packet-switched networks statistically share capacity. A link carries whichever packets are ready according to queues and policy.

Benefits include:

  • Efficient use of bursty traffic
  • Many simultaneous users
  • Flexible routing
  • Resilience around failures

The trade-off is variable delay. Packets may wait in queues when demand exceeds link capacity.

Real-time applications manage this uncertainty with buffers, adaptation, and quality-of-service techniques.

A concrete example: sending a photograph

Suppose an application sends a 5 MB photograph.

  1. The app reads or creates the file data.
  2. A transport protocol divides the byte stream into manageable segments.
  3. IP adds routing information to each.
  4. The local network wraps packets in frames.
  5. Routers forward packets hop by hop.
  6. The receiver validates and reorders transport data.
  7. Missing reliable data is requested again.
  8. The application reconstructs the file.

Packets from the photograph can travel between packets belonging to thousands of other conversations.

They may even take different routes and arrive out of order.

Maximum transmission unit

Each link has a maximum transmission unit, or MTU: the largest network-layer packet it can carry without additional handling.

Ethernet commonly uses an IP MTU around 1500 bytes, though other values exist.

If a packet is too large:

  • IPv4 may fragment it under some circumstances.
  • IPv6 routers do not fragment in transit; endpoints adjust using path-MTU discovery.

Fragmentation creates extra pieces and increases loss sensitivity. Modern systems try to send sizes that fit the path.

Incorrect MTU handling can produce strange failures where small messages work but large transfers stall.

Loss, duplication, and reordering

IP delivery is best effort. Packets can be:

  • Lost
  • Delayed
  • Duplicated
  • Reordered

Reasons include:

  • Congestion
  • Damaged signals
  • Routing changes
  • Buffer limits
  • Device failure

Transport or application protocols decide how to respond.

TCP numbers data and retransmits missing portions. A real-time voice application using UDP may prefer to skip an old missing packet rather than delay the conversation.

Reliability policy follows the application's needs.

Checksums and error detection

Frames and transport protocols can include calculated values used to detect corruption.

The sender calculates a checksum or cyclic redundancy check over selected data. The receiver repeats the calculation and compares.

Detection does not automatically repair the data. The receiver may discard it and rely on retransmission or another recovery mechanism.

Cryptographic integrity checks solve a stronger problem: detecting deliberate modification, not merely accidental transmission errors.

Packet lifetime

IP packets contain a lifetime-limiting field:

  • TTL in IPv4
  • Hop Limit in IPv6

Each router decreases it. When it reaches zero, the packet is discarded.

This prevents routing loops from circulating packets forever.

The traceroute family of tools deliberately uses changing lifetime values to reveal routers along a path.

Queues and congestion

If packets arrive faster than a link can send them, they wait in a queue.

Short queues absorb bursts. Large queues can add substantial latency, a problem called bufferbloat.

When queues fill, packets are dropped. Reliable senders treat loss or delay as a congestion signal and reduce sending rate.

Modern queue-management algorithms try to preserve throughput without allowing excessive delay.

Bandwidth is therefore not the only concern; queue behavior affects responsiveness.

Packet capture

Diagnostic tools can capture frames visible to a network interface.

A packet analyzer helps inspect:

  • Addresses
  • Protocols
  • Timing
  • Retransmissions
  • Handshakes
  • Errors

Encryption hides application contents but still leaves some metadata visible, such as endpoints, sizes, and timing.

Captures can contain sensitive information. Collect and share them carefully and only where authorized.

Common misunderstandings

"A file travels as one packet"

Large application data is divided across many packets or segments.

"Every packet follows the same route"

Routing can change, and packets in one conversation may take different paths.

"Packet loss always means the application fails"

Reliable protocols can retransmit. Real-time applications may conceal or skip small losses.

"A checksum proves the sender is trustworthy"

Ordinary error-detection checksums detect accidental corruption, not malicious forgery.

Knowledge check

1. Why divide data into packets?

Packets let many conversations share links, support independent forwarding, and limit retransmission to missing pieces.

2. What is encapsulation?

It is wrapping higher-layer data with each lower layer's header and structure.

3. What does an MTU describe?

It is the maximum packet size a link can carry without fragmentation or other additional handling.

4. Why does a packet have a lifetime limit?

It prevents packets caught in routing loops from circulating indefinitely.

The one idea to remember

Networks move structured packets, not whole application objects as one unbroken unit.

Headers support delivery, links carry frames, routers forward packets, and endpoints reconstruct the ordered meaning required by applications.

Next, we will examine the IP addresses routers use when deciding where packets should go.