Layer 2 switching technology is relatively mature. Layer 2 switches are data link layer equipment. They can identify the MAC address information in the data packet, forward them according to the MAC address, and record these MAC addresses and corresponding ports in an internal address table. The specific workflow is as follows:
(1) When the switch receives a data packet from a certain 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 package header and look for the corresponding port in the address table;
(3) If there is a port corresponding to this destination MAC address in the table, copy the data packet directly to this port;
(4) If the corresponding port cannot be found in the table, broadcast the data packet 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, there is no need to broadcast all ports. Through the continuous cycle, you can learn the MAC address information of the entire network. This is how the layer 2 switch establishes and maintains its own address table. From the working principle of the second layer switch, we can infer the following three points:
(1) Since the switch exchanges data on most ports simultaneously, this requires a very wide switch bus bandwidth. If the second layer switch has N ports, the bandwidth of each port is M, and the switch bus bandwidth exceeds N×M, then the switch can realize line-speed switching;
(2) Learn the MAC address of the machine connected to the port, write the address table, and the size of the address table (generally two ways of representation: one is BEFFER RAM and the other is the value of the MAC table entry). The size of the address table affects the access capacity of the switch;
(3) Another is that layer two switches generally contain an ASIC (Applicati on specific Integrated Circuit) chip specifically used to process packet forwarding, so the forwarding speed can be very fast. Since each manufacturer uses different ASICs, 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 comparing this when considering the selection of equipment.
Routing technology
The router operates at the third layer of the OSI model - the network layer. Its working mode is similar to that of the second layer exchange, but the router operates at the third layer. This difference determines that routing and exchange use different control information when passing packets, and the way of implementing functions 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, you should go there next step. If you can find the packet from the routing table, go there next step, and forward the link layer information; if you cannot know where the next step is going, discard the packet and return an information to the source address.
In essence, routing technology has only two functions: determining the optimal routing and forwarding packets. Various information is written in the routing table, the routing algorithm calculates the optimal path to reach the destination address, and then sends the data packets by a relatively simple and direct forwarding mechanism. The next router that accepts the data continues to forward in the same way, and so on, until the packet reaches the destination router.
There are two different ways to maintain routing tables. One is to update routing information, publish some or all of the routing information. By learning routing information from each other, the router masters the topology of the entire network. This type of routing protocol is called the distance vector routing protocol; the other is that the router broadcasts its own link state information, and masters the routing information from 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.
Since routers need to do a lot of path computing work, the working ability of general processors directly determines the performance advantages and disadvantages. Of course, this judgment is still for mid- and low-end routers, because high-end routers often adopt distributed processing system design.
Three-layer exchange technology
In recent years, the promotion of the third-layer technology can make your ears callous, and the third-layer technology is being called everywhere. Some people say that this is a very new technology, while others say that the third-layer switching is just a stack of routers and second-layer switches, and there is nothing new. Is this really the case? Let’s first look at the working process of the third-layer switch through a simple network.
Networking is simpler
Devices using IP A--------------------------------------------------------------------------------------------------------------------------
For example, if A wants to send data to B and has known the destination IP, then A uses the subnet mask to obtain the network address and determine whether the destination IP is on the same network segment as him. If you are in the same network segment but do not know the MAC address required to forward data, A will send an ARP request, B will return its MAC address, A will use this MAC to encapsulate the data packet and send it to the switch. The switch will use the Layer 2 switching module to find the MAC address table, and forward the data packet to the corresponding port.
If the destination IP address is not the same network segment, then A wants to communicate with B. If there is no corresponding MAC address entry in the stream cache entry, the first normal data packet will be sent to a default gateway. This default gateway is generally set up in the operating system and corresponds to the third layer routing module. Therefore, it can be seen that for data not the same subnet, the MAC address of the default gateway is first placed in the MAC table; then the third layer module receives this data packet, querys the routing table to determine the route to B, and a new frame header will be constructed, 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 identification trigger mechanism, the correspondence between the MAC address and forwarding port of host A and B is established, and the inflow cache entry table is recorded. The subsequent data from A to B is directly handed over to the second layer exchange module. This is usually called a route forwarding multiple times.
The above is a simple summary of the working process of the three-layer switch, which shows the characteristics of the three-layer switch:
High-speed forwarding of data is achieved through hardware combination
This is not a simple superposition of layer two switches and routers. The third-layer routing module is directly superimposed on the high-speed backplane bus of layer two switches, breaking through the interface rate limit of traditional routers, and the speed can reach dozens of Gbit/s. Including the backplane bandwidth, this
These are two important parameters of the performance of layer three switches.
Simple routing software simplifies the routing process
Most data forwarding, except for the necessary routing choices, is handled by the routing software, is forwarded at high speed with layer two modules. Most of the routing software is processed and efficient optimization software, not simply copying the software in the router.
The difference between the three exchange technologies
Layer 2 switches are used in small local area networks. There is no need to say more about this. In small LANs, broadcast packets have little impact. The fast switching function of layer 2 switches, multiple access ports and low-priced prices provide small network users with a very complete solution.
The advantages of a router are rich interface types, powerful layer three functions, and powerful routing capabilities. It is suitable for routing between large networks. Its advantages are the functions of routers that choose the best route, load sharing, link backup and exchange routing information with other networks.
The most important function of a layer three switch is to accelerate the rapid forwarding of data within a large local area network, and adding the routing function is also for this purpose. If large networks are divided into small local area networks according to department, region and other factors, this will lead to a large number of Internet access. Simply using Layer 2 switches cannot achieve Internet access; if you simply use a router, due to the limited number of interfaces and slow routing forwarding speed, the speed and network scale will be limited, and using a layer 3 switch with fast forwarding with routing functions will become the first choice.
Generally speaking, in networks where intranet data traffic is large and requires rapid forwarding and response, if all the Layer 3 switches do this work, it will cause excessive burden on the Layer 3 switches and affect the response speed. Leveraging the inter-network routes to the routers to complete, giving full play to the advantages of different devices is a good networking strategy. Of course, the premise is that the customer's pocket is very bulging, otherwise it will be second-rate, so that the Layer 3 switches are also interconnected.
A simple definition of Layer 4 exchange is that it is a function that determines that transmission is not only based on the MAC address (Layer 2 Bridge) or the source/destination IP address (Layer 3 routing), but also on the TCP/UDP (Layer 4) application port number. The fourth layer exchange function is like a virtual IP, pointing to a physical server. It transmits a variety of services that comply with, 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 address, TCP and UDP port.
In the fourth layer exchange, a virtual IP address (VIP) is set up for each server group for search, and each group of servers supports certain applications. 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 with the target server group (eg, a TCP SYN packet) 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 passes 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.
The principle of fourth layer exchange
The fourth layer of the OSI model is the transport layer. The transport layer is responsible for end-to-end communication, that is, coordinated 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) reside.
In the fourth layer, the TCP and UDP headers contain port numbers, which can uniquely distinguish which application protocols (such as HTTP, FTP, etc.) are included in each packet. Endpoint systems use this information to distinguish data in packets, especially port numbers, so that a receiving computer system can determine the type of IP packet it receives and hand it over to appropriate high-level software. A combination of port number and device IP address is usually called a "socket".
The port numbers between 1 and 255 are reserved, they are called "familiar" ports, that is, these port numbers are the same in all host TCP/IP protocol stack implementations. In addition to "familiar" ports, standard UNIX services are allocated in the range of ports 256 to 1024, and customized applications generally allocate port numbers above 1024. The latest list of allocated port numbers can be found on RFc1700 "Assigned Numbers". The additional information provided by the TCP/UDP port number can be utilized by network switches, which is the basis for Layer 4 switching. Examples of "familiar" 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 utilized by network switches, which is the basis for Layer 4 switching. Switches with layer 4 functions can function as a "virtual IP" (VIP) front-end connected to the server. Each server and server group that supports single or common applications are configured with a VIP address.
This VIP address is sent out and registered on the domain name system. When a service request is issued, the fourth layer switch recognizes the beginning of a session by determining the start of TCP. It then utilizes complex 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 uses the server's real IP address instead of the VIP address on the server.
Each Layer 4 switch holds a connection table associated with the selected server and the source TCP port. The fourth layer switch then forwards the connection request to the server. All subsequent packets are reinvested and forwarded between the client and the server until the switch discovers the session. In the case of using layer 4 switching, the access can be connected to the real server to satisfy user-designed rules such as having an equal number of accesses on each server or allocating the transport stream according to the capacity of the different servers.
How to choose the right fourth layer exchange
a. Speed
To be effective in enterprise networks, layer 4 switching must provide performance comparable to layer 3 line speed routers. That is, the Layer 4 switch must operate at full media speed on all ports, even on multiple Gigabit Ethernet connections. Gigabit Ethernet speed is equal to the maximum speed routing of 1488,000 packets per second (assuming the worst case, that is, all packets are the minimum size defined by the network, 64 bytes long).
b. Server capacity balance algorithm
Depending on the desired capacity balance interval size, there are many algorithms for the fourth layer switch to assign applications to the server, including simple detection of the closest connection of the loop, detection of the loop delay, or detection of the closed-loop feedback of the server itself. Of all predictions, closed-loop feedback provides the most accurate detection reflecting the server's existing traffic.
c. Table capacity
It should be noted that switches performing layer 4 switching need to have the ability to distinguish and store a large number of sending table entries. This is especially true when switches are at the heart of an enterprise network. Many second/third switches tend to send tables in a proportional way 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 sending table increases rapidly with the number of endpoint devices and application types. Layer 4 switch designers need to consider this growth in tables when designing their products. Large table capacity is crucial to manufacturing high-performance switches that support linear-speed transmission of layer 4 traffic.
d. Redundancy
The fourth layer switch has the function of supporting redundant topology. When a network card fault-tolerant connection with dual links, it is possible to establish a fully redundant system from one server to the network card, link and server switch.