Virtual gateway test method and system, electronic equipment and storage medium

By setting test ports and building test packets on the test device, and using the routing table entries of the virtual gateway for testing, the problem of difficulty and low efficiency of the virtual gateway test is solved, and efficient forwarding function testing is achieved.

CN119676135AActive Publication Date: 2025-03-21CHINA TELECOM CLOUD TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411743023.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-03-21
Estimated Expiration
2044-11-29

AI Technical Summary

Technical Problem

In the prior art, the testing of virtual gateways is difficult and work-intensive, and the testing efficiency is low, especially in dedicated-line scenarios, complex testing environments need to be built.

Method used

By setting the first test port and the second test port on the test device, using the routing table entries of the virtual gateway to build the test packet and test policy, and performing message conversion and parsing, it is determined whether the forwarding function is normal.

Benefits of technology

The forwarding function test of the virtual gateway is realized on a test device, without manually configuring complex testing strategies, greatly reducing the difficulty and workload of testing and improving testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119676135A_ABST
    Figure CN119676135A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a virtual gateway testing method and system, electronic equipment and a storage medium, relates to the field of cloud computing networks, is applied to testing equipment comprising a first testing port and a second testing port, and comprises the steps that the first testing port is used for testing a virtual gateway based on a routing table item, and the second testing port is used for testing the virtual gateway based on the routing table item; constructing a first test message and a test strategy, and sending the first test message to the virtual gateway; the second test port receives a second test message sent by the virtual gateway; and the second test port receives and analyzes the second test message based on the receiving strategy, and outputs the first test result under the condition that the second test message meets the test condition. The test message and the test strategy are generated based on the routing table item through the first test port, and the test message is tested through the second test port, so that the test requirement can be met based on one test device, the test strategy does not need to be configured manually, the test efficiency is improved, and the test difficulty and workload are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of cloud computing networks, and in particular, to a testing method, system, electronic device, and storage medium for a virtual gateway. Background Art

[0002] Vgw (Virtual Gateway / Cloud Gateway) is a virtual gateway on a cloud computing node and an important node in the cloud computing network system. Its function is similar to Open vSwitch in the open source Open Stack. It is divided into a control plane and a data plane. The control plane is responsible for issuing virtual machine network configurations, and the data plane is responsible for forwarding data packets. The virtual gateway Vgw mainly implements Layer 2 switching, Layer 3 routing, speed limiting, traffic monitoring, and data packet analysis for VMs (Virtual Machines) in Vpc (private network / virtual private cloud) networks.

[0003] The configuration test scheme of the Vgw cloud virtual gateway is mainly related to the configuration file test. According to the test function points, the configuration file is manually constructed. When testing the Vgw virtual gateway for dedicated line scenario traffic forwarding, it is necessary to build a dedicated line environment. Multiple devices and apply for related dedicated line resources are required to meet the test environment. In addition, the virtual intranet gateway in the cloud does not perceive the dedicated line type, which greatly increases the difficulty and workload of the test and reduces the test efficiency. Therefore, how to reduce the difficulty and workload of virtual gateway testing and improve test efficiency has become a problem that needs to be solved urgently in this field. Summary of the invention

[0004] The embodiments of the present application provide a method, system, electronic device and storage medium for testing a virtual gateway, aiming to solve the problem of how to reduce the difficulty and workload of testing the virtual gateway and improve the testing efficiency.

[0005] A first aspect of an embodiment of the present application provides a method for testing a virtual gateway, which is applied to a test device including a first test port and a second test port, and the method includes:

[0006] The first test port constructs a first test message and a test strategy based on the routing table entry of the virtual gateway, and sends the first test message to the virtual gateway, wherein the test strategy at least includes a receiving strategy;

[0007] The second test port receives a second test message sent by the virtual gateway, where the second test message is obtained by the virtual gateway performing message conversion based on the first test message;

[0008] The second test port receives and parses the second test message based on the receiving strategy, and determines whether the second test message meets the test condition;

[0009] When the second test message meets the test condition, a first test result is output, where the first test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is normal.

[0010] In an optional implementation, the determining whether the second test message meets a test condition includes:

[0011] Within a preset time after the first test port sends the first test message to the virtual gateway, the second test port continuously captures packets of the second test message to obtain the number of packets of the second test message;

[0012] Based on the routing table entry and the second test message, obtain key fields of the second test message, where the key fields at least include an outer key field, an inner key field, and a specific information key field;

[0013] Based on the number of the second test message and the key field of the second test message, it is determined whether the second test message meets the test condition.

[0014] In an optional implementation manner, the determining whether the second test message satisfies the test condition based on the number of messages of the second test message and a key field of the second test message includes:

[0015] Based on the filtering rules in the receiving strategy, matching the key fields of the second test message with the key fields corresponding to the first test message and the routing table entry respectively;

[0016] When the number of packets in the second test packet is equal to the number of packets in the first test packet and is not 0, and the key field of the first test packet is the same as the key fields corresponding to the second test packet and the routing table entry respectively, it is determined that the second test packet meets the test condition.

[0017] In an optional implementation, after determining whether the second test message meets the test condition, the method further includes:

[0018] If the second test message does not meet the test condition, a third test result is output, and the third test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is abnormal, wherein:

