In this article I will talk about the differences between two of the most common networking devices, routers and switches. You may already be somewhat familiar with these devices, even if you are not working in an IT department. Home internet connections became so common these days that we are practically addicted to them without even realizing we are. Because technology evolved so fast, newer, faster and cheaper networking devices have been developed to fulfill our needs. Many of you may own a router to connect to the Internet. If you are an IT professional, you probably know how network devices work, but for a casual user, these things may sound a bit like science fiction. If you’ve ever been curious about how routers and switches work, this is a perfect opportunity to learn about their role and functionality.
Protocol Stacks and Layers
Two main protocol stacks are used in today’s communications, OSI and TCP/IP. These designs define the rules that manage data communications inside computer networks. You should know that these stacks are divided into several layers. Each layer is independent and provides an important and unique role in communications. For more information about this, check out the following link from IT training day.
After having a general idea of protocol stacks, you can identify at what layer each networking device works. Based on a defined set of rules, both switches and routers take decisions on how and where data should be forwarded. If you don’t know by now, routers are also called layer 3 devices, while switches are layer 2 devices. But how did we get to this idea and what things are defined by each layer? Well, the networking layer (this is how it’s named in the OSI stack or the Internet layer in the TCP/IP design) is where routers take decisions based on the information gathered from the network. The IP (Internet Protocol) was developed as the central piece in data transmissions. There is much to talk about regarding this layer, but it’s not the main topic for this article. For those interested, read more here.
IP Addresses
An IP address is a 32 bit element used to identify a certain machine. Whenever data is sent between networking devices, it must be segmented into smaller pieces for better manipulation and transmission. At the network layer, these pieces are called packets. Each packet carries all the elements needed to communicate between devices. Layer three is responsible for the logical transmission between two devices. It’s called a logical transmission because even if devices are not physically connected, at layer three the transmission is seen as a client-server communication. Source and destination IP addresses are used to identify each machine involved in this operation and based on the information gathered from them, routers take forwarding decisions. All routing information is stored in routing tables
Switches are layer 2 devices because they make decisions based on the physical address (also known as the MAC address – Media Access Control). In the OSI stack, this layer is also known as the Data Link Layer. Each physical device uses the MAC address to uniquely identify itself in a computer network (two devices with the same MAC address cannot exist). Switches communicate between each other using physical addresses. To exchange information switches also use broadcasting and ARP mechanisms. The PDU, or the protocol data unit, defined at the Data Link Layer is known as the frame. A frame contains all the information involved in a layer 2 transmission. A frame is formed by adding the header (that contains the source and destination MAC address) and the trailer (error checking and other information) to a packet. This mechanism is also known as encapsulation.
Check out the following link from Wikipedia to better understand how Ethernet frames look. Switches store their layer 2 information in MAC address tables. The whole concept is pretty simple: when a frame is received, the switch will check the packet’s destination MAC addresses. If the address is found, the frame will be forwarded, through the desired interface, directly to the destination machine. MAC address tables store bindings between MAC addresses and switch ports. If the MAC address is not found, it will be added as a new entry in the MAC address table. The switch will then flood the frame on all its interfaces except the one that the frame was received from. This is known as a broadcast message and it is an important aspect of switches. Remember that switches will forward broadcasts while routers will block them.
Differences Between Switches and Routers
You may already know that routers define broadcast domains while switches define collision domains. A broadcast domain is defined by a single physical interface on a router. We say that switches segment collision domains because unlike hubs, each port defines a separate communication channel. In these channels collisions do not occur and transmission is made in full duplex mode (both sending and receiving of data can be done in the same time).
Another difference between these network devices is that usually, routers have a lower port density than switches. Then why should you use routers when you have a higher number of ports available on switches? Because each port connects a different network, the transmission between routers is made using the highest available speed on the physical port. With switches, the whole available speed is divided between all the transmitting ports. So even if you have fewer ports available on a router, the ports will forward data at the highest available speed. This is why routers are used when sending data between two distant networks.
Switches are used to create LANs while routers are used to interconnect LANs. A group of interconnected LANs is known as a WAN (Wide Area Network).
Routers and switches can use different ports. Besides the normal FastEthernet, Fiber or Serial ports, they can also be equipped with console or aux ports and other special interfaces. Some advanced networking devices are modular, meaning their configuration can be changed even when the device is turned on in order to reduce the downtime. These modular devices are redundant meaning that they have two or more components with the same functionality. Such network devices are expensive and are usually used by large enterprises or ISPs. Remember that the cost of a network device can vary from several to thousands of dollars.
Unlike switches, routers can also support additional services like DHCP, NAT or packet filtering. These services can be activated using the router’s GUI or the console line. Network devices use different technologies to support their functionality. For example, switches use VLANs, STP or VTP technologies and routers use dynamic routing protocols, VLSM or CIDR.
I hope all the important aspects of these two network devices have been pointed out. If you think that there is more to be added here don’t hesitate to leave a comment. Enjoy Poweradmin and stay tuned for the following articles.