The difference between Layer 2 switches, Layer 3 switches, and Layer 4 switches

The difference between Layer 2 switches, Layer 3 switches, and Layer 4 switches

The layer 2 switching technology is relatively mature. The layer 2 switch is a data link layer device that can identify the MAC address information in the data packet, forward it according to the MAC address, and record these MAC addresses and corresponding ports in their own internal Address table. The specific workflow is as follows:

(1) When the switch receives a data packet from a port, it first reads the source MAC address in the packet header, so that it knows which port the machine with the source MAC address is connected to;

(2) Then read the destination MAC address in the packet header and find the corresponding port in the address table;

(3) If there is a port corresponding to the destination MAC address in the table, copy the data packet directly to this port;

(4) If the corresponding port is not found in the table, the data packet is broadcast to all ports. When the destination machine responds to the source machine, the switch can learn which port the destination MAC address corresponds to. The next time the data is transmitted It is no longer necessary to broadcast to all ports.

Continuously looping this process can learn the MAC address information of the entire network. This is how the Layer 2 switch establishes and maintains its own address table.

The following three points can be inferred from the working principle of the Layer 2 switch:

(1) Since the switch exchanges the data of most ports at the same time, this requires a wide switching bus bandwidth. If the layer 2 switch has N ports, the bandwidth of each port is M, and the switch bus bandwidth exceeds N × M. Then this switch can achieve wire-speed switching;

(2) Learning the MAC address of the machine connected to the port, writing into the address table, the size of the address table (generally two representations: one for BEFFER RAM, one for the value of the MAC entry), the size of the address table affects the access capacity of the switch ;

(3) There is also a layer 2 switch that generally contains an ASIC (ApplicaTIon specific Integrated Circuit) chip dedicated to processing packet forwarding, so the forwarding speed can be very fast. Because each manufacturer uses ASIC differently, it directly affects product performance.

The above three points are also the main technical parameters for judging the performance of Layer 2 and Layer 3 switches. Please pay attention to the comparison when considering device selection.

(2) Routing technology

The router works at the third layer of the OSI model --- network layer operation. Its working mode is similar to the layer 2 switching, but the router works at the third layer. This difference determines that routing and switching use different control information when passing packets. The way to realize the function is different. The working principle is that there is also a table inside the router. This table indicates that if you want to go to a certain place, the next step should be to go there. If you can find the packet from the routing table, go to the next step and put the link layer The information is forwarded out; if you cannot know where to go next, discard the packet and return a message to the source address.

Routing technology is essentially two functions: determining the optimal route and forwarding packets. Various information is written in the routing table, the optimal path to the destination address is calculated by the routing algorithm, and then the data packet is sent by a relatively simple and direct forwarding mechanism. The next router that receives data continues to forward in the same way, and so on, until the data packet reaches the destination router.

There are also two different ways to maintain the routing table. One is the update of routing information. Some or all of the routing information is published. Routers learn the routing information from each other to master the topology of the entire network. This type of routing protocol is called the distance vector routing protocol; the other is The router broadcasts its own link state information, learns the routing information of the entire network through mutual learning, and then calculates the best forwarding path. This type of routing protocol is called the link state routing protocol.

Because routers need to do a lot of path calculation work, the working capacity of the general processor directly determines its performance. Of course, this judgment is still for low-end routers, because high-end routers often use distributed processing system design.

(3) Three-layer switching technology

In recent years, the promotion of the three-layer technology, the ear can pick up cocoons, and the three-layer technology is called everywhere. Some people say that this is a very new technology, and some people say that the three-layer switch is not the router and the two-layer switch Stacking, there is no new stuff, is this really the case? Let's take a look at the working process of Layer 3 switches through a simple network.


Networking is relatively simple

Equipment using IP A ------------------------ Layer 3 switch ------------------ ------ Device B using IP

For example, if A wants to send data to B and the destination IP is known, then A will use the subnet mask to obtain the network address and determine whether the destination IP is on the same network segment as himself.

If they are on the same network segment but do not know the MAC address required to forward the data, A sends an ARP request and B returns its MAC address. A uses this MAC to encapsulate the data packet and send it to the switch. The switch uses the Layer 2 switching module to find MAC address table, forward the data packet to the corresponding port.

