A test method and system of a virtual gateway, an electronic device, and a storage medium
By constructing test packets and policies based on routing table entries on the test device, the test results of virtual gateway forwarding packets are automatically judged, solving the problems of high difficulty and low efficiency in virtual gateway testing, and realizing efficient forwarding function testing.
Patent Information
- Application Number
- CN202411743023.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2044-11-29
AI Technical Summary
In existing technologies, testing virtual gateways is difficult, labor-intensive, and inefficient, especially in dedicated line scenarios where it requires setting up a dedicated line environment and applying for resources, which increases the complexity of testing.
By constructing test packets and policies based on the routing table entries of the virtual gateway on the first test port of the test device, and using the second test port to receive and parse the packets forwarded by the virtual gateway, the system automatically determines whether the packets meet the test conditions and outputs the test results, thereby realizing automated testing of the forwarding function of the virtual gateway.
No manual configuration of testing strategies is required; the forwarding function test of the virtual gateway can be completed through a single testing device, reducing testing difficulty and workload and improving testing efficiency.
Smart Images

Figure CN119676135B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the field of cloud computing networks, in particular, to a virtual gateway testing method and system, an electronic device, and a storage medium. BACKGROUND
[0002] A Vgw (Virtual Gateway / Cloud Gateway) is a virtual gateway on a cloud computing node and is an important node in a cloud computing network system. The Vgw has a function similar to that of an Open vSwitch in an open source Open Stack and is divided into a control plane and a data plane. The control plane is responsible for the issuance of virtual machine network configurations, and the data plane is responsible for data packet forwarding. The virtual gateway Vgw mainly implements functions such as layer 2 switching, layer 3 routing, speed limiting, traffic monitoring, and data packet analysis of a VM (Virtual Machine) in a Vpc (Virtual Private Cloud).
[0003] The configuration test scheme of the Vgw cloud internal virtual gateway is mainly related to configuration file testing. According to the test function points, a configuration file is manually constructed, and a dedicated line environment needs to be built when the Vgw virtual gateway is applied to the dedicated line scenario traffic forwarding. Multiple devices and related dedicated line resources need to be applied to meet the test environment. Moreover, the virtual internal network gateway in the cloud does not perceive the dedicated line type, which greatly increases the test difficulty and workload and reduces the test efficiency. Therefore, how to reduce the test difficulty and workload of the virtual gateway and improve the test efficiency has become a problem to be solved in the field. SUMMARY
[0004] Embodiments of the present application provide a virtual gateway testing method and system, an electronic device, and a storage medium, aiming to solve the problem of how to reduce the test difficulty and workload of the virtual gateway and improve the test efficiency.
[0005] The first aspect of the embodiments of the present application provides a virtual gateway testing method applied to a test device including a first test port and a second test port. The method includes the following steps.
[0006] The first test port constructs a first test packet and a test strategy based on a routing table item of a virtual gateway and sends the first test packet to the virtual gateway. The test strategy at least includes a receiving strategy.
[0007] The second test port receives a second test packet sent by the virtual gateway. The second test packet is obtained by packet conversion of the virtual gateway based on the first test packet.
[0008] The second test port receives and parses the second test packet based on the receiving strategy, and judges whether the second test packet meets a test condition or not;
[0009] In a case where the second test packet meets the test condition, a first test result is output, and the first test result is used to represent that a forwarding function of the virtual gateway for a first data transmission direction is normal.
[0010] In an optional embodiment, the judging whether the second test packet meets the test condition or not comprises:
[0011] Within a preset time length after the first test port sends the first test packet to the virtual gateway, the second test port continuously captures the second test packet to obtain a packet number of the second test packet;
[0012] Based on the routing table item and the second test packet, a key field of the second test packet is obtained, and the key field at least comprises an outer key field, an inner key field and a specific information key field;
[0013] Based on the packet number of the second test packet and the key field of the second test packet, whether the second test packet meets the test condition or not is judged.
[0014] In an optional embodiment, the judging whether the second test packet meets the test condition or not based on the packet number of the second test packet and the key field of the second test packet comprises:
[0015] Based on a filtering rule in the receiving strategy, the key field of the second test packet is matched with respectively corresponding key fields of the first test packet and the routing table item;
[0016] In a case where the packet number of the second test packet is equal to the packet number of the first test packet and is not 0, and the key field of the first test packet is same as respectively corresponding key fields of the second test packet and the routing table item, it is determined that the second test packet meets the test condition.
[0017] In an optional embodiment, after judging whether the second test packet meets the test condition or not, the method further comprises:
[0018] In a case where the second test packet does not meet the test condition, a third test result is output, and the third test result is used to represent that the forwarding function of the virtual gateway for the first data transmission direction is not normal, wherein,
[0019] In a case that the number of the second test packet is 0, or the number of the second test packet is not equal to the number of the first test packet and is not 0, or the key field of the second test packet is different from the key field corresponding to the first test packet and / or the routing table item respectively, it is determined that the second test packet does not satisfy the test condition.
[0020] In an optional embodiment, the test strategy further comprises a reply rule and a conversion strategy, and after outputting the first test result, the method further comprises:
[0021] The second test port constructs a third test packet based on the reply rule, the conversion strategy, the routing table item and the second test packet, and sends the third test packet to the virtual gateway in a case that the reply rule matches the second test packet;
[0022] The first test port receives a fourth test packet sent by the virtual gateway, the fourth test packet being obtained by the virtual gateway based on the third test packet;
[0023] The first test port receives and analyzes the fourth test packet based on the receiving strategy, and judges whether the fourth test packet satisfies a test condition based on the number and the key field of the fourth test packet;
[0024] In a case that the fourth test packet satisfies the test condition, a second test result is outputted, the second test result being used to represent that the forwarding function of the virtual gateway for a second data transmission direction is normal, the second transmission direction being opposite to the first transmission direction.
[0025] The second aspect of the embodiments of the present application provides a test method of a virtual gateway, applied to a virtual gateway, the method comprising:
[0026] Receiving a first test packet sent by a first test port;
[0027] Judging the first test packet based on the routing table item;
[0028] In a case that the first test packet matches the routing table item, performing packet conversion on the first test packet to obtain a second test packet;
[0029] Sending the second test packet to a second test port.
[0030] In an optional embodiment, after sending the second test packet to the second test port, the method further comprises:
[0031] receive a third test packet sent by the second test port;
[0032] judge the third test packet based on the routing table entry;
[0033] perform packet conversion on the third test packet to obtain a fourth test packet in a case where the third test packet matches the routing table entry;
[0034] send the fourth test packet to the first test port.
[0035] A third aspect of the embodiment of the present application provides a test system of 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;
[0036] The first test port is configured to construct a first test packet and a test strategy based on a routing table entry of the virtual gateway, and send the first test packet to the virtual gateway, wherein the test strategy at least comprises a receiving strategy.
[0037] The virtual gateway is configured to judge the first test packet based on the routing table entry, and perform packet conversion on the first test packet to obtain a second test packet in a case where the first test packet matches the routing table entry, and send the second test packet to the second test port.
[0038] The second test port is configured to receive and analyze the second test packet based on the receiving strategy, and judge whether the second test packet satisfies a test condition, and output a first test result in a case where the second test packet satisfies the test condition, wherein the first test result is used to represent that a forwarding function of the virtual gateway for a first data transmission direction is normal.
[0039] A fourth aspect of the 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 in the test method of the virtual gateway according to any one of the first aspect of the embodiment of the present application, or the processor executes the computer program to implement the steps in the test method of the virtual gateway according to any one of the second aspect of the embodiment of the present application.
[0040] A fifth aspect of the embodiment of the present application provides a computer readable storage medium having a computer program / instruction stored thereon, wherein the computer program / instruction is executed by a processor to implement the steps in the test method of the virtual gateway according to any one of the first aspect of the embodiment of the present application, or the computer program / instruction is executed by the processor to implement the steps in the test method of the virtual gateway according to any one of the second aspect of the embodiment of the present application.
[0041] A sixth aspect of this application provides a computer program product, including a computer program / instruction that, when executed by a processor, implements the steps in the virtual gateway testing method described in any one of the first aspects of this application, or, when executed by a processor, implements the steps in the virtual gateway testing method described in any one of the second aspects of this application.
[0042] Beneficial effects:
[0043] This application provides a testing method, system, electronic device, and storage medium for a virtual gateway, applied to a testing device including a first test port and a second test port. The method includes: the first test port constructing a first test message and a test policy based on the routing table entries of the virtual gateway, and sending the first test message to the virtual gateway, the test policy including at least a receiving policy; the second test port receiving a second test message sent by the virtual gateway, the second test message being obtained by the virtual gateway through message conversion based on the first test message; the second test port receiving and parsing the second test message based on the receiving policy, and determining whether the second test message meets the test conditions; if the second test message meets the test conditions, outputting a first test result, the first test result being used to characterize that the forwarding function of the virtual gateway for a first data transmission direction is normal. This application generates test messages and test policies based on the routing table entries of the virtual gateway through the first test port of the testing device, and tests the test messages forwarded by the virtual gateway through the second test port, thereby meeting the testing requirements with a single testing device, and eliminating the need for manual configuration of test policies, greatly improving testing efficiency and effectively reducing testing difficulty and workload. Attached Figure Description
[0044] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0045] Figure 1 This is a flowchart illustrating the steps of a testing method for a virtual gateway applied to a test device, as proposed in an embodiment of this application.
[0046] Figure 2 This is a flowchart illustrating the steps of a testing method for a virtual gateway applied to the virtual gateway side according to an embodiment of this application;
[0047] Figure 3 This is a schematic diagram of the test process for executing the first data transmission direction and the second data transmission direction in a test method for a virtual gateway proposed in an embodiment of this application;
[0048] Figure 4 This is a schematic diagram of the structure of a test device for a virtual gateway applied to the test equipment side according to an embodiment of this application;
[0049] Figure 5 This is a schematic diagram of the structure of a test device for a virtual gateway applied to the virtual gateway side according to an embodiment of this application;
[0050] Figure 6 This is a schematic diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0051] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0052] A Virtual Gateway (VGW) is a virtual gateway on a cloud computing node and a crucial node in the cloud computing network system. Its function is similar to the Open vSwitch in the open-source OpenStack. It consists of a control plane and a data plane. The control plane is responsible for distributing virtual machine network configurations, while the data plane is responsible for forwarding data packets. The VGW primarily implements Layer 2 switching, Layer 3 routing, rate limiting, traffic monitoring, and packet analysis for VMs (Virtual Machines) in VPC (Virtual Private Cloud) networks.
[0053] In related technologies, the configuration testing scheme for VGW cloud virtual gateways mainly involves testing configuration files. Based on the test functionalities, configuration files are manually constructed. Testing the VGW virtual gateway's traffic forwarding capabilities in leased line scenarios requires setting up a leased line environment, necessitating multiple devices and the application of relevant leased line resources to meet the testing requirements. Furthermore, the cloud-based virtual intranet gateway is unaware of leased line types, significantly increasing testing difficulty and workload while reducing testing efficiency. Therefore, how to reduce the testing difficulty and workload of virtual gateways and improve testing efficiency has become a pressing issue in this field.
[0054] In view of this, embodiments of this application propose a testing method for virtual gateways. Figure 1This application provides a schematic flowchart illustrating the steps of a testing method for a virtual gateway applied to a test device, as proposed in one embodiment. Figure 1 As shown, the method includes the following steps:
[0055] S101. The first test port constructs a first test message and a test policy based on the routing table entry of the virtual gateway, and sends the first test message to the virtual gateway. The test policy includes at least a receiving policy.
[0056] S102, the second test port receives the second test message sent by the virtual gateway, the second test message being obtained by the virtual gateway through 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 the test conditions.
[0058] S104. If the second test message meets the test conditions, output the first test result. The first test result is used to characterize that the forwarding function of the virtual gateway for the first data transmission direction is normal.
[0059] In this embodiment, the testing device is used to test whether the traffic forwarding function of the virtual gateway (Vgw) device for cloud and dedicated line scenarios to the cloud network is normal. The virtual gateway (Vgw) device refers to a virtual intranet gateway in the cloud, which is responsible for communication between the VPC network and the cloud, as well as communication between VPCs. VPC stands for Virtual Private Cloud. VPC is used to provide users with a logically isolated area to 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 lines / VPNs and other connection methods.
[0060] In this embodiment, the test device includes a first test port and a second test port. In a certain data transmission direction during the testing process of the virtual gateway, one of the first test port and the second test port acts as the sender of data packets, and the other acts as the receiver of data packets. All data transmission processes involve forwarding data packets through the virtual gateway under test. Thus, the forwarding function of the virtual gateway under test is tested based on the first test port and the second test port. This embodiment achieves the testing of the forwarding function of the virtual gateway through two test ports of a single test device. It eliminates the need to build a dedicated line environment for testing, and avoids the need for multiple devices to act as data senders and receivers and to apply for dedicated line resources to meet the required testing environment. This significantly saves testing resources and reduces testing difficulty and workload.
[0061] In this embodiment, the forwarding function of the virtual gateway in the first data transmission direction is tested. The first data transmission direction refers to the data transmission direction from the cloud-internal VPC network to the external dedicated line environment. In this scenario, the first test port corresponds to the cloud-internal VPC network and is used to send data packets, while the second test port corresponds to the external dedicated line environment and is used to receive data packets. Specifically, the first test port obtains the routing table entry of the virtual gateway. The routing table entry is used to characterize the key data structure in the network device used for storing and forwarding network traffic. 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 packet and a test strategy are constructed, and the first test packet is sent to the virtual gateway. For example, the first test port can use the scapy tool to construct a VXLAN packet format data packet based on the routing table entry as the first test packet. The first test message includes key fields. These key fields are used by the second test port, which receives the data message, to determine whether the forwarding function of the virtual gateway is normal based on whether the key fields of the data message before and after forwarding by the virtual gateway meet expectations.
[0062] In this embodiment, the test strategy is the expected test strategy set by the first test port based on the routing table entry of the virtual gateway before sending the first test message. The second test port of the test device is configured to automatically perform test functions such as message reception, testing, and backhaul based on the test strategy. This embodiment generates the test strategy based on the routing table entry and automatically completes the test process based on the test strategy, avoiding the need to manually construct the configuration files required for testing, greatly improving test efficiency and reducing workload. Specifically, the test strategy includes at least a reception strategy, a response rule, and a conversion strategy. The reception strategy is used to configure the second test port to receive data packets forwarded by the virtual gateway; the response rule is used to configure the second test port to determine whether a response is needed for data packets forwarded by the virtual gateway; and the conversion strategy is used to configure the second test port to construct a data packet for response.
[0063] In some optional implementations, the key fields in the first test packet include outer (underlay layer) key fields, inner (overlay layer) key fields, and specific information key fields. The outer key fields include the source IP and destination IP, where the source IP is the IP address of the first test port of the test device, and the destination IP is the VIP configured on the VGW device of the virtual gateway. The inner key fields include the VNI field of the first data packet in VXLAN packet format, the source MAC, destination MAC, source IP, and destination IP of the inner (overlay layer). The specific information key fields include transport layer content (selected as ICMP, UDP, or TCP packet) and specific information carried (such as TCP / UDP port numbers, ICMP packet type codes, etc.).
[0064] In this embodiment of the application, the second test port receives a second test message sent by the virtual gateway. 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 policy, 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 in the second test message; based on the routing table entry and the second test message, the key fields of the second test message are obtained, the key fields including at least an outer key field, an inner key field, and a specific information key field; based on the number of packets in the second test message and the key fields of the second test message, it is determined whether the second test message meets the test conditions. If the second test port determines that the second test message meets the test conditions based on the number of packets and the key fields, it indicates that the quantity and content of the packet data forwarded by the virtual gateway are normal, proving that the forwarding function of the virtual gateway along the first data transmission direction is normal; conversely, if the second test port determines that the second test message does not meet the test conditions based on the number of packets and the key fields, it indicates that the quantity and / or content of the packet data forwarded by the virtual gateway are abnormal, 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 conditions based on the number of packets in the second test message and the key fields of the second test message is performed according to the following steps: Based on the filtering rules in the receiving policy, the key fields of the second test message are matched with the corresponding key fields in the first test message and the routing table entry. For example, the second test message is a VXLAN message, and the filtering rules are set according to the sent second test message and the routing table entry to be tested on the VGW device of the virtual gateway. The matching is performed on the VNI in the key fields of the received VXLAN message, and the source MAC, destination MAC, source IP, and destination IP in the inner key fields of the message. If the key fields of the second test packet are the same as those in the first test packet and the routing table entry (wherein, the key fields of the source MAC and destination MAC of the second test packet will change according to the routing table entry of the virtual gateway, so the key fields of the source MAC and destination MAC are the fields corresponding to the routing table entry, and the other fields of the second test packet are the key fields corresponding to the first test packet), it indicates that the key fields of the packet before and after forwarding by the virtual gateway will not change, indicating that the forwarding function of the virtual gateway for the field content of the data packet has not been abnormal.
[0066] 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 in the second test message. For example, the preset time period can be 1 second. After obtaining the number of packets in the second test message, the number of packets in the first test message received by the virtual gateway is obtained. The number of packets in the first test message is compared with the number of packets in the second test message. If the number of packets in the second test message is 0, it indicates that the second test port did not receive the packet data forwarded by the virtual gateway, indicating that the forwarding function of the virtual gateway is abnormal. If the number of packets in the second test message is not equal to and not 0 of the data in the first test message, it indicates that the virtual gateway did not forward the packet data correctly, resulting in packet data redundancy or packet loss, indicating that the forwarding function of the virtual gateway is abnormal. If the number of packets in the second test message is equal to and not 0 of the data in the first test message, it indicates that the virtual gateway forwarded the packet data correctly, and the second test port received the correct packet data, indicating that the forwarding function of the virtual gateway is normal.
[0067] In some optional implementations, if the number of packets in the second test packet is equal to and not zero in the number of packets in the first test packet, 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, then the second test packet is determined to meet the test conditions. If the second test packet meets the test conditions, the test device outputs a first test result, which characterizes that the forwarding function of the virtual gateway for the first data transmission direction is normal.
[0068] In some optional implementations, if the number of packets in the second test packet is 0, or if the number of packets in the second test packet is not equal to and not 0 compared to the number of packets in the first test packet, or if the key fields of the second test packet are different from the key fields corresponding to the first test packet and the routing table entry, then the second test packet is determined to not meet the test conditions. If the second test packet does not meet the test conditions, a third test result is output, which indicates that the forwarding function of the virtual gateway for the first data transmission direction is abnormal.
[0069] Furthermore, if the second test message does not meet the test conditions, and the number of packets in the second test message is 0, a first prompt message is output, which indicates that the forwarding function of the virtual gateway has an anomaly of traffic forwarding failure; if the number of packets in the second test message is not equal to the number of packets in the first test message and is not 0, a second prompt message is output, which indicates that the forwarding function of the virtual gateway has an anomaly of packet loss.
[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 to. If the second test message needs to be replied to, the forwarding function of the virtual gateway in the second data transmission direction is tested. The second data transmission direction refers to the data transmission direction from the external cloud leased line environment to the internal cloud VPC network. In this scenario, the first test port corresponds to the internal cloud VPC network and is used to receive data packets, while the second test port corresponds to the external cloud leased line environment and is used to send data packets.
[0071] Specifically, the second test port obtains the response policy from the test strategy. If the response rule matches the second test message, the second test port determines that the second test message needs a response. Subsequently, based on the conversion policy in the test strategy, the routing table entry, and the second test message, a third test message is constructed and sent to the virtual gateway. The first test port receives a fourth test message sent by the virtual gateway, which is obtained by the virtual gateway through 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 conditions based on the message count and key fields. If the fourth test message meets the test conditions, a second test result is output. The second test result indicates 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 count and key fields of the captured fourth test message do not meet the test conditions, a fourth test result is output, indicating that the forwarding function of the virtual gateway for the second data transmission direction is abnormal.
[0072] It should be noted that the testing process of the first test port for the fourth test message is the same as the testing process of the second test port for the second test message. For details of the specific testing process, please refer to the above-described testing process for the second test message. This embodiment of the application will not repeat the description here.
[0073] In this embodiment, the forwarding function of the virtual gateway in two opposite data transmission directions is tested through the first test port and the second test port on the test device. Compared with the simple packet construction test of the traffic-breaking device, which can only test traffic in one direction at a time, this embodiment realizes the forwarding test of the backhaul traffic of the virtual gateway's VGW device, which can more fully cover the test scenario.
[0074] Based on the same inventive concept, embodiments of this application provide a testing method for a virtual gateway, applicable to virtual gateways. Figure 2 This application provides a schematic flowchart illustrating the steps of a testing method for a virtual gateway, as proposed in one embodiment. Figure 2 As shown, the method includes the following steps:
[0075] S201, Receive the first test message sent by the first test port.
[0076] S202. Based on the routing table entry, the first test packet is judged.
[0077] S203. If the first test message matches the routing table entry, perform message conversion on the first test message to obtain the 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; if 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] To enable those skilled in the art to better understand the technical solution of the virtual gateway testing method proposed in the embodiments of this application, Figure 3 This paper illustrates a schematic diagram of the test process for executing the first data transmission direction and the second data transmission direction in a test method for a virtual gateway according to an embodiment of this application. The following section will combine... Figure 3 Detailed descriptions of specific embodiments are provided below.
[0081] The testing equipment is a Vgw tester, used to test the Vgw device of the virtual gateway's ability to forward ICMP request packets in the data transmission direction from the cloud-internal VPC network to the external leased line environment. Specifically, relevant routing table entries and test policies related to the cloud-internal VPC network to the leased line network and vice versa are configured on the Vgw device of the virtual gateway. On the first test port of the testing equipment, based on the relevant entries configured on the Vgw device of the virtual gateway and the determined test policies and traffic test directions, a VXLAN packet with an inner ICMP request packet is constructed using the scapy module as the first test packet. The construction rules for the first test packet on the first test port are as follows:
[0082] The test device uses the Python scapy module to construct the IP layer key fields of the outer (underlay) layer using the IP address of the first test port and the IP address of the virtual gateway. The MAC layer of the outer (underlay) layer is automatically filled with Ethernet layer information by the Scapy module's Layer 3 packet sending function, which looks up routes in the routing table. The destination port number of the outer transport layer UDP packet is fixed at 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 to be tested on the VGW device. The Ethernet layer and IP layer information in the key fields of the inner (overlay) layer are filled with the MAC and IP information set in the routing table entries to be tested on the VGW device of the virtual gateway. The transport layer is filled with ICMP packets according to the test strategy, with the ICMP packet type and code filled with 8 and 0 respectively. The identifier and sequence number fields are randomly generated and filled by the test device.
[0083] After receiving 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] Within one second after the first test port sends the first test packet, the second test port calls the Python scapy module to capture packets according to the filtering rules. The filtering rules are set to inbound UDP packets with the destination port number of the UDP packets being 4789. Then, the captured VXLAN packets are matched to determine whether the key fields of the packet data and the number of packets meet the expectations. The matching method for the key fields is that the test device calls the assertion function to match the captured packets with the pre-set packet rules. The key fields to be matched include the VNI of the VXLAN packet, the source MAC, destination MAC, source IP, destination IP of the VXLAN packet (overlay layer), and whether the identifier and sequence number of the ICMP request packet are consistent with the pre-set rules.
[0085] If the second test message is determined to meet the test conditions, it is considered an expected message, and a corresponding first test result is generated. Simultaneously, if a response is required for the second test message, the test device responds to it and performs a forwarding function test of the virtual gateway for the second data transmission direction. Conversely, if the second test message is detected to not meet the test conditions, a third test result is output, and the process terminates directly.
[0086] If a response is required for the second test message, 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. The key fields in the third test message of the VXLAN message are of the same type as the key fields in the first test message. The filling rules can be found in the construction process of the first test message. Specifically, the key fields of the third test message are as follows: the destination port number of the outer transport layer UDP message is fixed at 4768, and the source port number is randomly generated; the VNI field of the VXLAN layer is filled with the VNI of the leased network to be tested selected on the VGW device; the inner layer (overlay) of the VXLAN message... The source and destination MAC addresses of the Ethernet layer (overlay layer) are filled with the destination and source MAC addresses of the received VXLAN packet's inner Ethernet layer, respectively. The source and destination IP addresses of the IP layer (overlay layer) of the VXLAN packet are filled with the destination and source IP addresses of the received VXLAN packet's inner IP layer, respectively. The transport layer packet type of the VXLAN packet's inner overlay layer is set to ICMP packet, and the ICMP packet type and code 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 packet carried in the received VXLAN packet, respectively.
[0087] After the second test port completes the construction of the third test packet in the VXLAN packet format, it sends the third test packet to the virtual gateway. After receiving the third test packet, the virtual gateway processes the third test packet according to the routing table entry to obtain the fourth test packet and forwards it back to the first test port of the test device.
[0088] Within one second after the second test port sends the third test message, the first test port calls the Python scapy module to capture packets according to the filtering rules; then, the captured VXLAN packets are matched to determine whether the key fields and packet count of the packet data meet the expectations. If the packet count and key fields of the captured fourth test message meet the test conditions, a second test result is generated; if the packet count and key fields of the captured fourth test message do not meet the test conditions, the fourth test result is output.
[0089] This application provides a testing method, system, electronic device, and storage medium for a virtual gateway, applied to a testing device including a first test port and a second test port. The method includes: the first test port constructing a first test message and a test policy based on the routing table entries of the virtual gateway, and sending the first test message to the virtual gateway, the test policy including at least a receiving policy; the second test port receiving a second test message sent by the virtual gateway, the second test message being obtained by the virtual gateway through message conversion based on the first test message; the second test port receiving and parsing the second test message based on the receiving policy, and determining whether the second test message meets the test conditions; if the second test message meets the test conditions, outputting a first test result, the first test result being used to characterize that the forwarding function of the virtual gateway for a first data transmission direction is normal. This application generates test messages and test policies based on the routing table entries of the virtual gateway through the first test port of the testing device, and tests the test messages forwarded by the virtual gateway through the second test port, thereby meeting the testing requirements with a single testing device, and eliminating the need for manual configuration of test policies, greatly improving testing efficiency and effectively reducing testing difficulty and workload.
[0090] Based on the same inventive concept, this application discloses a testing system for a virtual gateway. The system includes a virtual gateway and a testing device, and the testing device includes a first testing port and a second testing port.
[0091] The first test port is used to construct a first test message and a test policy based on the routing table entry of the virtual gateway, and send the first test message to the virtual gateway. The test policy includes at least a receiving policy.
[0092] The virtual gateway is configured to judge the first test packet based on the routing table entry; if the first test packet matches the routing table entry, perform packet conversion on the first test packet to obtain a second test packet; and send the second test packet to the second test port.
[0093] The second test port is used to receive and parse the second test message based on the receiving policy, and determine whether the second test message meets the test conditions; if the second test message meets the test conditions, a first test result is output, which is used to characterize that the forwarding function of the virtual gateway for the first data transmission direction is normal.
[0094] Based on the same inventive concept, embodiments of this application disclose a testing device for a virtual gateway, applied to a testing equipment including a first test port and a second test port. Figure 4This application provides a schematic diagram of the structure of a test apparatus for a virtual gateway applied to a test device, as shown in one embodiment. Figure 4 As shown, the device includes:
[0095] The first test message module is used to construct a first test message and a test policy based on the routing table entry of the virtual gateway on the first test port, and send the first test message to the virtual gateway. The test policy includes at least a receiving policy.
[0096] The second test message receiving module is used to receive the second test message sent by the virtual gateway at the second test port. The second test message is obtained by the virtual gateway through message conversion based on the first test message.
[0097] The first test module is used to receive and parse the second test message based on the receiving strategy at the second test port, and determine whether the second test message meets the test conditions.
[0098] The first result output module is used to output a first test result when the second test message meets the test conditions. The first test result is used to characterize that the forwarding function of the virtual gateway for the first data transmission direction is normal.
[0099] In one optional implementation, the first test module includes:
[0100] The first message counting submodule is used to continuously capture packets of the second test message within a preset time period after the first test port sends the first test message to the virtual gateway, and obtain the message count of the second test message;
[0101] The second key field submodule is used to obtain the key fields of the second test message based on the routing table entry and the second test message. 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 conditions based on the number of messages in the second test message and the key fields of the second test message.
[0103] In one optional implementation, the first test submodule includes:
[0104] The matching unit is used to match the key fields of the second test packet with the key fields corresponding to the first test packet and the routing table entry, respectively, based on the filtering rules in the receiving strategy.
[0105] The first test unit is configured to determine that the second test message meets the test conditions when the number of messages in the second test message is equal to and not zero, 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 testing unit is configured to output a third test result when the second test message does not meet the test conditions. The third test result indicates that the virtual gateway's forwarding function for the first data transmission direction is malfunctioning.
[0108] The third test unit is configured to determine that the second test message does not meet the test conditions if 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 and not 0 of the number of messages in the first test message, or the key fields of the first test message are different from the key fields corresponding to the second test message and / or the routing table entry, respectively.
[0109] In one alternative embodiment, the device further includes:
[0110] The third test message module is used to construct a third test message based on the conversion policy, the routing table entry, and the second test message when the second test port matches the reply rule and the second test message, and send the third test message to the virtual gateway;
[0111] The fourth test message receiving module is used to receive the fourth test message sent by the virtual gateway at the first test port. The fourth test message is obtained by the virtual gateway through message conversion based on the third test message.
[0112] The second test module is used 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 conditions based on the number of messages 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 conditions. The second test result is used to characterize 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, embodiments of this application provide a testing device for a virtual gateway, applied to a virtual gateway. Figure 5This application provides a schematic diagram of the structure of a test apparatus for a virtual gateway, as proposed in one embodiment. Figure 5 As shown, the device includes:
[0115] The first test message receiving module is used to receive the first test message sent by the first test port;
[0116] The first judgment module is used to judge the first test packet based on the routing table entry;
[0117] The second test message module is used to perform message conversion on the first test message to obtain the 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 one alternative embodiment, the device further includes:
[0120] The third test message receiving module is used to receive the third test message sent by the second test port;
[0121] The second judgment module is used to judge the third test packet based on the routing table entry;
[0122] The fourth test message module is used to perform message conversion on the third test message to obtain the fourth test message when the third test message matches the routing table entry.
[0123] The second forwarding module is used to send the fourth test message to the first test port.
[0124] Based on the same inventive concept, this application discloses an electronic device. Figure 6 A schematic diagram of an electronic device according to an embodiment of this 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. The memory 110 stores at least one instruction, at least one program, code set, or instruction set. The at least one instruction, the at least one program, the code set, or the instruction set can be loaded and executed on the processor 120 to implement the steps in the testing method for a virtual gateway applied to a testing device as described in the embodiments of this application, or to implement the steps in the testing method for a virtual gateway applied to a virtual gateway as described in the embodiments of this application.
[0125] Based on the same inventive concept, embodiments of this application disclose a computer-readable storage medium storing at least one instruction, at least one program, code set, or instruction set thereon. 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 testing method for a virtual gateway applied to a test device as described in embodiments of this application, or to implement the steps in the testing method for a virtual gateway applied to a virtual gateway as described in embodiments of this application.
[0126] Based on the same inventive concept, embodiments of this application disclose a computer program product, including a computer program / instruction. When the computer program / instruction is executed by a processor, it implements the steps in the testing method for a virtual gateway applied to a testing device as described in embodiments of this application, or, when the computer program / instruction is executed by a processor, it implements the steps in the testing method for a virtual gateway applied to a virtual gateway as described in embodiments of this application.
[0127] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0128] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, apparatuses, electronic devices, and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0129] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The 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 equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0131] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0132] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0133] The above provides a detailed description of the testing method, system, electronic device, and storage medium for a virtual gateway provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A testing method for a virtual gateway, characterized in that, The method, applied to a test device including a first test port and a second test port, includes: The first test port constructs a first test message and a test policy based on the routing table entry of the virtual gateway, and sends the first test message to the virtual gateway. The test policy includes at least a receiving policy. The second test port receives a second test message sent by the virtual gateway, the second test message being 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; If the second test message meets the test conditions, a first test result is output. 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 step of determining whether the second test message meets the test conditions includes: 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, the key fields of the second test message are obtained. The key fields include at least an outer key field, an inner key field, and a specific information key field. Based on the number of packets in the second test packet and the key fields of the second test packet, determine whether the second test packet meets the test conditions; The step of determining whether the second test message meets the test conditions based on the number of messages in the second test message and the key fields of the second test message includes: Based on the filtering rules in the receiving strategy, the key fields of the second test packet are matched with the key fields corresponding to the first test packet and the routing table entry, respectively. If the number of packets in the second test packet is equal to and not zero with the number of packets in the first test packet, and the key field of the second test packet is the same as the key field corresponding to the first test packet and the routing table entry, then the second test packet is determined to meet the test conditions. The outer key fields include the source IP and destination IP; the inner key fields include the VNI field, inner source MAC, inner destination MAC, inner source IP, and inner destination IP of the test packet in the VXLAN packet format; the specific information key fields include the transport layer content and the specific information carried by the transport layer content.
2. The testing method for a virtual gateway according to claim 1, characterized in that, After determining whether the second test message meets the test conditions, the method further includes: If the second test message does not meet the test conditions, a third test result is output. This third test result indicates that the virtual gateway's forwarding function for the first data transmission direction is malfunctioning. If the number of packets in the second test packet is 0, or the number of packets in the second test packet is not equal to and not 0 of the number of packets in the first test packet, or the key field of the first test packet is different from the key field corresponding to the second test packet and / or the routing table entry, then the second test packet is determined not to meet the test conditions.
3. The testing method for a virtual gateway according to claim 1, characterized in that, The testing strategy also includes response rules and transformation strategies. After outputting the first test result, the method further includes: If the response rule matches the second test message, the second test port constructs a third test message based on the conversion policy, 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, the fourth test message being obtained by the virtual gateway through 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 conditions based on the number of messages and key fields of the fourth test message. If the fourth test message meets the test conditions, a second test result is output. The second test result is used to characterize 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.
4. A testing system for a virtual gateway, characterized in that, The system includes a virtual gateway and a testing device, the testing device including a first testing port and a second testing port; The first test port is used to construct a first test message and a test policy based on the routing table entry of the virtual gateway, and send the first test message to the virtual gateway. The test policy includes at least a receiving policy. The virtual gateway is used to judge the first test packet based on the routing table entry; If the first test message matches the routing table entry, the first test message is converted to obtain the second test message. Send 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 to determine whether the second test message meets the test conditions. If the second test message meets the test conditions, a first test result is output. 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 step of determining whether the second test message meets the test conditions includes: 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, the key fields of the second test message are obtained. The key fields include at least an outer key field, an inner key field, and a specific information key field. Based on the number of packets in the second test packet and the key fields of the second test packet, determine whether the second test packet meets the test conditions; The step of determining whether the second test message meets the test conditions based on the number of messages in the second test message and the key fields of the second test message includes: Based on the filtering rules in the receiving strategy, the key fields of the second test packet are matched with the key fields corresponding to the first test packet and the routing table entry, respectively. If the number of packets in the second test packet is equal to and not zero with the number of packets in the first test packet, and the key field of the second test packet is the same as the key field corresponding to the first test packet and the routing table entry, then the second test packet is determined to meet the test conditions. The outer key fields include the source IP and destination IP; the inner key fields include the VNI field, inner source MAC, inner destination MAC, inner source IP, and inner destination IP of the test packet in the VXLAN packet format; the specific information key fields include the transport layer content and the specific information carried by the transport layer content.
5. An electronic device, characterized in that, The device includes 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 test method for the virtual gateway according to any one of claims 1-3.
6. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that, When the computer program / instruction is executed by the processor, it implements the steps in the test method for the virtual gateway as described in any one of claims 1-3.
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