[0019] When the number of messages in the second test message is 0, or the number of messages in the second test message is not equal to the number of messages in the first test message and is not 0, or the key field of the second test message is different from the key fields corresponding to the first test message and / or the routing table entry, it is determined that the second test message does not meet the test condition.

[0020] In an optional implementation, the test strategy further includes a response rule and a conversion strategy. After outputting the first test result, the method further includes:

[0021] When the reply rule matches the second test message, the second test port constructs a third test message based on the conversion strategy, the routing table entry and the second test message, and sends the third test message to the virtual gateway;

[0022] The first test port receives a fourth test message sent by the virtual gateway, where the fourth test message is obtained by the virtual gateway performing message conversion based on the third test message;

[0023] The first test port receives and parses the fourth test message based on the receiving strategy, and determines whether the fourth test message meets the test condition based on the message number and key fields of the fourth test message;

[0024] When the fourth test message meets the test condition, a second test result is output, where the second test result is used to indicate that the forwarding function of the virtual gateway for the second data transmission direction is normal, and the second transmission direction is opposite to the first transmission direction.

[0025] A second aspect of an embodiment of the present application provides a method for testing a virtual gateway, which is applied to a virtual gateway, and the method includes:

[0026] Receiving a first test message sent by a first test port;

[0027] Based on the routing table entry, judging the first test message;

[0028] When the first test message matches the routing table entry, performing message conversion on the first test message to obtain a second test message;

[0029] Send the second test message to the second test port.

[0030] In an optional implementation manner, after sending the second test message to the second test port, the method further includes:

[0031] Receiving a third test message sent by the second test port;

[0032] Based on the routing table entry, judging the third test message;

[0033] In a case where the third test message matches the routing table entry, performing message conversion on the third test message to obtain a fourth test message;

[0034] Sending the fourth test message to the first test port.

[0035] A third aspect of an embodiment of the present application provides a virtual gateway testing system, the system comprising a virtual gateway and a testing device, the testing device comprising a first test port and a second test port;

[0036] The first test port is used to construct a first test message and a test strategy based on the routing table entry of the virtual gateway, and send the first test message to the virtual gateway, wherein the test strategy at least includes a receiving strategy;

[0037] The virtual gateway is used to judge the first test message based on the routing table entry; if the first test message matches the routing table entry, perform message conversion on the first test message to obtain a second test message; and send the second test message to the second test port;

[0038] The second test port is used to receive and parse the second test message based on the receiving strategy, and determine whether the second test message meets the test conditions; if the second test message meets the test conditions, output a first test result, and the first test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is normal.

[0039] A fourth aspect of an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the virtual gateway testing method described in any one of the first aspect of the embodiment of the present application, or the processor executes the computer program to implement the steps of the virtual gateway testing method described in any one of the second aspect of the embodiment of the present application.

[0040] A fifth aspect of an embodiment of the present application provides a computer-readable storage medium having a computer program / instruction stored thereon. When the computer program / instruction is executed by a processor, the steps of the virtual gateway testing method described in any one of the first aspect of the embodiment of the present application are implemented; or, when the computer program / instruction is executed by a processor, the steps of the virtual gateway testing method described in any one of the second aspect of the embodiment of the present application are implemented.

[0041] A sixth aspect of an embodiment of the present application provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the virtual gateway testing method described in any one of the first aspect of the embodiment of the present application, or, when executed by a processor, implements the steps of the virtual gateway testing method described in any one of the second aspect of the embodiment of the present application.

[0042] Beneficial effects:

[0043] The embodiment of the present application provides a test method, system, electronic device and storage medium for a virtual gateway, which is applied to a test device including a first test port and a second test port, and the method includes: the first test port constructs a first test message and a test strategy based on the routing table of the virtual gateway, and sends the first test message to the virtual gateway, and the test strategy at least includes a receiving strategy; the second test port receives the second test message sent by the virtual gateway, and the second test message is obtained by the virtual gateway performing message conversion based on the first test message; the second test port receives and parses the second test message based on the receiving strategy, and determines whether the second test message meets the test condition; if the second test message meets the test condition, a first test result is output, and the first test result is used to characterize that the forwarding function of the virtual gateway for the first data transmission direction is normal. The present application generates a test message and a test strategy based on the routing table of the virtual gateway by the first test port of the test device, and tests the test message forwarded by the virtual gateway through the second test port, so that the test requirements can be met based on one test device, and there is no need to manually configure the test strategy, which greatly improves the test efficiency and effectively reduces the test difficulty and workload. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0045] Figure 1 It is a schematic diagram of the steps of a test method for a virtual gateway applied to a test device side proposed in an embodiment of the present application;

[0046] Figure 2 It is a schematic diagram of the steps of a method for testing a virtual gateway applied to a virtual gateway side proposed in an embodiment of the present application;

[0047] Figure 3 It is a schematic diagram of a test flow of executing a first data transmission direction and a second data transmission direction in a test method for a virtual gateway proposed in an embodiment of the present application;

[0048] Figure 4 It is a structural diagram of a test device for a virtual gateway applied to a test device side proposed in an embodiment of the present application;

[0049] Figure 5 It is a structural diagram of a virtual gateway testing device applied to a virtual gateway side proposed in an embodiment of the present application;

