A testing method and tester with automatic testing NAT64 function

By setting up NAT64 test module and port on the NAT64 tester, and comparing the encapsulated result file and address conversion result file, the problem of insufficient automated test in the existing technology is solved, and the automated testing of NAT64 functions is realized, reducing the number of testers. and improves testing efficiency.

CN115766499BActive Publication Date: 2024-12-17CHENGDU DBAPP SECURITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211363148.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-02
Publication Date
2024-12-17
Estimated Expiration
2042-11-02

AI Technical Summary

Technical Problem

The prior art has problems such as insufficient automation testing and high requirements for testers when automated testing of NAT devices. Especially in the mutual access between IPv6 and IPv4 networks, automated testing of NAT64 technology is difficult to implement.

Method used

Set up the NAT64 test module and tester port on the NAT64 tester. By receiving configured messages from the firewall, generate encapsulated result files, converting addresses and comparing result files, and determining whether the NAT64 test passes, reducing the requirements for testers. Automated testing is implemented.

Benefits of technology

It realizes automated testing of NAT64 function, supports sending all types of messages and multiple test scenarios, reducing the operational complexity and time of testers and improving testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115766499B_ABST
    Figure CN115766499B_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of NAT equipment testing, and in particular, provides a testing method and a tester with automatic NAT64 testing function. A NAT64 testing module and a tester port for testing the NAT64 function are arranged on the NAT64 tester. By comparing an encapsulation result file generated by the tester according to a configuration completion message received from a firewall, an address conversion result file generated by the firewall according to an address conversion message obtained from the tester, and a field result file generated by the tester according to a converted message obtained from the firewall, it is determined whether the NAT64 test is passed, thereby reducing the requirements for testers, realizing automatic testing, automatically sending configuration commands to the firewall through an API interface to realize automatic configuration, and supporting the sending of all types of messages and multiple test scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of NAT equipment testing, and in particular to a testing method and a testing instrument with automatic testing NAT64 function. Background Art

[0002] With the development of IPv6 network technology, incompatibility between IPv4 and IPv6 networks has emerged, which means that IPv6 and IPv4 networks cannot access each other. NAT64 technology is one of the technologies used for direct access between IPv6 and IPv4 networks. It converts the IPv6 address of the message into an IPv4 address and then sends it to the IPv4 network; or converts the IPv4 address of the message into an IPv6 address and then sends it to the IPv6 network. There is no need to implement dual stack or tunnel technology on network devices.

[0003] For example, the Chinese patent with application number 202111216457.2 and patent name “NAT tester and test method for automated testing of NAT device forwarding SCTP messages” has the following disadvantages:

[0004] 1. After the device under test creates a NAT policy, it generates a configuration message based on the NAT policy and sends it to the tester, which then makes a match judgment based on the configuration message. This implementation method mainly creates relevant configurations on the network device and then sends the relevant configurations to the tester. Since the configuration commands of different manufacturers are inconsistent, this implementation requires high requirements on the tester.

[0005] 2. Operations need to be performed on the tester and firewall, and automated testing is not fully realized. Summary of the invention

[0006] Aiming at the problems of insufficient automated testing and high requirements on testers in the prior art, the present invention proposes a test method and a tester with automatic NAT64 test function. A NAT64 test module and a tester port for testing the NAT64 function are arranged on the NAT64 tester. By comparing an encapsulation result file generated by the tester according to a configuration completion message received from a firewall, an address conversion result file generated by the firewall according to an address conversion message obtained from the tester, and a field result file generated by the tester according to the converted message obtained from the firewall, it is determined whether the NAT64 test is passed, thereby reducing the requirements on the testers and realizing automated testing.

[0007] The specific implementation contents of the present invention are as follows:

[0008] A test method for automatically testing NAT64 function, wherein a NAT64 test module and a tester port for testing NAT64 function are set on a NAT64 tester, and specifically comprises the following steps:

[0009] Step 1: The port of the tester for testing the NAT64 function sends a specific message to the firewall interface connected to it, obtains the configuration of the firewall interface, and sends the configuration from the firewall interface to the tester port;

[0010] Step 2: The tester determines whether the firewall has been configured with an IP address based on the configuration of the firewall interface received from the firewall;

