A test packet derivation method and device, a storage medium and an electronic device

By using genetic algorithms to select target individuals and transform the original message data to generate derived message data that matches the testing requirements, the problem of low efficiency in acquiring training data in existing technologies is solved, and the stability and accuracy of the testing system are improved.

CN115543842BActive Publication Date: 2025-12-16QI-ANXIN LEGENDSEC INFORMATION TECH (BEIJING) INC +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211318186.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-26
Publication Date
2025-12-16
Estimated Expiration
2042-10-26

AI Technical Summary

Technical Problem

Existing technologies struggle to efficiently acquire large amounts of training data that match testing requirements, impacting the stability and accuracy of network testing systems.

Method used

A genetic algorithm is used to generate test messages. By selecting target individuals and performing derivation operations on the original message data, derived message data matching the test requirements is generated.

Benefits of technology

It rapidly increased the amount of message data available for testing and training, improved the stability and accuracy of the testing system, and reduced labor costs and complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115543842B_ABST
    Figure CN115543842B_ABST
Patent Text Reader

Abstract

The application provides a test message derivation method and device, a storage medium and an electronic device. The method comprises the following steps: obtaining a target individual matched with a test requirement, the target individual containing gene characteristics matched with protocol information, the protocol information belonging to a network protocol corresponding to the test requirement, and each gene characteristic being used for indicating a derivation operation on the corresponding protocol information; obtaining target derived message data corresponding to the target individual, the target derived message data being derived message data obtained by performing a derivation operation on protocol information of original message data according to the gene characteristics contained in the target individual; and the target derived message data being used for testing a test system corresponding to the test requirement. The number of message data available for test training can be quickly enriched, the derived message data obtained can be used for test training of the test system corresponding to the test requirement, so that the stability and accuracy of the test system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of testing, in particular to a test packet derivation method and device, a storage medium and an electronic device. BACKGROUND

[0002] With the increasing complexity of network environment, the stability and accuracy of network equipment are increasingly required. For many network protocols in the network, how to test simply and effectively is also a test for the tester. More and more intelligent algorithms are applied to the testing field, focusing on improving and optimizing test cases or test systems in order to improve the stability and accuracy of network testing.

[0003] In the process of improvement and optimization, a large amount of training data is needed. The number, variety, comprehensiveness and matching degree of the training data with the test cases may affect the improvement effect. Therefore, how to efficiently obtain a large amount of training data has become a difficult problem for the technical personnel in the field. SUMMARY

[0004] The purpose of the present application is to provide a test packet derivation method, device, storage medium and electronic device to at least partially improve the above problems.

[0005] In order to achieve the above purpose, the technical solutions adopted by the embodiments of the present application are as follows:

[0006] In a first aspect, the embodiments of the present application provide a test packet derivation method, which comprises:

[0007] Obtaining a target individual matched with a test requirement, the target individual containing genetic characteristics matched with protocol information, the protocol information belonging to a network protocol corresponding to the test requirement, each genetic characteristic being used to indicate a derivation operation on the corresponding protocol information;

[0008] Obtaining target derived packet data corresponding to the target individual, the target derived packet data being derived packet data obtained by performing a derivation operation on protocol information of original packet data according to the genetic characteristics contained in the target individual; the target derived packet data being used to test a test system corresponding to the test requirement.

[0009] In a second aspect, the embodiments of the present application provide a test system training method, which comprises:

[0010] Training a test system based on a training set until the test system meets a preset training standard;

[0011] The training set comprises multiple groups of target derived packet data obtained by the above test packet derivation method.

[0012] In a third aspect, an embodiment of the present application provides a test packet derivation apparatus, the apparatus comprising:

[0013] a processing unit configured to obtain a target individual matching the test requirement, the target individual comprising genetic features matching protocol information, the protocol information belonging to a network protocol corresponding to the test requirement, each genetic feature being used to indicate a derivation operation on corresponding protocol information;

[0014] a derivation unit configured to obtain target derived packet data corresponding to the target individual, the target derived packet data being derived packet data obtained by performing a derivation operation on protocol information of original packet data according to genetic features comprised in the target individual, the target derived packet data being used to test a test system corresponding to the test requirement.

[0015] In a fourth aspect, an embodiment of the present application provides a test system training apparatus, the apparatus comprising:

[0016] a training unit configured to train a test system based on a training set until the test system meets a preset training standard;

[0017] the training set comprising a plurality of target derived packet data obtained by the test packet derivation method.

[0018] In a fifth aspect, an embodiment of the present application provides a storage medium having a computer program stored thereon, the computer program being executed by a processor to implement the method of the first aspect or the second aspect.

[0019] In a sixth aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: a processor and a memory, the memory being configured to store one or more programs; when the one or more programs are executed by the processor, the method of the first aspect or the second aspect is implemented.

[0020] Compared with the prior art, the test packet derivation method, device, storage medium and electronic equipment provided by the embodiment of the application comprise the following steps: obtaining a target individual matched with a test requirement, the target individual containing gene features matched with protocol information, the protocol information belonging to a network protocol corresponding to the test requirement, each gene feature being used for indicating that a corresponding protocol information is subjected to a derivation operation; obtaining target derived packet data corresponding to the target individual, the target derived packet data being derived packet data obtained by performing a derivation operation on protocol information of original packet data according to the gene features contained in the target individual; and the target derived packet data being used for testing a test system corresponding to the test requirement. The number of packet data that can be used for test training can be quickly enriched, and the derived packet data obtained can be used for test training of the test system corresponding to the test requirement, so as to improve the stability and accuracy of the test system.