[0050] Figure 6 It is a schematic diagram of an electronic device proposed in an embodiment of the present application. DETAILED DESCRIPTION

[0051] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0052] Vgw (Virtual Gateway / Cloud Gateway) is a virtual gateway on a cloud computing node and an important node in the cloud computing network system. Its function is similar to Open vSwitch in the open source Open Stack. It is divided into a control plane and a data plane. The control plane is responsible for issuing virtual machine network configurations, and the data plane is responsible for forwarding data packets. The virtual gateway Vgw mainly implements Layer 2 switching, Layer 3 routing, speed limiting, traffic monitoring, and data packet analysis for VMs (Virtual Machines) in Vpc (private network / virtual private cloud) networks.

[0053] In the related technology, the configuration test scheme of the Vgw cloud virtual gateway is mainly related to the configuration file test. According to the test function point, the configuration file is manually constructed. When testing the Vgw virtual gateway for dedicated line scenario traffic forwarding, it is necessary to build a dedicated line environment. Multiple devices and apply for related dedicated line resources are required to meet the test environment. In addition, the virtual intranet gateway in the cloud does not perceive the dedicated line type, which greatly increases the difficulty and workload of the test and reduces the test efficiency. Therefore, how to reduce the difficulty and workload of the virtual gateway test and improve the test efficiency has become a problem that needs to be solved urgently in this field.

[0054] In view of this, the present application embodiment proposes a method for testing a virtual gateway. Figure 1A schematic diagram of a test method for a virtual gateway applied to a test device side according to an embodiment of the present application is shown. Figure 1 As shown, the method comprises the following steps:

[0055] S101. The first test port constructs a first test message and a test strategy based on a routing table entry of a virtual gateway, and sends the first test message to the virtual gateway, where the test strategy at least includes a receiving strategy.

[0056] S102: The second test port receives a second test message sent by the virtual gateway, where the second test message is obtained by the virtual gateway performing message conversion based on the first test message.

[0057] S103: The second test port receives and parses the second test message based on the receiving strategy, and determines whether the second test message meets a test condition.

[0058] S104: When the second test message meets the test condition, output a first test result, where the first test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is normal.

[0059] In the embodiment of the present application, the test device is used to detect whether the traffic forwarding function of the virtual gateway Vgw device to the cloud network and the dedicated line scenario is normal; the virtual gateway Vgw device refers to the virtual intranet gateway in the cloud, which is responsible for the communication between the Vpc network and the cloud and the communication between Vpcs. Vpc refers to (Virtual Private Cloud). Vpc is used to provide users with a logically isolated area and build a secure, reliable, configurable and manageable virtual network environment. Vpc can form an on-demand customized network environment with traditional data centers through dedicated line / VPN and other connection methods.

[0060] In an embodiment of the present application, the test device includes a first test port and a second test port, and one of the first test port and the second test port acts as a sender of a data message in a certain data transmission direction in the test process of the virtual gateway, and the other acts as a receiver of a data message in the test process of the virtual gateway, wherein the data transmission process is forwarded by the virtual gateway to be tested, thereby completing the test of the forwarding function of the virtual gateway to be tested based on the first test port and the second test port. In an embodiment of the present application, the forwarding function of the virtual gateway to be tested is tested by using two test ports of a test device, without the need to build a dedicated line environment for the test, and without multiple devices acting as data sending devices and data receiving devices respectively and applying for related dedicated line resources to meet the required test environment, thereby greatly saving test resources and reducing the difficulty and workload of the test.

[0061] In an embodiment of the present application, the forwarding function of the virtual gateway in the first data transmission direction is tested, and the first data transmission direction refers to the data transmission direction from the Vpc network in the cloud to the dedicated line environment outside the cloud. In this scenario, the first test port corresponds to the Vpc network in the cloud, which is used to send data packets, and the second test port corresponds to the dedicated line environment outside the cloud, which is used to receive data packets. Specifically, the first test port obtains the routing table entry of the virtual gateway, and the routing table entry is used to characterize the key data structure used to store and forward network traffic in the network device. It consists of multiple key fields and has functions such as path selection, load balancing and fault recovery. Subsequently, based on the routing table entry of the virtual gateway, a first test message and a test strategy are constructed, and the first test message is sent to the virtual gateway. Exemplarily, the first test port can construct a data message in the VXLAN message format based on the routing table entry based on the scapy tool as the first test message. Among them, the first test message includes a key field, and the key field is used for the second test port to receive the data message. After receiving the data message, based on whether the key fields of the data message before and after forwarding by the virtual gateway meet expectations, it is determined whether the forwarding function of the virtual gateway is normal.

[0062] In an embodiment of the present application, the test strategy is an expected test strategy set based on the routing table entry of the virtual gateway before the first test port sends the first test message, and is configured so that the second test port of the test device automatically performs test functions such as message reception, testing, and backflow based on the test strategy. The embodiment of the present application generates the test strategy based on the routing table entry and automatically completes the test process based on the test strategy, thereby avoiding the manual construction of the configuration file required for the test, greatly improving the test efficiency and reducing the workload. Specifically, the test strategy includes at least a receiving strategy, a reply rule, and a conversion strategy. The receiving strategy is used to configure the second test port to receive the data message forwarded by the virtual gateway; the reply rule is used to configure the second test port to determine whether the data message forwarded by the virtual gateway needs to be replied; the conversion strategy is used to configure the second test port to construct a data message for reply.