If the destination IP address shows that it is not on the same network segment, then A has to communicate with B. If there is no corresponding MAC address entry in the flow cache entry, the first normal data packet is sent to a default gateway. This default gateway Generally set in the operating system, corresponding to the third layer routing module, so it can be seen that for data that is not the same subnet, the MAC address of the default gateway is first placed in the MAC table; then it is received by the layer 3 module This packet, querying the routing table to determine the route to B, will construct a new frame header, where the MAC address of the default gateway is the source MAC address and the MAC address of the host B is the destination MAC address. Through a certain recognition trigger mechanism, the correspondence between the MAC addresses of host A and B and the forwarding port is established, and recorded into the flow cache entry table. The subsequent data from A to B is directly handed over to the Layer 2 switching module. This is commonly referred to as a route for multiple forwarding.

The above is a brief summary of the working process of the layer 3 switch, and the characteristics of the layer 3 switch can be seen:
The combination of hardware realizes high-speed data forwarding.

This is not a simple superposition of Layer 2 switches and routers. Layer 3 routing modules are directly superimposed on the high-speed backplane bus of Layer 2 switches, which breaks through the interface rate limit of traditional routers and can reach tens of Gbit / s. Counting the backplane bandwidth, these are two important parameters of Layer 3 switch performance.

The simple routing software simplifies the routing process.

Most of the data forwarding, except the necessary routing is handled by the routing software, are two-layer module high-speed forwarding. Most of the routing software is processed and efficient optimization software, not simply copying the software in the router.

in conclusion

Layer 2 switches are used for small local area networks. It goes without saying that in small local area networks, broadcast packets have little effect. The fast switching function of Layer 2 switches, multiple access ports, and low prices provide a perfect solution for small network users.

The advantage of the router is that it has rich interface types, powerful three-layer functions, and powerful routing capabilities. It is suitable for routing between large networks. Its advantages are choosing the best route, load sharing, link backup, and routing with other networks. Routers have functions such as information exchange.

The most important function of the layer 3 switch is to speed up the fast forwarding of data within the large local area network. The addition of the routing function also serves this purpose. If the large network is divided into small local area networks according to factors such as department, region, etc., this will result in a large amount of Internet access. Simply using a Layer 2 switch cannot achieve Internet access; for example, using a router alone, due to the limited number of interfaces and The slow routing and forwarding speed will limit the speed and scale of the network, and the use of fast forwarding layer 3 switches with routing functions has become the first choice.

Generally speaking, in a network with large data traffic on the internal network and requiring fast forwarding of the response, if all the Layer 3 switches do this work, the Layer 3 switches will be overburdened and the response speed will be affected. It is done by the router to make full use of the advantages of different devices. It is a good networking strategy. Of course, the premise is that the customer's pockets are very strong, otherwise it will be the next best, so that the three-layer switch also serves as the Internet.

A simple definition of layer 4 switching is: it is a function that determines that the transmission is not only based on the MAC address (layer 2 bridge) or source / destination IP address (layer 3 routing), but also based on TCP / UDP ( Layer 4) Application port number. The Layer 4 switching function is like a virtual IP, pointing to the physical server. The services it transmits are subject to various protocols, including HTTP, FTP, NFS, Telnet, or other protocols. These services require complex load balancing algorithms based on physical servers. In the IP world, the service type is determined by the terminal TCP or UDP port address, and the application interval in the fourth layer exchange is determined by the source and terminal IP addresses, TCP and UDP ports.

In the fourth layer exchange, set up a virtual IP address (VIP) for each server group for search, each group of servers supports a certain application. Each application server address stored in a domain name server (DNS) is a VIP, not a real server address.

When a user applies for an application, a VIP connection request (such as a TCP SYN packet) with the target server group is sent to the server switch. The server switch selects the best server in the group, replaces the VIP in the terminal address with the IP of the actual server, and transmits the connection request to the server. In this way, all packets in the same interval are mapped by the server switch and transmitted between the user and the same server.

Principle of Layer 4 switching

The fourth layer of the OSI model is the transport layer. The transport layer is responsible for end-to-end communication, that is, to coordinate communication between the network source and the target system. In the IP protocol stack, this is the protocol layer where TCP (a transport protocol) and UDP (user packet protocol) are located.