[0021] In order to make the above objectives, characteristics and advantages of the present application more apparent, the following will describe a preferred embodiment in detail, and the accompanying drawings will be referred to, as follows. BRIEF DESCRIPTION OF DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be regarded as a limitation to the scope. For those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.

[0023] Figure 1 The structural schematic diagram of the electronic equipment provided by the embodiment of the present application;

[0024] Figure 2 The flowchart of the test packet derivation method provided by the embodiment of the present application;

[0025] Figure 3 The sub-step schematic diagram of S11 provided by the embodiment of the present application;

[0026] Figure 4 The derivation operation schematic diagram provided by the embodiment of the present application;

[0027] Figure 5 The sub-step schematic diagram of S114 provided by the embodiment of the present application;

[0028] Figure 6 The sub-step schematic diagram of S11 provided by the embodiment of the present application;

[0029] Figure 7 The sub-step schematic diagram of S111 provided by the embodiment of the present application;

[0030] Figure 8 A sub-step schematic diagram of S12 provided for the embodiment of the present application;

[0031] Figure 9 A sub-step schematic diagram of S12 provided for the embodiment of the present application;

[0032] Figure 10 A flow schematic diagram of the test system training method provided for the embodiment of the present application;

[0033] Figure 11 A unit schematic diagram of the test message derivation device provided for the embodiment of the present application;

[0034] Figure 12 A unit schematic diagram of the test system training device provided for the embodiment of the present application.

[0035] In the figure: 10-processor; 11-memory; 12-bus; 13-communication interface; 301-processing unit; 302-derivation unit; 401-information acquisition unit; 402-training unit. DETAILED DESCRIPTION

[0036] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the accompanying drawings can be arranged and designed in various different configurations.

[0037] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts, fall within the scope of protection of the present application.

[0038] It should be noted that: similar reference numerals and letters represent similar items in the following drawings, therefore, once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. Meanwhile, in the description of the present application, the terms "first", "second", etc. are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.

[0039] It should be noted that, in this article, the term "include", "contain" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "includes a" does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0040] In the description of the present application, it should be noted that, unless otherwise explicitly specified and limited, the terms "set", "connect" should be understood broadly, for example, it can be fixedly connected, or detachably connected, or integrally connected; it can be mechanically connected, or electrically connected; it can be directly connected, or indirectly connected through an intermediate medium, or it can be the communication inside two elements. For those skilled in the art, the specific meaning of the above terms in the present application can be understood according to the specific circumstances.

[0041] Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The following examples and features in the examples can be combined with each other without conflict.

[0042] It should be understood that, in order to improve the stability and accuracy of the test system when performing network testing, a large amount of training data is needed to train and verify the test system, and the number, variety, comprehensiveness of the training data and the matching degree with the test cases in the test system can affect the improvement effect of the training on the stability and accuracy of the test system.

[0043] In order to obtain rich test messages, the prior art provides the following possible implementation manners, please refer to the following.

[0044] Firstly, network messages are captured in actual application environment, and the captured messages are played back in the test environment. However, the operation of capturing packets in the actual environment is relatively complex, and it is difficult to screen effective messages, the number and type of messages obtained by actual packet capture are limited, and it is difficult to comprehensively cover the test functions of the test system according to the existing messages.

[0045] Secondly, the existing messages are randomly and specifically modified for testing. However, the modification of network messages has certain limitations, and it is difficult to perform a large number of targeted tests.

[0046] Thirdly, typical messages are constructed according to network protocol features and input into testing. However, the test personnel constructing the messages need to have certain understanding of various network protocols, the requirements for the staff are relatively high, and the human cost is large.

[0047] In order to overcome the above problems, the scheme provides a test packet derivation method. The genetic algorithm is applied to the generation of network data packets to seek a more intelligent and flexible way to generate data packets, improve the accuracy and coverage of the test, and optimize the deficiencies of the prior art. The test packet derivation method provided in the embodiments of the application can be applied to the electronic device described below.

[0048] The test packet derivation method provided in the embodiments of the application can filter out target individuals that match the test requirements by individual iterative genetics and population reproduction through the genetic algorithm, and then can complete packet data derivation based on the target individuals.

[0049] Genetic algorithm (GA) is a computational model simulating the natural selection and genetic mechanism of Darwin's biological evolution process, and is a method of searching for an optimal solution by simulating the natural evolution process.

[0050] The genetic algorithm starts from an initial population with a potential solution set. The population is composed of individuals encoded by genes, and the number of individuals in the population can be greater than or equal to 1. Then, according to natural selection, survival of the fittest and survival of the fittest, the individuals are evolved generation by generation to generate better individuals. The optimal individual is obtained by calculating the fitness of each generation population, and the genetic operators of natural genetics: replication, crossover and compilation are used to generate a population representing a new solution set, so as to obtain the optimal individual as the target individual. It should be noted that the individual can be a gene sequence obtained by gene coding according to a predetermined rule. Each individual includes all genes, but has different gene coding sequences. For example, the gene sequence (individual) is G n ={g1,g2,g3……g n}, where all genes are coded in binary, g r represents the rth gene, g r =0 indicates that the rth gene feature is not owned, and g r =1 indicates that the rth gene feature is owned. The electronic device provided in the embodiments of the application can be a server device, a computer device, a mobile phone device, and other terminal devices with signal processing capabilities. Please refer to Figure 1 , a structural diagram of the electronic device. The electronic device includes a processor 10, a memory 11, and a bus 12. The processor 10 and the memory 11 are connected through the bus 12. The processor 10 is used to execute executable modules stored in the memory 11, such as computer programs.