[0063] In some optional implementations, the key fields in the first test message include an outer layer (underlay layer) key field, an inner layer (overlay layer) key field, and a specific information key field, wherein the outer layer key field includes a source IP and a destination IP, the source IP is the IP address of the first test port of the test device, and the destination IP is the VIP configured for the Vgw device of the virtual gateway; the inner layer key field includes the VNI field of the first data message in the VXLAN message format, the source MAC, destination MAC, source IP, and destination IP of the inner layer (overlay layer); the specific information key field includes the transport layer content (select whether it is an ICMP, UDP, or TCP message) and the specific information carried (such as the TCP / UDP port number, the type code of the ICMP message, etc.).

[0064] In an embodiment of the present application, the second test port receives a second test message sent by the virtual gateway, where the second test message is obtained by the virtual gateway through message conversion based on the first test message; the second test port receives and parses the second test message based on the receiving strategy, and determines whether the second test message meets the test conditions. Specifically, within a preset time period after the first test port sends the first test message to the virtual gateway, the second test port continuously captures packets of the second test message to obtain the number of packets of the second test message; based on the routing table entry and the second test message, obtains the key fields of the second test message, the key fields at least including an outer key field, an inner key field and a specific information key field; based on the number of packets of the second test message and the key fields of the second test message, determines whether the second test message meets the test condition, wherein, when the second test port determines that the second test message meets the test condition based on the number of packets and the key fields, it indicates that there is no abnormality in the number and content of the message data forwarded by the virtual gateway, proving that the forwarding function of the virtual gateway along the first data transmission direction is normal; on the contrary, when the second test port determines that the second test message does not meet the test condition based on the number of packets and the key fields, it indicates that there is an abnormality in the number and / or content of the message data forwarded by the virtual gateway, proving that the forwarding function of the virtual gateway along the first data transmission direction is abnormal.

[0065] In some optional implementations, the determination of whether the second test message meets the test condition based on the number of messages in the second test message and the key field of the second test message is performed according to the following steps: based on the filtering rules in the receiving strategy, the key fields of the second test message are matched with the first test message and the key fields corresponding to the routing table items. Exemplarily, the second test message is a VXLAN message, and the filtering rules are set according to the second test message sent and the routing table item to be tested on the Vgw device of the virtual gateway, and the VNI in the key field of the received VXLAN message, the source MAC, the destination MAC, the source IP, and the destination I in the key fields of the inner layer of the message are matched. P and transport layer content (such as message type, TCP / UDP port number or ICMP message type code, etc.), if the key fields of the second test message are the same as the first test message and the key fields corresponding to the routing table items respectively (wherein the key fields of the source MAC and the destination MAC of the second test message will change according to the routing table item of the virtual gateway, so the key fields of the source MAC and the destination MAC are the fields corresponding to the routing table item, and the other fields of the second test message are the key fields corresponding to the first test message), it means that the key fields of the message will not change before and after forwarding by the virtual gateway, indicating that there is no abnormality in the forwarding of the field content of the data message by the virtual gateway forwarding function.

[0066] Within a preset time after the first test port sends the first test message to the virtual gateway, the second test port continuously captures packets of the second test message to obtain the number of packets of the second test message. Exemplarily, the preset time may be 1 second. After obtaining the number of packets of the second test message, the number of packets of the first test message received by the virtual gateway is obtained, and the number of packets of the first test message is compared with the number of packets of the second test message. If the number of packets of the second test message is 0, it indicates that the second test port has not received the packet data forwarded by the virtual gateway, indicating that the forwarding function of the virtual gateway is abnormal; if the number of packets of the second test message is not equal to the data of the first test message and is not 0, it indicates that the virtual gateway has not correctly forwarded the packet data, resulting in redundancy or packet loss of the packet data, indicating that the forwarding function of the virtual gateway is abnormal; if the number of packets of the second test message is equal to the data of the first test message and is not 0, it indicates that the virtual gateway has correctly forwarded the packet data, and the second test port has received the correct packet data, indicating that the forwarding function of the virtual gateway is normal.

[0067] In some optional implementations, when the number of packets in the second test packet is equal to the number of packets in the first test packet and is not 0, and the key fields of the first test packet are the same as the key fields corresponding to the second test packet and the routing table entry, respectively, it is determined that the second test packet meets the test condition. When the second test packet meets the test condition, the test device outputs a first test result, and the first test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is normal.

[0068] In some optional implementations, when the number of packets of the second test packet is 0, or the number of packets of the second test packet is not equal to the number of packets of the first test packet and is not 0, or the key field of the second test packet is different from the key fields corresponding to the first test packet and the routing table entry, it is determined that the second test packet does not meet the test condition. When the second test packet does not meet the test condition, a third test result is output, and the third test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is abnormal.