In the fourth layer, the TCP and UDP headers contain the port number (portnumber), they can uniquely distinguish which application protocol each packet contains (such as HTTP, FTP, etc.). The endpoint system uses this information to distinguish the data in the packet, especially the port number so that a receiving computer system can determine the type of IP packet it receives and give it to the appropriate high-level software. The combination of port number and device IP address is commonly referred to as a "socket". Port numbers between 1 and 255 are reserved, they are called "well-known" ports, that is, these port numbers are the same in all host TCP / IP protocol stack implementations. In addition to "well-known" ports, standard UNIX services are allocated in the 256 to 1024 port range, and custom applications are generally allocated port numbers above 1024. A recent list of allocated port numbers can be found on RFc1700 "Assigned Numbers". The additional information provided by the TCP / UDP port number can be used by network switches, which is the basis of layer 4 switching.

Examples of "well-known" port numbers:

Application protocol port number FTP 20 (data)
21 (Control)
TELNET 23
SMTP 25
HTTP 80
NNTP 119
NNMP 16
162 (SNMP traps)
The additional information provided by the TCP / UDP port number can be used by the network switch, which is the basis of the fourth layer exchange.

The switch with layer 4 functions can function as a "virtual IP" (VIP) front end connected to the server.

Each server and server group supporting a single or universal application are configured with a VIP address. This VIP address is sent out and registered on the domain name system.

When issuing a service request, the Layer 4 switch recognizes the start of a session by deciding on the start of TCP. It then uses sophisticated algorithms to determine the best server to handle this request. Once this decision is made, the switch associates the session with a specific IP address and replaces the VIP address on the server with the server's real IP address.

Each layer 4 switch maintains a connection table associated with the source IP address and source TCP port of the selected server. Then the layer 4 switch forwards the connection request to this server. All subsequent packets are remapped and forwarded between the client and server until the switch discovers the session.

In the case of using layer 4 switching, the access can be connected with a real server to meet the rules set by the user, such as making each server have an equal number of accesses or allocating transport streams according to the capacity of different servers.

How to choose the right layer 4 switch

a, speed

In order to be effective in enterprise networks, Layer 4 switching must provide comparable performance to Layer 3 wire-speed routers. That is, Layer 4 switching must operate at full media speed on all ports, even on multiple Gigabit Ethernet connections. Gigabit Ethernet speed is equal to routing at the maximum speed of 488000 packets per second (assuming the worst case, that is, all packets are the smallest size defined by the network and are 64 bytes long).

b, server capacity balancing algorithm


Depending on the desired capacity balance interval size, the layer 4 switch will allocate a variety of applications to the server. There are simple detection of the nearest connection of the loop, detection of the loop delay, or detection of the closed loop feedback of the server itself. In all predictions, closed-loop feedback provides the most accurate detection that reflects the server's existing traffic.

c, table capacity

It should be noted that a switch that performs Layer 4 switching needs to have the ability to distinguish and store a large number of transmission table entries. This is especially true when switches are at the core of an enterprise network. Many Layer 2 / Layer 3 switches tend to have a size that is proportional to the number of network devices. For Layer 4 switches, this number must be multiplied by the number of different application protocols and sessions used in the network. Therefore, the size of the transmission table increases rapidly with the increase in the number of endpoint devices and application types. Layer 4 switch designers need to consider this growth in the design of their products. Large meter capacity is critical for manufacturing high-performance switches that support wire-speed transmission of Layer 4 traffic.

d, redundancy

The layer 4 switch has the function of supporting redundant topology. When a fault-tolerant connection with a dual-link network card, it is possible to establish a completely redundant system from a server to the network card, link and server switch.

Need decoration for holiday, wedding, party & even light ideas? G-Lights offers a range of LED lighting to fit kinds of special need, no matter for indoor and outdoor requirement. Regular and customized product not only make bright and colorful, but also improve taste, design such as glow pole, firefly, light ball, bamboo, bubble tube, etc.

Easy installation and removal make the LED decoration lamps could be cyclic used. And the maintenance and repairment is not a hard work also. Just enjoy the beautiful effect.

LED Decoration Light

Decoration Lighting,Lighting Decoration,Restaurant Lighting Decoration,Wedding Lighting Decoration

ZHONGSHAN G-LIGHTS LIGHTING CO., LTD. , https://www.glightsled.com