Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Encapsulation & Network Devices
CN

Encapsulation & Network Devices

How data is wrapped in headers and the hardware that moves it: Routers, Switches, and Gateways.

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

LayerData unitHeader contains
ApplicationData
TransportSegmentSource/dest port, sequence number
NetworkPacketSource/dest IP address
Data LinkFrameSource/dest MAC address, FCS trailer
PhysicalBitsElectrical/optical signal

Encapsulation flow: Data → Segment → Packet → Frame → Bits

Network Devices

DeviceLayerFunctionKey trait
Hub1 (Physical)Repeats incoming signal to all portsBroadcast — no intelligence
Switch2 (Data Link)Forwards frames based on MAC addressLearns MAC addresses, creates collision domains
Router3 (Network)Routes packets between different networksUses IP addresses, runs routing protocols
GatewayAllConnects networks using different protocolsProtocol translation
Modem1 (Physical)Modulates/demodulates signalsDigital ↔ Analog conversion
Access Point2 (Data Link)Extends wired network via WiFiWireless 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.

My Private Notes

Notes are auto-saved locally to this device.