[0069] Furthermore, when the second test message does not meet the test condition, if the number of messages of the second test message is 0, a first prompt message is output, and the first prompt message is used to indicate that the forwarding function of the virtual gateway has an abnormality in that traffic forwarding cannot be performed; if the number of messages of the second test message is not equal to the number of messages of the first test message and is not 0, a second prompt message is output, and the second prompt message is used to indicate that the forwarding function of the virtual gateway has an abnormality in that packet loss exists.

[0070] In some optional implementations, after outputting the first test result, it is necessary to determine whether the second test message needs to be replied, and if the second test message needs to be replied, the forwarding function of the virtual gateway in the second data transmission direction is tested, and the second data transmission direction refers to the data transmission direction from the dedicated line environment outside the cloud to the Vpc network within the cloud. In this scenario, the first test port corresponds to the Vpc network within the cloud, which is used to receive data packets, and the second test port corresponds to the dedicated line environment outside the cloud, which is used to send data packets.

[0071] Specifically, the second test port obtains the reply policy in the test policy, and the second test port determines that the second test message needs to be replied when the reply rule matches the second test message; then, based on the conversion policy in the test policy, the routing table item and the second test message, a third test message is constructed, and the third test message is sent to the virtual gateway; the first test port receives a fourth test message sent by the virtual gateway, and the fourth test message is obtained by the virtual gateway performing message conversion based on the third test message; the first test port receives and parses the fourth test message based on the receiving policy, and determines whether the fourth test message meets the test condition based on the message number and key field of the fourth test message; if the fourth test message meets the test condition, a second test result is output, and the second test result is used to indicate that the forwarding function of the virtual gateway for the second data transmission direction is normal, and the second transmission direction is opposite to the first transmission direction. If the message number and key field of the captured fourth test message do not meet the test condition, the fourth test result is output, and the fourth test result is used to indicate that the forwarding function of the virtual gateway for the second data transmission direction is abnormal.

[0072] It should be noted that the test process of the first test port for the fourth test message is the same as the test process of the second test port for the second test message. For details of the specific test process, please refer to the above-mentioned test process for the second test message, and the embodiment of the present application will not be repeated here.

[0073] In the embodiment of the present application, the forwarding function of the virtual gateway in two relative data transmission directions is tested through the first test port and the second test port on the test device. Compared with the simple flow device packet test which can only test the traffic in one direction at a time, the embodiment of the present application realizes the forwarding test of the return traffic of the Vgw device of the virtual gateway, which can more fully cover the test scenarios.

[0074] Based on the same inventive concept, the embodiment of the present application provides a virtual gateway testing method, which is applied to the virtual gateway. Figure 2 A schematic diagram of the steps of a test method for a virtual gateway applied to a virtual gateway side proposed in an embodiment of the present application is shown. Figure 2 As shown, the method comprises the following steps:

[0075] S201: Receive a first test message sent by a first test port.

[0076] S202: Based on the routing table entry, judge the first test message.

[0077] S203: When the first test message matches the routing table entry, perform message conversion on the first test message to obtain a second test message.

[0078] S204: Send the second test message to the second test port.

[0079] In some optional implementations, after sending the second test message to the second test port, the method further includes: receiving a third test message sent by the second test port; judging the third test message based on the routing table entry; when the third test message matches the routing table entry, performing message conversion on the third test message to obtain a fourth test message; and sending the fourth test message to the first test port.

[0080] In order to enable those skilled in the art to better understand the technical solution of a virtual gateway testing method proposed in the embodiment of the present application, Figure 3 A schematic diagram of a test flow for executing a first data transmission direction and a second data transmission direction in a test method for a virtual gateway proposed in an embodiment of the present application is shown. Figure 3 The specific embodiments are described in detail.

[0081] The test device is a Vgw tester, which tests the function of the Vgw device of the virtual gateway to forward ICMP request messages in the data transmission direction from the Vpc network in the cloud to the dedicated line environment outside the cloud. Specifically, the relevant routing table items and test strategies related to the VPC network in the cloud to the dedicated line side network and the dedicated line side network to the VPC network in the cloud are configured on the Vgw device of the virtual gateway; on the first test port of the test device, according to the relevant table items configured on the Vgw device of the virtual gateway and the determined test strategy and traffic test direction, a VXLAN message with an inner layer message of an ICMP request message is constructed using the scapy module as the first test message, wherein the first test message construction rule of the first test port is as follows:

[0082] The test device calls the python scapy module to fill and construct the outer (underlay layer) key field IP layer with the IP address of the first test port and the IP address of the virtual gateway, wherein the MAC layer of the outer (underlay layer) is automatically filled with the outer (underlay layer) Ethernet layer information by the three-layer packet sending function of the scapy module according to the routing table to find the route. The destination port number of the outer transport layer udp message layer is fixed to 4768, and the source port number is randomly generated; the vni field of the VXLAN layer is filled with the VNI of the VPC network in the cloud that needs to be tested on the VGW device; the Ethernet layer and IP layer information in the inner (overlay layer) key field are filled with the MAC and IP information set in the routing table item information that needs to be tested on the VGW device of the virtual gateway; the transport layer is filled with ICMP messages according to the test strategy, and the type and code of the ICMP message are filled with 8 and 0 respectively; the identifier and sequence number fields are randomly generated by the test device and filled with legal fields.

