A switch is a halfway house between a hub and a router. It helps connect multiple parts of a network together or can be used to replace hubs. It performs routing by MAC level rather than IP level. MAC addresses are hardcode into each device by the manufacturer and take the format of 12 hex values. The exact nature of MAC addresses is not important but what is important is their uniqueness. Every MAC address is unique for every network device. Whilst IP address can be changed MAC address can not.

 

When a packet arrives at a switch it will look at the packet and forward it on to the correct port. It will know, by using special network algorithms, on which port each MAC address can be found. Normally it does this by sending a query packet out the first time that a packet destined for that address arrives. This information can then be stored in the switch for use later. The switch will then regularly purge the table it holds to ensure that it does not fill up with too much information.

 

You would not normally connect a switch directly to the internet. The internet would normally be connected to a router.