Data encapsulation is the process that adds additional protocol header information to the data before transmission. In most forms of data communications, the original data is encapsulated or wrapped in several protocols before being transmitted.
When sending messages on a network, the protocol stack on a host operates from top to bottom. In the web server example, we can use the TCP/IP model to illustrate the process of sending an HTML web page to a client.
The application layer protocol, HTTP, begins the process by delivering the HTML formatted web page data to the transport layer. There the application data is broken into TCP segments. Each TCP segment is given a label, called a header, containing information about which process running on the destination computer should receive the message. It also contains the information that enables the destination process to reassemble the data back to its original format.
The transport layer encapsulates the web page HTML data within the segment and sends it to the internet layer, where the IP protocol is implemented. Here the entire TCP segment is encapsulated within an IP packet, which adds another label, called the IP header. The IP header contains source and destination host IP addresses, as well as information necessary to deliver the packet to its corresponding destination process.
Next, the IP packet is sent to the network access layer where it is encapsulated within a frame header and trailer. Each frame header contains a source and destination physical address. The physical address uniquely identifies the devices on the local network. The trailer contains error checking information. Finally the bits are encoded onto the media by the server network interface card (NIC). Click the Play button in the figure to see the encapsulation process.