When a data packet is sent from one device to another, the switch receives it and reads the header to decide what to do with it. Then, the switch sends the container through the proper ports that connect to the destination devices after matching the destination address or addresses.
‍