[0051] Processor 10 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the test message derivation method can be completed through integrated logic circuits in the hardware or software instructions within processor 10. The aforementioned processor 10 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0052] The memory 11 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device.

[0053] Bus 12 can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. Figure 1 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus 12 or one type of bus 12.

[0054] The memory 11 is used to store programs, such as programs corresponding to a test message generation device. The test message generation device includes at least one software functional module that can be stored in the memory 11 in the form of software or firmware, or embedded in the operating system (OS) of the electronic device. Upon receiving an execution instruction, the processor 10 executes the program to implement the test message generation method.

[0055] The electronic device provided in this application embodiment may also include a communication interface 13. The communication interface 13 is connected to the processor 10 via a bus.

[0056] In one possible implementation, the electronic device can connect to the packet capture tool via the communication interface 13 to obtain the packets captured by the packet capture tool.

[0057] It should be understood that, Figure 1 The structure shown is only a partial schematic diagram of the electronic device; the electronic device may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.

[0058] The test message derivation method provided in this application embodiment can be applied to, but is not limited to, [various applications]. Figure 1 For the specific procedures of the electronic devices shown, please refer to [link / reference]. Figure 2 The test message derivation methods include S11 and S12, which are described in detail below.

[0059] S11, Obtain target individuals that match the testing requirements.

[0060] In this process, the genetic features of the target individual are matched with the protocol information, which belongs to the network protocol corresponding to the test requirements. Each genetic feature is used to indicate the derivation operation of the corresponding protocol information.

[0061] In one possible implementation, a gene is defined as a modification operation on known message data, which can be raw message data obtained through packet capture. The target individual can be a gene sequence obtained by encoding genes according to preset rules.

[0062] For example, predefine n genes, where n can be, but is not limited to, 50, and use binary encoding as follows: the gene sequence is G. n ={g1,g2,g3……g n}, where all genes are encoded in binary, g r G represents the r-th gene. r =0 indicates that the r-th gene trait is not possessed, g r =1 indicates possession of the r-th gene trait. Based on the network protocol type, genes can be categorized into several example types as shown in Table 1:

[0063]

[0064]

[0065] Table 1

[0066] In one possible implementation, the target individual can be represented as the k-th individual I. k I k =(g k1 g k2 g k3 g k4 ...gkn ), for example, I k =000100101101010110B(45 526D), g kr =0 indicates individual I k Not possessing the r-th gene trait, g kr =1 represents individual I k The target individual possesses the r-th gene trait. That is, the target individual has n digits, arranged according to a preset rule. Each digit corresponds to a gene, and the identifier on the digit indicates whether the corresponding gene trait is executed during data transformation based on the target individual. Each digit corresponds to a transformation behavior, such as generating character sequence data, IP fragmentation processing, random port processing, and redundant data processing, etc.

[0067] It should be understood that the identifier on a digit can be, but is not limited to, 0 or 1 as in the example above. At least one digit in the target individual indicates that the corresponding genetic feature is executed when performing data transformation based on the target individual; for example, at least one digit is 1. That is, the target individual includes at least one genetic feature that needs to be executed when performing data transformation based on the target individual. This genetic feature is used to convert any one or more of the data type, address type, length type, and protocol-related types in the original message during data transformation.

[0068] S12, Obtain the target-derived message data corresponding to the target individual.

[0069] Among them, the target derived message data is derived message data obtained by performing a transformation operation on the protocol information of the original message data based on the genetic characteristics contained in the target individual; the target derived message data is used to test the test system corresponding to the test requirements.

[0070] It should be understood that because the genetic characteristics of the target individual match the protocol information, and the protocol information belongs to the network protocol corresponding to the test requirements, each genetic characteristic is used to indicate the derivation operation on the corresponding protocol information. Therefore, based on the genetic characteristics of the target individual, the derived message data obtained by performing derivation operations on the protocol information of the original message data can be used to test and train the test system corresponding to the test requirements.

[0071] It should be noted that the number of target individuals is greater than or equal to 1, for example, it can be 10 groups of target individuals, and is not limited here. Through the test message derivation provided in the embodiments of this application, x groups of original message data can be transformed to obtain x new groups of derived message data. For example, when the number of target individuals is 10 groups, 10x groups of derived message data can be obtained, which can quickly enrich the number of message data that can be used for test training. The obtained derived message data can be used to test and train the test system corresponding to the test requirements, so as to improve the stability and accuracy of the test system.

[0072] The test packet derivation method provided in this application does not rely entirely on capturing network packets from the application environment. This solution obtains target individuals that match the testing requirements through screening, and then derives the original packet data based on these target individuals. Even with only a small amount of original packet data, a large amount of derived packet data that can improve the testing system can be obtained by deriving this small amount of original packet data. This method is simpler and less costly than manual construction.

[0073] In summary, the test message derivation method provided in this application includes: acquiring a target individual matching the test requirements, wherein the genetic features contained in the target individual match protocol information, the protocol information belongs to the network protocol corresponding to the test requirements, and each genetic feature is used to indicate a derivation operation on the corresponding protocol information; acquiring target derived message data corresponding to the target individual, wherein the target derived message data is derived message data obtained by performing a derivation operation on the protocol information of the original message data based on the genetic features contained in the target individual; and using the target derived message data to test the test system corresponding to the test requirements. This method can quickly enrich the amount of message data available for test training, and the obtained derived message data can be used to test and train the test system corresponding to the test requirements, thereby improving the stability and accuracy of the test system.

