Encapsulation or layering is the addition of Protocol Control Information (PCI) to a Protocol Data Unit (PDU) by a communications protocol. The encapsulation adds headers before the start of a PDU.
Encapsulation of data (an SDU) by adding a header (the PCI) to form a Ptotocol Data Unit processed by a lower layer
Encapsulation takes place at each layer of the OSI reference model, and to explain encapsulation OSI defines the concept of a "service" and a Service Data Unit (SDU).
An SDU is a piece of information passed by a layer above (the N+1 Layer in the figure below) to the current layer (the N-Layer) for transmission using the service of that layer. To transport the SDU, the current layer adds encapsulates the SDU by adding a protocol header (PCI). The combined PCI and SDU is known as a PDU belonging to that layer. This forms the SDU of the layer below. This process is known as encapsulation.
Protocol Header Processing for Transmission by Layer N
The figure below shows the corresponding processing on reception by the receiver at the corrseponding peer layer N protocol entity.
Protocol Header Processing on Reception by Layer N
The figure below shows the header associated with each of the seven layers of the OSI reference model. When a packet of data is passed by the application process to the layer, the layer processes it. It then prepends a protocol header and passes the packet (together with the header) to the layer below. This layer in turn processes the data and adds an additional new header. Each layer treats the assemblage of information from higher layers as data, and does not worry about its contents.This process continues until the packet reaches the physical layer.
Processing a packet by adding header information at the seven OSI layers
The physical layer serialises the packet (i.e. converts it to a series of bits) and sends it across a cable or telecommunications circuit to the destination (or an intermediate) system. At the receiver, the remote system reassembles the series of bits to form a packet and forwards the packet for processing by the link layer. This removes the link layer header, and passes it to the next layer. The processing continues until finally the original packet data is sent to the remote application program.