[0083] After obtaining the first test message, the first test port sends the first test message to the Vgw device of the virtual gateway. After receiving the first test message, the virtual gateway processes the first test message according to the routing table entry, obtains the second test message and forwards it back to the second test port of the test device.

[0084] The second test port calls the python scapy module to capture packets according to the filtering rules within 1 second after the first test port sends the first test message, and the filtering rules are set to UDP messages in the incoming direction and the destination port number of the UDP message is 4789; then the captured VXLAN message is matched to determine whether the key fields and the number of messages of the message data meet expectations respectively. The matching method of the key fields is that the test device calls the assertion function to match the captured message with the pre-set message rules. The key fields that need to be matched include the VNI of the VXLAN message, the source MAC of the VXLAN message (overlay layer), the destination MAC, the source IP, the destination IP, and the identifier and sequence number of the ICMP request message, whether they are consistent with the pre-set ones.

[0085] If it is determined that the second test message meets the test condition, the second test message is determined to be an expected message, and a corresponding first test result is generated. At the same time, if the second test message requires a reply, the test device replies to the second test message and performs a forwarding function test of the virtual gateway for the second data transmission direction; conversely, if it is detected that the second test message does not meet the test condition, a third test result is output and the process is terminated directly.

[0086] In the case that the second test message needs a reply, the second test port calls the python scapy module to construct a VXLAN message, obtains a third test message and sends it to the VGW device of the virtual gateway, wherein the key fields in the third test message of the VXLAN message are of the same type as the key fields of the first test message, and the filling rules can be found in the construction process of the first test message. The specific key fields of the third test message are as follows: the destination port number of the outer transport layer UDP message layer is fixed to 4768, and the source port number is randomly generated; the vni field of the VXLAN layer is filled with the VNI of the dedicated line network to be tested on the VGW device; the inner layer of the VXLAN message (overlay The source mac and destination mac of the Ethernet layer (layer) are filled with the destination mac and source mac of the inner Ethernet layer of the received VXLAN message, respectively. The source IP and destination IP of the IP layer of the inner layer (overlay layer) of the VXLAN message are filled with the destination IP and source IP of the inner IP layer of the received VXLAN message, respectively. The transport layer message type of the inner layer (overlay layer) of the VXLAN message is set to ICMP message, and the type and code of the ICMP message are filled with 0 and 0 respectively. The identifier and sequence number fields are filled with the identifier and sequence number of the ICMP request message carried by the received VXLAN message, respectively.

[0087] After the second test port completes constructing the third test message in the VXLAN message format, the third test message is sent to the virtual gateway; after receiving the third test message, the virtual gateway processes the third test message according to the routing table entry, obtains the fourth test message and forwards it back to the first test port of the test device.

[0088] The first test port calls the python scapy module to capture packets according to the filtering rules within 1 second after the second test port sends the third test message; then matches the captured VXLAN message to determine whether the key fields and the number of messages of the message data meet the expectations. If the number of messages and the key fields of the captured fourth test message meet the test and conditions, a second test result is generated; if the number of messages and the key fields of the captured fourth test message do not meet the test conditions, the fourth test result is output.

[0089] The embodiment of the present application provides a test method, system, electronic device and storage medium for a virtual gateway, which is applied to a test device including a first test port and a second test port, and the method includes: the first test port constructs a first test message and a test strategy based on the routing table of the virtual gateway, and sends the first test message to the virtual gateway, and the test strategy at least includes a receiving strategy; the second test port receives the second test message sent by the virtual gateway, and the second test message is obtained by the virtual gateway performing message conversion based on the first test message; the second test port receives and parses the second test message based on the receiving strategy, and determines whether the second test message meets the test condition; if the second test message meets the test condition, a first test result is output, and the first test result is used to characterize that the forwarding function of the virtual gateway for the first data transmission direction is normal. The present application generates a test message and a test strategy based on the routing table of the virtual gateway by the first test port of the test device, and tests the test message forwarded by the virtual gateway through the second test port, so that the test requirements can be met based on one test device, and there is no need to manually configure the test strategy, which greatly improves the test efficiency and effectively reduces the test difficulty and workload.

[0090] Based on the same inventive concept, an embodiment of the present application discloses a test system for a virtual gateway, the system comprising a virtual gateway and a test device, the test device comprising a first test port and a second test port;

[0091] The first test port is used to construct a first test message and a test strategy based on the routing table entry of the virtual gateway, and send the first test message to the virtual gateway, wherein the test strategy at least includes a receiving strategy;

[0092] The virtual gateway is used to judge the first test message based on the routing table entry; if the first test message matches the routing table entry, perform message conversion on the first test message to obtain a second test message; and send the second test message to the second test port;

[0093] The second test port is used to receive and parse the second test message based on the receiving strategy, and determine whether the second test message meets the test conditions; if the second test message meets the test conditions, output a first test result, and the first test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is normal.

[0094] Based on the same inventive concept, an embodiment of the present application discloses a test device for a virtual gateway, which is applied to a test device including a first test port and a second test port. Figure 4FIG. 1 shows a schematic diagram of a structure of a test device for a virtual gateway applied to a test device side, as proposed in an embodiment of the present application. Figure 4 As shown, the device comprises:

[0095] A first test message module, configured for the first test port to construct a first test message and a test strategy based on a routing table entry of a virtual gateway, and send the first test message to the virtual gateway, wherein the test strategy includes at least a receiving strategy;

[0096] A second test message receiving module, configured to receive, at the second test port, a second test message sent by the virtual gateway, wherein the second test message is obtained by the virtual gateway performing message conversion based on the first test message;

[0097] A first test module, configured for receiving and parsing the second test message by the second test port based on the receiving strategy, and determining whether the second test message meets a test condition;

[0098] The first result output module is used to output a first test result when the second test message meets the test condition, wherein the first test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is normal.

[0099] In an optional implementation, the first test module includes:

[0100] A first message number submodule, configured to, within a preset time period after the first test port sends the first test message to the virtual gateway, continuously capture packets of the second test message by the second test port to obtain the number of packets of the second test message;

[0101] A second key field submodule, configured to obtain key fields of the second test message based on the routing table entry and the second test message, wherein the key fields include at least an outer key field, an inner key field and a specific information key field;

[0102] The first test submodule is used to determine whether the second test message meets the test condition based on the number of messages in the second test message and a key field of the second test message.

[0103] In an optional implementation, the first test submodule includes:

[0104] A matching unit, configured to match the key fields of the second test message with the first test message and the corresponding key fields in the routing table entry based on the filtering rules in the receiving strategy;

[0105] The first test unit is used to determine that the second test message meets the test condition when the number of messages in the second test message is equal to the number of messages in the first test message and is not 0, and the key fields of the second test message are the same as the key fields corresponding to the first test message and the routing table entry respectively.

[0106] In an optional implementation, the first test submodule further includes:

[0107] The second test unit is used to output a third test result when the second test message does not meet the test condition, and the third test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is abnormal, wherein:

[0108] The third test unit is used to determine that the second test message does not meet the test condition when the number of messages in the second test message is 0, or the number of messages in the second test message is not equal to the number of messages in the first test message and is not 0, or the key field of the first test message is different from the key fields corresponding to the second test message and / or the routing table entry.

[0109] In an optional embodiment, the device further comprises:

[0110] A third test message module, configured for the second test port to construct a third test message based on the conversion strategy, the routing table entry and the second test message when the reply rule matches the second test message, and to send the third test message to the virtual gateway;

[0111] a fourth test message receiving module, configured to receive, through the first test port, a fourth test message sent by the virtual gateway, wherein the fourth test message is obtained by the virtual gateway through message conversion based on the third test message;

[0112] A second test module, configured for the first test port to receive and parse the fourth test message based on the receiving strategy, and to determine whether the fourth test message meets the test condition based on the message number and key fields of the fourth test message;

[0113] The second result output module is used to output a second test result when the fourth test message meets the test condition, wherein the second test result is used to indicate that the forwarding function of the virtual gateway for the second data transmission direction is normal, and the second transmission direction is opposite to the first transmission direction.

[0114] Based on the same inventive concept, the embodiment of the present application provides a virtual gateway testing device, which is applied to the virtual gateway. Figure 5FIG. 1 shows a schematic diagram of a structure of a virtual gateway testing device applied to a virtual gateway side proposed in an embodiment of the present application. Figure 5 As shown, the device comprises:

[0115] A first test message receiving module, used for receiving a first test message sent by a first test port;

[0116] A first judgment module, used to judge the first test message based on the routing table entry;

[0117] A second test message module, configured to perform message conversion on the first test message to obtain a second test message when the first test message matches the routing table entry;

[0118] The first forwarding module is used to send the second test message to the second test port.

[0119] In an optional embodiment, the device further comprises:

[0120] A third test message receiving module, used for receiving a third test message sent by the second test port;

[0121] A second judgment module, used to judge the third test message based on the routing table entry;

[0122] a fourth test message module, configured to perform message conversion on the third test message to obtain a fourth test message when the third test message matches the routing table entry;

[0123] The second forwarding module is configured to send the fourth test message to the first test port.

[0124] Based on the same inventive concept, the present application embodiment discloses an electronic device, Figure 6 A schematic diagram of an electronic device proposed in an embodiment of the present application is shown, such as Figure 6 As shown, the electronic device 100 includes: a memory 110 and a processor 120, the memory 110 and the processor 120 are connected via a bus communication, the memory 110 stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set can be loaded and run on the processor 120 to implement the steps in the test method of the virtual gateway applied to the test device described in the embodiment of the present application, or to implement the steps in the test method of the virtual gateway applied to the virtual gateway described in the embodiment of the present application.

[0125] Based on the same inventive concept, an embodiment of the present application discloses a computer-readable storage medium, on which is stored at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement the steps in the test method of the virtual gateway applied to the test device described in the embodiment of the present application, or to implement the steps in the test method of the virtual gateway applied to the virtual gateway described in the embodiment of the present application.

[0126] Based on the same inventive concept, an embodiment of the present application discloses a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the test method for a virtual gateway applied to a test device described in the embodiment of the present application, or, when executed by a processor, implements the steps of the test method for a virtual gateway applied to a virtual gateway described in the embodiment of the present application.

[0127] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0128] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, apparatuses, electronic devices, and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0129] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0130] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0131] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.

