A switch (second layer) is a communication component used to route information packets that reach it to the different network components that are in the same communication network, ie the same broadcast area. The switch is a communication layer from the line layer which is the second layer in the seven layer model (OSI) and therefore cannot route packets of information out of the network where it is located.
Each network component connected to the switch is in a collision complex that is separated from the other collision complexes and therefore transmission conflicts are nothing that happens in switches unlike hubs. The big advantage of separating beyond conflict prevention is the matter of information security, the information only reaches the desired computer and prevents the other computers on the network from hearing the same information.
The switch routes the communication packets accessed by using MAC addresses, the switch learns the MAC addresses of the computers connected to its ports by reading the control data in the information packets transmitted through it and stores them in the MAC table.
Most of the switches today are “smart” / third-layer switches. The third-layer switch enables the components to be bound to VLANs (artificial virtual broadcast complexes) to reduce transmission complexes and optimize the communications network and prevent information security problems arising from over-sized networks.