Sub topic 1
How Data Moves Across a Network: Encapsulation and Packets
Prerequisites
Assume you know what a network and an IP address are, recognize bytes and hexadecimal values, and can run basic terminal commands. This chapter explains how layers organize communication.
Why networks are built in layers
A network is easier to design when each layer has one main job. A layer provides services to the layer above it and uses the layer below it. For example, an application does not need to know how an Ethernet signal travels across a cable.
Layering also allows replacement. An application can use TCP over Ethernet, Wi-Fi, or a VPN without changing its application data. Common models include the four-layer TCP/IP model and the seven-layer OSI model. Their names and boundaries differ, but both separate responsibilities.
Headers and payloads: how a protocol does its job
A protocol is a set of communication rules. A header is control information placed before data. It can identify a sender, receiver, protocol, length, sequence number, or other details. A payload is the data carried by that header.
For example, a TCP header contains source and destination ports, sequence information, flags, and a checksum. The TCP payload might contain part of an HTTP request. The same bytes can be a payload at one layer and a complete protocol unit at another.
Encapsulation: wrapping data layer by layer
Encapsulation is the process of adding headers as data moves down the protocol stack. An HTTP request becomes application data. TCP adds a header and creates a segment. IP adds a header and creates a packet. Ethernet adds a header and creates a frame.
At the destination, decapsulation removes these headers in reverse order. Each layer reads its own header, performs its job, and passes the remaining payload upward.
Segment, packet, frame: naming the pieces
These names identify protocol data units, or PDUs. The exact terminology can vary, especially for UDP.
| Layer | Typical PDU | Main identity |
|---|---|---|
| Transport | TCP segment or UDP datagram | Ports |
| Network | IP packet | IP addresses |
| Link | Ethernet frame | MAC addresses |
A frame is local to one link. A router removes the old frame and builds a new frame for the next link. The IP packet usually continues across the route, while the transport segment remains inside it.
Exercise
What does a router normally replace when forwarding an IP packet to the next link?
Show answer
It replaces the link-layer frame, including its MAC addresses, while forwarding the IP packet toward its destination.