Networks Training

  • About
  • My Books
  • SUGGESTED TRAINING
  • HOME
  • Cisco Networking
    • Cisco General
    • Cisco IOS
    • Cisco VPN
    • Cisco Wireless
  • Cisco ASA
    • Cisco ASA General
    • Cisco ASA Firewall Configuration
  • Certifications Training
    • CCNA Training
    • Cisco Certifications
    • I.T Training
  • General
    • General Networking
    • IP Telephony
    • Network Security
    • Product Reviews
    • Software
  • Cisco Routers
  • Cisco Switches
You are here: Home / General Networking / Difference Between Routers and Switches in TCP/IP Networks

Difference Between Routers and Switches in TCP/IP Networks

Written By Harris Andrea

The key difference between routers and switches in TCP/IP networks is that Switches primarily function to provide Layer 2 connectivity and Routers provide Layer 3 connectivity (as described in the OSI layer model).

comparison of router and switch

What exactly does this mean? From a high level view it means that switches allow hosts to communicate as long as they are on a common network (e.g on a Local Area Network – LAN).

Routers, on the other hand, allow different networks to talk to each other and also allow communication between different hosts even if they are connected to separate and distant networks.

In this article we’ll also discuss Layer 3 switches (which have some overlapping functionality with Layer 3 routers) and describe the similarities and differences between Layer 3 switches vs Routers as well.

Before moving forward, let’s first see a network diagram which depicts a popular topology found in enterprise networks. The diagram will help in our discussion when comparing L2/L3 switches and Routers.

network diagram showing switches and routers

Table of Contents

  • Layer 2 Switch Functionality
  • Layer 3 Switch Functionality
  • Router Functionality
  • Layer 2 Switch Vs Router
  • Layer 3 Switch Vs Router   
    • Similarities
    • Differences
    • Use cases for Layer 3 Switches
    • Use cases for Routers
    • Comparison Table
  • Some Router Model Examples
    • Home Routers:
    • Small-Medium Business Routers:
    • Enterprise Routers
  • Some Switch Model Examples
    • Home Switches
    • Business Switches
    • Related Posts

Layer 2 Switch Functionality

The most common type of switch is a Layer 2 switch which operates only on the Layer 2 of the OSI model (Data link layer). There are also advanced switches that can operate at both Layer 2 and Layer 3 of  the OSI model. These are called Layer 3 switches as we will discuss later on. 

In this section we will focus on Layer 2 switches. 

Let’s describe a simplified communication scenario between two hosts on the same Layer 2 switch in order to understand its functionality.  

When a host A wants to communicate with another host B in a TCP/IP network, it sends an ARP request to find out the MAC address of the destination host B. Keep in mind that host A knows the IP address of host B but doesn’t know exactly how to reach that host (it doesn’t know its MAC address).

The ARP request is broadcasted to all other hosts on the switch and asks a question: “Hey, I want to communicate with a host having IP address a.b.c.d. What is the MAC address of this host?”  

If host B happens to be on the same switch (or Layer 2 broadcast domain) as host A, it will reply to ARP and give its MAC address to host A. On the other hand, if host B is not on the same Layer 2 domain as host A, the router will reply and give its own MAC address to the asking host.

A host connected to a switch, along with the other hosts and interfaces on the same switch, make up a Layer 2 broadcast domain.

To make things easier think of a broadcast domain as a single Local Area Network connection (LAN). The switch learns all the MAC addresses of all hosts connected to it and also knows at which physical port it can reach every MAC address.

Switches allow us the ability to break up these broadcast domains. Too many hosts on one broadcast domain can lead to a large amount of broadcast traffic which is not ideal for a network.

This can cause latency which if left unchecked can cause outages and loss of services. Switches have the ability to choose which LAN an interface belongs in, that is to say which broadcast domain it belongs in.

They accomplish this by creating virtual LANs, or VLANS. A single switch can have thousands of VLANs running at the same time.

The issue that switches face is that when they separate hosts into different VLANs they cannot allow the devices to communicate between VLANs unless the switch has a Layer3 functionality. This is where routers or L3 switches come into the picture.

Layer 3 Switch Functionality

a Layer 3 switch is a combo device which operates at both Layer 2 and Layer 3 of the OSI model.

That is, the Layer 3 switch forwards ethernet frames between ports but can also make routing decisions based on a routing table and Layer 3 IP addresses.

MORE READING:  Comparison of "peer-to-peer" vs "client-server" Network Models

Let’s see an example:

Assume we have a Layer 2 switch which has 3 different VLANs configured on it. If a host on VLAN 2 wants to communicate with a host on VLAN 3 (belonging to a different Layer 3 subnet) the L2 switch is not able to route the traffic between VLANs.

Now, assume we have a Layer3 switch with 3 different VLANs. Now, this type of switch is able to provide also routing between its VLANs since it has knowledge of the Layer 3 subnets and IP addresses and can route packets between these segments.

As shown on the diagram above, a Layer 3 switch can connect hosts directly to it and also have other Layer 2 switches connected in order to provide routing between VLANs (inter-vlan routing).

