Where to buy Submit Orders
search
Home / Resources / Blog & News

Layer 2 vs Layer 3 Switch, What's The Difference?

AuthorMoore

Date03/11/2023

This article will describe what a Layer 2 switch and a Layer 3 switch are. It will also cover the differences between Layer 2 and Layer 3 switches, and when to use Layer 3 switches and routers.

Layer 2 switches are ubiquitous for connecting network and client devices. However, the advancement of modern network applications and converged network implementations has brought about the prevalent adoption of Layer 3 switches in complex enterprise networks, data centers, and business applications. This article aims to introduce the distinction between Layer 2 vs Layer 3 switches and to provide insights into selecting the optimal network switch.

 

What Is OSI Model?

 

The Open Systems Interconnect (OSI) Model serves as a reference model utilized to define and elucidate network communications. Comprising seven distinct layers including the application layer, presentation layer, session layer, transport layer, network layer, data link layer, and physical layers. The Layer 2 and Layer 3 OSI models pertain to the data link and network layers, respectively. In adherence to the OSI Model's guidelines, switches that operate in these respective layers are identified as Layer 2 switches and Layer 3 switches.

 

What Is Layer 2 Switch?

 

Layer 2 switches operate at the data link layer of the OSI model and utilize network devices to determine the destination of frames via Media Access Control (MAC) addresses. The primary function of switches and bridges is to facilitate Layer 2 switching, which involves the division of a large collision domain into multiple smaller conflict domains.

 

The collision domain refers to the specific segment of a network where data packet collisions can take place. Such collisions arise when two or more network devices within a common network segment attempt to transmit data packets simultaneously. As a consequence of the collision, the affected devices are required to retransmit their packets, leading to a decline in network transmission efficiency.

 

In a Local Area Network (LAN), the devices are interconnected via a central device, commonly known as a hub. However, hubs suffer from significant drawbacks, such as their inability to manage the traffic flow, and will create large collision domains. To overcome this issue, bridges were introduced, which effectively break up collision domains. Nonetheless, bridges are limited in terms of port numbers, rendering them ineffective for larger networks. In contrast, switches are extensively utilized due to their ability to inspect incoming traffic and determine its optimal forwarding path. Additionally, switches provide multiple independent collision domains via their ports, thus eliminating the possibility of collisions.

 

The Function of Layer 2 Switch

 

A Layer 2 switch performs the following functions:

 

MAC address learning: The switch learns the MAC address of the device connected to each port, by analyzing the source address of the frames received on that port.

 

Message forwarding: The switch forwards frames in two modes: Unicast (directed to a specific destination) and Unknown Unicast (flooding to all ports except the source). This is accomplished using specialized Application-Specific Integrated Circuits (ASICs).

 

Filtering: The switch filters frames and forwards them only to the switch port where the MAC address has been previously learned, thereby reducing network congestion.

 

Spanning Tree Protocol (STP): The switch uses STP to prevent network loops by identifying and disabling redundant links.

 

Transparent bridging: The switch acts as a transparent bridge, forwarding frames between connected segments of a LAN.

 

VLANs: The switch can create smaller, logically independent broadcast domains called Virtual Local Area Networks (VLANs), which can enhance network security and performance by segmenting the network into smaller broadcast domains.

 

The Benefits of Layer 2 Switch

 

There are several compelling reasons to utilize a Layer 2 switch within a Local Area Network (LAN). The primary benefits of Layer 2 switches include:

 

1. Faster than routers

2. Hardware-based bridging

3. Low cost

4. Low latency

5. Wire-speed

 

What Is Layer 3 Switching?

 

The principal difference between Layer 2 and Layer 3 switches is their routing functionalities. While a Layer 3 switch encompasses the all functions of a Layer 2 switch, it additionally possesses static and dynamic routing capabilities. Layer 3 switches are equipped to evaluate incoming packets and establish routing decisions based on the source and destination addresses of these packets, incorporating both switch and router functions.

 

The Function of Layer 3 Switch

 

Layer 3 switches are used in the OSI data link and network layers, and in addition to the Layer 2 switch functions mentioned above, routing functions can also be implemented in either of two forms:

 

Cut-through switches utilize a switching technique that considers only the first packet summary to ascertain the IP address. Subsequently, the remaining packets are directed toward the MAC address, thereby resulting in higher data throughput. 

 

