Generally, if you want to connect all network devices and client devices in a network, a Layer 2 switch is one of the basic devices that you need. As the diversity of network applications increases and the implementation of converged networks grows, new network switch, such as Layer 3 switch, are thriving in both data centers, complicated enterprise networks, commercial applications, and even advanced customer projects. Layer 2 vs Layer 3 Switch, what are their differences?
The terms Layers 2 & 3 are adopted from the Open System Interconnect (OSI) model, which is a reference model for describing and explaining network communications. The OSI model has seven layers: application layer, presentation layer, session layer, transport layer, network layer, data link layer and physical layer, among which data link layer is Layer 2 and network layer is Layer 3. The switches working in these layers are called Layer 2 switch and Layer 3 switch respectively.
Figure 1: Layer 2 & Layer 3 in OSI model.
The main difference between Layer 2 and Layer 3 is the routing function. This is also the biggest difference lies between Layer 2 switch and Layer 3 switch. A Layer 2 switch works with MAC addresses only and does not care about IP address or any items of higher layers. A Layer 3 switch, or multilayer switch, can do all the job that a Layer 2 switch does. Additionally, it can do static routing and dynamic routing. That means, a Layer 3 switch has both MAC address table and IP routing table, and handles intra-VLAN communication and packets routing between different VLANs as well. A switch that adds only static routing is known as a Layer 2+ or Layer 3 Lite. Other than routing packets, Layer 3 switches also include some functions that require the ability to understand the IP address information of data entering the switch, such as tagging VLAN traffic based on IP address instead of manually configuring a port. Layer 3 switches are increased in power and security as demanded.
When lingering between Layer 2 and Layer 3 switches, you should think about where it will be used. If you have a pure Layer 2 domain, you can simply go for Layer 2 switch. A pure Layer 2 domain is where the hosts are connected, so a Layer 2 switch will work fine there. This is usually called access layer in a network topology. If you need the switch to aggregate multiple access switches and do inter-VLAN routing, then a Layer 3 switch is needed. This is known as the distribution layer in the network topology.
Figure 2: when to use Layer 2 switch, Layer 3 switch and router?
|Item||Layer 2 Switch||Layer 3 Switch|
|Routing Function||Mac address only||Supports higher routing such as static routing and dynamic routing|
|VLAN Tagging Based on IP Address||No||Yes|
|Using Scenario||Pure Layer 2 domain||Aggregate multiple access switches|
If you are buying a Layer 2 or Layer 3 switch, there are some key parameters that you should check out, including the forwarding rate, backplane bandwidth, number of VLANs, memory of MAC address, latency, etc.
The forwarding rate (or throughput rate) is the forwarding capabilities of a backplane (or switch fabric). When the forwarding capabilities are greater than the sum of speeds of all ports, we call the backplane non-blocking. The forwarding rate is expressed in packets per second (pps). The following formula gives how 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
For example, FS S5850-32S2Q has 32 10 Gbit/s ports and 2 40 Gbit/s ports, so its forwarding rate is:
32 * 14,880,950 pps + 2 * 4 * 14,880,950 pps = 595,238,000 pps ≈ 596 Mpps
The next parameter is the backplane bandwidth or switch fabric capacity, which is the sum of speeds of all ports. The sum of speeds of all ports are counted twice, one for Tx direction and one for Rx direction. Backplane bandwidth is expressed in bits per second (bps or bit/s).
Backplane Bandwidth (bps) = port number * port data rate * 2
So the backplane bandwidth for S5850-32S2Q is:
(32 * 10 Gbps + 2 * 40 Gbps) * 2 = 800 Gbps
Other important parameters are number of VLANs that can be configured. Generally, 1K = 1024 VLANs is enough for a Layer 2 switch, and the typical number of VLANs for Layer 3 switch is 4k = 4096. Memory of MAC address table is the number of MAC addresses that a switch can keep, usually expressed as 8k or 128k. Latency is the delay time that a data transfer suffers. It requires to be as short as possible, so the latency is usually expressed in nanosecond (ns).
This post has explained the differences of Layer 2 vs Layer 3 Switch. The comparison of their functions is also made, in the hope of solving the problem of deciding between these devices. Also key parameters for measuring a Layer 2 or Layer 3 switch are also discussed. It is not always the case that more advanced device is better, but it is right to choose the most appropriate one for your specific application.