As data moves down the protocol stack, each layer adds a header (and sometimes a trailer) — this is encapsulation. The receiving device performs the reverse process (de-encapsulation), stripping headers layer by layer.
Data Units at Each Layer
| Layer | Data unit | Header contains |
|---|---|---|
| Application | Data | — |
| Transport | Segment | Source/dest port, sequence number |
| Network | Packet | Source/dest IP address |
| Data Link | Frame | Source/dest MAC address, FCS trailer |
| Physical | Bits | Electrical/optical signal |
Encapsulation flow: Data → Segment → Packet → Frame → Bits
Network Devices
| Device | Layer | Function | Key trait |
|---|---|---|---|
| Hub | 1 (Physical) | Repeats incoming signal to all ports | Broadcast — no intelligence |
| Switch | 2 (Data Link) | Forwards frames based on MAC address | Learns MAC addresses, creates collision domains |
| Router | 3 (Network) | Routes packets between different networks | Uses IP addresses, runs routing protocols |
| Gateway | All | Connects networks using different protocols | Protocol translation |
| Modem | 1 (Physical) | Modulates/demodulates signals | Digital ↔ Analog conversion |
| Access Point | 2 (Data Link) | Extends wired network via WiFi | Wireless bridge |
Hub vs Switch
A hub broadcasts every incoming frame to every port — all devices on a hub share bandwidth (one large collision domain). A switch learns which MAC address is on which port and forwards frames only to the correct port — each port is its own collision domain.
Router vs Switch
A switch forwards within the same network (using MAC addresses). A router forwards between different networks (using IP addresses). The Internet is a network of networks connected by routers.
Q: What is encapsulation in networking?
A: Each layer adds a header (and maybe trailer) to data as it travels down the stack. Application data becomes a TCP segment (transport header), then an IP packet (network header), then an Ethernet frame (data link header). The receiver strips them off in reverse order.
Q: What is the difference between a Hub and a Switch?
A: A hub broadcasts data to all ports — one collision domain, inefficient. A switch learns MAC addresses and sends data only to the destination port — each port is its own collision domain, efficient.
Q: What is the role of a Gateway?
A: A gateway translates between different network protocols or architectures. For example, connecting a proprietary internal network to the standard TCP/IP internet requires a gateway to convert between the two.
Q: How does a Switch learn MAC addresses?
A: When a frame arrives, the switch records the source MAC address and the port it arrived on in a MAC address table. Future frames destined for that MAC are forwarded only to that port. Unseen MACs are flooded to all ports.
Premium Content
Unlock Encapsulation & Network Devices and all premium lessons with a subscription.
From ₹199.99/year — See plans