A switch and a router are two networking devices that manage the transfer of information between computers. Data travels across a network in packets, which are chunks of information. The data packet has two parts: the body, where the data is held, and the header, which contains information about the data, where it has come from and where it is going. Although switches and routers use header information to perform their work, they use different parts of the header and operate in different environments.
A switch is a machine with many sockets -- called ports. A cable connects between a "node" and one of the sockets on the switch. A node can be a computer, or a printer, or any other type of device manufactured for networking. Device A sends a message to device B, although the two devices are not connected to each other, they are both connected to the switch. The switch receives a message at the port to which device A is connected. It reads the header of the packet and sees that it is addressed to device B. It has already associated the address of device B with one of the sockets in its configuration. So, it sends the packet to the socket for device B.
Switches move data between devices connected to the same network. Routers move data across networks. Although, they do not dictate which path the data will cross, it has an idea of the best direction to send the data over the first hop to its destination. The next router in the chain makes a similar calculation and passes the packet on to one of the other routers to which it is connected. By this method, data is forwarded until it meets its destination.
A computer in the offices of A Corp in New York needs to send information to Bnet in Berlin. It sends the data packet to the switch which recognizes that the recipient is outside of it's direct neighborhood, and sends the packet to a router. The router reads the IP address in the header of the data packet. It maintains a database of best routes to get to various locations. It is connected to a number of other networks. By referencing the first part of the address, it decided to send it to neighbor X. The neighboring router X looks at the IP address and checks its database. It chooses its neighbor W. The process is repeated until the packet arrives at the router for Bnet in Berlin. The router there adds on the local address for the intended computer within the network and sends the packet to its switch. The switch forwards the packet to its destination.
The key difference between switches and routers is the addressing system each uses. Switches deal with MAC addresses. This is the Media Access Control address hard coded onto every network adapter. The router has to send data all over the world. It deals with IP addresses. The IP address is defined in the Internet Protocol. Each IP address is unique throughout the world. These addresses are assigned by central controlling authorities.
- Photo Credit Thinkstock Images/Comstock/Getty Images