[0011] Step 3: The tester generates an IPv4 address pool and an IPv6 address pool based on the judgment results, and sends the interface configuration and NAT64 configuration to the firewall through the API interface;

[0012] Step 4: The firewall completes the interface configuration and NAT64 configuration according to the interface configuration and NAT64 configuration obtained from the tester, and returns a configuration completion message to the tester;

[0013] Step 5: The tester completes the message according to the configuration received from the firewall, constructs the address translation message and sends it to the firewall, and generates the encapsulation result file;

[0014] Step 6: Based on the address translation message obtained from the tester, the firewall converts the IPv6 address of the address translation message into an IPv4 address according to the NAT64 configuration, obtains the translated message, and sends it to the tester port through the IPv4 network, records the translation result, and generates an address translation result file;

[0015] Step 7: The tester records the relevant field contents of the converted message according to the converted message obtained from the firewall, and generates a field result file;

[0016] Step 8: When the tester reaches the set NAT64 test time or reaches the set number of messages, it obtains the address translation result file from the firewall and sends a test stop message to the firewall. After receiving the test stop message, the firewall sends the address translation result file to the tester. The tester sends a command to delete the NAT64 related configuration to the firewall through the API interface;

[0017] Step 9: The tester compares the encapsulation result file, address translation result file, and field result file to determine whether the NAT64 test passes.

[0018] In order to better implement the present invention, further, the configuration of the firewall interface in step 1 includes: a firewall IP address and a firewall MAC address.

[0019] In order to better implement the present invention, further, the specific operation of judging whether the firewall has been configured with an IP address in step 2 is as follows: if there is no firewall IP address in the configuration returned by the firewall, the network type of the tester port is judged, and the network segment address of the corresponding network type is randomly selected and sent to the interface of the current firewall, and at the same time, the tester port randomly selects a non-conflicting IP address from the current network segment as the IP address of the tester port; if there is a firewall IP address in the configuration returned by the firewall, the tester first judges whether the IP address of the firewall interface is the same network type address, if the network type addresses are the same, the tester determines the network type, and sends the corresponding network type IP address to the firewall interface, and modifies the firewall interface, if the network type addresses are different, the tester port automatically generates an IP address with the same network segment as the firewall interface as the IP address of the tester port;

[0020] In order to better implement the present invention, further, the step 5 specifically includes the following steps:

[0021] Step 51: The tester completes the message according to the configuration received from the firewall, adds a field after the DATA field, and constructs an address translation message;

[0022] Step 52: The tester sends the address translation message to the firewall, encapsulates the IPv6 message through the socket function, and counts the number of sent messages according to the sequence number, records the IP address and sequence number of the sent address translation message, and generates an encapsulation result file.

[0023] In order to better implement the present invention, further, the address conversion result file in step 6 includes: the correspondence between the IPv6 address and the IPv4 address, and the serial number of the address conversion message.

[0024] In order to better implement the present invention, further, the field result file in step 7 includes: the IP address of the converted message and the serial number corresponding to the converted message.

[0025] In order to better implement the present invention, further, the specific operation of judging whether the NAT64 test is passed in step 9 is: the tester calls the difflib module of the python standard library to take values ​​of the encapsulation result file and the field result file, takes out the IP address of the configuration completion message with the same serial number and the IP address of the converted message, and compares them with the address conversion result file generated by the firewall; if the correspondence between the IP addresses of the configuration completion message with the same serial number and the converted message is exactly the same as the correspondence between the addresses of the firewall address conversion result file, and the serial numbers are the same, the NAT64 test of the current message passes; until the NAT64 test of all messages passes, the NAT64 test passes.

[0026] In order to better implement the present invention, further, a tester with automatic NAT64 test function is proposed, which is used to implement the above-mentioned test method with automatic NAT64 test function, including a NAT64 test module and a tester port for testing the NAT64 function;

[0027] The NAT64 test module includes an acquisition module, a judgment module, a generation module, an encapsulation module, a field module, a stop module, and an output module;

[0028] The acquisition module is used to acquire the configuration of the firewall interface connected to the tester port for testing the NAT64 function;

[0029] The judging module is used to judge whether the firewall has been configured with an IP address;

[0030] The generation module is used to generate an IPv4 address pool and an IPv6 address pool, and send the interface configuration and NAT64 configuration to the firewall through the API interface;

