A hub connects multiple devices to a single network but simply broadcasts all traffic to all ports. A switch can selectively send traffic only to the destination device, avoiding collisions. While hubs operate at the physical layer, switches operate at the data link layer and can learn MAC addresses to route frames efficiently. Switches generally perform better than hubs for networks with four or more devices or heavy traffic loads.