[0132] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.

[0133] The above is a detailed introduction to the testing method, system, electronic device and storage medium of a virtual gateway provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of ​​the present application; at the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for testing a virtual gateway, characterized in that: Applied to a test device including a first test port and a second test port, the method comprises: The first test port constructs a first test message and a test strategy based on the routing table entry of the virtual gateway, and sends the first test message to the virtual gateway, wherein the test strategy at least includes a receiving strategy; The second test port receives a second test message sent by the virtual gateway, where the second test message is obtained by the virtual gateway performing message conversion based on the first test message; The second test port receives and parses the second test message based on the receiving strategy, and determines whether the second test message meets the test condition; When the second test message meets the test condition, a first test result is output, where the first test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is normal.

2. The method for testing a virtual gateway according to claim 1, characterized in that: The determining whether the second test message meets the test condition includes: Within a preset time after the first test port sends the first test message to the virtual gateway, the second test port continuously captures packets of the second test message to obtain the number of packets of the second test message; Based on the routing table entry and the second test message, obtain key fields of the second test message, where the key fields at least include an outer key field, an inner key field, and a specific information key field; Based on the number of the second test message and the key field of the second test message, it is determined whether the second test message meets the test condition.

3. The method for testing a virtual gateway according to claim 2, characterized in that: The judging, based on the number of packets of the second test packet and a key field of the second test packet, whether the second test packet satisfies the test condition includes: Based on the filtering rules in the receiving strategy, matching the key fields of the second test message with the key fields corresponding to the first test message and the routing table entry respectively; When the number of packets in the second test packet is equal to the number of packets in the first test packet and is not 0, and the key fields in the second test packet are the same as the key fields corresponding to the first test packet and the routing table entry respectively, it is determined that the second test packet meets the test condition.