[0074] It should be understood that, in order to ensure the consistency between the target derived message data obtained through the target individual and the network protocol corresponding to the test requirements, that is, to ensure the degree of matching between the target derived message data and the test requirements of the test system, and thus ensure that the stability and accuracy of the test system can be improved after testing and training the test system corresponding to the test requirements using the derived message data, individual screening is required to obtain gene sequences that match the test requirements as target individuals. Based on this, since the embodiments of this application use the genetic algorithm described above, target individuals matching the test requirements can be obtained through population iterative reproduction. Figure 2 Regarding the content of S11, how to obtain the target individual, this application embodiment also provides a possible implementation method, please refer to... Figure 3S11 includes: S113, S114, S115, S116, S117 and S118, which are described in detail below.

[0075] S113, based on the gene characteristics contained in each individual to be confirmed in the i-th generation population, perform derivation operations on the protocol information of the original message data to obtain the corresponding derived message data to be confirmed.

[0076] The i-th generation population contains at least two individuals to be confirmed, where i is an integer greater than or equal to 1.

[0077] In one possible implementation, before performing population propagation using a genetic algorithm, an individual database can be pre-created. This database contains all individuals, for example, {I1, I2, I3, I4... I...} q}, 1≤q≤Q, where Q is expressed as follows:

[0078]

[0079] Where Q represents the total number of individuals in the individual database, and n represents the total number of genes. Population S i Characterizing the i-th generation population, population S i It includes at least two individuals to be identified, such as I mentioned above. k =(g k1 g k2 g k3 g k4 ...g kn ), g kr =0 indicates individual I k Not possessing the r-th gene trait, g kr =1 represents individual I k It possesses the r-th gene characteristic.

