What is encapsulation, and what is the data unit called at each layer?
Encapsulation means each layer wraps the data from the layer above with its own header. The unit is called data at the application layer, a segment (TCP) or datagram (UDP) at transport, a packet at network, a frame at data link, and bits at physical.
Explain it simply
Posting a letter to a friend in Ranchi: you write the letter, put it in an envelope with an address, and the post office puts that envelope in a mail bag labelled for Ranchi. Each stage adds its own wrapper. At the other end the wrappers come off in reverse order.
Example
Application "GET /index.html" data
Transport [TCP hdr: ports][data] segment
Network [IP hdr: src/dst IP][segment] packet
Data Link [Eth hdr: MACs][packet][trailer] frame
Physical 101100111000... bitsOn the sender, headers are added going down. On the receiver, the frame header is stripped by the network card, the IP header by the IP layer, the TCP header by TCP, and only the original data reaches the application. A router reads only up to the IP header, and a switch only the Ethernet header.
What to say in the interview
"Encapsulation is each layer adding its own header, and on the receiving side decapsulation removes them in reverse. The names are segment or datagram, packet, and frame. A switch looks at the frame, a router at the packet, and TCP and UDP at the segment, which is why each device can do its job without understanding the others' headers."
Common mistakes
- Using packet, segment and frame as if they were the same word. Interviewers listen for the layer each belongs to.