Networking devices like switches and routers allow computers to communicate over a network by receiving data on one port and transmitting it out another port. Switches operate at layer 2 and use MAC addresses to transmit data frames only to the destination device, while routers operate at layer 3 and use IP addresses to transmit packets between networks. Together, switches and routers are able to segment networks for improved performance and security while allowing communication between multiple devices and networks.