3. Data Encapsulation in the OSI Model

Concept: As data moves from the application layer to the physical layer, each layer adds its own header (and sometimes trailer) to the data, a process called encapsulation. At the receiving end, each layer removes its corresponding header to retrieve the original data.

Process:

1. Application Layer: User data (e.g., an HTTP request) is created.

2. Presentation Layer: Data is formatted or encrypted (e.g., into JSON or TLS-encrypted).

3. Session Layer: Session information is added (e.g., session ID).

4. Transport Layer: Segments data and adds a header (e.g., TCP header with port numbers).

5. Network Layer: Adds a header with logical addresses (e.g., IP header).

6. Data Link Layer: Frames data with a header and trailer (e.g., Ethernet frame with MAC addresses).

Physical Layer: Transmits bits over the medium (e.g., as electrical signals).


Decapsulation: The reverse occurs at the destination, with each layer stripping its header to pass data upward.