Sub topic 4
Which Device Works at Which Layer
Assume you already know the OSI and TCP/IP models, frames, MAC addresses, IP addresses, and basic encapsulation. The key rule is simple: a device works at a layer when it uses that layer’s information to make a forwarding or signal decision.
Hub: Physical Layer
A hub is a Layer 1, or physical-layer, device. It receives electrical, optical, or radio signals on one port and repeats the signal to every other port.
A hub does not understand:
- MAC addresses
- IP addresses
- Frames or packets
- Which host should receive the data
Every connected host sees the signal. Therefore, all hosts connected to one hub share one collision domain. Hubs are mostly obsolete because switches provide better performance and fewer collisions.
Bridge and Switch: Data-Link Layer
A bridge is a Layer 2 device. A switch is essentially a multiport bridge. Both forward data-link frames using MAC addresses.
A switch learns automatically:
- It receives a frame on port 1 from MAC address
AA. - It records that
AAis reachable through port 1. - It examines the destination MAC address.
- If the destination is known, it forwards the frame only through the correct port.
- If the destination is unknown, it floods the frame through other ports.
A switch does not normally use IP addresses to make ordinary Layer 2 forwarding decisions. Each switch port is usually a separate collision domain, but one VLAN forms one broadcast domain. A switch floods broadcast frames within that VLAN.
Router: Network Layer
A router is a Layer 3 device. It forwards packets using destination IP addresses and a routing table.
When a router receives an IP packet, it generally:
- Removes the incoming data-link frame header and trailer.
- Examines the destination IP address.
- Chooses the best matching route.
- Decrements the packet’s time-to-live field.
- Places the packet inside a new data-link frame for the outgoing interface.
A router separates broadcast domains. A broadcast sent on one interface is not automatically forwarded to another interface. Routers also separate networks that may use different data-link technologies, such as Ethernet and a point-to-point link.
Device Comparison
| Device | Main layer | Main information used | Typical forwarding behavior |
|---|---|---|---|
| Hub | Physical, Layer 1 | Signal or bits | Repeats to every other port |
| Bridge or switch | Data link, Layer 2 | Destination MAC address | Forwards or floods frames |
| Router | Network, Layer 3 | Destination IP address and routing table | Forwards packets between networks |
How the Devices Fit Together
All devices still depend on lower layers. A router has physical interfaces and sends data-link frames, but its key forwarding decision is made at Layer 3. Similarly, a switch transmits physical signals, but its key decision is made at Layer 2.
Common Errors
- Calling a hub a packet-forwarding device. A hub repeats signals without inspecting addresses.
- Saying that a switch routes using IP addresses. A basic switch uses MAC addresses.
- Assuming a router forwards broadcasts between all interfaces. Routers normally stop Layer 2 broadcasts.
- Treating bridge and switch as completely different concepts. A switch is a high-port-count, usually faster form of bridge.
Exercise
A frame arrives at a device, and the device checks the destination MAC address before selecting one output port. Is the device acting as a hub, switch, or router?
Show answer
It is acting as a switch or bridge. The destination MAC address belongs to the data-link layer.