Network Packet Generation Method, Apparatus, Device, and Medium
The network packet generation method addresses the limitations of existing generators by allowing for specific and random packet types within protocol constraints, ensuring comprehensive packet coverage.
Patent Information
- Application Number
- CN202310252778.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-15
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2043-03-15
AI Technical Summary
Existing network message generators have difficulty generating a specific type of random message, and cannot effectively cover thousands of message combinations, resulting in difficulty in testing.
It provides a network message generation method, which receives user configuration data structures through the display message format setting interface, filters and checks the message type collection, generates target messages that comply with the protocol, and supports the generation of messages of specific types and random types.
It realizes the generation of random messages of a specific type, and can output random messages of a certain level of a specific type and other levels within the scope of the protocol permission, meeting the testing needs of different network transmission protocols.
Smart Images

Figure CN116320050B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of chips and network packet generation, and particularly relates to a network packet generation method, device, equipment and medium. Background Art
[0002] With the rapid development of the network, different network transmission protocols have different encapsulations and conversions of packet formats. The packet generator needs to be able to cover the types supported or not supported by the chip application scenarios, and flexibly screen the required packet combinations according to the test needs.
[0003] However, the main functions that can be achieved by the packet generator in the related art center are: generating specific packets, where all parameters are determined values, that is, specifying all levels of the packet; and generating random packets, with random parameters, covering all packets that need to be supported, that is, the entire packet is completely random. Therefore, if you want to test a specific type of packet, you can only generate specific packets and perform manual permutations and combinations of the specific type of packet format. When there are thousands of combinations of a specific type of packet, it is difficult to achieve complete coverage. Summary of the Invention
[0004] The present invention provides a network packet generation method, device, computer equipment and medium to solve the technical problem of generating a random packet of a specific type and outputting a packet whose type at a certain level is a specific type and the types at other levels are random within the scope permitted by the protocol.
[0005] In a first aspect, a network packet generation method is provided, including:
[0006] Responding to a packet generation instruction, displaying a packet format setting interface, where the packet format setting interface receives the data structure configured by the user for the packet to be generated, and the data structure includes a packet type set, and the packet type set includes a random type and / or a specific type;
[0007] Determining whether the packet type set contains a random type. If it contains a random type, screening the packet type set to obtain a candidate packet type set that meets the protocol;
[0008] Performing a validity check on the candidate packet type set to obtain a target packet type set;
[0009] Generating a target packet according to the target packet type set.
[0010] In some embodiments, the packet format setting interface receiving the data structure configured by the user for the packet to be generated includes:
[0011] Receiving the following configuration information: configuration of whether the packet type set is random; configuration of whether it is a random packet of a specific type;
[0012] If the message type set is configured to be random, generate the hierarchical indexes of the messages. The type set packet_type_queue = {T0, T1, T2,..., T n}, where T represents Type, and the subscripts 0, 1, 2,..., n represent the indexes of the levels. n is the maximum number of levels supported by all protocols, and each of T0 to n has optional items;
[0013] If the message type set is configured to be non-random, the type set
[0014] packet_type_queue = {T c0 , T c1 , T c2 ,..., T cm}, where T c0~cm is a fixed value, and m is less than or equal to n.
[0015] In some embodiments, screening the message type set to obtain a candidate message type set that meets the protocol includes:
[0016] Determine the classification of the random types in the message type set;
[0017] If it is a completely random message, solve according to the forward and reverse constraints;
[0018] If it is a specific type of random, solve according to the three constraints of forward, reverse, and specific and the configured specific type constraints; among them, the configured specific types have two modes: inclusion and non-inclusion. Inclusion is to generate random messages of a specific type, and non-inclusion is that all generated random messages do not include this specific type.
[0019] In some embodiments, performing a validity check on the candidate message type set to obtain a target message type set includes:
[0020] Determine whether None and / or Pld exist in the candidate message type set;
[0021] If None and / or Pld exist between the message type sets, remove the invalid indexes until all elements in the set are traversed.
[0022] In some embodiments, performing a validity check on the candidate message type set to obtain a target message type set includes:
[0023] For each type in real_packet_type_queue, add the corresponding class entity one by one to a set of classes real_packet_class_queue. When adding the next class entity, modify the pld of the previous entity to point to the next class entity;
[0024] When real_packet_class_queue = {A, B, C}, packing A enables nested packing of B and C, and finally a message containing the three class entities A, B, and C is obtained.
[0025] In some embodiments, the data structure further includes: a preset message length and a message length integration method;
[0026] After generating the target message according to the target message type set, it further includes:
[0027] Determine whether the length of the target message is consistent with the preset message length,
[0028] If not, integrate the length of the target message into the preset message length according to the message length integration method.
[0029] In some embodiments, integrating the length of the target message into the preset message length according to the message length integration method includes:
[0030] If the preset message length is less than the length of the target message, intercept the message from the beginning according to the preset message length or output the complete message, and modify the preset message length to the length of the target message;
[0031] If the preset message length is greater than the length of the target message, fill in random numbers or fixed values according to the preset message length to make the length of the target message equal to the preset message length.
[0032] In a second aspect, a network message generation device is provided, including:
[0033] An initial module of the message, configured to respond to a message generation instruction, display a message format setting interface, and the message format setting interface receives the data structure configured by the user for the message to be generated, and the data structure includes a message type set, and the message type set includes a random type and / or a specific type;
[0034] A constraint module of the message, configured to determine whether the message type includes a random type. If it includes a random type, screen the message type set to obtain a candidate message type set that meets the protocol;
[0035] A message checking module for performing validity check on the candidate message type set to obtain a target message type set;
[0036] A message generation module for generating target messages according to the target message type set.
[0037] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above network message generation method are implemented.
[0038] In a fourth aspect, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above network message generation method are implemented.
[0039] In the solution implemented by the above network message generation method, apparatus, computer device, and storage medium, a message format setting interface can be displayed by responding to a message generation instruction. The message format setting interface receives the data structure configured by the user for the message to be generated. The data structure includes a message type set, and the message type set includes random types and / or specific types; it is determined whether the message type includes a random type. If it includes a random type, the message type set is screened to obtain a candidate message type set that meets the protocol; a validity check is performed on the candidate message type set to obtain a target message type set; target messages are generated according to the target message type set. In the present invention, a network message generator based on the UVM methodology is used to generate network messages that meet the requirements. The message generator can implement the following functions: generating specific messages with all parameters being determined values; generating random messages with random parameters, covering all messages that need to be supported; generating random messages of specific types, specifically used to test functions related to specific types. Thus, in a manner of generating random messages of specific types, messages with a specific type at a certain level and types at other levels being random within the scope permitted by the protocol can be output. Description of the Drawings
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0041] Figure 1 is an application environment schematic diagram of the network message generation method in an embodiment of the present invention;
[0042] Figure 2It is a schematic flowchart of a network packet generation method in an embodiment of the present invention;
[0043] Figure 3 It is an example of optional items in the packet type set of the network packet generation method in an embodiment of the present invention;
[0044] Figure 4 It is an example of an entity class corresponding to the packet type of the network packet generation method in an embodiment of the present invention;
[0045] Figure 5 It is the entity class nesting to generate packets in the network packet generation method in an embodiment of the present invention;
[0046] Figure 6 It is a schematic structural diagram of a network packet generation device in an embodiment of the present invention;
[0047] Figure 7 It is a schematic structural diagram of a computer device in an embodiment of the present invention;
[0048] Figure 8 It is another schematic structural diagram of a computer device in an embodiment of the present invention. Detailed implementation manners
[0049] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0050] The network packet generation method provided by the embodiments of the present invention can be applied, for example, in Figure 1In the application environment, the client communicates with the server through the network. The server can receive the user's configuration instructions through the client, respond to the message generation instruction, and display the message format setting interface. The message format setting interface receives the data structure configured by the user for the message to be generated. The data structure includes a message type set, and the message type set includes a random type and / or a specific type. Determine whether the message type set contains a random type. If it contains a random type, filter the message type set to obtain a candidate message type set that meets the protocol. Perform a validity check on the candidate message type set to obtain a target message type set. Generate a target message according to the target message type set. In the present invention, a network message generator based on the UVM methodology is used to generate network messages that meet the requirements, and can generate random messages of a specific type, and output messages with a specific type at a certain level and random types at other levels within the scope permitted by the protocol. Among them, the client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented by an independent server or a server cluster composed of multiple servers. The present invention will be described in detail through specific embodiments below.
[0051] Please refer to Figure 2 as shown in Figure 2 FIG. 1 is a schematic flowchart of a network message generation method provided by an embodiment of the present invention, including the following steps:
[0052] S10: Respond to the message generation instruction, display the message format setting interface, and the message format setting interface receives the data structure configured by the user for the message to be generated. The data structure includes a message type set, and the message type set includes a random type and / or a specific type.
[0053] It can be understood that the execution subject of the present invention is a network message generator, which includes four modules: an initial module of the message, which provides the data structure and configuration interface required for generating the message; a constraint module of the message, which restricts the selection conditions of the message type options according to the network protocol and configuration; an inspection module of the message, which performs a validity check on the results that meet the constraint conditions; a generation module of the message, which generates a message according to the type set obtained by the inspection module.
[0054] In some embodiments, the above-mentioned responding to the message generation instruction and displaying the message format setting interface may include:
[0055] In the first display area of the display interface for displaying at least two drop-down menu components of classification categories, determine the selected classification category;
[0056] Determine the classification item set and the to-be-selected item set corresponding to the selected classification category;
[0057] In the classification item display area of the second display area, display the set of classification items corresponding to the selected classification category; among them, the set of classification items includes first-level or multi-level classification items, and the lowest-level classification item is the last-level classification item;
[0058] In the option-to-be-selected display area of the second display area, display the set of options-to-be-selected corresponding to the last-level classification items in the selected classification category;
[0059] Among them, the classification item display area and the option-to-be-selected display area are separated.
[0060] After the drop-down menu component is triggered, at least two classification categories can be displayed. When the user selects one of the classification categories through the drop-down menu component in the first display area, the second display area will display the set of classification items and the set of options-to-be-selected corresponding to the selected classification category, so that the user can select options-to-be-selected according to different classification categories, improving the user experience.
[0061] Normally, the set of classification items and the set of options-to-be-selected are usually in one display area, which is not convenient for the user to distinguish between the set of classification items and the set of options-to-be-selected. Therefore, this embodiment proposes to display the set of classification items and the set of options-to-be-selected in two separate display areas respectively, so that the user can view the set of classification items in the classification item display area and view the set of options-to-be-selected in the option-to-be-selected display area, thus facilitating the user to distinguish between the set of classification items and the set of options-to-be-selected.
[0062] S20: Determine whether the message type contains a random type. If it contains a random type, filter the message type set to obtain a candidate message type set that meets the protocol;
[0063] In some embodiments, the above message format setting interface receives the data structure configured by the user for the message to be generated, which may include:
[0064] Receive the following configuration information: configuration of whether the message type set is random; configuration of whether it is a specific type of random message;
[0065] Specifically, if the message type set is configured to be random, the type set packet_type_queue = {T0, T1, T2,..., T n}, T represents Type, and the subscripts 0, 1, 2,..., n represent the indexes of the levels. n is the maximum number of levels supported by all protocols (here the protocol is the network message protocol, and the maximum number of levels supported by the protocol is the maximum number of levels of the message to be generated that conforms to the protocol), and each T 0~n has optional items; if the message type set is configured to be non-random, the type set packet_type_queue = {Tc0, T c1 , T c2 ,..., T cm}, T c0~cm is a fixed value, and m is less than or equal to n;
[0066] Among them, T 0~n , T c0~cn For all types of entities corresponding to the optional ones in, ClassA, B, C... All these classes are extensions of a message base class ClassBase. ClassBase will nest a ClassBase class, and this class is named pld. Its function is to serve as a pointer to the entity of the next class. ClassBase will contain a refresh function and a packing function. ClassA, B, C... will add protocol fields corresponding to the types on the basis of ClassBase and modify the corresponding refresh functions and packing functions. The values of the fields in the class entity that are not related to the next type can be randomly or fixedly selected according to the configuration, and the fields in the class entity that are related to the next type need to be generated by the refresh function.
[0067] In some embodiments, the data structure for configuring the message to be generated may further include: the default value of the payload, and the random value and the fixed value can be selected; Figure 1 The following is an example of the optional items in the message type set. For example, T0 is the MAC header, T1 is the user-defined header or the index indicates that the type does not exist (None) / Pld, T2 is the vlan / index indicates that the type does not exist (None) / Pld. The index indicates that the type does not exist (None) means that the content of this type is not generated, and Pld means that the following part is all payload and the type does not need to be concerned. T x The optional items of are UDP / TCP / SCTP / index indicates that the type does not exist (None), etc.; the more protocol type levels supported by the type set, the larger n is. Figure 2 The following are examples of ClassA and B.
[0068] S30: Perform a validity check on the candidate message type set to obtain the target message type set;
[0069] In some embodiments, if the message type set is configured randomly in the initial module, each element in the packet_type_queue needs to select a type from its optional items, and the combinations of these types are completely random. Many random combinations do not meet the protocol requirements. The message generator uses the constraint mechanism of the UVM platform to screen out the combinations that meet the protocol.
[0070] The above screening of the message type set to obtain the candidate message type set that meets the protocol may include:
[0071] Determine the classification of the random types in the message type set;
[0072] If it is a completely random message, solve it according to the forward and reverse constraints;
[0073] If it is a specific type of randomness, solve according to the three constraints of forward, reverse, and specific and the specific type constraints configured; among them, the configured specific types have two modes of inclusion and non-inclusion. Inclusion means generating random packets of a specific type, and non-inclusion means that all generated random packets do not include this specific type.
[0074] It can be understood that the constraints on the packet type in the present invention are divided into three types: forward constraint, reverse constraint, and specific constraint.
[0075] The forward constraint is to constrain from the smallest to the largest index of the packet_type_queue. Applicable scenarios are as follows: when the type of T x is A, the type of T y must be B; when the type of T x is C, the type of T y cannot be B; y is greater than x;
[0076] The reverse constraint is to constrain from the largest to the smallest index of the packet_type_queue. Applicable scenarios are as follows: when the type of Tn is D, the type of Tm must be E, and n is greater than m;
[0077] The specific constraint is to ensure that the finally generated is a specific type of randomness, and it must ensure the constraint that no packet combination of the specific type level can be generated before the specific type level.
[0078] In some embodiments, the above-mentioned validity check of the candidate packet type set to obtain the target packet type set includes:
[0079] Determine whether there is None (that is, the index indicates that the type does not exist) and / or Pld in the candidate packet type set;
[0080] If there is None and / or Pld between the packet type sets, then remove the invalid indexes until all elements in the set are traversed.
[0081] It can be understood that when there are None and Pld between the packet type sets generated by the constraint module, it means none; when Pld represents the packet payload, the check module needs to process it and remove the invalid indexes until all elements in the set are traversed.
[0082] packet_type_queue = {MAC, index indicates that the type does not exist (None), index indicates that the type does not exist (None), Llc, index indicates that the type does not exist (None),..., index indicates that the type does not exist (None), index indicates that the type does not exist (None),..., Pld}, check from front to back to obtain the actual type set
[0083] real_packet_type_queue = {MAC, LLc, Pld}, and the checking module may also include functions that are difficult to implement by the constraint module.
[0084] S40: Generate target packets according to the set of target packet types.
[0085] In some embodiments, the generating of target packets according to the set of target packet types may include:
[0086] According to each type in real_packet_type_queue, add the corresponding class entity one by one to a set of classes real_packet_class_queue. When adding the next class entity, modify the pld of the previous entity to point to the next class entity;
[0087] When real_packet_class_queue = {A, B, C}, packing A can nest and pack B and C, and finally obtain a packet containing the three class entities A, B, and C.
[0088] Among them, during the packing process, if there are fields in the previous entity that are associated with the next entity, update them first and then pack.
[0089] In some embodiments, the data structure further includes: the preset length of the packet and the packet length integration method;
[0090] After generating the target packets according to the set of target packet types, it may further include:
[0091] Determine whether the length of the target packet is consistent with the preset length of the packet,
[0092] If they are inconsistent, then according to the packet length integration method, integrate the length of the target packet into the preset length of the packet.
[0093] Among them, after packing is completed, the total length of this packet can be obtained. If the configured specified length is smaller than this length at this time, the packet generator supports two modes:
[0094] One is the compromise mode, which intercepts the packet from the beginning according to the specified length;
[0095] One is the forced mode, which outputs the complete packet and modifies the specified length to the actual length of the complete packet.
[0096] If the configured length is larger than this length, random numbers or fixed values can be filled according to the configured value.
[0097] As can be seen from the above solution, a message format setting interface can be displayed by responding to a message generation instruction. The message format setting interface receives the data structure configured by the user for the message to be generated. The data structure includes a message type set, and the message type set includes a random type and / or a specific type. It is determined whether the message type set contains a random type. If it contains a random type, the message type set is filtered to obtain a candidate message type set that meets the protocol. The candidate message type set is subjected to a validity check to obtain a target message type set. A target message is generated according to the target message type set.
[0098] It can be seen that in the above solution, a network message generator based on the UVM methodology is used to generate network messages that meet the requirements. The message generator can implement the following functions: generate specific messages with all parameters being determined values; generate random messages with random parameters, covering all messages that need to be supported; generate random messages of a specific type, which are specifically used to test functions related to the specific type. Thus, in a way that can generate random messages of a specific type, a message with a specific type at a certain level and random types at other levels within the scope permitted by the protocol is output.
[0099] The Universal Verification Methodology (UVM) is a standard for quickly constructing an efficient and reusable verification environment and verification IP (VIP) in the verification process. It is a complete set of verification methodologies developed based on the SystemVerilog language. Accellera is a verification methodology alliance jointly organized by companies such as Cadence, Mentor Graphics, and Synopsys. This alliance launched the UVM verification methodology based on the OVM verification methodology. UVM is essentially a class library defined using the syntax and semantics of SystemVerilog. This verification method is a tree-shaped verification platform, which incorporates many of the latest verification methodologies, maximally realizes verification reuse, thereby improving the verification efficiency. Using it, solid, reusable, and interoperable verification IP and testbench components can be created, and it is being widely accepted and adopted in the industry.
[0100] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The order of execution of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0101] In one embodiment, a network message generation device is provided, and the network message generation device corresponds one-to-one with the network message generation method in the above embodiment. As Figure 6As shown in the figure, the network packet generating device includes a packet initialization module 101, a packet constraint module 102, a packet inspection module 103, and a packet generation module 104. The detailed descriptions of each functional module are as follows:
[0102] The packet initialization module 101 is used to respond to a packet generation instruction, display a packet format setting interface, and the packet format setting interface receives the data structure configured by the user for the packet to be generated. The data structure includes a packet type set, and the packet type set includes a random type and / or a specific type;
[0103] The packet constraint module 102 is used to determine whether the packet type includes a random type. If it includes a random type, the packet type set is screened to obtain a candidate packet type set that meets the protocol;
[0104] The packet inspection module 103 is used to perform a validity check on the candidate packet type set to obtain a target packet type set;
[0105] The packet generation module 104 is used to generate target packets according to the target packet type set.
[0106] The present invention provides a network packet generating device, a network packet generator based on the UVM methodology, which is used to generate network packets that meet the requirements. The packet generator can implement the following functions: generating specific packets with all parameters being determined values; generating random packets with random parameters, covering all packets that need to be supported; generating random packets of a specific type, which are specifically used to test functions related to the specific type.
[0107] For the specific limitations of the network packet generating device, reference can be made to the limitations of the network packet generating method in the above text, which will not be elaborated here. Each module in the above network packet generating device can be implemented in whole or in part by software, hardware, and their combinations. The above modules can be embedded in the processor of the computer device in hardware form or be independent of it, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0108] In one embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 7As shown in the figure. The computer device includes a processor, a memory, a network interface, and a database connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, it realizes the functions or steps on the server side of a network packet generation method.
[0109] In one embodiment, a computer device is provided. The computer device can be a client, and its internal structure diagram can be as Figure 8 As shown in the figure. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it realizes the functions or steps on the client side of a network packet generation method
[0110] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:
[0111] In response to a packet generation instruction, display a packet format setting interface. The packet format setting interface receives the data structure configured by the user for the packet to be generated. The data structure includes a packet type set, and the packet type set includes a random type and / or a specific type;
[0112] Determine whether the packet type set contains a random type. If it contains a random type, then filter the packet type set to obtain a candidate packet type set that meets the protocol;
[0113] Perform a validity check on the candidate packet type set to obtain a target packet type set;
[0114] Generate a target packet according to the target packet type set.
[0115] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by the processor, the following steps are implemented:
[0116] Upon receiving a response message generation instruction, a message format setting interface is displayed. The message format setting interface receives the data structure configured by the user for the message to be generated. The data structure includes a message type set, and the message type set includes a random type and / or a specific type;
[0117] Determine whether the message type set includes the random type. If the random type is included, the message type set is filtered to obtain a candidate message type set that meets the protocol;
[0118] Perform a validity check on the candidate message type set to obtain a target message type set;
[0119] Generate a target message according to the target message type set.
[0120] It should be noted that for the functions or steps that can be achieved by the above computer-readable storage medium or computer device, reference can be made to the relevant descriptions on the server side and the client side in the foregoing method embodiments. To avoid repetition, they will not be described in detail here.
[0121] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above method embodiments. Among them, any reference to the memory, storage, database or other media used in the embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memories can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memories can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0122] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.
[0123] The above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention and should all be included in the protection scope of the present invention.
Claims
1. A method for generating network packets, characterized in that, Including: In response to a message generation instruction, a message format setting interface is displayed. The message format setting interface receives the data structure configured by the user for the message to be generated. The data structure includes a message type set, and the message type set includes a random type and / or a specific type. The data structure further includes the default value of the payload. The optional items in the message type set include T0, T1, and T2. T0 is the MAC header, T1 is a user-defined header or an index indication type where Pld does not exist, and T2 is a vlan / index indication type where Pld does not exist. Pld means that the following is all payload. Determine whether the message type includes a random type. If it includes a random type, filter the message type set to obtain a candidate message type set that meets the protocol. Perform a validity check on the candidate message type set to obtain a target message type set. Generate a target message according to the target message type set.
2. The network packet generation method according to claim 1, characterized in that, The message format setting interface receives the data structure configured by the user for the message to be generated, including: Receiving the following configuration information: configuration of whether the message type set is random; configuration of whether it is a random message of a specific type. If the message type set is configured to be random, generate the hierarchical indexes of the messages. The type set packet_type_queue = {T0, T1, T2,..., T n}, where T represents Type, and the subscripts 0, 1, 2,..., n represent the indexes of the levels. n is the maximum number of levels supported by all protocols. T 0~n each has optional items; If the message type set is configured as non-random, the type set packet_type_queue = {T c0 , T c1 , T c2 ,..., T cm}, where T c0~cm is a fixed value and m is less than or equal to n.
3. The network packet generation method according to claim 1, wherein The filtering the message type set to obtain a candidate message type set that meets the protocol includes: Determining the classification of the random type in the message type set. If it is a completely random message, solve according to forward and reverse constraints. If it is a specific type of random, solve according to three constraints: forward, reverse, and specific, and the configured specific type constraint. Among them, the configured specific type has two modes: inclusion and non-inclusion. Inclusion means generating a random message of a specific type, and non-inclusion means that all generated random messages do not include this specific type.
4. The network packet generation method according to claim 1, wherein The performing a validity check on the candidate message type set to obtain a target message type set includes: Determining whether None and / or Pld exist in the candidate message type set. If None and / or Pld exist between the message type sets, remove the invalid indexes until all elements in the set are traversed.
5. The network packet generation method according to claim 1, wherein The performing a validity check on the candidate message type set to obtain a target message type set includes: According to each type in the real_packet_type_queue, add the corresponding class entity one by one to a set of classes real_packet_class_queue. When adding the next class entity, modify the pld of the previous entity to point to the next class entity. When real_packet_class_queue = {A, B, C}, pack A, and then be able to pack B and C nestedly, and finally obtain a message containing three class entities A, B, and C.
6. The network packet generation method according to claim 1, wherein The data structure further includes: the preset message length and the message length integration method. After generating the target message according to the target message type set, it further includes: Determining whether the length of the target message is consistent with the preset message length. If not, integrate the length of the target message into the preset message length according to the message length integration method.
7. The network packet generation method according to claim 6, wherein Integrating the length of the target message into the preset message length according to the message length integration method includes: If the preset message length is less than the length of the target message, intercept the message from the beginning according to the preset message length or output the complete message, and modify the preset message length to the length of the target message; If the preset message length is greater than the length of the target message, fill in random numbers or fixed values according to the preset message length to make the length of the target message equal to the preset message length.
8. A network packet generating device, characterized in that, Including: An initial module of the message, which is used to respond to the message generation instruction, display a message format setting interface, and the message format setting interface receives the data structure configured by the user for the message to be generated. The data structure includes a message type set, and the message type set includes a random type and / or a specific type. The data structure also includes the default value of the payload. The optional items in the message type set include T0, T1, and T2. T0 is the MAC header, T1 is a user-defined header or an index indication type where Pld does not exist, and T2 is vlan / index indication type where Pld does not exist. Pld means that the following is all payload; A constraint module of the message, which is used to determine whether the message type includes a random type. If it includes a random type, screen the message type set to obtain a candidate message type set that meets the protocol; An inspection module of the message, which is used to perform validity inspection on the candidate message type set to obtain a target message type set; A generation module of the message, which is used to generate a target message according to the target message type set.
9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the network message generation method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the network message generation method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Test data generating method and device
CN101247294A