[0080] It should be understood that {I1, I2, I3, I4...I... q Each individual in the group contains all genes and has a different gene coding sequence. For example, I k Including g k1 g k2 g k3 g k4 ...g kn It possesses n types of genes, but I k It may not include all genetic characteristics, i.e., g k1 g k2 g k3 g k4 ...g kn There are one or more values ​​equal to 0.

[0081] Assume population Si Including 4 individuals to be confirmed, namely I i1 I i2 I i3 and I i4 I i1 I i2 I i3 and I i4 Let S represent the populations respectively. i The first, second, third, and fourth individuals, I i1 I i2 I i3 and I i4 Belonging to {I1, I2, I3, I4...I q}

[0082] For details on how to perform evolutionary operations on the protocol information of the original message data based on the genetic characteristics of each individual to be confirmed in the i-th generation population, please refer to [reference needed]. Figure 4 , Figure 4 A schematic diagram of the derivation operation provided in the embodiments of this application.

[0083] like Figure 4 As shown, assume I i1 I i2 I i3 and I i4 The decimal representations of these numbers are 1262, 52, 1646, and 327, which, after binary parsing, are 1010110010, 0000101010, 1110100110, and 0011010111.

[0084] It should be noted that, Figure 4 Population S is shown in the figure. i The number of individuals to be confirmed is 4, but this is only for the sake of explanation; the number of individuals in each generation of the population is not limited here. Figure 4 The example shows 10 genes per individual, but this is for illustrative purposes only; the actual number of genes per individual is not limited. For ease of explanation... Figure 4 Processing layer I in i1 I i2 I i3 and I i4 One of the gene features contained in the processing layer is shown as an example. The gene features in the processing layer are: (1) generating character sequence data, (2) IP fragmentation, (3) random port and (t) redundant data. Each of these gene features is to be confirmed. t is less than or equal to n, where n is the total number of genes.

[0085] After processing and completing the derivation operation, derived message data corresponding to the original message data can be obtained. Assuming there are 10 sets of original message data, after performing the derivation operation based on the i-th generation population, 40 sets of derived message data can be obtained. All derived message data can be summarized into a derived data record, i.e. Figure 4 All packets in the data.

[0086] S114. Based on each pending derived message data, obtain the fitness of the corresponding pending individual.

[0087] Among them, fitness characterizes the degree to which the data of the derived message to be confirmed matches the test requirements.

[0088] It should be understood that the degree to which the data in the derived message to be confirmed matches the test requirements can be used as a measure of the fitness of the corresponding individual to be confirmed.

[0089] It should be noted that a higher fitness level for an individual to be confirmed indicates a higher degree of match between the individual and the testing requirements, a greater likelihood that the individual will be the target individual, or a higher proportion of the genetic traits required by the target individual. It should be understood that using individuals with higher fitness as target individuals to match the testing requirements, or using individuals with higher fitness for breeding to obtain target individuals that match the testing requirements, ensures the consistency between the target-derived message data obtained through the target individual and the network protocol corresponding to the testing requirements. In other words, it ensures the degree of match between the target-derived message data and the testing requirements of the testing system. This, in turn, ensures that training the testing system corresponding to the testing requirements using the derived message data improves the stability and accuracy of the testing system.

[0090] S115, confirm whether there are any individuals of the target number whose fitness meets the fitness condition. If yes, proceed to S118; otherwise, proceed to S116.

[0091] Optionally, the fitness condition indicates that the fitness is greater than a preset fitness threshold, such as 95% and the number of targets is such as 10.

[0092] If the fitness of the target number of individuals to be confirmed meets the fitness condition, it means that the current generation i contains a sufficient number of target individuals, and S118 can be executed to select the corresponding individuals to be confirmed as target individuals. Otherwise, it is necessary to use a genetic algorithm to reproduce on the basis of the generation i, and then S116 should be executed.

[0093] Furthermore, when there are no individuals in the i-th generation whose fitness meets the fitness condition for the target number of individuals, population propagation using a genetic algorithm is necessary to obtain the target number of individuals. Therefore, by using a strategy of differentiating between the first, second, and third types of individuals and differentiating weights, the proportion of common genetic characteristics in the (i+1)-th generation population is increased, thereby increasing the number of individuals in the (i+1)-th generation whose fitness meets the fitness condition. For details, please refer to the following text.

[0094] S116, when there is no target number of individuals whose fitness meets the fitness condition, obtain the first type of individuals to be confirmed, the second type of individuals to be confirmed, and the third type of individuals to be confirmed.

[0095] Among them, the fitness of the first type of individuals to be identified is among the top N in the ranking, and any two individuals of the first type to be identified have common genetic characteristics; the fitness of the second type of individuals to be identified is among the top N in the ranking, and any two individuals of the first type to be identified have different genetic characteristics; the fitness of the third type of individuals to be identified is not among the top N in the ranking.

[0096] Optionally, if the number of individuals to be confirmed that meet the fitness criteria in the i-th generation population is less than the target number, relatively common genetic features are extracted from the individuals to be confirmed that rank in the top N in fitness. Common genetic features are those individuals to be confirmed that meet the fitness criteria and have the highest probability of possession, or a probability greater than a preset threshold. For example, in the i-th generation population, if 5 individuals all possess the first genetic feature (g1 = 1), and the probability of possessing the first genetic feature is the highest and / or greater than a preset probability threshold, then this can be considered a common genetic feature. It should be noted that the number of common genetic features can be greater than 1.

[0097] Based on whether they share common genetic characteristics, individuals of the first and second categories are identified from those whose fitness ranks in the top N, while individuals of the third category are identified from those whose fitness does not rank in the top N.

[0098] For example, if N = 50, the first N digits represent the first 50 individuals. The i-th population can be divided into two groups according to fitness: one group is G (the 50 individuals with the highest fitness), and the other group is the remaining individuals excluding G. This results in three types of individuals:

[0099] Io: Individuals whose fitness is not in the top 50, the third category of individuals to be identified.

[0100] Id: Individuals belonging to G but without common genetic characteristics, Category II individuals awaiting confirmation.

[0101] Ic: Individuals belonging to G and sharing common genetic characteristics, the first category of individuals awaiting confirmation.

[0102] It should be noted that since the common genetic characteristics of a population with high fitness are also genetic characteristics with high fitness, it is necessary to perform weighted breeding on these common genetic characteristics. Therefore, breeding is carried out on populations with high fitness, such as the first type of individuals to be identified and the second type of individuals to be identified, with the goal of obtaining individuals with high fitness more quickly.

[0103] S117, Based on the difference-derived weight strategy, the first type of unconfirmed individuals, the second type of unconfirmed individuals, and the third type of unconfirmed individuals are propagated to obtain the (i+1)th generation population.

[0104] Among them, the difference-derived weighting strategy is used to indicate the proportion of common genetic features.

[0105] Optionally, the difference-derived weight strategy means that, based on the i-th generation population, the population is propagated based on the first weight (W1), the second weight (W2), and the third weight (W3) to obtain the (i+1)-th generation population.

[0106] Among them, the first weight, the second weight, and the third weight decrease in sequence. The first weight represents the probability that the first type of unconfirmed individuals in the i-th generation population will reproduce in the next generation. The second weight represents the probability that the first type of unconfirmed individuals and the second type of unconfirmed individuals in the i-th generation population will cross-reproduce. The third weight represents the probability that the first type of unconfirmed individuals in the i-th generation population will reproduce in the next generation.

[0107] It should be understood that by setting weights, the proportion of common genetic traits in the (i+1)th generation population can be increased.

[0108] It should be understood that individual iterative inheritance can be achieved through S117. The following explains the genetic operators used in the individual iterative inheritance process: replication, mutation, and crossover.

[0109] The replication genetic operator means to completely preserve the gene sequence of the previous generation, for example, copying from g0 to g1. g0 is the same as g1.

[0110] Mutation genetic operators represent bit flips in certain gene factors of the original individual; a gene factor is replaced by another gene factor, or a gene factor is deleted or added, etc. Here, gene factors are represented as binary sequences, and bitwise operations are actually used to implement them. For example, gene changes are achieved through bit flips, and the mutation process is as follows:

[0111] If the I gene sequence has 12 positions, and if positions 4, 5, and 6 are flipped, then...

[0112] If only one bit is flipped, for example, if the third bit (from low to high) of I = 1110100B undergoes a bit flip, then

[0113] The crossover genetic operator represents the strategy of combining the genes of two individuals to generate a new individual. It is actually implemented using bitwise operations, including point crossover and sequential crossover.

[0114] For example, the intersection of points is: I1 = 0110110B, I2 = 1010100B → I new =1110110B; Sequential crossing is, for example: I1 = 0110100B, I2 = 1010111B → I new =0110110B.

[0115] If the gene sequence has 12 positions, I1 retains the lower 8 positions and I2 retains the upper 4 positions. The specific generation process is as follows:

[0116]

[0117] For example,

[0118] Optionally, during the reproduction process, a weighted natural selection method is selected to analyze the fitness of new individuals, screen the G individuals with the highest fitness for their relatively common genes, assign a weight R to randomly cross individuals containing the gene with other individuals, and conduct random crossover, mutation, and other processes on other individuals.

[0119] After executing S117, the (i+1)th generation population can be obtained. At this point, further processing is needed to obtain the target individual, so return to execute S113.

[0120] S118, when the fitness of the target number of individuals to be confirmed meets the fitness condition, the corresponding individuals to be confirmed are taken as target individuals.

[0121] Optionally, a preset number of individuals to be confirmed are selected as target individuals from those that meet the fitness criteria. The preset number can be less than or equal to the target number.

[0122] Optionally, when the preset number is less than the target number, the preset number of individuals to be confirmed can be determined as target individuals in descending order of fitness.

[0123] It should be understood that the fitness of the individual to be confirmed is a crucial indicator for selecting target individuals. The accuracy of the fitness of the individual to be confirmed directly affects the degree of matching between the target individual and the testing requirements of the testing system, that is, it affects the degree of matching between the target derived message data derived from the target individual and the testing requirements of the testing system. In order to ensure that the stability and accuracy of the testing system can be improved after testing and training the testing system corresponding to the testing requirements using derived message data, it is necessary to accurately obtain the fitness of the individual to be confirmed.

[0124] exist Figure 3 Building upon the previous method, this application also provides a possible implementation for accurately obtaining the fitness of the individual to be confirmed in S114. Please refer to [link / reference]. Figure 5 S114 includes: S114-1, S114-2 and S114-3, which are described in detail below.

[0125] S114-1, obtain the target fault hit value corresponding to each unacknowledged derived message data. The target fault hit value represents the proportion of network protocol faults hit by the unacknowledged derived message data.

[0126] Optionally, the testing system can test the message data corresponding to the network protocol to detect defects and faults, thereby forming a defect database. The defect database contains all or some types of defects detected by the testing system, and the defects in the defect database are different for each type.

[0127] Furthermore, based on the number of faults in the network protocol hit by the derived message data to be confirmed (i.e., the number of faults hit in the defect database) and the total number of faults in the defect database, the target fault hit value can be determined. It should be understood that in order to improve the stability and accuracy of the testing system, the derived message data needs to cover all faults and defects as comprehensively as possible. Therefore, the greater the number of faults in the network protocol hit by the derived message data to be confirmed, the greater the target fault hit value.

[0128] Optionally, the target fault hit value is obtained based on the following operator:

[0129] Eper(I) = I(e) / En*100%;

[0130] Where Eper(I) represents the target fault hit value, I(e) represents the number of faults in the network protocol that the data of the derived message to be confirmed hits, and En represents the total number of faults in the defect database, that is, the total number of faults corresponding to the network protocol.

[0131] S114-2, obtain the processing flow coverage value corresponding to each unacknowledged derived message data. The processing flow coverage value represents the proportion of the processing flow in the network protocol covered by the unacknowledged derived message data.

[0132] Optionally, the processing flow in the network protocol is the same as the flow in the test object of the test system. It should be understood that, in order to improve the stability and accuracy of the test system, the derived message data needs to cover the processing flow in the network protocol as comprehensively as possible. Therefore, the larger the proportion of the derived message data to be confirmed that covers the processing flow in the network protocol, the better.

[0133] Optionally, the values ​​covered by the processing flow are obtained based on the following operators:

[0134] Bper(I) = I(b) / Bn*100%;

[0135] Wherein, Bper(I) represents the value covered by the processing flow, I(b) represents the number of processing flows in the network protocol covered by the data of the derived message to be acknowledged, and En represents the total number of processing flows in the network protocol.

[0136] S114-3, based on the target fault hit value and the processing flow coverage value, determine the fitness of the individual to be confirmed corresponding to the derived message data to be confirmed.

[0137] Optionally, the target fault hit value and the processing procedure coverage value can be weighted and fused to obtain the fitness of the individual to be confirmed. Alternatively, the fitness of the individual to be confirmed can be obtained by averaging the target fault hit value and the processing procedure coverage value.

[0138] Optionally, the fitness of the individual to be identified is obtained based on the following operator:

[0139] F(I)=Eper(I)*40%+Bper(I)*60%, 1%≤F(i)≤100%;

[0140] Wherein, F(I) represents the fitness of the individual to be identified.

[0141] Optionally, a convergence limit L (e.g., 95%) of the fitness function F(I) can be specified. When an individual reaches the limit L of F(I), it is considered to have obtained the optimal individual.

[0142] It should be noted that S114-1 can be executed after S113, and S115 can be executed after S114-3.

[0143] It should also be noted that the test message derivation method provided in this application can flexibly replace the test focus by updating the condition settings in the fitness function, and can also dynamically add gene feature definitions.

[0144] exist Figure 3 Based on this, regarding how to ensure reproduction only within the population, this application also provides a possible implementation method, please refer to... Figure 6Before S113, S11 also includes S111 and S112, which are described in detail below.

[0145] S111, select M individuals from the individual database as the initial population.

[0146] Each individual in the individual database is unique.

[0147] In one possible implementation, the individual database contains all individuals, and the individual database is, for example, {I1, I2, I3, I4... I...} q}, 1≤q≤Q, where Q is expressed as follows:

