Network traffic generation method, apparatus, device, and storage medium
By applying multicast processing mechanisms and reprocessing operations in switches to generate network traffic copies, the problem of low generation flexibility in existing technologies is solved, and efficient and low-cost network device performance testing is achieved.
Patent Information
- Application Number
- CN202411684199.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2044-11-22
AI Technical Summary
Existing methods for generating network traffic are not flexible enough to quickly adapt to the needs of different testing scenarios, and the cost of using professional testing equipment is high.
By using multicast processing mechanisms and reprocessing operations in the switch, target network packets are identified, copied, and reprocessed to generate multiple copies of the network packets, which are then forwarded to the target network device, thus achieving high-concurrency performance testing.
Performing high-load performance tests with a limited number of ports reduces testing costs, increases the flexibility and applicability of network traffic generation, and enhances the convenience of performance testing.
Smart Images

Figure CN119520403B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of cloud computing and cloud network technology, and in particular to a method, apparatus, computer equipment, computer-readable storage medium, and computer program product for generating network traffic. Background Technology
[0002] In network device performance testing, it is often necessary to generate high traffic loads to evaluate the device's processing capacity and stability. Network traffic generation typically involves using specialized testing equipment to generate large amounts of network traffic. However, this equipment is usually expensive, its port count limits the maximum amount of traffic it can generate, and the process often requires complex configuration, making it difficult to quickly generate network traffic suitable for different testing scenarios.
[0003] It is evident that existing methods for generating network traffic suffer from a lack of flexibility. Summary of the Invention
[0004] Therefore, it is necessary to provide a network traffic generation method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the flexibility of network traffic generation in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a network traffic generation method applied to a switch, the method comprising:
[0006] Receive network messages, which include multiple network data packets;
[0007] When the target network data packet to be copied is identified from multiple network data packets, for each target network data packet, the target network data packet is copied through a preset multicast processing mechanism to obtain multiple first network data packet copies of the target network data packet;
[0008] If it is determined that the first network data packet copy needs to be reprocessed, the first network data packet copy is reprocessed to inject the first network data packet copy into the data processing entry of the switch.
[0009] If it is determined that the first network data packet copy needs to be copied, the first network data packet copy is copied based on a preset multicast processing mechanism to obtain multiple second network data packet copies of the first network data packet copy;
[0010] Multiple copies of the second network data packets are assigned to the corresponding switch output ports and forwarded to the target network device.
[0011] In one embodiment, a preset multicast processing mechanism is used to replicate the target network data packets to obtain multiple first network data packet copies of the target network data packets, including:
[0012] Determine the number of available ports on the switch;
[0013] Based on the number of available ports and a preset multicast processing mechanism, the target network data packets are copied to obtain multiple first network data packet copies. The number of first network data packet copies is proportional to the number of available ports.
[0014] In one embodiment, determining the number of available ports on the switch includes:
[0015] Get the current network status;
[0016] Determine the number of available ports on the switch based on the network status.
[0017] In one embodiment, identifying the target network packet to be copied from a plurality of network packets includes:
[0018] Parse the header information of each network data packet to obtain the header parsing result;
[0019] Based on the packet header parsing results, determine whether the network data packets need to be copied.
[0020] In one embodiment, determining whether a network data packet needs to be copied based on the packet header parsing result includes:
[0021] If the packet header parsing results indicate that there are target traffic characteristics in the network data packets that need to be copied, it is determined that the network data needs to be copied.
[0022] Target traffic characteristics include the target source address, destination address, or protocol type.
[0023] In one embodiment, reprocessing the first network data packet copy includes:
[0024] If it is determined that the header information of the first network data packet copy needs to be modified, then modify the header information of the first network data packet copy.
[0025] The modified first network packet copy is reprocessed.
[0026] Secondly, this application also provides a network traffic generation device, comprising:
[0027] The data packet receiving module is used to receive network messages sent by the test device. The network messages include multiple network data packets.
[0028] The multicast processing module is used to, when identifying the target network data packet to be copied from multiple network data packets, perform copying processing on each target network data packet using a preset multicast processing mechanism to obtain multiple first network data packet copies of the target network data packet; when it is determined that the first network data packet copy needs to be copied, perform copying processing on the first network data packet copy based on the preset multicast processing mechanism to obtain multiple second network data packet copies of the first network data packet copy.
[0029] The reprocessing module is used to perform reprocessing operations on the first network data packet copy when it is determined that the first network data packet copy needs to be reprocessed, so as to inject the first network data packet copy into the data processing entry of the switch.
[0030] The packet forwarding module is used to distribute multiple copies of the second network packets to the corresponding switch output ports and forward them to the target network device.
[0031] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in any of the above-described network traffic generation method embodiments.
[0032] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in any of the above-described network traffic generation method embodiments.
[0033] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps in any of the above-described network traffic generation method embodiments.
[0034] The aforementioned network traffic generation method, apparatus, computer equipment, computer-readable storage medium, and computer program product differ from traditional methods that use specialized testing equipment to generate network traffic. Instead, they identify the target network data packet to be copied from network data packets, use a multicast processing mechanism to copy the target network data packet, obtaining multiple first network data packet copies. Combined with a reprocessing operation, these first network data packet copies are injected into the corresponding switch input ports. Then, the data packet is copied again using the multicast processing mechanism to obtain multiple second network data packet copies of the first network data packet copies. Finally, these multiple second network data packet copies are distributed to the corresponding switch output ports and forwarded to the target network device, facilitating performance testing of high-concurrency network devices. Therefore, compared with the method of generating network traffic using multiple professional testing devices, the network traffic generation method of this application has several advantages. First, by generating network traffic through multicast processing mechanisms and re-operation, high-load performance testing can be performed even when the number of ports is limited. Second, it eliminates the need to add more testing devices or more advanced devices to increase the number of ports and enhance testing capabilities, thus significantly reducing the overall cost of network device performance testing. Third, it allows for adjustments to the multicast processing mechanism according to different testing scenarios and needs, improving the flexibility and applicability of network traffic generation, and further enhancing the convenience of performance testing. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0036] Figure 1 This is a flowchart illustrating a network traffic generation method in one embodiment;
[0037] Figure 2 This is a flowchart illustrating a network traffic generation method in another embodiment;
[0038] Figure 3 This is a flowchart illustrating the network traffic generation method in yet another embodiment;
[0039] Figure 4 This is a flowchart illustrating a network traffic generation method in a detailed embodiment;
[0040] Figure 5 This is a structural block diagram of a network traffic generation device in one embodiment;
[0041] Figure 6This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0043] The network traffic generation method provided in this application can be applied to a switch. The switch is connected to the input and output ports of the target network device.
[0044] In this embodiment, the switch is a programmable network switch, which allows the use of the P4 programming language to define and implement specific network data plane functions. The target network device can be a dedicated hardware device that connects various servers, PCs, application terminals, and other nodes to form an information communication network, including but not limited to switches, routers, firewalls, bridges, hubs, gateways, VPN servers, network interface cards (NICs), wireless access points (WAPs), modems, 5G base stations, optical transceivers, and fiber optic transceivers.
[0045] P4 (Programming Protocol-independent Packet Processors) is a domain-specific language (DSL) designed specifically for programming network devices, allowing developers to define how packets are processed.
[0046] In one exemplary embodiment, such as Figure 2 As shown, a method for generating network traffic is provided, which can be applied to... Figure 1 Taking switch 102 as an example, the explanation includes the following steps S100 to S400. Wherein:
[0047] S100 receives network messages, which include multiple network data packets.
[0048] In this embodiment, a Tofino switch is used as an example. The Tofino switch is a high-performance, fully programmable network processor designed by Barefoot Networks. It supports the P4 programming language to define and implement specific network functions.
[0049] In practical applications, Tofino switches receive network packets from the network. These network packets can be randomly generated by testing tools and sent to the Tofino switch, or they can be sent by other devices in the network.
[0050] S200: When the target network data packet to be copied is identified from multiple network data packets, for each target network data packet, the target network data packet is copied through a preset multicast processing mechanism to obtain multiple first network data packet copies of the target network data packet.
[0051] The multicast processing mechanism is a function defined in Tofino switches, used to copy a data packet into multiple copies and distribute them to different output ports.
[0052] In practical applications, Tofino switches can be programmed using the P4 language to implement multicast processing mechanisms. Specifically, after identifying the target network data packet to be processed, the replication rules (such as the number of copies and the content to be copied) and the port allocation rules for the copied network data packet are defined. For the identification of the target network data packet, the characteristics of the network data packet used for performance testing can be determined based on the testing requirements of the network device, and the identification rules for the target data to be copied can be set according to these characteristics. For example, network device performance testing may include throughput testing, latency testing, packet loss rate testing, or concurrent connection testing. Different testing requirements may have different requirements for the content of the data packet. For instance, in throughput testing, the focus is mainly on the amount of data between the sender and receiver; therefore, the identification rule for the target network data packet could be that it meets a preset fixed data packet size (such as 64 bytes). For latency testing, different sized data packets can be generated to detect the latency performance of the network device when processing data packets of different sizes; the identification rule for the target network data packet could include different data packet sizes.
[0053] Therefore, after acquiring multiple network data packets, the Tofino switch identifies the target network data packet requiring traffic amplification from among them. Then, according to the replication rules of the target network data packet in the preset multicast processing mechanism, it performs replication processing to obtain multiple copies of the target network data packet. For example, the replication rule sets the replication quantity to the number of switch ports. If the number of switch ports is 32, then one target network data packet, after passing through the multicast processing mechanism, yields 32 copies of the first network data packet. During the replication process, a replication marker is added to the replicated first network data packet to distinguish it from the original data packet.
[0054] S300: If it is determined that the first network data packet copy needs to be reprocessed, the first network data packet copy is reprocessed to inject the first network data packet copy into the data processing entry of the switch.
[0055] Recirculate refers to the operation of sending partially processed network packets that have entered the switch's processor back to the processor's initial stage for secondary processing. The data processing entry point, also known as the data plane entry point, is primarily responsible for processing and forwarding various types of data in the switch.
[0056] In practical applications, triggering conditions for reprocessing operations on the switch can be pre-programmed, such as the data packet carrying a replication marker or the reprocessing operation count not reaching a threshold. Therefore, after obtaining a copy of the first network data packet carrying the replication marker, based on the replication marker and the current reprocessing operation count, if it is determined that the first network data packet copy needs reprocessing, the reprocessing operation condition is triggered, the reprocessing operation function is invoked, and these copies of the first network data packet are sent to the Recirculate queue, so that the switch injects the copies of the first network data packet into the data plane entry point of the switch's processor.
[0057] S400, if it is determined that the first network data packet copy needs to be copied, the first network data packet copy is copied based on a preset multicast processing mechanism to obtain multiple second network data packet copies of the first network data packet copy.
[0058] In practical applications, after reprocessing the first network data packet copy and re-injecting it into the data plane entry point, the multiple copied copies of the first network data packet can be treated as a newly received network data packet. Based on the preset target network data packet identification rules, the multiple copies of the first network data packet are identified again. If it is determined that the first network data packet copy also meets the target network identification conditions, it indicates that the first network data packet copy needs to be copied. According to the data packet copying rules in the preset multicast processing mechanism, the first network data packet copy is copied to obtain multiple second network data packet copies. For example, copying 32 first network data packet copies again through reprocessing can yield 32*32=1024 second network data packet copies.
[0059] The S500 distributes multiple copies of the second network data packets to the corresponding switch output ports and forwards them to the target network device.
[0060] In practical applications, the preset multicast processing mechanism defines port allocation rules for replicated network data packets. Specifically, the port allocation rules specify the output port of the switch corresponding to the second network data packet copy.
[0061] After obtaining multiple copies of the second network data packets, these copies are distributed to the corresponding output ports of the switch and forwarded through the output ports to the target network devices connected to the Tofino switch (such as the network devices to be tested for performance). This allows different numbers of copies of the second network data packets to be sent to multiple different target network devices simultaneously, depending on the port used.
[0062] The aforementioned network traffic generation method differs from traditional methods that use specialized testing equipment to generate network traffic. It identifies the target network data packet to be copied from network data packets, uses a multicast processing mechanism to copy the target network data packet, obtaining multiple first network data packet copies. Combined with a reprocessing operation, these first network data packet copies are injected into the corresponding switch input ports. Then, the data packet is copied again using the multicast processing mechanism, obtaining multiple second network data packet copies of the first network data packet copies. Finally, these multiple second network data packet copies are distributed to the corresponding switch output ports and forwarded to the target network device, facilitating high-concurrency network device performance testing. Therefore, compared to methods using multiple specialized testing equipment to generate network traffic, this application's network traffic generation method offers several advantages. First, by using a multicast processing mechanism and reprocessing to generate network traffic, it enables high-load performance testing even with a limited number of ports. Second, it eliminates the need for additional testing equipment or more advanced equipment to increase the number of ports and enhance testing capabilities, significantly reducing the overall cost of network device performance testing. Third, it allows for adjustments to the multicast processing mechanism according to different testing scenarios and needs, improving the flexibility and applicability of network traffic generation and further enhancing the convenience of performance testing.
[0063] To improve the efficiency of network traffic generation, in one exemplary embodiment, such as Figure 2 As shown, the target network data packets are copied using a preset multicast processing mechanism to obtain multiple first network data packet copies of the target network data packets, including steps S220 to S240. Wherein:
[0064] S220 determines the number of available ports on the switch.
[0065] In practical applications, the number of available ports on a switch can be queried through the switch's command-line interface.
[0066] S240, based on the number of available ports and a preset multicast processing mechanism, the target network data packets are copied to obtain multiple first network data packet copies of the target network data packets. The number of first network data packet copies is proportional to the number of available ports.
[0067] In practical applications, multicast groups can be configured using the P4 language based on the number of available ports. Each multicast group corresponds to a set of designated output ports. The multicast processing mechanism performs replication processing based on the multicast group, obtaining network packet copies proportional to the number of available ports in the multicast group. For example, assuming a switch has 32 available ports, a multicast group can be configured to correspond to 32 ports. After identifying the data packet to be replicated, according to the configured multicast group, one network packet will be replicated into 32 copies, and each copy will be assigned to a unique output port. These copies will be sent in parallel to the corresponding ports, preparing for subsequent reprocessing. This process is highly efficient because the generation of all copies occurs almost simultaneously, ensuring extremely low latency and high throughput.
[0068] In this embodiment, the target network data packets are copied using the number of available ports of the switch and a preset multicast processing mechanism to obtain multiple first network data packet copies proportional to the number of available ports. This enables flexible copying of the target data packets, reduces network latency, and improves network throughput.
[0069] To improve the real-time adaptability of network traffic generation, in an exemplary embodiment, S220 further includes S222 to S224. Wherein:
[0070] S222, Get the network status at the current moment.
[0071] S224 determines the number of available ports on the switch based on network conditions.
[0072] In practical applications, obtaining the current network status can be achieved through built-in statistics tables, monitoring the traffic of each port, etc. After obtaining the traffic of each port, the number of available ports on the switch can be determined based on the traffic of different ports, thereby dynamically adjusting the switch ports corresponding to the multicast group to realize the dynamic adjustment of the network packet replication strategy.
[0073] In this embodiment, the number of available ports of the switch is determined based on the network status at the current moment. This is beneficial for adjusting the processing method of target data packets in real time according to changes in network status, thereby improving the real-time adaptability of network traffic generation.
[0074] In an exemplary embodiment, the target network data packet to be copied is identified from a plurality of network data packets, including steps S260 to S280. Wherein:
[0075] S260, parse the header information of each network data packet to obtain the header parsing result.
[0076] S280 determines whether network data packets need to be copied based on the packet header parsing results.
[0077] In practical applications, after a switch receives multiple network data packets, these network data packets enter the data plane. Through a predefined header structure, including multiple header fields (destination address, source address, total length, time to live, protocol type, etc.), the parser parses the data packets, extracts the fields in the packet header, and obtains the packet header parsing result.
[0078] Based on performance testing requirements, target header fields can be configured in a switch table, such as a specific destination IP address (Internet Protocol) or a specific protocol type (e.g., TCP). After obtaining the header parsing results, a table lookup is used to match the header parsing results of multiple network packets. Based on the matching results, it is determined whether the network packet needs to be copied.
[0079] In this embodiment, a packet filtering mechanism is used to parse the header information in the network packets to determine the network packets that need to be copied, so as to perform targeted traffic amplification and improve the flexibility of network traffic generation.
[0080] To improve the effectiveness of network traffic generation, in one exemplary embodiment, such as Figure 4 As shown, S280 includes S282. Wherein:
[0081] S282, if the packet header parsing result indicates that there are target traffic characteristics in the network data packet that need to be copied, it is determined that the network data needs to be copied. The target traffic characteristics include the target source address, destination address or protocol type.
[0082] In practical applications, target traffic characteristics can be determined based on the performance testing requirements. For example, if the testing requirement is to evaluate the performance of network devices when processing traffic of different protocols, specific protocol types can be specified in the target traffic characteristics.
[0083] In this embodiment, by designing target traffic characteristics and filtering network data packets before copying them, target traffic characteristics can be set according to different performance testing requirements, thereby enabling targeted traffic amplification and improving the flexibility of network traffic generation.
[0084] In an exemplary embodiment, the reprocessing operation of the first network packet copy includes steps S320 to S340. Wherein:
[0085] S320: If it is determined that the header information of the first network data packet copy needs to be modified, the header information of the first network data packet copy is modified.
[0086] In practical applications, based on testing requirements, during the process of copying the first network data packet, a header modification flag can be added to the first network data packet copy. Then, after injecting the first network data packet copy into the data plane entry point through reprocessing, the header information of the first network data packet copy is parsed. If a header modification flag is identified, it indicates that the header information needs to be modified to meet testing requirements. The header modification logic corresponding to the flag is then used to modify the header information of the first network data packet copy. For example, in test scenarios involving load balancing such as ECMP (Equal-cost multi-path routing), it is necessary to modify the src_port (source port) or dst_port (destination port) in the header for copying to ensure that the hash algorithm produces different results, thereby ensuring the effective simulation of the load balancing test scenario.
[0087] S340, reprocesses the modified first network packet copy.
[0088] In practical applications, the modified first network data packet copy is re-injected into the processing entry point. This allows the switch to inject the modified first network data packet copy into the switch's processor's data plane entry point after obtaining the modified first network data packet copy. Based on the copy flag and the current number of reprocessing operations, if it is determined that the modified first network data packet copy needs to be reprocessed, the reprocessing operation condition is triggered, and the reprocessing operation function is invoked. These modified first network data packet copies are then sent to the Recirculate queue, enabling the switch to inject the first network data packet copy into the switch's processor's data plane entry point.
[0089] In this embodiment, by modifying the header information of the network data packet copy and then performing a reprocessing operation, the corresponding network data packet copy can be adaptively generated according to the needs of different test scenarios, which helps to improve the flexibility of traffic generation.
[0090] To provide a clearer explanation of the network traffic generation method provided in this application, a specific embodiment and accompanying drawings are described below. Figure 4 The specific embodiment includes the following steps:
[0091] S1 receives network messages, which include multiple network data packets.
[0092] S2, parse the header information of each network data packet to obtain the header parsing result. If the header parsing result indicates that there are target traffic characteristics in the network data packet that need to be copied, it is determined that the network data needs to be copied. The target traffic characteristics include the target source address, destination address or protocol type.
[0093] S3. Obtain the network status at the current moment. Based on the network status, determine the number of available ports of the switch. Based on the number of available ports and the preset multicast processing mechanism, perform replication processing on the target network data packets to obtain multiple first network data packet copies of the target network data packets. The number of first network data packet copies is proportional to the number of available ports.
[0094] S4. If it is determined that the header information of the first network data packet copy needs to be modified, the header information of the first network data packet copy is modified, and the modified first network data packet copy is reprocessed to inject the modified first network data packet copy into the data processing entry of the switch.
[0095] S5, if it is determined that the modified first network data packet copy needs to be copied, the modified first network data packet copy is copied based on the preset multicast processing mechanism to obtain multiple second network data packet copies of the first network data packet copy.
[0096] S6 distributes multiple copies of the second network data packets to the corresponding switch output ports and forwards them to the target network device.
[0097] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0098] In one exemplary embodiment, such as Figure 5 As shown, a network traffic generation device 600 is provided, including: a data packet receiving module 610, a multicast processing module 620, a reprocessing module 630, and a data packet forwarding module 640, wherein:
[0099] The data packet receiving module 610 is used to receive network messages, which include multiple network data packets.
[0100] The multicast processing module 620 is used to, when identifying the target network data packet to be copied from multiple network data packets, perform copying processing on each target network data packet through a preset multicast processing mechanism to obtain multiple first network data packet copies of the target network data packet; when it is determined that the first network data packet copy needs to be copied, perform copying processing on the first network data packet copy based on the preset multicast processing mechanism to obtain multiple second network data packet copies of the first network data packet copy.
[0101] The reprocessing module 630 is used to perform a reprocessing operation on the first network data packet copy when it is determined that the first network data packet copy needs to be reprocessed, so as to inject the first network data packet copy into the data processing entry of the switch.
[0102] The packet forwarding module 640 is used to distribute multiple copies of the second network data packets to the corresponding switch output ports and forward them to the target network device.
[0103] In an exemplary embodiment, the multicast processing module 620 is further configured to determine the number of available ports of the switch; and to perform replication processing on the target network data packets based on the number of available ports and a preset multicast processing mechanism to obtain multiple first network data packet copies of the target network data packets, wherein the number of first network data packet copies is proportional to the number of available ports.
[0104] In an exemplary embodiment, the multicast processing module 620 is further configured to obtain the network status at the current moment; and determine the number of available ports of the switch based on the network status.
[0105] In an exemplary embodiment, the network traffic generation device 600 further includes a target network data packet identification module 650, which is used to parse the header information of each network data packet to obtain the header parsing result; and based on the header parsing result, to determine whether the network data packet needs to be copied.
[0106] In an exemplary embodiment, the target network data packet identification module 650 is further configured to determine that network data needs to be copied if the packet header parsing result indicates that there are target traffic characteristics in the network data packet that need to be copied; the target traffic characteristics include the target source address, destination address, or protocol type.
[0107] In an exemplary embodiment, the multicast processing module 620 is further configured to modify the header information of the first network data packet copy when it is determined that the header information of the first network data packet copy needs to be modified.
[0108] The reprocessing module 630 is also used to reprocess the modified copy of the first network data packet.
[0109] Each module in the aforementioned network traffic generation device 600 can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0110] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a network traffic generation method.
[0111] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0112] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in any of the above embodiments of the network traffic generation method.
[0113] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in any of the above embodiments of the network traffic generation method.
[0114] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in any of the network traffic generation method embodiments described above.
[0115] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0116] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0117] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0118] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for generating network traffic, characterized in that, Applied to a switch, the method includes: Receive network messages, wherein the network messages include multiple network data packets; When a target network data packet to be copied is identified from a plurality of network data packets, for each target network data packet, a preset multicast processing mechanism is used to copy the target network data packet to obtain a plurality of first network data packet copies of the target network data packet; If it is determined that the first network data packet copy needs to be reprocessed, the first network data packet copy is reprocessed to inject the first network data packet copy into the data processing entry of the switch. If the first network data packet copy injected into the data processing entry of the switch meets the identification conditions of the target network data packet, then it is determined that the first network data packet copy needs to be copied. If it is determined that the first network data packet copy needs to be copied, the first network data packet copy is copied based on a preset multicast processing mechanism to obtain multiple second network data packet copies of the first network data packet copy; Multiple copies of the second network data packets are assigned to the corresponding switch output ports and forwarded to the target network device.
2. The method according to claim 1, characterized in that, The step of replicating the target network data packets using a preset multicast processing mechanism to obtain multiple first network data packet copies of the target network data packets includes: Determine the number of available ports on the switch; The target network data packets are copied based on the number of available ports and a preset multicast processing mechanism to obtain multiple first network data packet copies of the target network data packets. The number of first network data packet copies is proportional to the number of available ports.
3. The method according to claim 2, characterized in that, Determining the number of available ports on the switch includes: Get the current network status; Based on the network status, determine the number of available ports on the switch.
4. The method according to claim 1, characterized in that, Identifying the target network data packet to be copied from the plurality of network data packets includes: Parse the header information of each network data packet to obtain the header parsing result; Based on the packet header parsing results, determine whether the network data packet needs to be copied.
5. The method according to claim 4, characterized in that, The step of determining whether the network data packet needs to be copied based on the packet header parsing result includes: If the packet header parsing result indicates that there are target traffic characteristics in the network data packet that need to be copied, it is determined that the network data needs to be copied; The target traffic characteristics include the target source address, destination address, or protocol type.
6. The method according to any one of claims 1 to 5, characterized in that, The reprocessing operation on the first network data packet copy includes: If it is determined that the header information of the first network data packet copy needs to be modified, the header information of the first network data packet copy is modified. The modified copy of the first network data packet is reprocessed.
7. A network traffic generation device, characterized in that, The device includes: A data packet receiving module is used to receive network messages sent by the test device, wherein the network messages include multiple network data packets; The multicast processing module is used to, when identifying a target network data packet to be copied from multiple network data packets, perform copying processing on each target network data packet using a preset multicast processing mechanism to obtain multiple first network data packet copies of the target network data packet; if the first network data packet copy injected into the data processing entry of the switch meets the identification conditions of the target network data packet, it is determined that the first network data packet copy needs to be copied; if it is determined that the first network data packet copy needs to be copied, the first network data packet copy is copied based on the preset multicast processing mechanism to obtain multiple second network data packet copies of the first network data packet copy; The reprocessing module is used to perform a reprocessing operation on the first network data packet copy when it is determined that the first network data packet copy needs to be reprocessed, so as to inject the first network data packet copy into the data processing entry of the switch. The packet forwarding module is used to distribute multiple copies of the second network data packets to the corresponding switch output ports and forward them to the target network device.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data stream amplification method and device, convergence diverter and storage medium
CN113489652A
Generating high-speed test traffic in a network switch
US20170366442A1