Packet-by-Packet Layer 3 (PPL3) switches scrutinize every packet in a sequence to determine the IP address. The PPL3 switch possesses an in-built hardware routing function, enabling its use as a high-speed router. Additionally, PPL3 switches can execute other standard router functions such as:

 

1. Verifying packet integrity using checksums

2. Updating the time-to-live (TTL) of packets after each hop

3. Managing all optional information in packet headers.

 

The Benefits of Layer 3 Switch

 

The primary benefits of Layer 3 switches include:

 

1. Enables VLAN routing

2. Enhances fault isolation

3. Simplifies security management

4. Reduces broadcast traffic

5. Eases configuration by eliminating the need for a separate router between VLANs

6. Improves traffic segregation through routing tables

7. Simplifies troubleshooting

8. Reduces network latency

 

The Difference Between Layer 2 vs Layer 3 Switch

 

The fundamental distinction between Layer 2 and Layer 3 switches is the variance in routing functions. Layer 2 switches employ MAC addresses, and they are indifferent to IP addresses or other higher-level elements. Conversely, Layer 3 switches are equipped with supplementary static and dynamic routing capabilities, in addition to all the features of a Layer 2 switch. Layer 3 switches possess both MAC address and IP routing tables, facilitating intra-VLAN communication, and packet routing between dissimilar VLANs. Furthermore, Layer 2+ (Layer 3 Lite) switches have become available, which only introduce static routing compared to Layer 2 switches. Apart from packet routing, Layer 3 switches also offer advanced functionality that necessitates information about the IP address of data entering the switch, such as VLAN traffic tagging based on IP address, rather than manual port configuration. Layer 3 switches also deliver superior power and security compared to Layer 2 switches.

 

Determining the appropriate switch for your business entails a thorough assessment of the network environment in which it will be utilized. In the event that the switches will be employed in a Layer 2 network domain, opting for a Layer 2 switch is sufficient. A pure Layer 2 switch is utilized at the access layer of a network topology where it connects hosts. Conversely, if the objective is to consolidate access and configure inter-VLAN routes through the integration of multiple switches, a Layer 3 switch must be selected. The Layer 3 network is situated at the distribution layer of the network topology.

 

 

 

Layer 2 Switch

Layer 3 Switch

Routing Function

Only Mac Address

Static Routing and Dynamic Routing

VLAN Tagging via IP Address

No

Yes

Inter-VLAN

No

Yes

Application

Pure Layer 2 domain

Aggregate Multiple Access Switches

 

What Should You Consider When You Are Choosing A L2 or L3 Switch?

 

When you choose to order an L2 or L3 switch, you should consider these key parameters to determine which one is more appropriate for your network environment: forwarding rate, backplane bandwidth, number of VLANs, the memory of MAC address, latency, etc.

 

The forwarding rate is the forwarding capacity of the backplane. When the forwarding capacity is greater than the sum of all port speeds, we call the backplane non-blocking, and the unit of forwarding rate is packet per second (pps). Here is the formula to calculate the forwarding rate of a switch.

 

Forwarding Rate (pps) = number of 10Gbit/s ports * 14,880,950 pps + number of 1 Gbit/s ports * 1,488,095 pps + number of 100Mbit/s ports * 148,809 pps

 

Another more important parameter is the backplane bandwidth, which is the sum of the speeds of all ports on the switch. Note that the sum is twice the speed of all ports, as it needs to include the Tx direction and Rx direction. The unit of backplane bandwidth is bits per second(bps or bit/s).

 

Backplane Bandwidth (bps) = port number * port data rate * 2

 

Another three important parameters are the number of VLANs that can be configured. Generally, 1K=1024 VLANs are sufficient for Layer 2 switches. The typical number of VLANs for Layer 3 switches is 4k=4096. The memory of the MAC address table refers to the number of MAC addresses that can be reserved by a switch, generally 8k or 128k. Delay refers to the delay time suffered by the switch to transmit data. The shorter the delay time for users, the better, so the unit of delay is generally nanoseconds (ns).

 

Conclusion

 

This article introduces the main differences between Layer 2 switches and Layer 3 switches. It also introduces the functions and benefits of Layer 2 and Layer 3 switches. When you need to order a switch, the more expensive one is not more suitable for you. You need to consider the key parameters of the Layer 2 or Layer 3 switches introduced earlier, it is more important for you to choose a suitable switch for your specific application.

share

Contact us
ok