Sergey Nivens - Fotolia

What's the difference between a Layer 3 switch and a router?

Even though they have common traits, there is a difference between a Layer 3 switch and a router. Each plays a key role in making sure packets get sent to their proper destination.

 

To determine the difference between a Layer 3 switch and a router, it's helpful to understand how routing works in an enterprise network.

Routing occurs at Layer 3 of the OSI model and is responsible for intersubnet communications. A router first analyzes the Layer 3 destination address of every packet and then determines the best next-hop IP address the packet should take toward its final destination. Layer 3 addresses are most commonly IPv4 or IPv6 addresses.

The router determines how to send the packets by either relying on static routes manually configured by a network administrator or by learning the optimal next-hop destination IP address through dynamic routing. The router maintains this static, dynamic or a combined static-dynamic table of all networks it knows about. This is known as a routing table. Based on the information the router has, it will send the packet to its destination IP address after it matches the specific destination IP with the proper subnet.

In the following example, we see a simple routing table that lists three known networks and the IP addresses and/or physical interfaces through which the router will send packets outbound:

routing table

Next, let's look at Layer 2 switches and the evolution of Layer 3 switches. Layer 2 devices operate at the data link layer of the OSI model. The primary difference here is that these switches only focus on intrasubnet communications, as opposed to the intersubnet communications that routers deal with.

In other words, if the source and destination device reside on the same subnet or virtual LAN (VLAN), the traffic is switched. If the source and destination device reside on different subnets or VLANs, the traffic is routed.

Additionally, instead of routing based on a Layer 3 address, such as a destination IP and routing, Layer 2 switches use the network interface card's media access control (MAC) address to locate the ideal outgoing interface through which to send data. Layer 2 switches use a stored static or dynamic table to reveal the identity of known destination MAC addresses and which interface they were heard on.

If a destination MAC is not known, the switch will send a broadcast frame destined to all devices in this subnet. If the device with the destination MAC address replies, that MAC address is stored in the MAC table along with the switch port number the switch heard the reply on. Then, all subsequent frames can be forwarded out -- to that output port only -- until the dynamic MAC table timer expires.

Here's an example of a Layer 2 switch MAC table:

MAC address table

A Layer 3 switch is engineered to forward frames at Layer 2 with a MAC address table, as well as route intersubnet packets at Layer 3 with a routing table. Prior to the development of Layer 3 switches, a Layer 2 switch would have to send all traffic to a dedicated router, where it would access a route table to determine how the packets should be sent to the next hop destination. This setup is known as a router on a stick.

Several decades ago, it became cost-effective to put routing capabilities into Layer 2 switches. This reduced the number of dedicated hardware devices on a network and enabled the industry to take advantage of switch backplane bandwidth capabilities. This advancement also ushered in the development of Layer 3 devices.

The advancements in Layer 3 switches include route table lookup caching, which made it possible for the device to look up a destination IP only once during a flow, as opposed to each individual packet requiring a lookup. This is known as a route once, switch many routing architecture, and it set the stage for routing at wire speed.

Having explained some of the mechanisms underlying the difference between a Layer 3 switch and a router, understand that some Layer 3 switches don't have all the same functionality that dedicated routers have. Layer 3 switches are primarily intended to be deployed within the core and distribution layers of the corporate LAN. Thus, certain dynamic routing capabilities, such as Border Gateway Protocol, as well as some advanced edge network security features, are missing from Layer 3 switches.

As a result, in certain WAN or internet edge network designs, dedicated routers remain the better choice, while Layer 3 switches can be deployed throughout the rest of the corporate LAN.

Dig Deeper on Network infrastructure

Unified Communications
Mobile Computing
Data Center
ITChannel
Close