Network Switch
A network switch is a device that connects multiple computers, printers, servers and access points within one local network and forwards Ethernet frames between them using their hardware (MAC) addresses. It operates at layer 2, the data link layer, of the OSI model and sends each frame only to the port where its destination is located, not to every connected device. Where a router connects different networks by IP address and a modem converts the line signal, the switch is the device that links machines on the same network.
A switch learns where devices are by watching traffic and recording what it sees in a MAC address table, so that it needs no manual configuration for basic operation. Every Ethernet frame carries a source and a destination MAC address, a 48-bit identifier assigned to a network interface. When a frame enters a port, the switch notes that the source address is reachable through that port, and then looks up the destination: if known, the frame leaves only through the matching port; if unknown, or if it is a broadcast, the frame is flooded out of every other port until the destination replies and is learned. Entries that go unused age out after a few minutes, so the table follows devices that move. Because frames are sent only where needed, many conversations can happen simultaneously at full speed on different ports.
Switches replaced hubs, which repeated every incoming signal to every port, and the change is what made modern Ethernet scale. On a hub, all devices shared one collision domain, so only one could transmit at a time and collisions slowed everything as traffic grew; a switch gives each port its own collision domain and supports full-duplex links that send and receive at the same time. Switches also bring features unavailable to hubs: virtual LANs (IEEE 802.1Q) split one switch into several isolated networks, link aggregation combines ports for more bandwidth, and Power over Ethernet delivers electricity to cameras and access points through the cable. The spanning tree protocol, devised by Radia Perlman in 1985 and later standardized, prevents loops caused by redundant cabling, which would otherwise make frames circulate endlessly.
The switch is frequently confused with the router, and the distinction comes down to what each one reads and which networks it joins. A switch reads the MAC address in the Ethernet header and moves frames inside a single broadcast domain; it knows nothing about IP addresses or the wider internet, and it cannot by itself connect a LAN to another network. A router reads the IP address, works between networks and keeps a routing table. A typical home gadget labeled router contains a small switch for its wired ports, which is why the two blur together. So-called layer 3 switches complicate the picture by adding routing between VLANs in fast hardware, and they are widely used in enterprise networks. Unmanaged switches work out of the box, while managed switches can be configured and monitored with commands or web interfaces.
Common pitfalls include assuming that a switch provides internet access, that it can be unplugged into itself, and that it makes traffic private. Plugging in a switch adds ports but connects to the internet only if one port reaches a router, and connecting two ports of the same switch with one cable can create a loop that floods the network unless spanning tree is active. Because a switch sends frames to only one port, ordinary sniffing is harder than on a hub, but attacks such as MAC flooding or ARP spoofing can defeat that, and encryption is still necessary. At large scale, rows of switches form the fabric of every data center, where the networks that join GPUs during machine learning training rely on very high-speed switches with low and predictable delay.
Read a network switch as the local post office sorter: it learns which MAC address lives behind which port, forwards each frame only to its destination, floods only when it must guess, and by staying within a single network leaves the work of crossing between networks to the router.