4. The method for testing a virtual gateway according to claim 3, characterized in that: After determining whether the second test message meets the test condition, the method further includes: If the second test message does not meet the test condition, a third test result is output, and the third test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is abnormal, wherein: When the number of messages of the second test message is 0, or the number of messages of the second test message is not equal to the number of messages of the first test message and is not 0, or the key field of the first test message is different from the key fields corresponding to the second test message and / or the routing table entry, it is determined that the second test message does not meet the test condition.

5. The method for testing a virtual gateway according to claim 1, characterized in that: The test strategy also includes a response rule and a conversion strategy. After outputting the first test result, the method further includes: When the reply rule matches the second test message, the second test port constructs a third test message based on the conversion strategy, the routing table entry and the second test message, and sends the third test message to the virtual gateway; The first test port receives a fourth test message sent by the virtual gateway, where the fourth test message is obtained by the virtual gateway performing message conversion based on the third test message; The first test port receives and parses the fourth test message based on the receiving strategy, and determines whether the fourth test message meets the test condition based on the message number and key fields of the fourth test message; When the fourth test message meets the test condition, a second test result is output, where the second test result is used to indicate that the forwarding function of the virtual gateway for the second data transmission direction is normal, and the second transmission direction is opposite to the first transmission direction.

6. A method for testing a virtual gateway, characterized in that: Applied to a virtual gateway, the method includes: Receiving a first test message sent by a first test port; Based on the routing table entry, judging the first test message; When the first test message matches the routing table entry, performing message conversion on the first test message to obtain a second test message; Send the second test message to the second test port.

7. The method for testing a virtual gateway according to claim 6, characterized in that: After sending the second test message to the second test port, the method further includes: Receiving a third test message sent by the second test port; Based on the routing table entry, judging the third test message; In a case where the third test message matches the routing table entry, performing message conversion on the third test message to obtain a fourth test message; Sending the fourth test message to the first test port.

8. A virtual gateway testing system, characterized in that: The system includes a virtual gateway and a test device, wherein the test device includes a first test port and a second test port; The first test port is used to construct a first test message and a test strategy based on the routing table entry of the virtual gateway, and send the first test message to the virtual gateway, wherein the test strategy at least includes a receiving strategy; The virtual gateway is used to judge the first test message based on the routing table entry; When the first test message matches the routing table entry, performing message conversion on the first test message to obtain a second test message; Sending the second test message to the second test port; The second test port is used to receive and parse the second test message based on the receiving strategy, and determine whether the second test message meets the test condition; When the second test message meets the test condition, a first test result is output, where the first test result is used to indicate that the forwarding function of the virtual gateway for the first data transmission direction is normal.

9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps in the method for testing a virtual gateway as described in any one of claims 1 to 5, or the processor executes the computer program to implement the steps in the method for testing a virtual gateway as described in claim 6 or 7.

10. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instruction is executed by the processor, the steps in the virtual gateway testing method described in any one of claims 1-5 are implemented, or when the computer program / instruction is executed by the processor, the steps in the virtual gateway testing method described in claim 6 or 7 are implemented.

Citation Information

Patent Citations

  • Path diagnosis method for use in virtual gateway system and device thereof

    CN104753727A

  • Transmitting device, reflecting device and network performance testing method and system

    CN110891285A

  • Vehicle-mounted gateway test method and system and computer readable storage medium

    CN115242689A

  • Systems and methods for testing networks with a controller

    US20150138993A1

  • Two-way measurement control method, service transmitting apparatus and service receiving apparatus

    WO2017202177A1