What is a switch used for in networking?
A Layer 2 device that connects devices within a LAN and forwards frames by MAC address, sending traffic only to the correct port.
A switch is the device that ties together all the computers in a single LAN. The whole point is efficiency: instead of repeating every frame to every device (which wastes bandwidth and exposes traffic to everyone), a switch learns which device lives on which port and then sends each frame only where it needs to go. It builds this knowledge automatically by noting the source MAC (Media Access Control) address of every frame it receives, so no manual configuration is needed.
* A switch learns source MACs, then forwards each frame only to the known port — flooding only when the destination is still unknown. *
Key characteristics:
- Operates at Layer 2 (Data Link) of the OSI model
- Gives each port its own collision domain, so connected devices don't have to contend for the wire
- Learns MAC addresses automatically into a MAC address table
- For each frame, it forwards (to the known port), filters (drops if not needed), or floods (sends everywhere only when the destination is still unknown)
How it works:
- Receives a frame on a port
- Reads the destination MAC address
- Looks that MAC up in its table
- Forwards only to the matching port — keeping other ports quiet
This is why a switch is called "smart": it switches traffic only to where it belongs rather than broadcasting it everywhere.
Go deeper:
Host to Host through a Switch (Practical Networking) — deepest: a learning/flooding/forwarding/filtering walkthrough of how a switch actually moves frames.
Network switch (Wikipedia) — Layer 2, MAC-based forwarding, with one collision domain per port.