IT Share NVP -ViettechgroupVN-Phuong Nguyen blog Viettechgroup.vn | Share make us stronger Knowledge is Sharing Viettechgroup- Sharing Make Us Stronger-Kiến thức CNTT là sự chia sẻ- NVP-Chia sẻ làm chúng ta mạnh hơn-Viettechgroup.vn Viettechgroup.com.vn| ITShareNVP Channel | Phương Nguyễn | Phuong Nguyen Blog| Lưu trữ kiến thức chia sẽ kinh nghiệm CNTT | Phương Nguyễn

Layer 2 vs Layer 3 Switch: Which One Do You Need?

0 1,013

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. When you traverse between LANs (local area networks)/VLANs (virtual local area networks) or reach the WAN (wide area network), router is the device that helps you connect these different networks. 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.

What Are Layers 2 & 3?

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 network layer is Layer 3 and data link layer is Layer 2.

Figure 1: Layer 2 & Layer 3 in OSI model.

The Layer 2 provides direct data transfer between two devices within a LAN. A Layer 2 switch functions by keeping a table of media access control (MAC) addresses. The switch MAC address table records hardware’s MAC addresses it has learned and the associated physical port they are last seen. The data frames are switched by MAC addresses only within the LAN and will not be known outside it. A Layer 2 switch can assign VLANs to specific switch ports, which in turn are in different layer 3 subnets. So the communication with other LANs, or VLANs, needs the function of Layer 3.

Layer 3 handles packet routing by logical addressing and subnet control. A router is the most common network device belonging to Layer 3. A router functions to route packets to their destination IP (Internet Protocol) address. In Layer 3, it checks the source and destination IP addresses of every packet in its IP routing table, and determines the best next hop for the packet (to a router, or to a switch). If no destination IP is found in the table, it will drop the packet unless it has a default router. Thus, the routing process often causes some latency.

Layer 2 vs Layer 3 Switch vs. Router

The functions of a Layer 3 switch (or multilayer switch) combine some of a Layer 2 switch and some of a router. In essence, they are three different devices designed for different applications, which are significantly dependent on the functions they can provide. But they also have some similarities in their functions.

What’s the Difference Between Them?

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 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.

Generally, Layer 3 switches are faster than routers, but they lack some advanced functionalities of routers. In a Layer 3 switch, after a destination address has been searched in the IP routing table for the first time, a cache entry is made in the fast memory. Next time when the destination address appears, the Layer 3 switch needs not to look up the table but just to take the next hop information from the cache then switch the packet. So Layer 3 switch routes packets faster than a router. However, a Layer 3 switches are basically used in LAN environment where routing is needed. Layer 3 switch lacks some Quality of Service (QoS) features and does not support Network Address Translation (NAT). Unlike Layer 3 switches, routers support many different WAN technologies. Another difference is that, Layer 3 switches and high-end routers generally route packets on hardware, like Application Specific Integrated Circuit (ASCI), but a general-purpose router uses software to route.

Which Device Do You Need?

With the emergence of Layer 3 switch, the problems of when to use Layer 2 switch and when Layer 3 switch, and choosing Layer 3 switch for routing or choosing router, are troubling many people. Which device is the better one for your need?

Figure 2: when to use Layer 2 switch, Layer 3 switch and router?

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; if you need to do inter-VLAN routing, then you need a Layer 3 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 the need the switch to aggregate multiple access switches and do inter-VLAN routing, then a Layer 3 switch is needed. This is known as distribution layer in network topology.

Since both the Layer 3 switch and the router have routing function, which one is better? Actually it’s less a question of which is better for routing, as both are useful in particular applications. If you want to do many switching and inter-VLAN routing, and need no further routing to the Internet Service Provider (ISP)/WAN, then you can go well with a Layer 3 switch. Otherwise, you should go for a router with more Layer 3 features.

Key Parameters to Consider for Layer 3 and Layer 2 Switches Purchasing

If you are buying a Layer 2 or Layer 3 switch for your use, 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).

Summary

This post has explained the layers 2 & 3 and commonly used devices in these layers, including Layer 2 switch, Layer 3 switch and router. 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.

Source from : https://community.fs.com/blog/layer-2-switch-vs-layer-3-switch-which-one-do-you-need.html

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. AcceptRead More