What is the actual difference between a router and a switch?
Both forward traffic, both have ports, both show up in every topology diagram. When does a frame stop at a switch versus getting routed? What decision does each device actually make?
1 Answer
They work at different layers and make different decisions. A switch forwards frames inside one network using MAC addresses: it learns which MAC lives on which port and forwards (or floods when it doesn't know). It never changes the frame. A router forwards packets between networks using IP: it looks up the destination network in its routing table, decrements TTL, and writes a brand-new Layer 2 header for the next hop. Quick test: if source and destination are in the same subnet, only switching happens; if they're in different subnets, a router must be involved — that's why a PC needs a default gateway. Build two PCs + a switch in the lab, ping, and watch the frame; then add a router between two subnets and watch the MAC addresses change at each hop while the IPs stay constant.