Methods, devices, computer equipment, and storage media for testing the traffic of switches
By establishing a virtual LAN between the first and second ports of the switch, test traffic can be directly forwarded and received, and a self-loop working mode is adopted, which solves the problem of low efficiency in existing switch traffic testing and achieves more efficient and accurate testing.
Patent Information
- Application Number
- CN202310028225.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-09
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2043-01-09
AI Technical Summary
Existing methods for testing switch traffic are inefficient and need to be improved to increase testing efficiency.
By establishing a virtual LAN between the first and second ports of the switch, test traffic is directly forwarded and received, reducing the number of times test traffic is forwarded across all ports of the switch, and port testing is performed using a loopback mode.
It improves the efficiency and accuracy of switch traffic testing, reduces testing time, and lowers the probability of retesting due to equipment failure.
Smart Images

Figure CN116132325B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network application technology, and in particular to a method, apparatus, computer equipment, storage medium, and computer program product for testing the traffic of a switch. Background Technology
[0002] As the primary connection device in a local area network (LAN), the switch has become one of the fastest-growing network devices, widely used in various industries such as power, new energy, and transportation. With the continuous development of network technology, the requirements for switches are becoming increasingly stringent to ensure network security and data integrity, thus necessitating switch measurement and testing.
[0003] Existing methods for testing the traffic of switches involve serially connecting the port of the tester to the port of the switch. The traffic then passes through all the ports of the switch before returning to the tester, resulting in low testing efficiency. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, apparatus, computer equipment, computer-readable storage medium, and computer program product for testing the traffic of a switch, which can improve the efficiency of traffic testing of the switch, in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a method for testing the traffic of a switch. Applied in a test network, the test network includes a first switch and a measuring instrument connected to the first switch. The measuring instrument includes a first test port and a second test port. The method includes:
[0006] The test traffic sent by the first test port is received through the first port of the first switch, and the test traffic is forwarded to the second port of the first switch so that the test traffic is sent to the second test port via the second port of the first switch to obtain the first test data of the first switch; wherein, the first port and the second port of the first switch are in the same virtual local area network;
[0007] The test traffic sent by the second test port is received through the second port of the first switch, and the test traffic is forwarded to the first port of the first switch so that the test traffic is sent to the first test port through the first port, thereby obtaining the second test data of the first switch;
[0008] The test results of the first switch are determined based on the first test data and the second test data.
[0009] In one embodiment, the method further includes:
[0010] The test traffic is forwarded to the third port of the first switch, which is in the same virtual LAN as the first port of the first switch. This allows the third port of the first switch to forward the test traffic to adjacent ports of the first switch in a loopback mode until the last port stops forwarding, thus obtaining the number of packets received by the last port of the first switch. The loopback mode is implemented using a loopback module.
[0011] In one embodiment, the first test data includes the number of packets received by the first port of the first switch, the number of packets sent by the second port of the first switch, the number of packets sent by the first test port, and the number of packets received by the second test port; the second test data includes the number of packets received by the second port of the first switch, the number of packets sent by the first port of the first switch, the number of packets received by the first test port, and the number of packets sent by the second test port; and determining the test result of the first switch based on the first test data and the second test data includes:
[0012] If the number of packets received by the first port of the first switch is equal to the number of packets sent by the second port of the first switch, the number of packets sent by the first test port is equal to the number of packets received by the second test port, the number of packets received by the second port of the first switch is equal to the number of packets sent by the first port of the first switch, and the number of packets received by the first test port is equal to the number of packets sent by the second test port, then the first switch is determined to have passed the test.
[0013] In one embodiment, before determining that the first switch test has passed, the method further includes:
[0014] Determine whether the number of packets received by the first port of the first switch is equal to the number of packets received by the last port;
[0015] If the number of packets received by the first port of the first switch is equal to the number of packets received by the last port, then the first switch is determined to have passed the test.
[0016] In one embodiment, the test network includes a second switch connected to the first switch, which forwards the test traffic to a second port of the first switch, so that the test traffic is sent to the second test port via the second port of the first switch, including:
[0017] The test traffic is forwarded to the second port of the first switch, and then forwarded to the first port of the second switch through the second port of the first switch, so that the first port of the second switch forwards the test traffic to the second port of the second switch, and then the test traffic is sent to the second test port through the second port of the second switch; the first port of the second switch and the second port of the second switch are in the same virtual local area network.
[0018] In one embodiment, receiving the test traffic sent by the second test port through the second port of the first switch includes:
[0019] The second port of the first switch receives test traffic sent by the first port of the second switch; the test traffic is received by the second port of the second switch from the test traffic sent by the second test port and forwarded to the first port of the second switch.
[0020] The test traffic is forwarded to the first port of the first switch through the second port of the first switch.
[0021] In one embodiment, the method further includes:
[0022] The test traffic is forwarded to the second port of the first switch, then forwarded to the first port of the second switch via the second port of the first switch, and then forwarded to the second port and the third port of the second switch via the first port of the second switch, so that the third port of the second switch forwards the test traffic to the adjacent ports of the second switch in the loopback mode until the last port ends the forwarding; wherein the third port of the second switch and the first port of the second switch are in the same virtual LAN.
[0023] Secondly, this application also provides a traffic testing device for a switch. It is applied in a test network, the test network including a first switch and a measuring instrument connected to the first switch. The measuring instrument includes a first test port and a second test port. The device includes:
[0024] The traffic transceiver module is used to receive test traffic sent by the first test port through the first port of the first switch, and forward the test traffic to the second port of the first switch, so that the test traffic is sent to the second test port via the second port of the first switch to obtain the first test data of the first switch; wherein, the first port and the second port of the first switch are in the same virtual local area network.
[0025] The test traffic sent by the second test port is received through the second port of the first switch, and the test traffic is forwarded to the first port of the first switch so that the test traffic is sent to the first test port through the first port, thereby obtaining the second test data of the first switch;
[0026] The traffic testing module is used to determine the test results of the first switch based on the first test data and the second test data.
[0027] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0028] The test traffic sent by the first test port of the measuring instrument is received through the first port of the first switch, and the test traffic is forwarded to the second port of the first switch so that the test traffic is sent to the second test port of the measuring instrument via the second port of the first switch to obtain the first test data of the first switch; wherein, the first port and the second port of the first switch are in the same virtual local area network.
[0029] The test traffic sent by the second test port is received through the second port of the first switch, and the test traffic is forwarded to the first port of the first switch so that the test traffic is sent to the first test port through the first port, thereby obtaining the second test data of the first switch;
[0030] The test results of the first switch are determined based on the first test data and the second test data.
[0031] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0032] The test traffic sent by the first test port of the measuring instrument is received through the first port of the first switch, and the test traffic is forwarded to the second port of the first switch so that the test traffic is sent to the second test port of the measuring instrument via the second port of the first switch to obtain the first test data of the first switch; wherein, the first port and the second port of the first switch are in the same virtual local area network.
[0033] The test traffic sent by the second test port is received through the second port of the first switch, and the test traffic is forwarded to the first port of the first switch so that the test traffic is sent to the first test port through the first port, thereby obtaining the second test data of the first switch;
[0034] The test results of the first switch are determined based on the first test data and the second test data.
[0035] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0036] The test traffic sent by the first test port of the measuring instrument is received through the first port of the first switch, and the test traffic is forwarded to the second port of the first switch so that the test traffic is sent to the second test port of the measuring instrument via the second port of the first switch to obtain the first test data of the first switch; wherein, the first port and the second port of the first switch are in the same virtual local area network.
[0037] The test traffic sent by the second test port is received through the second port of the first switch, and the test traffic is forwarded to the first port of the first switch so that the test traffic is sent to the first test port through the first port, thereby obtaining the second test data of the first switch;
[0038] The test results of the first switch are determined based on the first test data and the second test data.
[0039] The aforementioned traffic testing method, apparatus, computer equipment, storage medium, and computer program product for switches, in the switch test network, receive test traffic sent by a first test port through a first port of a first switch, and the first port directly forwards the test traffic to a second port of the first switch to obtain first test data; and receive test traffic sent by a second test port through a second port of the first switch, and forward the test traffic directly to the first port of the first switch to obtain second test data. This eliminates the need for test traffic to be forwarded through all ports of the first switch before returning to the second test port, and also eliminates the need for test traffic to be forwarded through all ports of the first switch before returning to the first test port, thus reducing test time and improving test efficiency. Attached Figure Description
[0040] Figure 1 This is a diagram illustrating the application environment of a traffic testing method for a switch in one embodiment.
[0041] Figure 2 This is a flowchart illustrating a traffic testing method for a switch in one embodiment;
[0042] Figure 3 This is a flowchart illustrating the steps for determining the test results of the first switch in one embodiment.
[0043] Figure 4 This is a flowchart illustrating a traffic testing method for a switch, as shown in another embodiment.
[0044] Figure 5 This is a schematic diagram illustrating an application scenario of a traffic testing method for a switch in one embodiment;
[0045] Figure 6 This is a structural block diagram of a flow testing device for a switch in one embodiment;
[0046] Figure 7 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0048] The traffic testing method for switches provided in this application embodiment can be applied to, for example... Figure 1 The application environment shown. Figure 1The application environment shown includes at least one switch 102, a serial port server 104, a measuring instrument 106, and a terminal 108. The switch, serial port server, and measuring instrument are connected, and the serial port server, measuring instrument, and terminal are connected respectively. The measuring instrument includes a first test port and a second test port. It receives test traffic sent from the first test port of the first switch through the first port and forwards the test traffic to the second port of the first switch, so that the test traffic is sent from the second port to the second test port, obtaining the first test data of the first switch. The first and second ports of the first switch are in the same virtual local area network (VLAN). It receives test traffic sent from the second test port through the second port of the first switch and forwards the test traffic to the first port of the first switch, so that the test traffic is sent from the first port to the first test port, obtaining the second test data of the first switch. The first and second test data are sent to the terminal, and the test result of the first switch is determined based on the first and second test results. A data storage system can store the data that the switch 102 needs to process. The data storage system can be integrated on the switch 102 or placed in the cloud or on another network server. The switch 102 can be, but is not limited to, various types of switches, and the terminal can be, but is not limited to, personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. The serial port server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0049] It is understandable that "first" and "second" are only used to distinguish different objects. For example, the first test port and the second test port are used to distinguish different test ports. The first test port can also be called the second test port, and the second test port can also be called the first test port.
[0050] In one embodiment, such as Figure 2 As shown, a method for testing the traffic of a switch is provided, which can be applied to... Figure 1 Taking the application environment in [the document] as an example, the following steps are included:
[0051] Step 202: Receive the test traffic sent by the first test port through the first port of the first switch, and forward the test traffic to the second port of the first switch, so that the test traffic is sent to the second test port through the second port of the first switch, and obtain the first test data of the first switch.
[0052] In this setup, the first port and the second port of the first switch are in the same virtual LAN. It's understandable that ports belonging to the same VLAN can be directly accessed, while ports belonging to different VLANs cannot. Performing traffic tests on the switch can detect packet loss during data transmission and reception, ensuring the reliability of data transmission.
[0053] The number of ports in a switch can be configured according to actual needs. In this embodiment, 64 ports are used for illustration. The first and second ports use cables for data transmission, while ports three through sixty-four use a loopback mode. Loopback mode means that traffic received from the current port is forwarded out and then comes back in through the current port. This means that the number of packets received and sent at the current port can be obtained. The number of received and sent packets can be understood as the number of received messages and the number of sent messages, respectively. Figure 3 The diagram shown is a schematic of a switch in one embodiment. Before testing, each port of the switch is pre-configured to ensure the reliability and efficiency of the test. Taking a switch with 64 ports as an example, each port is configured with allowed VLANs. The first port (port1) of the switch is configured with VLAN 1, VLAN 2, and pvlan1; the second port (port2) is configured with VLAN 1, VLAN 2, and pvlan2; the third port (port3) is configured with VLAN 1, VLAN 3, and pvlan3; the fourth port (port4) is configured with VLAN 3, VLAN 4, and pvlan4; the fifth port (port5) is configured with VLAN 4, VLAN 5, and pvlan5, and so on. The sixty-third port (port63) is configured with VLAN 62, VLAN 63, and pvlan63; and the sixty-fourth port (port64) is configured with VLAN 63, VLAN 64, and pvlan64.
[0054] Test traffic can be understood as packets or frames broadcast by the measuring instrument through the first test port. Test traffic does not carry a virtual LAN tag. The first test data includes the number of packets received by the first port of the first switch, the number of packets sent by the second port of the first switch, the number of packets sent by the first test port, the number of packets received by the sixty-fourth port of the first switch, and the number of packets received by the second test port.
[0055] Specifically, after receiving test traffic, the first port of the first switch will send it to the second and third ports within the same virtual network. If there is only one switch under test, the test traffic will be sent to the second test port of the measuring instrument through the second port of the first switch to obtain the first test data of the first switch. It is not necessary to traverse the switch from the third port to the second port via the sixty-fourth port to obtain the first test data. Furthermore, under normal circumstances, the traffic of the switch can be tested by measuring the number of packets sent and received on the first and second ports of the first switch.
[0056] Step 204: Receive the test traffic sent by the second test port through the second port of the first switch, and forward the test traffic to the first port of the first switch so that the test traffic is sent to the first test port through the first port, thereby obtaining the second test data of the first switch.
[0057] The second test data includes the number of packets received by the second port of the first switch, the number of packets sent by the first port of the first switch, the number of packets received by the first test port, and the number of packets sent by the second test port.
[0058] Furthermore, to ensure the accuracy of the switch traffic test, a reverse traffic test is performed on the first switch. Test traffic is sent through the second test port of the tester, and the test traffic sent from the second test port is received through the second port of the first switch. The test traffic is then forwarded to the first port of the first switch, so that the test traffic is sent from the first port to the first test port, thus obtaining the second test data of the first switch.
[0059] Step 206: Determine the test results of the first switch based on the first test data and the second test data.
[0060] Specifically, based on the number of packets received by the first port of the first switch, the number of packets sent by the second port of the first switch, the number of packets sent by the first test port and the number of packets received by the second test port of the first switch in the first test data, and the number of packets received by the second port of the first switch, the number of packets sent by the first port of the first switch, the number of packets received by the first test port and the number of packets sent by the second test port of the first switch in the second test data, the test result of the first switch is determined based on the first test data and the second test data.
[0061] In the above embodiments, in the test network of the switch, the test traffic sent by the first test port is received through the first port of the first switch, and the test traffic is directly forwarded to the second port of the first switch through the first port and sent back to the second test port to obtain the first test data; the test traffic sent by the second test port is received through the second port of the first switch, and the test traffic is directly forwarded to the first port of the first switch through the second port and sent back to the first test port to obtain the second test data. It is not necessary for the test traffic to be forwarded to all ports of the first switch before returning to the second test port, nor is it necessary for the test traffic to be forwarded to all ports of the first switch before returning to the first test port, which reduces the test time and improves the test efficiency.
[0062] Furthermore, during traffic testing on the first switch, in order to more accurately obtain the test results for each port of the first switch.
[0063] In one embodiment, test traffic is copied through the first port of the first switch and forwarded to the third port of the first switch, which is in the same virtual LAN as the first port of the first switch. This allows the third port of the first switch to operate in a loopback mode, forwarding the test traffic to adjacent ports of the first switch until the last port finishes forwarding, thus obtaining the number of packets received by the last port of the first switch. The loopback mode is implemented using a loopback module, where the ports of the loopback module send packets before receiving them. By utilizing the loopback mode on the ports of the first switch, traffic testing can be performed on ports with loopback operation. It is understood that in this embodiment, when the last port receives the forwarded test packets, it finds that the packets have no destination port to forward to.
[0064] In one embodiment, the test result of the first switch is determined based on the first test data and the second test data, such as... Figure 3 As shown, it includes the following steps:
[0065] Step 302: If the number of packets received by the first port of the first switch is equal to the number of packets sent by the second port of the first switch, the number of packets sent by the first test port is equal to the number of packets received by the second test port, the number of packets received by the second port of the first switch is equal to the number of packets sent by the first port of the first switch, and the number of packets received by the first test port is equal to the number of packets sent by the second test port, then proceed to step 304.
[0066] Step 304: Determine whether the number of packets received by the first port of the first switch is equal to the number of packets received by the last port.
[0067] Step 306: If the number of packets received by the first port of the first switch is equal to the number of packets received by the last port, then the first switch is confirmed to have passed the test.
[0068] Specifically, if the number of packets received on the first port of the first switch is equal to the number of packets received on the last port, then the first switch is considered to have passed the test; otherwise, there is an anomaly. The corresponding ports can be tested based on the number of packets sent and received on the ports of the first switch to obtain the test results for each port, thereby improving the efficiency of fault location and the pass rate of retesting after repair.
[0069] In the above embodiments, when testing the traffic of a single switch, closed-loop detection is performed by sending test traffic to the switch in both forward and reverse directions, and based on the number of packets received at the first port of the first switch, the number of packets sent at the second port of the first switch, the number of packets sent at the first test port and the number of packets received at the second test port, the number of packets received at the second port of the first switch, the number of packets sent at the first port of the first switch, the number of packets received at the first test port and the number of packets sent at the second test port, and the number of packets received at the last port of the switch. This improves the efficiency and accuracy of traffic testing. It is understandable that actual switch testing takes a long time. To improve testing efficiency, multiple switches are tested. Currently, traffic testing of multiple switches is performed by cascading them together, resulting in low testing efficiency.
[0070] In another embodiment, such as Figure 4 As shown, a method for testing the traffic of a switch is provided. The test network includes a second switch connected to a first switch, and this method is applied to... Figure 1 Taking the application environment in [the document] as an example, the following steps are included:
[0071] Step 402: Receive the test traffic sent by the first test port through the first port of the first switch.
[0072] Step 404: Forward the test traffic to the second port of the first switch, and then forward the test traffic to the first port of the second switch through the second port of the first switch, so that the first port of the second switch forwards the test traffic to the second port of the second switch, and then sends the test traffic to the second test port through the second port of the second switch to obtain the first test data of the second switch.
[0073] In this configuration, the first port of the second switch and the second port of the second switch are in the same virtual LAN. The first test data of the second switch includes the number of packets received by the first port of the second switch, the number of packets sent by the second port of the second switch, the number of packets sent by the first test port, and the number of packets received by the second test port.
[0074] Specifically, the test traffic is forwarded to the second port of the first switch, then forwarded from the second port of the first switch to the first port of the second switch, and so on. The test traffic is then sent from the second port of the second switch to the second test port, thus obtaining the first test data from the second switch. It is understood that the testing principles of the second switch and the first switch are the same. If the test network includes a second switch connected to the first switch, the first test data from the first switch will also be obtained.
[0075] Step 406: Forward the test traffic to the second port of the first switch, then forward the test traffic to the first port of the second switch via the second port of the first switch, and then forward it to the second port of the second switch and the third port of the second switch, so that the third port of the second switch forwards the test traffic to the adjacent ports of the second switch in the self-loop working mode until the last port ends the forwarding.
[0076] The third port of the second switch and the first port of the second switch are in the same virtual local area network.
[0077] Specifically, when performing traffic tests on the first and second switches, test traffic sent from the first test port is received through the first port of the first switch. The test traffic is then forwarded through the first port to the second and third ports of the first switch. Within the first switch, the third port, operating in a loopback mode, forwards the test traffic to adjacent ports until the last port finishes forwarding, thus obtaining the number of packets received at the last port of the first switch. The traffic is then forwarded through the second port of the first switch to the first port of the second switch. The first port of the second switch performs the same steps as the first port of the first switch. The traffic test is then completed through the third port of the second switch. Finally, the test traffic is sent from the second port of the second switch to the second test port, obtaining the first test data of both the first and second switches. The first test data of the second switch includes the number of packets received at the first port of the second switch, the number of packets sent at the second port of the second switch, the number of packets sent at the first test port, and the number of packets received at the second test port.
[0078] It is understandable that while testing the first switch and obtaining the first test data of the first switch, the first test data of the second switch will also be obtained.
[0079] Step 408: The second port of the first switch receives the test traffic sent by the first port of the second switch; wherein, the test traffic is received by the second port of the second switch from the test traffic sent by the second test port and forwarded to the first port of the second switch.
[0080] Step 410: Forward the test traffic to the first port of the first switch through the second port of the first switch, so that the test traffic is sent to the first test port through the first port and the second test data of the second switch is obtained.
[0081] The second test data includes the number of packets received by the second port of the second switch, the number of packets sent by the first port of the second switch, the number of packets received by the first test port, and the number of packets sent by the second test port.
[0082] Specifically,
[0083] The test traffic is forwarded from the first port of the second switch to the second port of the first switch. When the second port of the first switch receives the test traffic sent from the first port of the second switch, it forwards the test traffic back to the first port of the first switch through the second port of the first switch, so that the test traffic is sent to the first test port via the first port, and the second test data of the second switch is obtained. Similarly, the second test data of the first switch can also be obtained.
[0084] Step 412: Determine the test result of the second switch based on the first test data and the second test data of the second switch.
[0085] Furthermore, when determining the test result of the second switch based on the first test data and the second test data of the second switch, the test result of the first switch can also be determined based on the first test data and the second test data of the first switch.
[0086] For example, the test network includes an (n+1)th switch connected to the nth switch. The test traffic sent by the first test port is received through the first port of the nth switch. The test traffic is forwarded to the first port of the (n+1)th switch through the second port of the nth switch, and then forwarded to the second port and the third port of the nth switch. This allows the third port of the nth switch to forward the test traffic to the adjacent ports of the nth switch in a loopback mode until the last port stops forwarding. This yields the number of packets sent and received by the port using the loopback module, the number of packets received by the first port of the nth switch, and the number of packets sent by the second port of the nth switch.
[0087] The test traffic is forwarded from the second port of the nth switch to the first port of the (n+1)th switch, so that the first port of the second switch forwards the test traffic to the second and third ports of the (n+1)th switch. The test traffic is then sent to the second test port via the second port of the second switch. In the loopback mode, the third port of the (n+1)th switch forwards the test traffic to the adjacent ports of the (n+1)th switch until the last port ends the forwarding. The number of packets sent and received by the port using the loopback module is obtained, as well as the number of packets received by the first port of the (n+1)th switch, the number of packets sent by the second port of the (n+1)th switch, the number of packets sent by the first test port, and the number of packets received by the second test port. To perform a reverse test on the switches, the test traffic sent from the second test port is received through the second port of the (n+1)th switch, and then forwarded to the first port of the (n+1)th switch. After being received again through the second port of the nth switch, the test traffic is forwarded to the first port of the nth switch, so that the test traffic is sent from the first port of the nth switch to the first test port. This allows us to obtain the number of packets received by the second port of the (n+1)th switch, the number of packets sent by the first port of the (n+1)th switch, the number of packets received by the first test port and the number of packets sent by the second test port, as well as the number of packets received by the second port of the nth switch and the number of packets sent by the first port of the nth switch. Based on the results of the forward and reverse tests, we can obtain the test results of the nth switch and the (n+1)th switch.
[0088] In the above embodiments, when the test network includes at least two switches, when testing the switches, the test traffic is forwarded to the next switch through a designated port of the previous switch to complete the measurement test of the next switch. It is not necessary to forward the test traffic to the next switch after traversing all ports of the previous switch. The failure of ports other than cascaded ports on the previous switch does not affect the testing of other switch devices, which greatly reduces the probability that other switches need to be retested due to the failure of one device, improves the testing efficiency and ensures the reliability of the test.
[0089] Understandably, in practical applications, multiple switches are tested simultaneously during testing. This means multiple switches are cascaded between the first and second switches to perform batch testing, improving testing efficiency. In one implementation, we will illustrate this by simultaneously testing three switches, such as... Figure 5As shown, a third switch, Switch B, is cascaded between the first switch (SwitchA) and the second switch (SwitchC). Switches A, C, and B are connected to a serial server via serial ports, and the server and terminals communicate via Ethernet ports. The first and second ports of each of the three switches (SwitchA, SwitchC, and SwitchB) can be considered cascade ports and are connected by cables. The remaining ports use loopback modules and do not require cable connections. Each switch can have up to 64 ports; the number can be preset according to actual needs and is not limited here.
[0090] The first port of the first switch receives test traffic sent from the first test port. The first port replicates the test traffic to the second and third ports of the first switch. Within the first switch, the test traffic is forwarded to the fourth port of the first switch via the third port in a loopback mode, obtaining the test data for the third port. The fourth port forwards the test traffic to the fifth port using the same operating mode as the third port, and so on, until the last port completes the loopback, ending the forwarding process and obtaining the packet count for the last port of the first switch. The first port of the first switch forwards the test traffic to the first port of the second switch via the second port. The testing principle of the second switch is the same as that of the first switch. The first port of the second switch replicates the test traffic to the second and third ports of the second switch. The traffic test on the remaining ports of the second switch is completed via the third port of the second switch. Finally, the replicated test traffic is forwarded to the first port of the third switch via the second port of the second switch, and the testing principle of the third switch is the same as that of the first switch. The test traffic is forwarded from the first port of the third switch to the second and third ports of the third switch respectively. The traffic test of the remaining ports in the third switch is completed through the third port of the third switch. The second port of the third switch forwards the test traffic to the second test port of the measuring instrument. The number of packets received by the first port of the first switch, the number of packets sent by the second port of the second switch, the number of packets sent by the first test port and the number of packets received by the second test port of the third switch, and the number of packets received by the last port of each switch can be obtained respectively.
[0091] The test traffic sent from the second test port is received through the second port of the third switch. The second port forwards the test traffic to the first port of the third switch. Following the above testing method, traffic tests are performed on the second and first switches respectively, and the number of packets received, sent, received, and sent by the second and second test ports of the first, second, and third switches are obtained respectively. For example, this explanation assumes that the first, second, and third switches have 64 ports. The measuring instrument's first test port TC1 sends test traffic without VLAN tags to switch A's first port 1 in the form of broadcast or unknown unicast messages. Switch A's first port 1, second port 2, and third port 3 are in the same VLAN. Test traffic received at first port 1 is forwarded out through third port 3. Third port 3 has a loopback module installed, so traffic leaving third port 3 returns through third port 3. Since the VLAN of third port 3 is the same as that of fourth port 4, traffic from third port 3 is forwarded to fourth port 4, and so on, until it reaches sixty-fourth port 64. Traffic in this direction terminates after looping at port 64. Since ports 1 and 2 are also in the same VLAN, traffic received at port 1 is forwarded out through port 2. Similarly, traffic reaches switch B's port 1, and then... When port 1 receives traffic, it will be copied into two copies. One copy will go out through port 3 and traverse all ports on this switch, and the other copy will go out through port 2. Similarly, when port 1 of switch C receives traffic, it will be copied into two copies. One copy will go out through port 3 and traverse all ports on this switch, and the other copy will be sent from port 2 to the second test port TC 2 of the measuring instrument.
[0092] The reverse traffic is sent from the second test port TC 2 to port 2 of switch C without VLAN tag. The VLAN of port 2 of switch C is the same as that of port 1, so the traffic goes out directly from port 1. Similarly, when port 2 of switch B receives the traffic, it goes out directly from port 1. When port 2 of switch A receives the traffic, it goes out directly from port 1. The test traffic is received by port 1 of TC.
[0093] The test results for the first, second, and third switches are determined based on the packet counts received at the first port, packet counts sent at the second port, packet counts sent at the first test port, and packet counts received at the second test port, as well as the packet count received at the last port of each switch. Similarly, the test results for the first, second, and third switches are determined by replicating and forwarding test traffic through the first or second port of each switch to other cascaded switches. This eliminates the need to replicate and forward test traffic through all ports of the previous switch to the next switch, or wait for the test traffic to return to the measuring instrument after passing through all switch ports. In other words, a failure on a port other than the cascade port will not affect the testing of other switch devices. Only the device that fails the test needs to be troubleshooted and retested, significantly reducing the probability of retesting other devices due to a single device failure and improving testing efficiency. It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0094] Based on the same inventive concept, this application also provides a switch traffic testing device for implementing the above-described switch traffic testing method. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations of one or more switch traffic testing device embodiments provided below can be found in the limitations of the switch traffic testing method described above, and will not be repeated here.
[0095] In one embodiment, such as Figure 6 As shown, a traffic testing device for a switch is provided, comprising: a traffic transceiver module 602 and a traffic testing module 604, wherein:
[0096] The traffic transceiver module 602 is used to receive test traffic sent from the first test port through the first port of the first switch, and forward the test traffic to the second port of the first switch, so that the test traffic is sent to the second test port through the second port of the first switch to obtain the first test data of the first switch; wherein, the first port and the second port of the first switch are in the same virtual local area network.
[0097] The test traffic sent by the second test port is received through the second port of the first switch, and the test traffic is forwarded to the first port of the first switch so that the test traffic is sent to the first test port through the first port, thereby obtaining the second test data of the first switch.
[0098] The traffic test module 604 is used to determine the test results of the first switch based on the first test data and the second test data.
[0099] In the above embodiments, in the test network of the switch, the test traffic sent by the first test port is received through the first port of the first switch, and the first port directly forwards the test traffic to the second port of the first switch to receive back the test traffic and obtain the first test data; the test traffic sent by the second test port is received through the second port of the first switch, and the test traffic is directly forwarded to the first port of the first switch to receive back the test traffic and obtain the second test data. It is not necessary for the test traffic to return to the second test port after going through all the ports of the first switch, nor is it necessary for the test traffic to return to the first test port after going through all the ports of the first switch, which reduces the test time and improves the test efficiency.
[0100] Optionally, in one embodiment, the traffic transceiver module 602 is further configured to forward the test traffic to the third port of the first switch, which is in the same virtual local area network as the first port of the first switch, so that the third port of the first switch forwards the test traffic to the adjacent ports of the first switch in a loopback mode until the last port ends forwarding, thereby obtaining the number of packets received by the last port of the first switch; wherein, the loopback mode is implemented by using a loopback module.
[0101] Optionally, in one embodiment, the traffic test module 604 is further configured to determine that the first switch has passed the test if the number of packets received by the first port of the first switch is equal to the number of packets sent by the second port of the first switch, the number of packets sent by the first test port is equal to the number of packets received by the second test port, the number of packets received by the second port of the first switch is equal to the number of packets sent by the first port of the first switch, and the number of packets received by the first test port is equal to the number of packets sent by the second test port.
[0102] Optionally, in one embodiment, the traffic test module 604 is further configured to determine whether the number of packets received by the first port of the first switch and the number of packets received by the last port are equal; if the number of packets received by the first port of the first switch and the number of packets received by the last port are equal, then the test of the first switch is determined to be passed.
[0103] Optionally, in one embodiment, the traffic transceiver module 602 is further configured to forward test traffic to the second port of the first switch, and forward test traffic to the first port of the second switch through the second port of the first switch, so that the first port of the second switch forwards test traffic to the second port of the second switch, and sends test traffic to the second test port through the second port of the second switch; the first port of the second switch and the second port of the second switch are in the same virtual local area network.
[0104] Optionally, in one embodiment, the traffic transceiver module 602 is further configured to receive test traffic sent by the first port of the second switch at the second port of the first switch; the test traffic is received by the second port of the second switch from the test traffic sent by the second test port and forwarded to the first port of the second switch;
[0105] The test traffic is forwarded to the first port of the first switch via the second port of the first switch.
[0106] Optionally, in one embodiment, the traffic transceiver module 602 is further configured to forward test traffic to a second port of a first switch, forward test traffic to a first port of a second switch via the second port of the first switch, and forward the test traffic to a second port of the second switch and a third port of the second switch via the first port of the second switch, so that the third port of the second switch forwards test traffic to adjacent ports of the second switch in a loopback mode until the last port ends forwarding; wherein the third port of the second switch and the first port of the second switch are in the same virtual local area network.
[0107] The modules in the aforementioned flow testing device for the switch can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0108] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a method for testing the flow of a switch. The display screen can be an LCD screen or an e-ink display screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0109] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0110] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0111] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0112] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0113] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0114] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0115] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0116] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for testing the traffic of a switch, applied in a test network, the test network comprising a first switch and a measuring instrument connected to the first switch, the measuring instrument comprising a first test port and a second test port, and at least one second switch connected to the first switch, characterized in that, The method includes: The first test traffic is received by the first test port through the first port of the first switch, and the first test traffic is forwarded to the second port of the first switch so that the first test traffic is sent to the second test port through the second port of the first switch to obtain the first test data of the first switch; wherein, the first port and the second port of the first switch are in the same virtual local area network. The second test traffic sent by the second test port is received through the second port of the first switch, and the second test traffic is forwarded to the first port of the first switch so that the test traffic is sent to the first test port via the first port to obtain the second test data of the first switch. The first test traffic is forwarded to the third port of the first switch, which is in the same virtual LAN as the first port of the first switch. This allows the third port of the first switch to forward the first test traffic to adjacent ports of the first switch in a loopback mode until the last port stops forwarding, thus obtaining the number of packets received by the last port of the first switch. The loopback mode is implemented using a loopback module. If the number of packets received by the first port of the first switch is equal to the number of packets sent by the second port of the first switch, the number of packets sent by the first test port is equal to the number of packets received by the second test port, the number of packets received by the second port of the first switch is equal to the number of packets sent by the first port of the first switch, the number of packets received by the first test port is equal to the number of packets sent by the second test port, and the number of packets received by the first port of the first switch is equal to the number of packets received by the last port, then the first switch is determined to have passed the test. In this process, the data is forwarded from the first switch to the first port of the second switch via the second port of the first switch. The testing principle of the second switch is the same as that of the first switch.
2. The method according to claim 1, characterized in that, The first test data includes the number of packets received by the first port of the first switch, the number of packets sent by the second port of the first switch, the number of packets sent by the first test port, and the number of packets received by the second test port. The second test data includes the number of packets received by the second port of the first switch, the number of packets sent by the first port of the first switch, the number of packets received by the first test port, and the number of packets sent by the second test port.
3. The method according to claim 1, characterized in that, The test network includes a second switch connected to the first switch, which forwards the first test traffic to a second port of the first switch, so that the first test traffic is sent to the second test port via the second port of the first switch, including: The first test traffic is forwarded to the second port of the first switch, and then forwarded to the first port of the second switch through the second port of the first switch, so that the first port of the second switch forwards the first test traffic to the second port of the second switch, and then sends the first test traffic to the second test port through the second port of the second switch; the first port of the second switch and the second port of the second switch are in the same virtual local area network.
4. The method according to claim 3, characterized in that, The step of receiving the test traffic sent by the second test port through the second port of the first switch includes: The second port of the first switch receives test traffic sent by the first port of the second switch; the test traffic is received by the second port of the second switch from the test traffic sent by the second test port and forwarded to the first port of the second switch. The test traffic is forwarded to the first port of the first switch through the second port of the first switch.
5. The method according to claim 3, characterized in that, The method further includes: The test traffic is forwarded to the second port of the first switch, then forwarded to the first port of the second switch via the second port of the first switch, and then forwarded to the second port and the third port of the second switch via the first port of the second switch, so that the third port of the second switch forwards the test traffic to the adjacent ports of the second switch in the loopback mode until the last port ends the forwarding; wherein the third port of the second switch and the first port of the second switch are in the same virtual LAN.
6. A flow testing device for a switch, characterized in that, The device includes: A traffic transceiver module is used to receive first test traffic sent from a first test port through a first port of a first switch, and forward the first test traffic to a second port of the first switch, so that the first test traffic is sent to the second test port via the second port of the first switch to obtain first test data of the first switch; wherein, the first port and the second port of the first switch are in the same virtual local area network; the first switch is connected to a measuring instrument, and the measuring instrument includes the first test port and the second test port. The second test traffic sent by the second test port is received through the second port of the first switch, and the second test traffic is forwarded to the first port of the first switch so that the second test traffic is sent to the first test port through the first port, thereby obtaining the second test data of the first switch; The traffic transceiver module is further configured to forward the first test traffic to the third port of the first switch, which is in the same virtual local area network as the first port of the first switch, so that the third port of the first switch forwards the first test traffic to the adjacent ports of the first switch in a loopback mode until the last port ends forwarding, thereby obtaining the number of packets received by the last port of the first switch; wherein, the loopback mode is implemented by using a loopback module. The traffic testing module is configured to determine that the first switch has passed the test if the number of packets received by the first port of the first switch is equal to the number of packets sent by the second port of the first switch, the number of packets sent by the first test port is equal to the number of packets received by the second test port, the number of packets received by the second port of the first switch is equal to the number of packets sent by the first port of the first switch, the number of packets received by the first test port is equal to the number of packets sent by the second test port, and the number of packets received by the first port of the first switch is equal to the number of packets received by the last port. In this process, the first switch forwards data to the first port of at least one second switch connected to the first switch via the second port of the first switch. The testing principle of the second switch is the same as that of the first switch.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Port test method and system for switch
CN111431766A
Shunting switch and testing device, system and method of switch
CN115426328A
System for testing switch stability
CN201226523Y