Concepts and theorems · Intermediate

Packet encapsulation: separate the units carried by each layer

Relate application messages, TCP bytes, IP packets and link frames without assuming their boundaries coincide.

Ask Logeia about this articleTry the three questionsReview your answers

Updated

On this page
  1. Each layer adds a different context
  2. Application writes do not define packet boundaries
  3. Account for headers within a size budget
  4. The outer link context changes along a route
  5. Ask Logeia about this articleCheck your understanding

Each layer adds a different context

Encapsulation treats one layer’s data as content carried by another layer, adding the context needed for that layer’s operation. In a typical TCP/IP path, the application supplies bytes to TCP, IP carries TCP segments, and a link frame carries an IP packet. Addresses and lengths at these layers do not have identical meanings. An IP destination participates in network-layer delivery, while a link destination identifies the next recipient on that link. State which unit you are examining before interpreting a size, address or boundary from a packet capture or program interface.

Application writes do not define packet boundaries

An application may write 100 bytes and then 200 bytes, but TCP treats them as 300 ordered bytes rather than preserving two application records. The receiver is not guaranteed to obtain matching reads of 100 and 200 bytes. The bytes also need not occupy one IP packet: segmentation depends on timing, size limits and implementation behaviour. If the application needs message boundaries, it must define framing, such as a length prefix or an unambiguous delimiter. Correct framing starts by acknowledging that the units exposed by different layers need not align with one another.

Account for headers within a size budget

Assume a path size budget of 1500 bytes for an IP packet. With a 20-byte IPv4 header and 20-byte TCP header and no options, a simple payload calculation gives 1460 bytes. Replacing the IPv4 header with the 40-byte IPv6 base header gives 1440 bytes under the same simplified assumptions. Options, extension headers and tunnels change the calculation. The 1500-byte budget is not a universal path constant either. Use the applicable path limit and layer-specific length definitions instead of memorizing a payload size without its assumptions or assuming every captured frame has that layout.

The outer link context changes along a route

When a router forwards an IP packet to another link, it places it in a frame suitable for that outgoing link. Changing the link destination does not mean ordinary routing necessarily changes the final IP destination. NAT and tunnelling add other transformations that should be traced explicitly. Captures taken on a host can also reflect offload behaviour rather than exactly the frames seen on the wire. Specify the observation point before comparing traces. A surprising boundary or checksum display can reflect where the capture occurred, rather than evidence that the protocol’s layer definitions have changed.

Reading and practice are recorded separately in this browser, for each language.

Learn this in order

Understand the systems behind the web · STEP 10

Choose a learning path