[0031] The encapsulation module is used to complete the message according to the configuration received from the firewall, construct an address translation message and send it to the firewall, and generate an encapsulation result file;

[0032] The field module is used to record the relevant field content of the converted message according to the converted message obtained from the firewall, and generate a field result file;

[0033] The stop module is used to obtain the address translation result file from the firewall and send a test stop message to the firewall when the tester reaches the set NAT64 test time or reaches the set number of messages, and send a command to delete the NAT64 related configuration to the firewall through the API interface;

[0034] The output module is used to compare the encapsulation result file, the address translation result file, and the field result file to determine whether the NAT64 test passes.

[0035] The present invention has the following beneficial effects:

[0036] (1) The present invention performs two operations on the tester, namely, setting a NAT64 test module and setting a tester port, thereby realizing automated testing throughout the entire process and realizing automated testing of the NAT64 tester.

[0037] (2) The present invention compares the encapsulation result file, the address conversion result file, and the field result file to determine whether the NAT64 test has passed, thereby reducing the requirements for testers and realizing automated testing.

[0038] (3) The tester proposed in the present invention automatically sends configuration commands to the firewall through the API interface to achieve automatic configuration, and supports sending all types of messages and multiple test scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is the overall flow chart of the present invention;

[0040] Figure 2 A schematic diagram of the connection structure between a firewall configured with a correct IPv6 address and IPv4 address and a tester in an embodiment of the present invention;

[0041] Figure 3 This is a schematic diagram of the connection structure between the firewall configured with only an IPv4 address and a tester in an embodiment of the present invention;

[0042] Figure 4 This is a connection diagram for the tester module. DETAILED DESCRIPTION

