Network protocol test data generation method and device, equipment and medium
By introducing a multi-head self-attention mechanism into the WGAN model, the gradient explosion problem in the traditional GAN generation of network protocol test data is solved, generating diverse and efficient test data, thus improving testing efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU DIANZI UNIV
- Filing Date
- 2026-01-20
- Publication Date
- 2026-05-08
AI Technical Summary
Traditional GANs suffer from backpropagation gradient explosion when generating network protocol test data, resulting in poor diversity of generated test cases. Furthermore, traditional tools are inefficient in generating test cases, increasing the burden on testers.
We adopt the WGAN model as the basic framework and add a multi-head self-attention mechanism to it to construct a target generative adversarial network model. We process the long and short distance dependencies of data through LSTM layers and multi-head self-attention layers to generate diverse network protocol test data.
It improves the robustness and efficiency of test data generation, making the generated test data more accurate and less likely to be rejected by the software server, thus saving labor costs.
Smart Images

Figure CN121996552A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method, apparatus, device, and medium for generating network protocol test data. Background Technology
[0002] As the Internet of Things (IoT) industry continues to grow, the risks of network protocol security threats are also increasing. Therefore, comprehensive security testing of commonly used software systems is crucial. Typically, security testing employs fuzzing, which involves providing the target program with a large number of unexpected inputs. This helps uncover potential security issues, improves the software's resistance to attacks, and contributes to ensuring information security.
[0003] A crucial aspect of fuzzing is the generation of test data. Fuzzing can verify software security and identify potential vulnerabilities and issues by automatically generating a large amount of "random" input data. However, the "randomness" of the input data does not mean arbitrary data, but rather a dataset with characteristics similar to the original dataset.
[0004] In related technologies, traditional GANs are used to generate fake data packets from the original dataset. However, traditional GANs suffer from the backpropagation gradient explosion problem, and the use of a binary classifier as a discriminator fails to provide additional useful information to the generator, resulting in poor diversity of generated test cases. Other methods use automated tools to randomly mutate all fields of the data to generate network protocol test data. This approach requires standardizing the input data format, increasing the burden on testers and leading to low testing efficiency. Summary of the Invention
[0005] This invention provides a method, apparatus, device, and medium for generating network protocol test data. By using the LSTM layer and multi-head self-attention layer of the generator in the target generative adversarial network model based on WGAN, it can more effectively handle the long and short distance dependencies of data, stably generate diverse network protocol test data, save manpower, and improve testing efficiency.
[0006] According to one aspect of the present invention, a method for generating network protocol test data is provided, the method comprising:
[0007] Acquire reference test data for the software system under test and a pre-built target generative adversarial network model based on WGAN; wherein, the target generative adversarial network model includes a generator and a discriminator, the generator includes an LSTM layer and a multi-head self-attention layer, and the discriminator includes a GRU layer and a multi-head self-attention layer;
[0008] Initial test data is generated using the generator in the target generative adversarial network model, and the target generative adversarial network model is iteratively trained based on the initial test data and the reference test data.
[0009] When the target generative adversarial network model meets the preset stopping condition, the training process of the target generative adversarial network model is stopped, and the generator in the target generative adversarial network model is determined as the data generation model, so as to generate the target test data of the software system under test based on the data generation model.
[0010] According to another aspect of the present invention, an apparatus for generating network protocol test data is provided, the apparatus comprising:
[0011] The information acquisition module is used to acquire reference test data of the software system under test and a target generative adversarial network model pre-built based on WGAN; wherein, the target generative adversarial network model includes a generator and a discriminator, the generator includes an LSTM layer and a multi-head self-attention layer, and the discriminator includes a GRU layer and a multi-head self-attention layer;
[0012] The network model training module is used to generate initial test data using the generator in the target generative adversarial network model, and to iteratively train the target generative adversarial network model based on the initial test data and the reference test data.
[0013] The test data generation module is used to stop the training process of the target generative adversarial network model when the target generative adversarial network model meets the preset stopping conditions, and to determine the generator in the target generative adversarial network model as the data generation model, so as to generate target test data of the software system under test based on the data generation model.
[0014] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0015] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the method for generating network protocol test data according to any embodiment of the present invention.
[0016] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the method for generating network protocol test data according to any embodiment of the present invention.
[0017] The technical solution of this invention first obtains reference test data of the software system under test and a target generative adversarial network model pre-built based on WGAN. The target generative adversarial network model includes a generator and a discriminator. The generator includes an LSTM layer and a multi-head self-attention layer, and the discriminator includes a GRU layer and a multi-head self-attention layer. Then, initial test data is generated using the generator in the target generative adversarial network model. The target generative adversarial network model is iteratively trained based on the initial test data and the reference test data. When the target generative adversarial network model meets a preset stopping condition, the training process of the target generative adversarial network model is stopped, and the generator in the target generative adversarial network model is determined as the data generation model, so as to generate target test data of the software system under test based on the data generation model. This technical solution addresses the problem of gradient explosion during backpropagation that traditional GANs are prone to. It adopts the WGAN model as the basic framework and adds a multi-head self-attention mechanism to the original WGAN model to construct a target generative adversarial network model. This mechanism enables the model to handle the long and short distance dependencies of data more effectively, thereby generating more diverse, accurate test data that is less likely to be rejected by the software server. This improves the robustness of test data generation, saves manpower, improves testing efficiency, and obtains more comprehensive and effective test data.
[0018] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart of a method for generating network protocol test data according to an embodiment of the present invention;
[0021] Figure 2 This is a flowchart of a target generative adversarial network model provided according to an embodiment of the present invention;
[0022] Figure 3 This is a flowchart of another method for generating network protocol test data according to an embodiment of the present invention;
[0023] Figure 4 This is a schematic diagram of a network protocol test data generation device according to an embodiment of the present invention;
[0024] Figure 5 This is a schematic diagram of the structure of an electronic device that implements a method for generating network protocol test data according to an embodiment of the present invention. Detailed Implementation
[0025] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0026] It should be noted that the terms "first," "second," "target," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] Example 1
[0028] Figure 1 This is a flowchart illustrating a method for generating network protocol test data according to Embodiment 1 of the present invention. This embodiment is applicable to generating diverse network protocol test data. The method can be executed by a network protocol test data generation device, which can be implemented in hardware and / or software and can be configured in an electronic device with data processing capabilities. Figure 1 As shown, the method includes:
[0029] S110, acquire reference test data of the software system under test and a target generative adversarial network model pre-built based on WGAN; wherein, the target generative adversarial network model includes a generator and a discriminator, the generator includes an LSTM layer and a multi-head self-attention layer, and the discriminator includes a GRU layer and a multi-head self-attention layer.
[0030] The software system under test (MST) can refer to a software system that requires network protocol testing. Reference test data refers to real test data from the MST, which can serve as an important basis for training the network model. For example, for simulation software, industrial protocol data can be collected as its reference test data, represented in hexadecimal character format. The target generative adversarial network (GAN) model can refer to a GAN model built based on WGAN, specifically including a generator and a discriminator. The generator includes LSTM layers and multi-head self-attention layers, and the discriminator includes GRU layers and multi-head self-attention layers. To obtain more accurate and more dependent fuzzy test data, this invention adds a multi-head self-attention mechanism to the generator framework, enabling the generator to possess fine-grained sequence modeling capabilities.
[0031] Among them, WGAN (Wasserstein Generative Adversarial Network) is an improvement on Generative Adversarial Networks (GANs). By introducing Wasserstein distance (i.e., the distance the Earth moves) as a loss function, it solves the problems of unstable training and pattern collapse in traditional GANs, significantly improving the quality and diversity of generated samples. LSTM (Long Short-Term Memory) is a special type of recurrent neural network (RNN). By introducing gating mechanisms and memory units, it effectively solves the gradient vanishing and gradient exploding problems faced by traditional RNNs when processing long sequence data, and can capture long-term dependencies in the sequence. Multi-Head Self-Attention, by computing multiple attention heads in parallel, enables the model to simultaneously capture multiple dependencies at different positions and in different subspaces of the input sequence, significantly improving the model's ability to model complex semantics and long-distance dependencies. GRU (Gated Recurrent Unit) solves the gradient vanishing and gradient exploding problems of traditional RNNs by introducing gating mechanisms, and achieves effective modeling of long sequence dependencies with a simpler structure (compared to LSTM).
[0032] S120: Initial test data is generated using the generator in the target generative adversarial network model, and the target generative adversarial network model is iteratively trained based on the initial test data and reference test data.
[0033] The initial test data can refer to fake test data generated by the generator in the target generative adversarial network (PGAN) model. The PGAN model employs an iterative training approach, alternately optimizing the generator and discriminator, adjusting their learning rates using cosine annealing after each iteration. Through this alternating training of the generator and discriminator, the generator eventually learns the distribution characteristics of real data, generating realistic data that is difficult for the discriminator to distinguish.
[0034] Furthermore, the loss function used during model training is defined using the WGAN-GP (Wasserstein GAN with Gradient Penalty) architecture. WGAN-GP is an improvement on Generative Adversarial Networks (GANs) by introducing a gradient penalty term, which solves the training instability problem caused by weight clipping in the original WGAN, significantly improving the training stability and generation performance of the target GAN model.
[0035] In this embodiment, optionally, the discriminator loss function of the target generative adversarial network model is constructed based on the negative mean of the discriminator output corresponding to the reference test data, the mean of the discriminator output corresponding to the initial test data, and the gradient penalty term. For example, the discriminator loss function loss_D can be specifically expressed as follows: loss_D = fake_score.mean() - real_score.mean() + GP_WEIGHT × gp, where fake_score.mean() represents the mean of the discriminator output corresponding to the initial test data, -real_score.mean() represents the negative mean of the discriminator output corresponding to the reference test data, GP_WEIGHT represents the weight (i.e., penalty coefficient) of the gradient penalty term, and gp represents the gradient penalty term, calculated by the gradient penalty function, which can be used to satisfy the 1-Lipschitz constraint of WGAN-GP.
[0036] In this embodiment, optionally, the generator loss function of the target generative adversarial network model is constructed based on the negative mean of the discriminator output corresponding to the initial test data.
[0037] The generator loss function, loss_G, calculates the negative mean loss with the goal of maximizing the discriminator score, and can be expressed as: loss_G = -fake_score.mean(). All loss calculations are performed in the embedding space, significantly improving model training stability.
[0038] In this embodiment, optionally, the generator in the target generative adversarial network model generates initial test data, including: inputting random noise data into the generator, converting the random noise data into a format based on a preset mapping dictionary to obtain reference noise data; determining the hidden state of the reference noise data at each time step through an LSTM layer, and weighting and fusing the hidden states at each time step through a multi-head self-attention layer to obtain target noise data; and performing linear projection and nonlinear activation on the target noise data to obtain the initial test data corresponding to the random noise data.
[0039] Figure 2 This invention provides a flowchart of a target generative adversarial network (GAN) model. The generator in this model includes an input layer, a reshaping layer, an LSTM layer, layer normalization, a multi-head self-attention layer, a feedforward network, a fully connected layer, and an output layer. Figure 2 As shown, random noise data is first input into the generator through the input layer, and then the random noise data is converted into reference noise data through the reshaping layer based on a preset mapping dictionary. The pre-defined mapping dictionary describes how to transform the input data into the format required by the model. Then, the reference noise data is mapped to a sequence of hidden states in chronological order using an LSTM layer. See formula This allows us to obtain the hidden state of the reference noise data at each time step and perform layer normalization. These are the memory units of the LSTM layer, with the same tensor form as the hidden state, used to record additional information; As the output gate unit of the LSTM layer, the output gate determines how much information is passed from the memory cell to the hidden state during the computation process. As and Partial input. Then, the hidden states at each time step are weighted and fused through a multi-head self-attention layer to obtain the target noise data. Then, a nonlinear transformation is performed through a feedforward network, and then a fully connected layer is used to perform linear projection and nonlinear activation on the target noise data. The softmax function is used to generate the character probability vector of the target noise data and output it through the output layer. Thus, the initial test data generated using random noise data (i.e., Figure 2 (The protocol data in the file).
[0040] In this embodiment, after generating initial test data, the target generative adversarial network model can be iteratively trained based on the initial test data and reference test data. Optionally, iterative training of the target generative adversarial network model based on the initial test data and reference test data includes: determining interpolated test data based on the initial test data and reference test data; inputting the initial test data, reference test data, and interpolated test data into the discriminator, and determining the discriminator output corresponding to the initial test data, reference test data, and interpolated test data, respectively; determining a gradient penalty term based on the discriminator output corresponding to the interpolated test data, and determining the current discriminator loss based on the negative mean of the discriminator output corresponding to the reference test data, the mean of the discriminator output corresponding to the initial test data, and the gradient penalty term; determining the gradient of the current discriminator loss with respect to the current discriminator parameters as the current gradient, and optimizing the current discriminator parameters based on the current gradient; and backpropagating the current gradient to the generator, and optimizing the current generator parameters based on the current gradient.
[0041] Specifically, firstly, in the initial test data and reference test data (i.e. Figure 2 Interpolation test data is generated by randomly interpolating between real datasets (as shown in the following formula): ,in, , This represents interpolated test data. This indicates that the reference test data is being used. This represents the initial test data. Then, the initial test data, reference test data, and interpolated test data (not included in the initial data) are presented. Figure 2 The inputs (as shown in the image) are fed into the discriminator to determine the discriminator outputs (i.e., the initial test data, reference test data, and interpolated test data) corresponding to the initial test data, reference test data, and interpolated test data, respectively. Figure 2 (discrimination probability in the data).
[0042] In this embodiment, optionally, the discriminator outputs corresponding to the initial test data, reference test data, and interpolated test data are determined respectively, including: performing format conversion based on a preset mapping dictionary for the initial test data, reference test data, and interpolated test data respectively, and raising them to the hidden dimension through linear projection; obtaining the hidden state at each time step by scanning in chronological order through a GRU layer, performing weighted fusion of the hidden states at each time step through a multi-head self-attention layer, and obtaining a fixed-length sentence representation through average pooling; and determining the scalar score corresponding to the fixed-length sentence representation as the discriminator output through a two-layer spectral normalized linear mapping.
[0043] For example, taking industrial protocol data represented by hexadecimal characters as reference test data, when performing format conversion, the hexadecimal characters are first converted into integer indices of 0-15 through a preset mapping dictionary, and then the processed integer sequence is converted into a PyTorch long integer tensor, thereby mapping the character index sequence into a continuous word vector.
[0044] Next, the gradient penalty term is determined based on the discriminator output corresponding to the interpolated test data, as shown in the following formula: ,in, Represents the gradient penalty term. This represents the gradient of the discriminator with respect to the interpolated test data. This represents the gradient penalty function. express The corresponding discriminator output. Then, the negative mean of the discriminator output corresponding to the reference test data, the mean of the discriminator output corresponding to the initial test data, and the gradient penalty term are added together to obtain the current discriminator loss.
[0045] After obtaining the current discriminator loss, the gradient of the current discriminator loss with respect to the current discriminator parameters is calculated as the current gradient, and the current discriminator parameters are optimized based on this gradient. Optionally, optimizing the current discriminator parameters based on the current gradient includes: gradient clipping of the current gradient, and optimizing the current discriminator parameters based on the clipped gradient. Gradient penalty avoids gradient vanishing or exploding caused by weight clipping, enabling smoother discriminator parameter updates. Finally, the current gradient is backpropagated to the generator, and the current generator parameters are optimized based on the current gradient, allowing the generator to more efficiently learn the distribution characteristics of the real data and generate new data samples with similar characteristics to the original data but with some variations.
[0046] S130, when the target generative adversarial network model meets the preset stopping condition, stop the training process of the target generative adversarial network model, and determine the generator in the target generative adversarial network model as the data generation model, so as to generate the target test data of the software system under test based on the data generation model.
[0047] The preset stopping condition can refer to a pre-set condition for ending model training based on actual needs. For example, the preset stopping condition could be set to the current loss function value being less than a preset loss value or the current iteration count reaching a preset number. The target test data can refer to fake test data generated using a data generation model.
[0048] In this embodiment, after each iteration of training, it is necessary to determine whether the target generative adversarial network (GAN) model meets the preset stopping condition. If it does not meet the condition, iterative training needs to continue; if it does meet the condition, the training process of the target GAN model is immediately stopped, and the generator in the target GAN model is determined as the data generation model. Subsequent use only requires inputting the original protocol data into the data generation model to generate the target test data corresponding to the original protocol data, which can then be used as fuzzy test data input into the software system under test (see [link]). Figure 2 Network software testing is performed on the system under test (the system in question) to verify the security of the software system under test.
[0049] The technical solution of this invention first obtains reference test data of the software system under test and a target generative adversarial network model pre-built based on WGAN. The target generative adversarial network model includes a generator and a discriminator. The generator includes an LSTM layer and a multi-head self-attention layer, and the discriminator includes a GRU layer and a multi-head self-attention layer. Then, initial test data is generated using the generator in the target generative adversarial network model. The target generative adversarial network model is iteratively trained based on the initial test data and the reference test data. When the target generative adversarial network model meets a preset stopping condition, the training process of the target generative adversarial network model is stopped, and the generator in the target generative adversarial network model is determined as the data generation model, so as to generate target test data of the software system under test based on the data generation model. This technical solution addresses the problem of gradient explosion during backpropagation that traditional GANs are prone to. It adopts the WGAN model as the basic framework and adds a multi-head self-attention mechanism to the original WGAN model to construct a target generative adversarial network model. This mechanism enables the model to handle the long and short distance dependencies of data more effectively, thereby generating more diverse, accurate test data that is less likely to be rejected by the software server. This improves the robustness of test data generation, saves manpower, improves testing efficiency, and obtains more comprehensive and effective test data.
[0050] Example 2
[0051] Figure 3 This is a flowchart of a method for generating network protocol test data according to Embodiment 2 of the present invention. This embodiment is an optimization based on the above embodiment.
[0052] like Figure 3 As shown, the method in this embodiment specifically includes the following steps:
[0053] S210: Obtain reference test data for the software system under test and a pre-built target generative adversarial network model based on WGAN.
[0054] The target generative adversarial network model includes a generator and a discriminator. The generator includes an LSTM layer and a multi-head self-attention layer, and the discriminator includes a GRU layer and a multi-head self-attention layer.
[0055] S220: Input random noise data into the generator, and perform format conversion on the random noise data based on a preset mapping dictionary to obtain reference noise data.
[0056] S230 uses an LSTM layer to determine the hidden state of the reference noise data at each time step, and uses a multi-head self-attention layer to perform weighted fusion of the hidden states at each time step to obtain the target noise data.
[0057] S240 performs linear projection and nonlinear activation on the target noise data to obtain the initial test data corresponding to the random noise data.
[0058] S250, the target generative adversarial network model is iteratively trained based on the initial test data and the reference test data.
[0059] The discriminator loss function of the target generative adversarial network model is constructed based on the negative mean of the discriminator output corresponding to the reference test data, the mean of the discriminator output corresponding to the initial test data, and a gradient penalty term. The generator loss function of the target generative adversarial network model is constructed based on the negative mean of the discriminator output corresponding to the initial test data.
[0060] S260, when the target generative adversarial network model meets the preset stopping condition, stop the training process of the target generative adversarial network model, and determine the generator in the target generative adversarial network model as the data generation model, so as to generate the target test data of the software system under test based on the data generation model.
[0061] The technical solution of this invention addresses the problem of gradient explosion during backpropagation that is common in traditional GANs. It adopts the WGAN model as the basic framework and adds a multi-head self-attention mechanism to the original WGAN model to construct a target generative adversarial network model. This mechanism enables the model to more effectively handle long and short distance dependencies in data, thereby generating diverse, more accurate test data that is less likely to be rejected by the software server. This improves the robustness of test data generation, saves manpower, increases testing efficiency, and obtains more comprehensive and effective test data.
[0062] Example 3
[0063] Figure 4 This is a schematic diagram of a network protocol test data generation device provided in Embodiment 3 of the present invention. This device can execute the network protocol test data generation method provided in any embodiment of the present invention, and possesses the corresponding functional modules and beneficial effects of the method. For example... Figure 4As shown, the device includes:
[0064] The information acquisition module 310 is used to acquire reference test data of the software system under test and a target generative adversarial network model pre-built based on WGAN; wherein, the target generative adversarial network model includes a generator and a discriminator, the generator includes an LSTM layer and a multi-head self-attention layer, and the discriminator includes a GRU layer and a multi-head self-attention layer.
[0065] The network model training module 320 is used to generate initial test data using the generator in the target generative adversarial network model, and to iteratively train the target generative adversarial network model based on the initial test data and the reference test data.
[0066] The test data generation module 330 is used to stop the training process of the target generative adversarial network model when the target generative adversarial network model meets the preset stopping conditions, and to determine the generator in the target generative adversarial network model as the data generation model, so as to generate the target test data of the software system under test based on the data generation model.
[0067] Optionally, the discriminator loss function of the target generative adversarial network model is constructed based on the negative mean of the discriminator output corresponding to the reference test data, the mean of the discriminator output corresponding to the initial test data, and the gradient penalty term.
[0068] Optionally, the generator loss function of the target generative adversarial network model is constructed based on the negative mean of the discriminator output corresponding to the initial test data.
[0069] Optionally, the network model training module 320 is used for:
[0070] Random noise data is input into the generator, and reference noise data is obtained by format conversion of the random noise data based on a preset mapping dictionary.
[0071] The hidden state of the reference noise data at each time step is determined by an LSTM layer, and the target noise data is obtained by weighted fusion of the hidden states at each time step by a multi-head self-attention layer.
[0072] The target noise data is subjected to linear projection and nonlinear activation to obtain the initial test data corresponding to the random noise data.
[0073] Optionally, the network model training module 320 is further configured to:
[0074] The interpolated test data is determined based on the initial test data and the reference test data;
[0075] The initial test data, reference test data, and interpolated test data are input into the discriminator, and the discriminator outputs corresponding to the initial test data, reference test data, and interpolated test data are determined respectively.
[0076] The gradient penalty term is determined based on the discriminator output corresponding to the interpolated test data, and the current discriminator loss is determined based on the negative mean of the discriminator output corresponding to the reference test data, the mean of the discriminator output corresponding to the initial test data, and the gradient penalty term.
[0077] The gradient of the current discriminator loss with respect to the current discriminator parameters is determined as the current gradient, and the current discriminator parameters are optimized based on the current gradient;
[0078] The current gradient is backpropagated to the generator, and the parameters of the current generator are optimized based on the current gradient.
[0079] Optionally, the network model training module 320 is further configured to:
[0080] For the initial test data, reference test data, and interpolated test data, respectively, format conversion is performed based on the preset mapping dictionary, and then linear projection is used to raise them to the hidden dimension.
[0081] The hidden state at each time step is obtained by scanning in chronological order through the GRU layer, and the hidden state at each time step is weighted and fused through the multi-head self-attention layer. The fixed-length sentence representation is obtained by average pooling.
[0082] The scalar score corresponding to the fixed-length sentence representation is determined by a two-layer spectral normalized linear mapping and used as the output of the discriminator.
[0083] Optionally, the network model training module 320 is further configured to:
[0084] The current gradient is clipped, and the parameters of the current discriminator are optimized based on the clipped gradient.
[0085] The network protocol test data generation device provided in this embodiment of the invention can execute the network protocol test data generation method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0086] Example 4
[0087] Figure 5A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0088] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0089] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0090] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as methods for generating network protocol test data.
[0091] In some embodiments, the method for generating network protocol test data may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the method for generating network protocol test data described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the method for generating network protocol test data by any other suitable means (e.g., by means of firmware).
[0092] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0093] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0094] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0095] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0096] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0097] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0098] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0099] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for generating network protocol test data, characterized in that, The method includes: Acquire reference test data for the software system under test and a pre-built target generative adversarial network model based on WGAN; wherein, the target generative adversarial network model includes a generator and a discriminator, the generator includes an LSTM layer and a multi-head self-attention layer, and the discriminator includes a GRU layer and a multi-head self-attention layer; Initial test data is generated using the generator in the target generative adversarial network model, and the target generative adversarial network model is iteratively trained based on the initial test data and the reference test data. When the target generative adversarial network model meets the preset stopping condition, the training process of the target generative adversarial network model is stopped, and the generator in the target generative adversarial network model is determined as the data generation model, so as to generate the target test data of the software system under test based on the data generation model.
2. The method according to claim 1, characterized in that, The discriminator loss function of the target generative adversarial network model is constructed based on the negative mean of the discriminator output corresponding to the reference test data, the mean of the discriminator output corresponding to the initial test data, and the gradient penalty term.
3. The method according to claim 1, characterized in that, The generator loss function of the target generative adversarial network model is constructed based on the negative mean of the discriminator output corresponding to the initial test data.
4. The method according to any one of claims 1-3, characterized in that, Initial test data is generated using the generator in the target generative adversarial network model, including: Random noise data is input into the generator, and reference noise data is obtained by format conversion of the random noise data based on a preset mapping dictionary. The hidden state of the reference noise data at each time step is determined by an LSTM layer, and the target noise data is obtained by weighted fusion of the hidden states at each time step by a multi-head self-attention layer. The target noise data is subjected to linear projection and nonlinear activation to obtain the initial test data corresponding to the random noise data.
5. The method according to claim 4, characterized in that, Iterative training of the target generative adversarial network model based on the initial test data and the reference test data includes: The interpolated test data is determined based on the initial test data and the reference test data; The initial test data, reference test data, and interpolated test data are input into the discriminator, and the discriminator outputs corresponding to the initial test data, reference test data, and interpolated test data are determined respectively. The gradient penalty term is determined based on the discriminator output corresponding to the interpolated test data, and the current discriminator loss is determined based on the negative mean of the discriminator output corresponding to the reference test data, the mean of the discriminator output corresponding to the initial test data, and the gradient penalty term. The gradient of the current discriminator loss with respect to the current discriminator parameters is determined as the current gradient, and the current discriminator parameters are optimized based on the current gradient; The current gradient is backpropagated to the generator, and the parameters of the current generator are optimized based on the current gradient.
6. The method according to claim 5, characterized in that, Determine the discriminator outputs corresponding to the initial test data, reference test data, and interpolated test data, respectively, including: For the initial test data, reference test data, and interpolated test data, respectively, format conversion is performed based on the preset mapping dictionary, and then linear projection is used to raise them to the hidden dimension. The hidden state at each time step is obtained by scanning in chronological order through the GRU layer, and the hidden state at each time step is weighted and fused through the multi-head self-attention layer. The fixed-length sentence representation is obtained by average pooling. The scalar score corresponding to the fixed-length sentence representation is determined by a two-layer spectral normalized linear mapping and used as the output of the discriminator.
7. The method according to claim 5, characterized in that, Optimize the current discriminator parameters based on the current gradient, including: The current gradient is clipped, and the parameters of the current discriminator are optimized based on the clipped gradient.
8. A device for generating network protocol test data, characterized in that, The device includes: The information acquisition module is used to acquire reference test data of the software system under test and a target generative adversarial network model pre-built based on WGAN; wherein, the target generative adversarial network model includes a generator and a discriminator, the generator includes an LSTM layer and a multi-head self-attention layer, and the discriminator includes a GRU layer and a multi-head self-attention layer; The network model training module is used to generate initial test data using the generator in the target generative adversarial network model, and to iteratively train the target generative adversarial network model based on the initial test data and the reference test data. The test data generation module is used to stop the training process of the target generative adversarial network model when the target generative adversarial network model meets the preset stopping conditions, and to determine the generator in the target generative adversarial network model as the data generation model, so as to generate target test data of the software system under test based on the data generation model.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the method for generating network protocol test data according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, implement the method for generating network protocol test data according to any one of claims 1-7.