Router Functionality

Routers allow different LANs, or networks, to communicate with one another. Inside the routing table, which is stored in the memory of the router, the device has detailed information of all the networks it knows about and how to get there.

As shown on the diagram above, Network Switches mostly exist on the internal LAN network in order to provide ethernet connectivity to internal hosts and VLANs.

The router on the other hand is usually connected to the border  for providing a boundary between the internal LAN and the external WAN world (e.g the Internet or another WAN network).

The routing table is built either dynamically (using a dynamic routing protocol) or statically (i.e the administrator configures static routes on the device).

When the router receives a packet that needs to reach a certain destination IP, it will look in its routing table for a match. When a match is found, the router will look at what the next hop gateway is for that destination IP and send the packet out the appropriate physical or logical interface.

If I have two devices, let’s say a computer and a printer, with IPs in a common subnet in an office then I would only need a switch for them to communicate. I could place them on a common VLAN and they could send traffic directly.

But let’s say we need our computer to print something in a distant office off a printer that sits in a different network. We would then need a router in the path that could take packets from our computer and know where to direct them to reach an IP in a separate subnet.

Layer 2 Switch Vs Router

In summary, switches allow devices to communicate on a common network as well as allow us to break up those networks into smaller broadcast domains. A switch learns all the MAC addresses of all the hosts connected to it in order to pass traffic between hosts in Layer 2.

Routers on the other hand allow us the ability to take different networks and pass traffic to one another in Layer 3. Routers build maps (called “routing table”) for how to reach other networks and work as “traffic cops” to direct where to send packets to reach distant destinations.

A L2 switch also has several hardware differences compared to a Router. The switch connects uses only Ethernet ports (e.g electrical RJ45, fiber gigabit ports etc) to connect hosts to the network. The router on the other hand can have different types of ports such as ADSL, cable, fiber, dial-up etc (including Ethernet). 

Layer 3 Switch Vs Router   

As mentioned at the beginning of this article, a switch can be either Layer 2 (most common) or Layer 3. The latter, can also provide routing functionality in addition to pure Layer 2 functionality.

Now that we have a general idea of each device, let’s examine and compare some of the similarities and differences between L3 Switches and Routers.

Similarities

Both devices have a routing table in order to decide how each IP packet will be forwarded through the device.

They both look at the destination IP address included in each packet header and then look into their routing table which provides information pertaining to where each destination network can be reached.

MORE READING:  Comparison of TCP/IP vs OSI Models in Networking

In order to built their routing table, both a L3 switch and a Router support dynamic routing protocols such as OSPF, RIP etc, or statically configured routes.

Moreover, both devices can enforce traffic control to packets (usually with Access Control Lists) in order to allow or block traffic between networks. These Access Control Lists can usually work up to TCP layer 4 whereby they can also control traffic at the port level as well (e.g allow traffic to IP 5.5.5.5 at port 443).  

Differences

The main difference between a L3 switch and router is that a Router device supports different types of WAN interfaces, whereas a switch consists of multiple Ethernet ports (such as RJ45 electrical ports or multi-Gigabit Fiber optic ports).

The router on the other hand can support various WAN interfaces such as Fiber optic, ADSL, Cable, ATM, Frame Relay, Electrical Ethernet etc.

Moreover, the forwarding performance of a switch is much higher than a router because the switch uses hardware ASIC chips to perform the packet forwarding whereas a router usually uses software routing (except some high-end routers).

Although a Layer 3 switch can provide basic routing functionality (just like a router), this is only on Ethernet physical connections (LAN networks) in star topologies.

The router on the other hand supports more advanced networking features such as QoS (quality of service for traffic), Tunnel termination (e.g GRE or IPSEC for VPNs), Network Address Translation (NAT), advanced routing protocols such as BGP etc.

Use cases for Layer 3 Switches

Layer 3 switches are mostly used in campus LAN networks, in Data centers and in large internal corporate networks to provide routing between VLANs.

Because of their large port density, they can accommodate multiple internal hosts and work at very high speeds such as Gigabit, 10 Gigabit etc.

If you want to segment a large internal LAN into multiple VLANs and provide routing between them, the L3 switch is ideal for such scenario.

Use cases for Routers

The main use case of a router is for WAN connectivity as discussed above. Especially if you want to provide WAN redundancy or Internet access redundancy, a router is ideal for connecting to multiple WAN networks and for routing failover and load-balancing using BGP for example.

Comparison Table

Let’s see a side by side comparison between the two devices.

Layer 3 Switch Router
Works both at Layer 2 and Layer 3 of OSI model Works only at Layer 3 of OSI model
Supports only Ethernet Interfaces (electrical, optical) Supports different types of interfaces such as Ethernet, ADSL, Cable, Fiber, ATM, E1 etc
Higher forwarding throughput Lower forwarding throughput
Supports basic routing functionality Supports advanced routing functionality with more protocols such as BGP, ISIS, MPLS support, VRF etc.
No advanced networking features Supports advanced networking features such as QoS, VPN, Tunnelling (GRE,IPSEC), NAT, VRF etc
Lower Cost Higher Cost
Used mostly within internal networks, Data Centers, Campus LANs etc Used mostly as border device between LAN/WAN, in ISP environments etc.
High Port Density Lower Port Density
Smaller routing table Large routing table