[0148]

[0149] Where Q represents the total number of individuals in the individual database, and n represents the total number of genes.

[0150] M individuals can be randomly selected from the individual database as the initial population, or they can be matched based on test cases in the test system to determine the M individuals as the initial population; no limitation is made here.

[0151] S112, based on the initial population, the population is propagated to obtain the first generation population.

[0152] It should be understood that in S112, the above-mentioned genetic algorithm is used to complete the population reproduction to obtain the first generation population through genetic operators such as replication, mutation and crossover.

[0153] exist Figure 6 Building upon S111, regarding how to quickly determine the initial population, this application embodiment also provides a possible implementation method, please refer to... Figure 7 S111 includes S111-1 and S111-2, which are described in detail below.

[0154] S111-1, randomly select M different integers from the preset data range [1, Q].

[0155] M can be, but is not limited to, 50.

[0156] S111-2, take the individuals in the individual database corresponding to M integers as the initial population.

[0157] It should be understood that decimal numbers in the preset data range [1, Q] can be converted to binary to represent different individuals.

[0158] exist Figure 3 Based on this, for the content in S12, this application embodiment also provides a possible implementation method, please refer to... Figure 8S12 includes: S121, which is described in detail below.

[0159] S121, determine the target derived message data corresponding to the target individual in the derived data record, wherein the derived data record includes the derived message data obtained in the process of determining the target individual.

