Hardware-friendly online detection method and storage medium for periodic items in high-speed network flows
By obtaining and counting the time intervals and frequencies of data packets in network flows on the hardware platform, and using hash bucket arrays and random replacement strategies, the problem of inability to deploy PeriodicSketch technology and computing performance bottlenecks is solved, and an efficient cycle of high-speed network flows is achieved. item detection.
Patent Information
- Application Number
- CN202410913131.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-09
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-07-09
AI Technical Summary
The existing PeriodicSketch technology cannot be directly deployed on the hardware platform, and there is a computing performance bottleneck in high-speed network flows, making it difficult to match the actual network flow speed and unable to effectively detect periodic items in high-speed network flows.
By obtaining the elements and arrival time in each data packet, calculating the time interval, counting the frequency of new elements, and using the hash bucket array and random replacement strategy to detect periodic items, avoid cyclic dependency processing, and reduce time complexity.
The linear rate periodic item detection of high-speed network flows is implemented on the hardware platform, which improves the detection accuracy and applicability, reduces the time complexity, and adapts to the actual rate of high-speed network flows.
Smart Images

Figure CN118473997B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network flow periodic item detection, and in particular to a hardware-friendly high-speed network flow periodic item online detection method and storage medium. Background Art
[0002] Massive high-speed network flows carry a lot of valuable information, especially some special patterns in network flows, such as persistent items and periodic items, which help us analyze user behavior patterns, monitor network anomalies, etc., and thus provide a data basis for network security detection, management, and prediction and trend analysis of future network usage. Here, a periodic item refers to a data item that appears periodically in a network flow. For example, in cache technology, a cache flow is composed of a series of memory requests, and each memory request can be regarded as an item. In actual scenarios, programs such as loop structures may perform read and write operations periodically, thus forming a periodic item. If we can find such periodic items in the cache flow and load them into the cache in advance, we can avoid frequently loading data items from the main memory and greatly improve the cache hit rate. In addition, if a transaction of a customer on an e-commerce platform for a specific product is regarded as an item, mining periodic items can discover the customer's periodic consumption behavior and push appropriate product advertisements to him; and detecting periodic flows in network flows can help us find network attacks such as advanced persistent threat (APT) attacks that present low-frequency and periodic characteristics.
[0003] However, the problem of periodic item detection in data streams was first proposed in 2022. Currently, only the PeriodicSketch technology published at the international conference ICDE can solve this problem. The PeriodicSketch technology designs two compact data structures for recording and detecting periodic items in data streams, and achieves good memory efficiency and throughput. However, through analysis, it is found that although the PeriodicSketch technology is effective for some high-speed data stream application scenarios, it cannot be truly applied to the online periodic item detection of high-speed network flows. This is because the online detection of high-speed network flows needs to be deployed on the network processor chips of P4 switches or smart routers, and these programmable hardware devices do not support the processing of circular dependencies on data. Unfortunately, the data structure maintained by PeriodicSketch has a circular dependency in the insertion operation, and the circular dependency cannot be eliminated by simple modification, so it cannot be directly deployed on the above hardware. In addition, PeriodicSketch has a high time complexity for the processing of each data item, and there is also a computing performance bottleneck in high-speed network flow applications, which is difficult to match the actual network flow rate.
[0004] The inventors of the present application discovered during the process of implementing the present invention that the above-mentioned solution in the prior art has the defect that it cannot be deployed and used on a hardware platform. Summary of the invention
[0005] The purpose of the embodiments of the present invention is to provide a hardware-friendly online detection method for periodic items of high-speed network flows and a storage medium, which can be deployed and used on a hardware platform.
[0006] In order to achieve the above object, an embodiment of the present invention provides a hardware-friendly online detection method for periodic items of high-speed network flows, including:
[0007] Obtain a data packet for each item, wherein the data packet includes an element and an arrival time;
[0008] Acquire a new element according to the data packet of each item, wherein the new element includes a time interval;
[0009] Obtaining the frequency of each new element according to the new element;
[0010] A periodic term is obtained according to the frequency of each of the new elements.
[0011] Optionally, getting new elements from the data packet for each item includes:
[0012] Get the elements in the data packet;
[0013] According to formula (1), the hash unit of the element is obtained.
[0014] , (1)
[0015] in, is the hash unit, is a hash function, For the element, is the length of the hash unit.
[0016] Optionally, obtaining new elements according to the data packet of each item also includes:
[0017] Get the time when the element last arrived;
[0018] According to formula (2), the time interval between the arrival of the elements is obtained.
[0019] , (2)
[0020] in, is the time interval between the arrival of the elements, is the current arrival time of the element, is the time of last arrival;
[0021] Combine the element and the time interval between the arrival of the element into a new element.
[0022] Optionally, obtaining the frequency of each new element according to the new element includes:
[0023] Construct multiple bucket arrays, where each bucket includes a key field and a count field;
[0024] Insert the new element into each of the bucket arrays and obtain the corresponding hash bucket;
[0025] Update the key field and count field of the hash bucket;
[0026] The frequency of each of the new elements is obtained according to the key field and the count field of the hash bucket.
[0027] Optionally, inserting the new element into each of the bucket arrays and obtaining the corresponding hash bucket includes:
[0028] According to formula (3), the hash bucket of each bucket array is obtained.
[0029] , (3)
[0030] in, For the hash buckets of the bucket array, For the The hash function of the bucket array, is an integer number, is the length of the bucket array, is the new element.
[0031] Optionally, updating the key field and count field of the hash bucket includes:
[0032] Update the count field of the hash bucket according to formula (4):
[0033] , (4)
[0034] in, is the value of the count field of the hash bucket.
[0035] Optionally, updating the key field and count field of the hash bucket further includes:
[0036] Determine whether the hash bucket is empty;
[0037] When it is determined that the hash bucket is empty, the key field of the hash bucket is set to the current new element.
[0038] Optionally, updating the key field and count field of the hash bucket further includes:
[0039] In the case where it is determined that the hash bucket is not an empty bucket, determining whether the key field of the hash bucket is the current new element;
[0040] If it is determined that the key field of the hash bucket is the current new element, no operation is performed;
[0041] When it is determined that the key field of the hash bucket is not the current new element, randomly generate a random number;
[0042] Determine whether the random number satisfies the condition shown in formula (5),
[0043] , (5)
[0044] in, is the random number, is the default value, and ;
[0045] When it is determined that the random number satisfies the condition shown in formula (5), the key field of the hash bucket is replaced with the current new element;
[0046] If it is determined that the random number does not satisfy the condition shown in formula (5), no operation is performed.
[0047] Optionally, obtaining a periodic item according to the frequency of each of the new elements includes:
[0048] Get the frequency of the new element in each of the bucket arrays;
[0049] The frequency estimate of the new element is calculated according to formula (6):
[0050] , (6)
[0051] in, For the new element The frequency estimate of ;
[0052] sorting the new elements according to the frequency estimate of each of the new elements;
[0053] A preset number of the new elements with a higher order are obtained and used as periodic items.
[0054] On the other hand, the present invention further provides a computer-readable storage medium storing instructions, wherein the instructions are used to be read by a machine so that the machine executes any of the above-described methods for online detection of periodic items of high-speed network flows.
[0055] Through the above technical scheme, the hardware-friendly high-speed network flow periodic item online detection method and storage medium provided by the present invention first obtain the data packet corresponding to each element, convert it into a new element with a time interval, and then obtain the frequency of each new element by statistics, and finally select multiple periodic items with higher frequencies according to the frequency of each new element, thereby being able to implement periodic item detection of high-speed network flow on a hardware platform, thereby realizing line rate processing, with high detection accuracy and wider applicability.
[0056] Other features and advantages of the embodiments of the present invention will be described in detail in the subsequent detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present invention, but do not constitute a limitation on the embodiments of the present invention. In the accompanying drawings:
[0058] Figure 1 is a flowchart of a hardware-friendly high-speed network flow periodic item online detection method according to an embodiment of the present invention;
[0059] Figure 2 is a flowchart of obtaining new elements in a hardware-friendly high-speed network flow periodic item online detection method according to an embodiment of the present invention;
[0060] Figure 3 is a flowchart of obtaining the frequency of elements in a hardware-friendly high-speed network flow periodic item online detection method according to an embodiment of the present invention;
[0061] Figure 4 It is a flowchart of updating a hash bucket key field in a hardware-friendly high-speed network flow periodic item online detection method according to an embodiment of the present invention;
[0062] Figure 5 The flowchart is a method for obtaining a frequency estimate of a new element in a hardware-friendly online detection method for periodic items in a high-speed network flow according to an embodiment of the present invention. DETAILED DESCRIPTION
[0063] The specific implementation of the embodiment of the present invention is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described here is only used to illustrate and explain the embodiment of the present invention, and is not used to limit the embodiment of the present invention.
[0064] Figure 1 1 is a flowchart of a hardware-friendly high-speed network flow periodic item online detection method according to an embodiment of the present invention. Figure 1In the method, the high-speed network flow periodic item online detection method may include:
[0065] In step S10, a data packet of each item is obtained, wherein the data packet includes elements and arrival time. Specifically, the data packet may include elements and arrival time ,use Indicated in Elements arriving at the moment Specifically, the element It can be defined as the source address, destination port, source port, a combination of any segment of the data packet header, etc. The destination address is used as an example for explanation.
[0066] In step S11, a new element is obtained according to the data packet of each item, wherein the new element includes a time interval. Specifically, the time interval is the arrival time of two consecutive times of the same item. In addition, the new element has the same meaning as the element indicated, that is, it is the same item, but there are differences in form and content.
[0067] In step S12, the frequency of each new element is obtained according to the new element. time interval, so new elements can be inserted to obtain the frequency of each new element.
[0068] In step S13, a periodic term is obtained according to the frequency of each new element. After the frequency of each new element is obtained, a new element with a larger frequency can be selected as a periodic term.
[0069] In step S10 to step S13, first obtain the data packet of each item in the network flow, that is, the data packet corresponding to each element, which includes the element And the arrival time. According to the two adjacent arrival times of the element, the time interval is obtained to form a new element, and the new element is stored to obtain the frequency of each new element. Finally, the periodic item in the network flow can be obtained according to the frequency of each new element.
[0070] Traditional data flow periodic detection uses PeriodicSketch technology, but the data structure maintained by this technology has circular dependencies in the insertion operation, and the circular dependencies cannot be eliminated by simple modification, so it cannot be directly deployed on the above-mentioned hardware. In addition, PeriodicSketch has a high time complexity for the processing of each data item, and there is also a computing performance bottleneck in high-speed network flow applications, which is difficult to match with the actual network flow rate. In this embodiment of the present invention, the method of obtaining the time interval and frequency of each element is adopted, and there is no need for circular dependency processing, that is, the periodic item detection of high-speed network flow can be realized on the hardware platform, thereby realizing line rate processing, and the detection accuracy is high and the applicability is wider. In addition, this method has low time complexity and good matching with the actual network flow rate.
[0071] In this embodiment of the present invention, in order to convert the data packet into a new element, it is also necessary to convert the element The calculation is performed at the time interval between two adjacent arrivals. The specific calculation steps can be as follows: Figure 2 Specifically, Figure 2 In the method, the high-speed network flow periodic item online detection method may further include:
[0072] In step S110, an element in the data packet is obtained. The element is the element .
[0073] In step S111, the hash unit of the element is obtained according to formula (1):
[0074] , (1)
[0075] in, is the hash unit, is a hash function, which can be any hash function with good randomness. For elements, Hash unit Specifically, here is the storage address number of the hash unit, note that it is the same as the following hash bucket distinguish.
[0076] In step S112, the time when the element last arrived is obtained. After that, we can get the element Last arrival time ,Right now .
[0077] In step S113, the time interval between element arrivals is obtained according to formula (2):
[0078] , (2)
[0079] in, is the time interval between element arrivals, is the current arrival time of the element, is the time of the last arrival. Specifically, after calculating the element After the current time interval, the hash unit is updated to the current arrival time, that is, .
[0080] In step S114, the element and the time interval between the arrival of the element are combined into a new element. With time interval Synthesize into new elements , that is .
[0081] In step S110 to step S114, the elements in the data packet are first Hash to To get the hash unit, get the element according to the hash unit The time of last arrival. Combined with the elements in the data packet Current arrival time to get the time interval , and finally the element With time interval Create new elements.
[0082] In this embodiment of the present invention, after obtaining the new element, it is also necessary to store and count its frequency. The specific steps can be as follows: Figure 3 Specifically, Figure 3 In the method, the high-speed network flow periodic item online detection method may further include:
[0083] In step S120, multiple bucket arrays are constructed, where each bucket includes a key field and a count field. The data of each bucket array is , each bucket consists of two fields: key field and count field, which are and During initialization, the key field in each bucket is initialized to empty and the count field is initialized to 0.
[0084] In step S121, the new element is inserted into each bucket array, and the corresponding hash bucket is obtained. Insert into each bucket array, and the operation is the same. Specifically, the hash bucket of each bucket array can be obtained according to formula (3):
[0085] , (3)
[0086] in, For the A hash bucket of an array of buckets, For the The hash function for an array of buckets, is an integer number, where In order to To distinguish, here is the storage address number of the hash bucket, is the length of the bucket array, For the new element. In addition, each bucket array Each corresponds to a hash function , The hash functions need to be independent of each other.
[0087] In step S122, the key field and count field of the hash bucket are updated. After that, the count field of the hash bucket needs to be updated. Specifically, the count field of the hash bucket can be updated according to formula (4):
[0088] , (4)
[0089] in, is the value of the count field of the hash bucket. Specifically, formula (4) is the operation of incrementing the count field by 1.
[0090] When hash buckets are needed When the key domain is updated, the hash bucket needs to be updated. The specific judgment steps can be as follows: Figure 4 Specifically, Figure 4 In the method, the high-speed network flow periodic item online detection method may further include:
[0091] In step S1220, it is determined whether the hash bucket is empty.
[0092] In step S1221, if the hash bucket is determined to be empty, the key field of the hash bucket is set to the current new element. If it is an empty bucket, the key field in the bucket can be set to the current new element. .
[0093] In step S1222, if the hash bucket is not empty, determine whether the key field of the hash bucket is the current new element. If the bucket is not empty, further judgment is required.
[0094] In step S1223, if the key field of the hash bucket is determined to be the current new element, no operation is performed. The key field is the current new element , no action is taken.
[0095] In step S1224, if it is determined that the key field of the hash bucket is not the current new element, a random number is randomly generated. If the key field of is not the current new element, a probabilistic replacement strategy needs to be implemented. Specifically, a random number between 0 and 1 is randomly generated. , and then determine whether it satisfies the conditions of formula (5).
[0096] In step S1225, it is determined whether the random number satisfies the condition shown in formula (5).
[0097] , (5)
[0098] in, is a random number, is the default value, and .
[0099] In step S1226, if the random number satisfies the condition shown in formula (5), the key field of the hash bucket is replaced with the current new element. Make a replacement.
[0100] In step S1227, if it is determined that the random number does not satisfy the condition shown in formula (5), no operation is performed.
[0101] In step S123, the frequency of each new element is obtained according to the key field and count field of the hash bucket. Insert separately Bucket array After that, the next arriving data packet can be processed, and then the Count the frequency of each new element in .
[0102] In steps S120 to S123, after obtaining the new element After that, multiple bucket arrays are constructed and the new element Insert each element into each bucket array to obtain multiple corresponding hash buckets. Then update the key and count fields of the hash bucket. Specifically, increment the count field by 1 and replace or do nothing with the key field. Insert separately Bucket array After that, the next arriving data packet can be processed, and then the Count the frequency of each new element in .
[0103] In this embodiment of the present invention, after obtaining the frequency of each new element, it is necessary to calculate the corresponding frequency estimate. The specific calculation steps can be as follows: Figure 5 Specifically, Figure 5 In the method, the high-speed network flow periodic item online detection method may further include:
[0104] In step S130, the frequency of the new element in each bucket array is obtained. May be stored in multiple bucket arrays So the frequency of the new element in each bucket array forms a set. Specifically, the frequency of the new element corresponds to the value of the count field of the hash bucket.
[0105] In step S131, the frequency estimate of the new element is calculated according to formula (6):
[0106] , (6)
[0107] in, For new elements The frequency estimate of The value set of the count field of the hash bucket is selected, and the minimum value in the set is selected as the frequency estimate.
[0108] In step S132, the new elements are sorted according to the frequency estimation value of each new element, wherein the new elements can be sorted from large to small.
[0109] In step S133, a preset number of new elements with a high ranking are obtained and used as periodic items. You can set it according to the data flow situation, select The largest element can be used as the final periodic term.
[0110] In steps S130 to S133, the new element is first placed in multiple bucket arrays. Summarize to get the frequency set of each new element. Then calculate the frequency estimate of each new element based on the frequency set, sort them, and collect a preset number of new elements as the periodic items of the network flow.
[0111] On the other hand, the present invention further provides a computer-readable storage medium storing instructions, wherein the instructions are used to be read by a machine so as to enable the machine to execute any of the above methods for online detection of periodic items of high-speed network flows.
[0112] Through the above technical scheme, the hardware-friendly high-speed network flow periodic item online detection method and storage medium provided by the present invention first obtain the data packet corresponding to each element, convert it into a new element with a time interval, and then obtain the frequency of each new element by statistics, and finally select multiple periodic items with higher frequencies according to the frequency of each new element, thereby being able to implement periodic item detection of high-speed network flow on a hardware platform, thereby realizing line rate processing, with high detection accuracy and wider applicability.
[0113] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0114] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0115] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0116] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0117] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0118] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0119] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0120] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0121] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A hardware-friendly high-speed network flow periodic item online detection method, characterized in that: include: Obtain a data packet for each item, wherein the data packet includes an element and an arrival time; Acquire a new element according to the data packet of each item, wherein the new element includes a time interval; Obtaining the frequency of each new element according to the new element; Obtaining a periodic term according to the frequency of each of the new elements; Obtaining the frequency of each new element according to the new element includes: Construct multiple bucket arrays, where each bucket includes a key field and a count field; Insert the new element into each of the bucket arrays and obtain the corresponding hash bucket; Update the key field and count field of the hash bucket; Obtain the frequency of each of the new elements according to the key field and the count field of the hash bucket; Inserting the new element into each of the bucket arrays and obtaining the corresponding hash buckets includes: According to formula (3), the hash bucket of each bucket array is obtained. ,(3) in, For the hash buckets of the bucket array, For the The hash function of the bucket array, is an integer number, is the length of the bucket array, is the new element; Obtaining periodic items according to the frequency of each of the new elements includes: Get the frequency of the new element in each of the bucket arrays; The frequency estimate of the new element is calculated according to formula (6): ,(6) in, For the new element The frequency estimate of is the value of the count field of the hash bucket; sorting the new elements according to the frequency estimate of each of the new elements; A preset number of the new elements with a higher order are obtained and used as periodic items.
2. The method for online detection of periodic items of high-speed network flows according to claim 1, characterized in that: Getting new elements from each item's data package involves: Get the elements in the data packet; According to formula (1), the hash unit of the element is obtained. ,(1) in, is the hash unit, is a hash function, For the element, is the length of the hash unit.
3. The method for online detection of periodic items of high-speed network flows according to claim 2, characterized in that: Getting new elements from each item's data package also includes: Get the time when the element last arrived; According to formula (2), the time interval between the arrival of the elements is obtained. ,(2) in, is the time interval between the arrival of the elements, is the current arrival time of the element, is the time of last arrival; Combine the element and the time interval between the arrival of the element into a new element.
4. The method for online detection of periodic items of high-speed network flows according to claim 1, characterized in that: Updating the key field and count field of the hash bucket includes: Update the count field of the hash bucket according to formula (4): ,(4)。 5. The method for online detection of periodic items of high-speed network flows according to claim 4, characterized in that: Updating the key field and count field of the hash bucket also includes: Determine whether the hash bucket is empty; When it is determined that the hash bucket is empty, the key field of the hash bucket is set to the current new element.
6. The method for online detection of periodic items of high-speed network flows according to claim 5, characterized in that: Updating the key field and count field of the hash bucket also includes: In the case where it is determined that the hash bucket is not an empty bucket, determining whether the key field of the hash bucket is the current new element; If it is determined that the key field of the hash bucket is the current new element, no operation is performed; When it is determined that the key field of the hash bucket is not the current new element, randomly generate a random number; Determine whether the random number satisfies the condition shown in formula (5), ,(5) in, is the random number, is the default value, and ; When it is determined that the random number satisfies the condition shown in formula (5), the key field of the hash bucket is replaced with the current new element; If it is determined that the random number does not satisfy the condition shown in formula (5), no operation is performed.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, and the instructions are used to be read by a machine so that the machine executes the online detection method for periodic items of a high-speed network flow according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data stream detection method and detection device
CN115150306A