[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. It should be understood that the described embodiments are only part of the embodiments of the present invention, not all of the embodiments, and therefore should not be regarded as limiting the scope of protection. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technical personnel in this field without making creative work are within the scope of protection of the present invention.

[0044] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "disposed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0045] Embodiment 1:

[0046] A test method with automatic NAT64 testing function, such as Figure 1 As shown in the figure, setting the NAT64 test module on the NAT64 tester and the tester port for testing the NAT64 function specifically includes the following steps:

[0047] Step 1: The port of the tester for testing the NAT64 function sends a specific message to the firewall interface connected to it, obtains the configuration of the firewall interface, and sends the configuration from the firewall interface to the tester port;

[0048] Step 2: The tester determines whether the firewall has been configured with an IP address based on the configuration of the firewall interface received from the firewall;

[0049] Step 3: The tester generates an IPv4 address pool and an IPv6 address pool based on the judgment results, and sends the interface configuration and NAT64 configuration to the firewall through the API interface;

[0050] Step 4: The firewall completes the interface configuration and NAT64 configuration according to the interface configuration and NAT64 configuration obtained from the tester, and returns a configuration completion message to the tester;

[0051] Step 5: The tester completes the message according to the configuration received from the firewall, constructs the address translation message and sends it to the firewall, and generates the encapsulation result file;

[0052] Step 6: Based on the address translation message obtained from the tester, the firewall converts the IPv6 address of the address translation message into an IPv4 address according to the NAT64 configuration, obtains the translated message, and sends it to the tester port through the IPv4 network, records the translation result, and generates an address translation result file;

[0053] Step 7: The tester records the relevant field contents of the converted message according to the converted message obtained from the firewall, and generates a field result file;

[0054] Step 8: When the tester reaches the set NAT64 test time or reaches the set number of messages, it obtains the address translation result file from the firewall and sends a test stop message to the firewall. After receiving the test stop message, the firewall sends the address translation result file to the tester. The tester sends a command to delete the NAT64 related configuration to the firewall through the API interface;

[0055] Step 9: The tester compares the encapsulation result file, address translation result file, and field result file to determine whether the NAT64 test passes.

[0056] Working principle: The present invention sets two operations, NAT64 test module and tester port, on the tester, realizes automatic testing throughout the whole process, realizes automatic testing of the NAT64 tester, and compares the encapsulation result file generated by the tester according to the configuration completion message received from the firewall, the address conversion result file generated by the firewall according to the address conversion message obtained from the tester, and the field result file generated by the tester according to the converted message obtained from the firewall to determine whether the NAT64 test is passed, thereby reducing the requirements for testers and realizing automatic testing.

[0057] Embodiment 2:

[0058] This embodiment describes the specific steps of the testing method based on the above embodiment 1.

[0059] The configuration of the firewall interface in step 1 includes: firewall IP address and firewall MAC address.

[0060] The specific operation of determining whether the firewall has been configured with an IP address in step 2 is as follows: if there is no firewall IP address in the configuration returned by the firewall, determine the network type of the tester port, and randomly select the network segment address of the corresponding network type and send it to the interface of the current firewall. At the same time, the tester port randomly selects a non-conflicting IP address from the current network segment as the IP address of the tester port; if there is a firewall IP address in the configuration returned by the firewall, the tester first determines whether the IP address of the firewall interface is the same network type address. If the network type addresses are the same, the tester determines the network type and sends the IP address of the corresponding network type to the firewall interface, and modifies the firewall interface. If the network type addresses are different, the tester port automatically generates an IP address of the same network segment as the firewall interface as the IP address of the tester port;

[0061] The step 5 specifically comprises the following steps:

[0062] Step 51: The tester completes the message according to the configuration received from the firewall, adds a field after the DATA field, and constructs an address translation message;

[0063] Step 52: The tester sends the address translation message to the firewall, encapsulates the IPv6 message through the socket function, and counts the number of sent messages according to the sequence number, records the IP address and sequence number of the sent address translation message, and generates an encapsulation result file.

[0064] The address conversion result file in step 6 includes: the correspondence between the IPv6 address and the IPv4 address, and the sequence number of the address conversion message.

[0065] The field result file in step 7 includes: the IP address of the converted message and the serial number corresponding to the converted message.

[0066] The specific operation of judging whether the NAT64 test is passed in step 9 is as follows: the tester calls the difflib module of the python standard library to obtain the values ​​of the encapsulation result file and the field result file, takes out the IP address of the configuration completion message with the same serial number and the IP address of the converted message, and compares them with the address conversion result file generated by the firewall; if the correspondence between the IP addresses of the configuration completion message with the same serial number and the converted message is exactly the same as the correspondence between the addresses in the firewall address conversion result file, and the serial numbers are the same, the NAT64 test of the current message passes; until the NAT64 test of all messages passes, the NAT64 test passes.

[0067] The other parts of this embodiment are the same as those of the above-mentioned embodiment 1, and thus will not be described in detail.

[0068] Embodiment 3:

[0069] This embodiment is based on any one of the above embodiments 1-2. Figure 4 As shown, a tester with automatic NAT64 test function is proposed, which is used to implement the above-mentioned test method with automatic NAT64 test function, including a NAT64 test module and a tester port for testing NAT64 function;

[0070] The NAT64 test module includes an acquisition module, a judgment module, a generation module, an encapsulation module, a field module, a stop module, and an output module;

[0071] The acquisition module is used to acquire the configuration of the firewall interface connected to the tester port for testing the NAT64 function;

[0072] The judging module is used to judge whether the firewall has been configured with an IP address;

[0073] The generation module is used to generate an IPv4 address pool and an IPv6 address pool, and send the interface configuration and NAT64 configuration to the firewall through the API interface;

[0074] The encapsulation module is used to complete the message according to the configuration received from the firewall, construct an address translation message and send it to the firewall, and generate an encapsulation result file;

[0075] The field module is used to record the relevant field content of the converted message according to the converted message obtained from the firewall, and generate a field result file;

[0076] The stop module is used to obtain the address translation result file from the firewall and send a test stop message to the firewall when the tester reaches the set NAT64 test time or reaches the set number of messages, and send a command to delete the NAT64 related configuration to the firewall through the API interface;

[0077] The output module is used to compare the encapsulation result file, the address translation result file, and the field result file to determine whether the NAT64 test passes.

[0078] The other parts of this embodiment are the same as any of the above embodiments 1-2, so they are not repeated here.

[0079] Embodiment 4:

[0080] This embodiment is based on any one of the above embodiments 1-3. Figure 2 As shown in the figure, the test method is described in detail by taking the firewall interface configured with the correct IPv6 address and IPv4 address as an example.

[0081] Step 1: Enable the NAT64 automatic test function on the NAT64 tester, select port1 and port2 as the ports for NAT64 test, and send specific messages to the firewall port connected to it on the tester port1 and port2 to obtain the configuration of the firewall port, including the IP address and MAC address of the interface. After receiving the message, the firewall sends the configuration of the interface from the interface that receives the message to the tester port.

[0082] Step 2: After the tester receives the interface configuration of the firewall, it determines that the firewall has been configured with an IP address and meets the NAT64 test conditions, that is, one of the interface addresses is an IPv4 address and the other is an IPv6 address. The tester port1 automatically generates an IPV4 address in the same network segment as the firewall interface, and the port2 automatically generates an IPV6 address in the same network segment as the firewall interface as the IP address of the tester port.

[0083] Step 3: The tester automatically generates an IPv4 address pool and an IPv6 address pool, which are used for address translation of the NAT64 function on the firewall, as well as related NAT64 policies, and automatically sends the relevant configurations to the firewall through the API interface.

[0084] Step 4: After the firewall completes the interface configuration and NAT64 configuration, it returns a configuration completion message to the tester.

[0085] Step 5: After receiving the configuration, the tester starts to automatically construct a message and sends it to the firewall from port 2 on the IPv6 network side.

[0086] In step 5, the method for encapsulating the tester message adopts the socket function of C++, and the specific steps include the following:

[0087] Step 51: When constructing a message, add a field after the DATA field to store the sequence number, that is, each time the tester constructs and sends a message, the sequence number is increased by 1.

[0088] Step 52: After the tester sends the message, it will count the number of sent messages according to the sequence number, and record the IP address and sequence number of the sent message to generate a result file.

[0089] Step 6: After receiving the message, the firewall converts the IPv6 address of the message into an IPv4 address according to the NAT64 policy, and sends the converted message to the IPv4 side to the tester interface; at the same time, the firewall records the conversion result, that is, the corresponding relationship and serial number of the IP address conversion, and generates a conversion result file.

[0090] In step 6, the generated conversion file content includes: the correspondence between the IPv6 address and the IPv4 address, and the sequence number of the message, that is, the IPv6 address of a message is converted to a certain IPv4 address, and the sequence number of the message is what.

[0091] Step 7: The tester receives the converted message, records the IP address and serial number of the message, and generates a result file;

[0092] In step 7: the result file generated by the tester contains the IP address of the received message and the corresponding sequence number.

[0093] Step 8: After the NAT64 test time of the tester expires, the tester sends a test stop message to the firewall and obtains the address translation result file generated by the firewall. After receiving the message, the firewall sends the file to the tester. At the same time, the tester sends a command to delete the NAT64 related configuration to the firewall through the API interface.

[0094] In step 8: the tester takes values ​​from the result file before sending and the result file generated after receiving the message according to the sequence number value, takes out the IP address of the message before sending and the IP address of the received message with the same sequence number, and compares them with the conversion file generated by the firewall; if the correspondence between the IP addresses of the message before sending and the received message with the same sequence number is completely consistent with the address correspondence in the firewall conversion file, and the sequence numbers are the same, the NAT64 test of the message passes. The NAT64 test passes until all the address correspondence information is verified.

[0095] Step 9: The test compares the file generated before sending the message, the conversion file generated by the firewall, and the result file generated after receiving the message to determine whether the NAT64 test passes.

[0096] The other parts of this embodiment are the same as any one of the above embodiments 1-3, so they are not repeated here.

[0097] Embodiment 5:

[0098] This embodiment is based on any one of the above embodiments 1-4. Figure 3 As shown, the interface value of the firewall configuration is configured with an IPv4 address.

[0099] Step 1: Enable the NAT64 automatic test function on the NAT64 tester, select port1 and port2 as the ports for NAT64 test, and send specific messages to the firewall port connected to it on the tester port1 and port2 to obtain the configuration of the firewall port, including the IP address and MAC address of the interface. After receiving the message, the firewall sends the configuration of the interface from the interface that receives the message to the tester port.

[0100] Step 2: After the tester receives the interface configuration of the firewall, it determines that the firewall has been configured with an IP address. However, it meets the NAT64 test conditions and the addresses are all IPv4 addresses. The tester randomly selects one of its own interfaces, port2, as the IPv4 network type, and automatically generates an IPv4 network segment. It randomly selects two addresses of the network segment, one of which is sent to the firewall interface address of the other end through the API interface, and the other is used as the interface address of the tester port2; another tester port, port1, is an IPv6 network type port, and automatically generates an IPv6 network segment. It randomly selects two addresses of the network segment, one of which is sent to the firewall interface address of the other end through the API interface, and the other is used as the interface address of the tester port1.

[0101] Step 3: The tester automatically generates an IPv4 address pool and an IPv6 address pool, which are used for address translation of the NAT64 function on the firewall, as well as related NAT64 policies, and automatically sends the relevant configurations to the firewall through the API interface.

[0102] Step 4: After the firewall completes the interface configuration and NAT64 configuration, it returns a configuration completion message to the tester.

[0103] Step 5: After receiving the configuration, the tester starts to automatically construct a message and sends it to the firewall from port 2 on the IPv6 network side.

[0104] Step 6: After receiving the message, the firewall converts the IPv6 address of the message into an IPv4 address according to the NAT64 policy, and sends the converted message to the IPv4 side to the tester interface; at the same time, the firewall records the conversion result, that is, the corresponding relationship and serial number of the IP address conversion, and generates a conversion result file.

[0105] Step 7: The tester receives the converted message, records the IP address and serial number of the message, and generates a result file

[0106] Step 8: After the NAT64 test time of the tester expires, the tester sends a test stop message to the firewall and obtains the address translation result file generated by the firewall. After receiving the message, the firewall sends the file to the tester. At the same time, the tester sends a command to delete the NAT64 related configuration to the firewall through the API interface.

[0107] Step 9: The test compares the file generated before sending the message, the conversion file generated by the firewall, and the result file generated after receiving the message to determine whether the NAT64 test passes.

[0108] Among them, the method of encapsulating the message of the tester in step 5 adopts the socket function of C++, and the specific steps include the following:

[0109] Step 51: When constructing a message, add a field after the DATA field to store the sequence number, that is, each time the tester constructs and sends a message, the sequence number is increased by 1.

[0110] Step 52: After the tester sends the message, it will count the number of sent messages according to the sequence number, and record the IP address and sequence number of the sent message to generate a result file.

[0111] In step 6, the generated conversion file content includes: the correspondence between the IPv6 address and the IPv4 address, and the sequence number of the message, that is, the IPv6 address of a message is converted to a certain IPv4 address, and the sequence number of the message is what.

[0112] In step 7: the result file generated by the tester contains the IP address of the received message and the corresponding sequence number.

[0113] In step 8: the tester takes values ​​from the result file before sending and the result file generated after receiving the message according to the sequence number value, takes out the IP address of the message before sending and the IP address of the received message with the same sequence number, and compares them with the conversion file generated by the firewall; if the correspondence between the IP addresses of the message before sending and the received message with the same sequence number is completely consistent with the address correspondence in the firewall conversion file, and the sequence numbers are the same, the NAT64 test of the message passes. The NAT64 test passes until all the address correspondence information is verified.

[0114] The other parts of this embodiment are the same as any one of the above embodiments 1-4, so they are not repeated here.

[0115] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any simple modification or equivalent change made to the above embodiment based on the technical essence of the present invention shall fall within the protection scope of the present invention.

Claims

1. A test method with automatic NAT64 test function, characterized in that: Setting up the NAT64 test module on the NAT64 tester and the tester port for testing the NAT64 function includes the following steps: Step 1: The tester port for testing the NAT64 function sends a specific message to the firewall interface connected to it, and obtains the configuration of the firewall interface from the firewall interface; Step 2: The tester determines whether the firewall has been configured with an IP address based on the configuration of the firewall interface obtained from the firewall; Step 3: The tester generates an IPv4 address pool and an IPv6 address pool based on the judgment results, and sends the interface configuration and NAT64 configuration to the firewall through the API interface; Step 4: The firewall completes the interface configuration and NAT64 configuration according to the interface configuration and NAT64 configuration obtained from the tester, and returns a configuration completion message to the tester; Step 5: The tester completes the message according to the configuration received from the firewall, constructs the address translation message and sends it to the firewall, and generates the encapsulation result file; Step 6: Based on the address translation message obtained from the tester, the firewall converts the IPv6 address of the address translation message into an IPv4 address according to the NAT64 configuration, obtains the translated message, and sends it to the tester port through the IPv4 network, records the translation result, and generates an address translation result file; Step 7: The tester records the relevant field contents of the converted message according to the converted message obtained from the firewall, and generates a field result file; Step 8: When the tester reaches the set NAT64 test time or reaches the set number of messages, it obtains the address translation result file from the firewall and sends a test stop message to the firewall. After receiving the test stop message, the firewall sends the address translation result file to the tester. The tester sends a command to delete the NAT64 configuration to the firewall through the API interface. Step 9: The tester compares the encapsulation result file, address translation result file, and field result file to determine whether the NAT64 test passes; The specific operation of determining whether the firewall has been configured with an IP address in step 2 is as follows: if there is no firewall IP address in the configuration returned by the firewall, determine the network type of the tester port, and randomly select the network segment address of the corresponding network type and send it to the interface of the current firewall. At the same time, the tester port randomly selects a non-conflicting IP address from the current network segment as the IP address of the tester port; if there is a firewall IP address in the configuration returned by the firewall, the tester first determines whether the IP address of the firewall interface is the same network type address. If the network type addresses are the same, the tester determines the network type and sends the corresponding network type IP address to the firewall interface, modifies the firewall interface, and if the network type addresses are different, the tester port automatically generates an IP address of the same network segment as the firewall interface as the IP address of the tester port; The step 5 specifically comprises the following steps: Step 51: The tester completes the message according to the configuration obtained from the firewall, adds a field after the DATA field, and constructs an address translation message; Step 52: The tester sends the address translation message to the firewall, encapsulates the IPv6 message through the socket function, counts the number of sent messages according to the sequence number, records the IP address of the sent address translation message and the sequence number of the address translation message, and generates an encapsulation result file; The specific operation of judging whether the NAT64 test passes in step 9 is as follows: the tester calls the difflib module of the python standard library to obtain the values ​​of the encapsulation result file and the field result file, takes out the IP address of the configuration completion message with the same serial number and the IP address of the converted message, and compares them with the address conversion result file generated by the firewall. If the correspondence between the IP addresses of the configuration completion message with the same serial number and the converted message is exactly the same as the correspondence between the addresses in the firewall address conversion result file, and the serial numbers are the same, the NAT64 test of the current message passes, and the comparison continues until the NAT64 test of all messages passes.

2. A test method with automatic NAT64 test function as claimed in claim 1, characterized in that: The configuration of the firewall interface in step 1 includes: firewall IP address and firewall MAC address.

3. A test method with automatic NAT64 test function as claimed in claim 1, characterized in that: The address conversion result file in step 6 includes: the correspondence between the IPv6 address and the IPv4 address, and the sequence number of the address conversion message.

4. A test method with automatic NAT64 test function as claimed in claim 3, characterized in that: The field result file in step 7 includes: the IP address of the converted message and the serial number corresponding to the converted message.

5. A tester with automatic NAT64 testing function, used to implement a test method with automatic NAT64 testing function as claimed in any one of claims 1 to 4, characterized in that: Includes NAT64 test module and tester port for testing NAT64 function; The NAT64 test module includes an acquisition module, a judgment module, a generation module, an encapsulation module, a field module, a stop module, and an output module; The acquisition module is used to acquire the configuration of the firewall interface connected to the tester port for testing the NAT64 function; The judging module is used to judge whether the firewall has been configured with an IP address; The generation module is used to generate an IPv4 address pool and an IPv6 address pool, and send the interface configuration and NAT64 configuration to the firewall through the API interface; The encapsulation module is used to complete the message according to the configuration received from the firewall, construct an address translation message and send it to the firewall, and generate an encapsulation result file; The field module is used to record the relevant field content of the converted message according to the converted message obtained from the firewall, and generate a field result file; The stop module is used to obtain the address translation result file from the firewall and send a test stop message to the firewall when the tester reaches the set NAT64 test time or reaches the set number of messages, and send a command to delete the NAT64 related configuration to the firewall through the API interface; The output module is used to compare the encapsulation result file, the address translation result file, and the field result file to determine whether the NAT64 test passes.