[0160] Optionally, when executing S113, based on the gene characteristics contained in each individual to be confirmed in the i-th generation population, performing a transformation operation on the protocol information of the original message data to obtain the corresponding derived message data to be confirmed, the derived message data to be confirmed can be stored to obtain a derived data record.

[0161] It should be understood that directly matching derived data records to determine the target derived message data corresponding to the target individual is, relative to... Figure 9 The proposed solution can reduce one derivation process, thereby improving efficiency.

[0162] exist Figure 2 Based on this, for the content in S12, this application embodiment also provides a possible implementation method, please refer to... Figure 9 S12 includes: S122, which is described in detail below.

[0163] S122, Based on the target individual, perform data transformation on the original message data to obtain target derived message data.

[0164] It should be understood that before executing S11, actual packet data can be captured using packet capture tools. The captured object can be a pre-defined test object, i.e., the test object corresponding to the test packet or test case. Known network packet data can be obtained through packet capture as raw packet data.

[0165] The test message derivation method provided in this application does not require testers to have a detailed understanding of various network protocols; it can generate more effective test data packets in scenarios with limited message data; and it can perform a large number of targeted tests based on the characteristics of the network data testing system, thereby improving the accuracy and coverage of the tests.

[0166] This application also provides a method for training a testing system. Please refer to [link / reference]. Figure 10 The training methods for the test system include S201 and S202, which are described in detail below.

[0167] S201, Obtain the training set.

[0168] The training set includes multiple sets of target derived message data obtained through the aforementioned test message derivation method.

[0169] S202, train the test system based on the training set until the test system meets the preset training criteria.

[0170] It should be understood that training is used to improve the accuracy and coverage of tests.

[0171] Please see Figure 11 , Figure 11 A test message generation device is provided as an embodiment of this application. Optionally, the test message generation device is applied to the electronic device described above.

[0172] The test message generation device includes a processing unit 301 and a generation unit 302.

[0173] The processing unit 301 is used to acquire target individuals that match the test requirements. The genetic features contained in the target individuals match the protocol information. The protocol information belongs to the network protocol corresponding to the test requirements. Each genetic feature is used to indicate the derivation operation on the corresponding protocol information.

[0174] The derivative unit 302 is used to acquire target derivative message data corresponding to the target individual. The target derivative message data is derived message data obtained by performing a transformation operation on the protocol information of the original message data based on the genetic characteristics contained in the target individual. The target derivative message data is used to test the test system corresponding to the test requirements.

[0175] Optionally, the processing unit 301 may execute S11 as described above, and the derivative unit 302 may execute S12 as described above.

[0176] It should be noted that the test message generation device provided in this embodiment can execute the method flow shown in the above method flow embodiment to achieve the corresponding technical effect. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments.

[0177] Please see Figure 12 , Figure 12 The present application provides a test system training device, which is optionally applied to the electronic device described above.

[0178] The test system training device includes an information acquisition unit 401 and a training unit 402.

[0179] Information acquisition unit 401 is used to acquire the training set.

[0180] The training set includes multiple sets of target derived message data obtained through the aforementioned test message derivation method.

[0181] Training unit 402 is used to train the test system based on the training set until the test system meets the preset training criteria.

[0182] Optionally, the information acquisition unit 401 can execute the above-described S201, and the training unit 402 can execute the above-described S202.

[0183] It should be noted that the testing system training device provided in this embodiment can execute the method flow shown in the above method flow embodiment to achieve the corresponding technical effects. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments.

[0184] This application also provides a storage medium storing computer instructions and programs. When read and executed, these instructions and programs perform the test message derivation method and / or test system training method described above. The storage medium may include memory, flash memory, registers, or a combination thereof.

[0185] The following provides an electronic device, which may be a server device, a computer device, a mobile phone device, or other terminal device with computing signal processing capabilities. This electronic device, such as... Figure 1 As shown, the above-described test message derivation method / or test system training method can be implemented; specifically, the electronic device includes: a processor 10, a memory 11, and a bus 12. The processor 10 may be a CPU. The memory 11 is used to store one or more programs, which, when executed by the processor 10, execute the test message derivation method and / or test system training method of the above embodiments.

[0186] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function.

[0187] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0188] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0189] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

[0190] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that this application can be implemented in other specific forms without departing from the spirit or essential characteristics of this application. Therefore, the embodiments should be considered illustrative and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within this application. No reference numerals in the claims should be construed as limiting the scope of the claims.

Claims