Some Router Model Examples

Routers can be distinguished by many different specs and features. For example, number and types of network interfaces (WAN and LAN mainly), hardware performance (e.g how many packets per second they can handle), software features (e.g what routing protocols they support) etc.

In more general categories, we have home routers, business routers, enterprise models, ISP models etc.

Let’s see some example brands below:

Home Routers:

  • Netgear
  • D-link
  • TP-link
  • Linksys

Small-Medium Business Routers:

  • Cisco
  • Mikrotik
  • Ubiquity

Enterprise Routers

  • Cisco
  • Juniper
  • HPE routers
  • Huawei

Some Switch Model Examples

Switches are mainly distinguished by their hardware features and most importantly their physical interface ports. Almost all modern switches support at least Gigabit ethernet ports even on small home models. Higher-end models support also 10Gigabit ports and also fiber optic ports.

Let’s see some example switch vendors:

Home Switches

  • Netgear
  • D-link
  • TP-link

Business Switches

  • Ubiquity
  • Cisco
  • HPE
  • Juniper
  • Huawei

Related Posts

  • What is OSPF NSSA (Not So Stubby Area) and How is it Configured?
  • Comparison of BOOTP vs DHCP Protocols in Computer Networks
  • Pros and Cons of SD-WAN in Networks – Description and Discussion
  • Comparison of GNS3 vs EVE-NG vs Packet Tracer for Networks Simulation
  • Subnetting vs Supernetting – What’s the Difference? (Explanation Guide)

Filed Under: General Networking

Download Free Cisco Commands Cheat Sheets

Enter your Email below to Download our Free Cisco Commands Cheat Sheets for Routers, Switches and ASA Firewalls.

We use Elastic Email as our marketing automation service. By submitting this form, you agree that the information you provide will be transferred to Elastic Email for processing in accordance with their Terms of Use and Privacy Policy. Also, you allow me to send you informational and marketing emails from time-to-time.

About Harris Andrea

Harris Andrea is an Engineer with more than two decades of professional experience in the fields of TCP/IP Networks, Information Security and I.T. Over the years he has acquired several professional certifications such as CCNA, CCNP, CEH, ECSA etc.

He is a self-published author of two books ("Cisco ASA Firewall Fundamentals" and "Cisco VPN Configuration Guide") which are available at Amazon and on this website as well.

Comments

  1. some it support says

    December 25, 2020 at 3:04 am

    wow this is a very easy to understand article. thanks for sharing! from Philippines

  2. Blinton Poudon says

    February 1, 2021 at 1:15 am

    Mega thanks and really simplified explanation to someone like me who who never had studied Networking but is the field that always interests me.

    From: Papua New Guinea

  3. Harris Andrea says

    February 1, 2021 at 8:49 am

    Thanks for your comment and feedback. I’m glad you liked my explanation.

    Harris

  4. Yohan says

    May 20, 2021 at 9:07 pm

    Outstanding article. I’ve worked in IT for over 20 years and this is the clearest explanation I’ve ever read.

  5. Harris Andrea says

    May 21, 2021 at 5:10 am

    Yohan, thanks a lot for your feedback.

    I’m glad you liked my article.

    Have a nice day

    Harris

  6. Mikael says

    December 11, 2021 at 7:00 pm

    Hi Harris

    Thank you for a great explanation.

    If I understand you right several VLANs kan be administrated by one level 2 switch but a layer 3 switch with a routing table is needed for a device on one of the VLANs to communicate with a device on another VLAN even if both VLANs are connected to the same switch ?
    Example: In your diagram a device connected to VLAN 2 and physically connected to the middle Layer 2 switch would need the Layer 3 switch which this Layer 2 switch is connected to to reach a device on VLAN 3 even if this device is physically connected to the same Layer 2 switch

  7. Harris Andrea says

    December 11, 2021 at 8:10 pm

    Mikael,
    You are absolutely correct. Even if two devices are connected on the same Layer2 switch but on a different VLAN, they need a Layer3 switch (or a router) in order to communicate.

    Harris

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search this site

About Networks Training

We Provide Technical Tutorials and Configuration Examples about TCP/IP Networks with focus on Cisco Products and Technologies. This blog entails my own thoughts and ideas, which may not represent the thoughts of Cisco Systems Inc. This blog is NOT affiliated or endorsed by Cisco Systems Inc. All product names, logos and artwork are copyrights/trademarks of their respective owners.

Amazon Disclosure

As an Amazon Associate I earn from qualifying purchases.
Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.

Search

BLOGROLL

Tech21Century
Firewall.cx

Copyright © 2023 | Privacy Policy | Terms and Conditions | Hire Me | Contact | Amazon Disclaimer | Delivery Policy

0 shares