Data Encapsulation and Decapsulation
A network protocol is a set of rules for exchanging data in a structured format.
- 2 principle functions:
- Addressing
- describes where data messages should go
- Encapsulation
- describes how data messages should be packaged for transmission
- e.g., like an envelope for a letter
- each layer requires its own encapsulation
- each layer adds fields in a header to whatever payload data it receives from an application or protocol
- Addressing
- a network uses many different protocols
- not all protocols conform exactly to OSI model
- at each layer, for two nodes to communicate they must be running the same protocol
- communication between nodes at the same layer is same layer interaction
- for communication on each node, each layer provides services for the layer above and uses the services of the layer below
- referred to as adjacent layer interaction

Encapsulation
- when a message is sent from one node to another:
- messages travels down the stack of layers on sending node
- reaches receiving node via the transmission media
- passes up the stack on the receiving node
- at each layer except physical layer, the sending node adds a header to the data payload
- forms a chunk of data called a protocol data unit (PDU)
- this process is encapsulation
Example
- Data generated by application on sending node (e.g. HTTP) with its own application header
- at transport layer, a TCP header is added to the application data
- at network layer, the TCP segment is wrapped in an IP header
- at data link layer, the IP packet is encapsulated in an Ethernet frame
- at the physical layer, the stream of bits making up the frame is transmitted over the network as a modulated electrical signal
Decapsulation
- Decapsulation is the reverse process performed by the receiving node:
- receives stream of bits at the physical layer
- decodes an Ethernet frame
- extracts the IP packet from the frame
- resolves the information in IP header
- resolves the information in the TCP header
- resolves the information in the Application header
- extracts the HTTP data for processing by a software application