1. A method for generating test messages, characterized in that, The method includes: Obtain target individuals that match the testing requirements. The genetic features contained in the target individuals match the protocol information. The protocol information belongs to the network protocol corresponding to the testing requirements. Each genetic feature is used to indicate the derivation operation on the corresponding protocol information. Obtain target-derived message data corresponding to the target individual. The target-derived message data is derived from the protocol information of the original message data by performing a transformation operation based on the genetic characteristics contained in the target individual. The target-derived message data is used to test the test system corresponding to the test requirements. The steps for obtaining target individuals that match the testing requirements include: Based on the genetic characteristics of each individual to be confirmed in the i-th generation population, the protocol information of the original message data is transformed to obtain the corresponding derived message data to be confirmed. The i-th generation population contains at least two individuals to be confirmed. Based on each of the derived message data to be confirmed, the fitness of the corresponding individual to be confirmed is obtained; the fitness represents the degree to which the derived message data to be confirmed matches the test requirements. When the fitness of a target number of individuals to be confirmed meets the fitness condition, the corresponding individual to be confirmed is taken as the target individual.

2. The test message derivation method as described in claim 1, characterized in that, Also includes: When there are no individuals of the target number whose fitness meets the fitness condition, obtain the first type of individuals to be confirmed, the second type of individuals to be confirmed, and the third type of individuals to be confirmed. Wherein, the fitness of the first type of individuals to be confirmed is among the top N in the ranking, and any two individuals of the first type to be confirmed have common genetic characteristics; the fitness of the second type of individuals to be confirmed is among the top N in the ranking, and any two individuals of the first type to be confirmed have different genetic characteristics; the fitness of the third type of individuals to be confirmed is not among the top N in the ranking. Based on the difference-derived weighting strategy, the first type of unconfirmed individuals, the second type of unconfirmed individuals, and the third type of unconfirmed individuals are propagated to obtain the (i+1)th generation population; the difference-derived weighting strategy is used to indicate the increase of the proportion of the common genetic characteristics.

3. The test message derivation method as described in claim 1, characterized in that, The step of obtaining the fitness of the corresponding individual to be confirmed based on each of the derived message data to be confirmed includes: Obtain the target fault hit value corresponding to each of the unacknowledged derived message data, wherein the target fault hit value represents the proportion of the unacknowledged derived message data that hits a fault in the network protocol; Obtain the processing flow coverage value corresponding to each of the unacknowledged derived message data, wherein the processing flow coverage value represents the proportion of the unacknowledged derived message data that covers the processing flow in the network protocol; Based on the target fault hit value and the processing flow coverage value, the fitness of the individual to be confirmed corresponding to the derived message data to be confirmed is determined.

4. The test message derivation method as described in claim 1, characterized in that, The step of obtaining target individuals that match the testing requirements also includes: M individuals are selected from the individual database as the initial population, wherein each individual in the individual database is distinct; Based on the initial population, the population is propagated to obtain the first generation population.

5. The test message derivation method as described in claim 4, characterized in that, The step of determining M individuals from the individual database as the initial population includes: M distinct integers are randomly selected from the preset data range [1, Q]. in, Q represents the total number of individuals in the individual database, n represents the total number of genes, and different integers correspond to different individuals in the individual database; Use the individuals in the database corresponding to the M integers as the initial population.

6. The test message derivation method as described in claim 1, characterized in that, The step of obtaining the target-derived message data corresponding to the target individual includes: The target derived message data corresponding to the target individual is determined in the derived data record, wherein the derived data record includes the derived message data obtained in the process of determining the target individual.

7. The test message derivation method as described in claim 1, characterized in that, The step of obtaining the target-derived message data corresponding to the target individual includes: Based on the target individual, the original message data is transformed to obtain the target derived message data.

8. A method for training a testing system, characterized in that, The method includes: The test system is trained based on the training set until the test system meets the preset training criteria. The training set includes multiple sets of target derived message data obtained by the test message derivation method according to any one of claims 1-7.

9. A test message generation device, characterized in that, The device includes: The processing unit is used to acquire target individuals that match the test requirements. The genetic features contained in the target individuals match the protocol information, which belongs to the network protocol corresponding to the test requirements. Each genetic feature is used to indicate the derivation operation on the corresponding protocol information. The derivation unit is used to acquire target derived message data corresponding to the target individual. The target derived message data is derived message data obtained by performing a derivation operation on the protocol information of the original message data based on the genetic characteristics contained in the target individual. The target derived message data is used to test the test system corresponding to the test requirements. The acquisition of target individuals matching the testing requirements includes: performing a transformation operation on the protocol information of the original message data based on the gene characteristics contained in each individual to be confirmed in the i-th generation population to obtain corresponding derived message data to be confirmed, wherein the i-th generation population contains at least two individuals to be confirmed; obtaining the fitness of the corresponding individual to be confirmed based on each derived message data to be confirmed; the fitness characterizes the degree to which the derived message data to be confirmed matches the testing requirements; when there is a target number of individuals to be confirmed whose fitness meets the fitness condition, the corresponding individuals to be confirmed are taken as the target individuals.

10. A test system training device, characterized in that, The device includes: The training unit is used to train the test system based on the training set until the test system meets the preset training criteria. The training set includes multiple sets of target derived message data obtained by the test message derivation method according to any one of claims 1-7.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7 or 8.

12. An electronic device, characterized in that, include: Processor and memory, the memory being used to store one or more programs; When the one or more programs are executed by the processor, the method as described in any one of claims 1-7 or 8 is implemented.

Citation Information

Patent Citations

  • Vulnerability mining method and device, vulnerability repairing and verification method and device, and electronic equipment

    CN110348220A

  • Fuzzy test method and device based on network protocol and computer readable medium

    CN111628900A