Encapsulation at the network layer represents a critical transition point where data transforms from simple segments into routable packets capable of traversing interconnected networks. When asking what information is added during encapsulation at OSI Layer 3, the answer centers on the IP header, a structured block of metadata that equips the packet with logical addressing, routing instructions, and control mechanisms necessary for end-to-end delivery across heterogeneous network segments. Unlike Layer 2, which handles physical addressing on a single link, Layer 3 encapsulation prepares data for the complexities of internetworking, ensuring packets can manage routers, manage fragmentation, and prioritize traffic flows.
The Core Component: The IP Header
The primary artifact added during Layer 3 encapsulation is the Internet Protocol (IP) header. Here's the thing — whether the network operates on IPv4 or IPv6, this header sits directly in front of the Layer 4 segment (TCP or UDP) and behind the Layer 2 frame header. It acts as the packet's passport, containing all the bureaucratic data routers need to forward the payload toward its final destination.
In IPv4, the header is a minimum of 20 bytes but can extend to 60 bytes with options. Plus, iPv6 streamlines this to a fixed 40-byte base header, with extension headers handling optional features. Despite structural differences, both versions serve the identical fundamental purpose: providing the logical topology map required for routing.
Logical Addressing: Source and Destination IP Addresses
The most defining pieces of information added at this layer are the Source IP Address and Destination IP Address. These 32-bit (IPv4) or 128-bit (IPv6) identifiers are hierarchical, consisting of a network portion and a host portion. This hierarchy is what allows routers to make forwarding decisions based on network prefixes rather than individual device identities.
- Source IP Address: Identifies the originating host. It allows the destination device to reply and enables intermediate routers to send error messages (via ICMP) back to the sender if delivery fails.
- Destination IP Address: Identifies the intended recipient. Routers examine this field, compare it against their routing tables, and determine the next hop interface.
Unlike MAC addresses, which change at every router hop (Layer 2 rewrite), IP addresses typically remain constant from the original sender to the final receiver, providing true end-to-end logical connectivity But it adds up..
Version and Header Length Identification
Immediately following the addresses in importance are the fields that tell the receiving device how to parse the header itself.
- Version (4 bits): Explicitly states the IP version (0100 for IPv4, 0110 for IPv6). This allows dual-stack devices to process both protocol families correctly.
- Internet Header Length (IHL) / Payload Length: In IPv4, the IHL field (4 bits) indicates the header length in 32-bit words, necessary because the options field makes the header variable in size. IPv6 replaces this with a Payload Length field (16 bits) indicating the size of the payload including extension headers, simplifying processing since the base header is fixed.
Quality of Service and Traffic Management
Layer 3 encapsulation adds critical fields for Quality of Service (QoS), allowing the network to treat packets differently based on application requirements Still holds up..
- Differentiated Services Code Point (DSCP) / Traffic Class: This 6-bit field (replacing the old Type of Service/ToS byte in IPv4) classifies packets into service classes—such as Expedited Forwarding (EF) for voice/video or Assured Forwarding (AF) for business-critical data. Routers read this value to apply queuing, policing, or shaping policies.
- Explicit Congestion Notification (ECN): The last 2 bits of the IPv4 ToS byte (or Traffic Class in IPv6) signal network congestion without dropping packets, allowing endpoints to throttle transmission rates proactively.
Packet Identification and Fragmentation Control
Because Layer 3 packets traverse links with varying Maximum Transmission Units (MTUs), encapsulation includes fields to manage fragmentation and reassembly.
- Identification (16 bits in IPv4 / Fragment Header in IPv6): A unique value assigned to each original packet. If a router must fragment a packet because the outgoing link MTU is too small, all fragments carry this same ID so the destination can reassemble them.
- Flags (3 bits in IPv4): Contains the Don't Fragment (DF) bit and the More Fragments (MF) bit. DF instructs routers to drop the packet rather than fragment it (used in Path MTU Discovery). MF indicates if more fragments follow the current one.
- Fragment Offset (13 bits in IPv4): Specifies the position of the fragment's data relative to the beginning of the original payload, measured in 8-byte blocks. This ensures the receiver stitches the payload back together in the correct order.
IPv6 handles fragmentation differently: only the source node fragments packets (using a Fragment Extension Header), and routers never fragment IPv6 packets, dropping them instead if they exceed the path MTU. This architectural shift reduces router CPU load.
Time-to-Live and Hop Limit: Preventing Routing Loops
A crucial field added during encapsulation is the Time-to-Live (TTL) in IPv4 or Hop Limit in IPv6. This 8-bit counter is initialized by the sender (commonly 64, 128, or 255) and decremented by one at every router hop The details matter here..
If the value reaches zero before the packet arrives at its destination, the router discards the packet and sends an ICMP Time Exceeded message back to the source. Even so, this mechanism prevents packets from circulating indefinitely in routing loops, consuming bandwidth and router resources. It also forms the basis of the traceroute diagnostic utility Small thing, real impact..
Protocol Identification: The Upper-Layer Handoff
The Protocol field (IPv4) or Next Header field (IPv6) identifies the encapsulated Layer 4 protocol. This tells the destination host's network stack which transport layer process—TCP (6), UDP (17), ICMP (1), or others like SCTP (132)—should receive the payload after the IP header is stripped Not complicated — just consistent..
Real talk — this step gets skipped all the time.
In IPv6, the Next Header field creates a chaining mechanism. If the value indicates an extension header (e.g., Hop-by-Hop Options, Routing, Fragment), the receiver processes that extension header first, which then points to the next header, eventually terminating at the upper-layer protocol header.
Header Integrity: The Header Checksum (IPv4 Only)
IPv4 includes a Header Checksum field (16 bits) calculated over the header fields only. Practically speaking, since the TTL field changes at every hop, the checksum must be recalculated by every router. This provides a basic integrity check against bit corruption in router memory or processing logic Easy to understand, harder to ignore..
IPv6 deliberately removes the Header Checksum. The designers relied on the strong error detection of Layer 2 (Ethernet CRC) and Layer 4 (TCP/UDP checksums), reasoning that recalculating a Layer 3 checksum at every hop was an unnecessary performance penalty for high-speed routing.
IPv4 Options and IPv6 Extension Headers
Beyond the mandatory fields, Layer 3 encapsulation allows for optional capabilities Small thing, real impact..
- IPv4 Options: Variable-length fields appended to the standard header. Examples include Record Route (storing the path taken), Timestamp, and Security classifications. Because they make header length variable and require CPU-intensive processing by routers, they are rarely used in modern high-performance networks.
- IPv6 Extension Headers: A modular, chainable system replacing IPv4 options. Common extension headers include:
- Hop-by-Hop Options: Examined by every router (e.g., Router Alert for RSVP).
- Routing: Source routing (similar