Encapsulation
Layered protocol models rely on encapsulation, which allows one protocol to be used for relaying another's messages.Encapsulation, closely related to the concept of Protocol Layering, refers to the practice of enclosing data using one protocol within messages of another protocol.To make use of encapsulation, the encapsulating protocol must be open-ended, allowing for arbitrary data to placed in its messages. Another protocol can then be used to define the format of that data.
Encapsulation Example
For example, consider an Internet host that requests a hypertext page over a dialup serial connection. The following scenario is likely:First, the HyperText Transfer Protocol (HTTP) is used to construct a message requesting the page. The message, the exact format of which is unimportant at this time, is represented as follows:
Next, the Transmission Control Protocol (TCP) is used to provide the connection management and reliable delivery that HTTP requires, but does not provide itself. TCP defines a message header format, which can be followed by arbitrary data. So, a TCP message is constructed by attaching a TCP header to the HTTP message, as follows: